pub struct TransferManager { /* private fields */ }Expand description
Public entry point for layout and transfer management.
TransferManager combines layout registration/metadata management with transfer execution capabilities, providing a unified API for:
- Registering local layouts and obtaining handles
- Exporting/importing layout metadata for remote workers
- Executing transfers between layouts using handles
- Managing CUDA, NIXL, and other execution resources
Implementations§
Source§impl TransferManager
impl TransferManager
Sourcepub fn builder() -> TransferConfigBuilder
pub fn builder() -> TransferConfigBuilder
Create a new TransferManager builder.
The builder configures the worker ID, NIXL agent, CUDA device, and other execution parameters before creating the manager.
§Example
let manager = TransferManager::builder()
.worker_id(0) // NIXL agent name defaults to "worker-0"
.nixl_backend("ucx") // Optional: defaults to UCX from env
.cuda_device_id(0)
.build()?;
// Or with custom agent name:
let manager = TransferManager::builder()
.worker_id(0)
.nixl_agent_name("custom-agent")
.build()?;Sourcepub fn register_layout(&self, layout: PhysicalLayout) -> Result<LayoutHandle>
pub fn register_layout(&self, layout: PhysicalLayout) -> Result<LayoutHandle>
Register a local physical layout and return a unique handle.
This registers the layout with the embedded memory manager, assigning it a unique handle that can be used for handle-based transfers.
§Arguments
layout- Physical layout to register
§Returns
Unique handle for the registered layout
§Errors
Returns an error if layout IDs are exhausted (u16::MAX reached)
Sourcepub fn export_metadata(&self) -> Result<SerializedLayout>
pub fn export_metadata(&self) -> Result<SerializedLayout>
Export layout metadata for transmission to remote workers.
This exports all registered local layouts along with NIXL metadata needed for remote memory registration.
§Returns
Packed metadata ready for transmission to remote workers
Sourcepub fn import_metadata(
&self,
metadata: SerializedLayout,
) -> Result<Vec<LayoutHandle>>
pub fn import_metadata( &self, metadata: SerializedLayout, ) -> Result<Vec<LayoutHandle>>
Import remote layout metadata.
This loads NIXL metadata and reconstructs physical layouts from a remote worker’s exported metadata.
§Arguments
metadata- Packed metadata from remote worker
§Returns
Vector of handles for the imported remote layouts
§Errors
Returns an error if the remote worker was already loaded or if metadata loading/reconstruction fails
Sourcepub fn build_logical_descriptor(
&self,
handle: LayoutHandle,
logical_type: LogicalLayoutHandle,
) -> Result<LogicalLayoutDescriptor>
pub fn build_logical_descriptor( &self, handle: LayoutHandle, logical_type: LogicalLayoutHandle, ) -> Result<LogicalLayoutDescriptor>
Build a logical layout descriptor for a specific handle.
This creates a descriptor that includes the logical layout type (G1, G2, G3, G4) for use in RDMA metadata exchange. The caller must provide the logical type mapping since only the caller (e.g., DirectWorker) knows which handle corresponds to which logical tier.
§Arguments
handle- Handle to the local layoutlogical_type- The logical tier (G1, G2, G3, G4) this handle represents
§Returns
A LogicalLayoutDescriptor ready for serialization
§Errors
Returns an error if the handle is not found or serialization fails
Sourcepub fn get_nixl_metadata(&self) -> Result<Vec<u8>>
pub fn get_nixl_metadata(&self) -> Result<Vec<u8>>
Get the NIXL metadata for this worker.
Returns the raw NIXL metadata bytes needed for remote registration.
Sourcepub fn worker_address(&self) -> WorkerAddress
pub fn worker_address(&self) -> WorkerAddress
Get the worker address for this manager.
Sourcepub fn nixl_agent(&self) -> &NixlAgent
pub fn nixl_agent(&self) -> &NixlAgent
Get a reference to the NIXL agent.
This is useful for building layouts that need to register memory with the same agent that the TransferManager uses.
Sourcepub fn get_layout_config(&self, handle: LayoutHandle) -> Result<LayoutConfig>
pub fn get_layout_config(&self, handle: LayoutHandle) -> Result<LayoutConfig>
Get the layout configuration for a registered layout.
Returns a clone of the layout’s configuration, which includes dimensions like num_blocks, num_layers, page_size, etc.
§Arguments
handle- Handle to a registered layout (local or remote)
§Returns
A clone of the layout’s configuration
§Errors
Returns an error if the handle is not found
Sourcepub fn execute_transfer(
&self,
src_handle: LayoutHandle,
src_blocks: &[BlockId],
dst_handle: LayoutHandle,
dst_blocks: &[BlockId],
options: TransferOptions,
) -> Result<TransferCompleteNotification>
pub fn execute_transfer( &self, src_handle: LayoutHandle, src_blocks: &[BlockId], dst_handle: LayoutHandle, dst_blocks: &[BlockId], options: TransferOptions, ) -> Result<TransferCompleteNotification>
Transfer complete blocks between layouts using handles.
This function copies entire blocks (all layers and outer dimensions) between the source and destination layouts identified by their handles. The transfer strategy (memcpy, CUDA, NIXL) is automatically selected based on storage locations.
The lock on the registry is held only briefly during layout lookup, then released before executing the actual transfer.
§Arguments
src_handle- Handle to source layoutsrc_blocks- Source block IDs to transferdst_handle- Handle to destination layoutdst_blocks- Destination block IDs to transfer
§Returns
A notification handle that can be awaited for transfer completion
§Errors
Returns an error if:
- Either handle is invalid
- Block IDs are out of bounds
- Transfer execution fails
Sourcepub fn execute_g4_offload(
_src_handle: LayoutHandle,
_src_blocks: &[BlockId],
_dst_object: &[SequenceHash],
_options: TransferOptions,
) -> Result<TransferCompleteNotification>
pub fn execute_g4_offload( _src_handle: LayoutHandle, _src_blocks: &[BlockId], _dst_object: &[SequenceHash], _options: TransferOptions, ) -> Result<TransferCompleteNotification>
Execute a G4 offload.
Takes a LayoutHandle and a vector of block IDs for the source blocks and a list of SequenceHashes for the destination blocks.
use an extension on TransferOptions to pass in the “rank/part” of the the object in a multi-worker/multi-tp scenario.
pub fn execute_g4_onboard()
Sourcepub fn get_local_handles(&self) -> Vec<LayoutHandle>
pub fn get_local_handles(&self) -> Vec<LayoutHandle>
Get handles for all locally registered layouts.
Sourcepub fn get_remote_handles(&self) -> Vec<LayoutHandle>
pub fn get_remote_handles(&self) -> Vec<LayoutHandle>
Get handles for all imported remote layouts.
Sourcepub fn get_physical_layout(
&self,
handle: LayoutHandle,
) -> Option<PhysicalLayout>
pub fn get_physical_layout( &self, handle: LayoutHandle, ) -> Option<PhysicalLayout>
Trait Implementations§
Source§impl Clone for TransferManager
impl Clone for TransferManager
Source§fn clone(&self) -> TransferManager
fn clone(&self) -> TransferManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TransferManager
impl !UnwindSafe for TransferManager
impl Freeze for TransferManager
impl Send for TransferManager
impl Sync for TransferManager
impl Unpin for TransferManager
impl UnsafeUnpin for TransferManager
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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::Request