pub struct CoordinatedWorker { /* private fields */ }Expand description
Leader’s view of a worker with coordination state.
§Coordination State vs Execution State
CoordinatedWorker maintains coordination state - the leader’s view of what
handles a worker has and how to route transfers. This is distinct from
execution state which DirectWorker maintains for actual transfer execution.
| State Type | Owner | Purpose |
|---|---|---|
| Execution | DirectWorker | Handles needed by TransferManager to execute |
| Coordination | CoordinatedWorker | Leader’s tracking for routing decisions |
When the inner worker is a DirectWorker, handles exist in both places. This duplication is intentional:
- DirectWorker needs handles to call TransferManager
- CoordinatedWorker provides uniform API for local AND remote workers
- VeloWorkerClient is stateless, so leader must track handles somewhere
§Usage
// Leader creates CoordinatedWorker wrapping actual worker
let worker = CoordinatedWorker::new(
Box::new(direct_worker),
rank,
host_instance,
);
// After configure_layouts RPC, populate coordination state
worker.apply_layout_response(&response)?;
// Leader can now query handles for routing
if let Some(g2) = worker.local_g2() {
// Route G2 transfers through this worker
}§Remote Handle Mappings
For cross-leader transfers (e.g., Prefill pulling from Decode), the leader imports remote worker metadata and stores rank-aware mappings:
// Prefill leader imports Decode workers' metadata
worker.import_remote_metadata(decode_leader_id, decode_rank, metadata).await?;
// Later, execute transfer using stored mapping
worker.transfer_from_remote(
decode_leader_id,
decode_rank,
LogicalLayoutHandle::G2, // source
src_block_ids,
LogicalLayoutHandle::G2, // destination
dst_block_ids,
options,
)?;Implementations§
Source§impl CoordinatedWorker
impl CoordinatedWorker
Sourcepub fn new(
inner: Box<dyn Worker>,
rank: usize,
host_instance: InstanceId,
) -> Self
pub fn new( inner: Box<dyn Worker>, rank: usize, host_instance: InstanceId, ) -> Self
Create a new CoordinatedWorker wrapping an existing Worker.
Sourcepub fn host_instance(&self) -> InstanceId
pub fn host_instance(&self) -> InstanceId
Get the instance ID of the process hosting this worker.
Sourcepub fn set_local_g1(&self, handle: LayoutHandle) -> Result<()>
pub fn set_local_g1(&self, handle: LayoutHandle) -> Result<()>
Sourcepub fn set_local_g2(&self, handle: LayoutHandle) -> Result<()>
pub fn set_local_g2(&self, handle: LayoutHandle) -> Result<()>
Sourcepub fn set_local_g3(&self, handle: LayoutHandle) -> Result<()>
pub fn set_local_g3(&self, handle: LayoutHandle) -> Result<()>
Sourcepub fn apply_layout_response(
&self,
response: &WorkerLayoutResponse,
) -> Result<()>
pub fn apply_layout_response( &self, response: &WorkerLayoutResponse, ) -> Result<()>
Apply layout response from configure_layouts RPC.
This is the primary way to populate coordination state. After the leader sends a configure_layouts RPC to the worker, the response contains the handles that were created. This method extracts those handles from the serialized metadata.
§Arguments
response- The WorkerLayoutResponse from configure_layouts RPC
§Example
// Leader calls configure_layouts on worker
let response = worker_client.configure_layouts(config).await?;
// Populate coordination state from response
coordinated_worker.apply_layout_response(&response)?;Sourcepub fn local_g1(&self) -> Option<LayoutHandle>
pub fn local_g1(&self) -> Option<LayoutHandle>
Get the local G1 handle if set.
Sourcepub fn local_g2(&self) -> Option<LayoutHandle>
pub fn local_g2(&self) -> Option<LayoutHandle>
Get the local G2 handle if set.
Sourcepub fn local_g3(&self) -> Option<LayoutHandle>
pub fn local_g3(&self) -> Option<LayoutHandle>
Get the local G3 handle if set.
Sourcepub async fn import_remote_metadata(
&self,
remote_leader_id: InstanceId,
remote_rank: usize,
metadata: SerializedLayout,
) -> Result<()>
pub async fn import_remote_metadata( &self, remote_leader_id: InstanceId, remote_rank: usize, metadata: SerializedLayout, ) -> Result<()>
Import metadata from a remote worker and store handle mappings.
This is called when the leader receives metadata from another leader’s workers during cross-leader coordination (e.g., prefill→decode).
§Arguments
remote_leader_id- Instance ID of the remote leaderremote_rank- Rank of the remote worker under its leadermetadata- Serialized layout metadata from the remote worker
Sourcepub fn resolve_remote_handle(
&self,
remote_leader_id: InstanceId,
remote_rank: usize,
logical_type: LogicalLayoutHandle,
) -> Option<LayoutHandle>
pub fn resolve_remote_handle( &self, remote_leader_id: InstanceId, remote_rank: usize, logical_type: LogicalLayoutHandle, ) -> Option<LayoutHandle>
Look up physical handle for a remote transfer.
§Arguments
remote_leader_id- Instance ID of the remote leaderremote_rank- Rank of the remote workerlogical_type- Logical layout type (G1/G2/G3)
Sourcepub fn has_remote_metadata(
&self,
remote_leader_id: InstanceId,
remote_rank: usize,
) -> bool
pub fn has_remote_metadata( &self, remote_leader_id: InstanceId, remote_rank: usize, ) -> bool
Check if remote metadata has been imported for a specific remote worker.
Sourcepub fn transfer_from_remote(
&self,
remote_leader_id: InstanceId,
remote_rank: usize,
src_logical: LogicalLayoutHandle,
src_block_ids: Vec<BlockId>,
dst_logical: LogicalLayoutHandle,
dst_block_ids: Arc<[BlockId]>,
options: TransferOptions,
) -> Result<TransferCompleteNotification>
pub fn transfer_from_remote( &self, remote_leader_id: InstanceId, remote_rank: usize, src_logical: LogicalLayoutHandle, src_block_ids: Vec<BlockId>, dst_logical: LogicalLayoutHandle, dst_block_ids: Arc<[BlockId]>, options: TransferOptions, ) -> Result<TransferCompleteNotification>
Execute transfer from a remote worker.
This method looks up the remote handle from stored mappings and executes an RDMA transfer to pull data from the remote worker.
§Arguments
remote_leader_id- Instance ID of the remote leaderremote_rank- Rank of the source worker under its leadersrc_logical- Source logical layout type (e.g., G2)src_block_ids- Block IDs on the remote to pulldst_logical- Destination logical layout type on this workerdst_block_ids- Destination block IDsoptions- Transfer options
Trait Implementations§
Source§impl ObjectBlockOps for CoordinatedWorker
impl ObjectBlockOps for CoordinatedWorker
Source§fn has_blocks(
&self,
keys: Vec<SequenceHash>,
) -> BoxFuture<'static, Vec<(SequenceHash, Option<usize>)>>
fn has_blocks( &self, keys: Vec<SequenceHash>, ) -> BoxFuture<'static, Vec<(SequenceHash, Option<usize>)>>
Source§fn put_blocks(
&self,
keys: Vec<SequenceHash>,
src_layout: LogicalLayoutHandle,
block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn put_blocks( &self, keys: Vec<SequenceHash>, src_layout: LogicalLayoutHandle, block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Source§fn get_blocks(
&self,
keys: Vec<SequenceHash>,
dst_layout: LogicalLayoutHandle,
block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn get_blocks( &self, keys: Vec<SequenceHash>, dst_layout: LogicalLayoutHandle, block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Source§fn put_blocks_with_layout(
&self,
keys: Vec<SequenceHash>,
_layout: PhysicalLayout,
_block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn put_blocks_with_layout( &self, keys: Vec<SequenceHash>, _layout: PhysicalLayout, _block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Source§fn get_blocks_with_layout(
&self,
keys: Vec<SequenceHash>,
_layout: PhysicalLayout,
_block_ids: Vec<BlockId>,
) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
fn get_blocks_with_layout( &self, keys: Vec<SequenceHash>, _layout: PhysicalLayout, _block_ids: Vec<BlockId>, ) -> BoxFuture<'static, Vec<Result<SequenceHash, SequenceHash>>>
Auto Trait Implementations§
impl !Freeze for CoordinatedWorker
impl !RefUnwindSafe for CoordinatedWorker
impl !UnwindSafe for CoordinatedWorker
impl Send for CoordinatedWorker
impl Sync for CoordinatedWorker
impl Unpin for CoordinatedWorker
impl UnsafeUnpin for CoordinatedWorker
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);