pub struct ParameterServer { /* private fields */ }Expand description
Sharded parameter server with sync/async update modes.
See module-level docs for semantics.
Implementations§
Source§impl ParameterServer
impl ParameterServer
Sourcepub fn new(
config: ParameterServerConfig,
entity_ids: Vec<String>,
relation_ids: Vec<String>,
shard_manager: ModelShardManager,
) -> Result<Self>
pub fn new( config: ParameterServerConfig, entity_ids: Vec<String>, relation_ids: Vec<String>, shard_manager: ModelShardManager, ) -> Result<Self>
Build a new parameter server.
entity_ids and relation_ids must list every entity / relation the
server should own; the server hashes each entity ID into a shard via
the supplied ModelShardManager. Embedding rows are initialised to
small uniform values in [-0.05, 0.05] for reproducibility.
Sourcepub fn num_shards(&self) -> usize
pub fn num_shards(&self) -> usize
Number of shards.
Sourcepub fn config(&self) -> &ParameterServerConfig
pub fn config(&self) -> &ParameterServerConfig
Configuration snapshot.
Sourcepub fn shard_manager(&self) -> &ModelShardManager
pub fn shard_manager(&self) -> &ModelShardManager
Shard manager view (read-only).
Sourcepub async fn pull(&self, shard_id: usize) -> Result<ShardSnapshot>
pub async fn pull(&self, shard_id: usize) -> Result<ShardSnapshot>
Pull a snapshot of shard_id.
Returns owned data so workers can compute gradients without holding any
lock. Panics-free: an out-of-range shard_id returns an Err.
Sourcepub async fn push(
&self,
shard_id: usize,
worker_id: u32,
rows: Vec<(usize, Vec<f32>)>,
) -> Result<()>
pub async fn push( &self, shard_id: usize, worker_id: u32, rows: Vec<(usize, Vec<f32>)>, ) -> Result<()>
Push entity-row gradients to shard_id.
rows is (row_index_inside_shard, gradient_row) pairs. In
UpdateMode::Sync the push is buffered until expected_workers
pushes have accumulated for this shard or the per-step barrier
timeout fires. In UpdateMode::Async the gradient is applied
immediately and the per-shard staleness counter is incremented.
Sourcepub async fn push_relation(
&self,
worker_id: u32,
rows: Vec<(usize, Vec<f32>)>,
) -> Result<()>
pub async fn push_relation( &self, worker_id: u32, rows: Vec<(usize, Vec<f32>)>, ) -> Result<()>
Apply gradients to relation rows.
Relation gradients are always averaged across the most-recent push
regardless of update_mode — they’re a tiny fully-replicated table.
Sourcepub async fn stats(&self) -> ParameterServerStats
pub async fn stats(&self) -> ParameterServerStats
Snapshot of current stats.
Sourcepub async fn shard_steps(&self) -> Vec<u64>
pub async fn shard_steps(&self) -> Vec<u64>
Total per-shard step counts (for tests).
Auto Trait Implementations§
impl Freeze for ParameterServer
impl !RefUnwindSafe for ParameterServer
impl Send for ParameterServer
impl Sync for ParameterServer
impl Unpin for ParameterServer
impl UnsafeUnpin for ParameterServer
impl !UnwindSafe for ParameterServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.