pub struct ExternalDeviceMemory { /* private fields */ }Expand description
Wrapper for externally-allocated device (GPU) memory.
This type wraps a raw pointer to GPU memory that is owned by an external framework (like vLLM). It provides the necessary traits for NIXL registration without taking ownership of the underlying memory.
§Safety
This type relies on the caller to guarantee that:
- The pointer points to valid GPU memory on the specified device
- The memory remains valid for the lifetime of this wrapper
- The memory size is exactly as specified
- The external framework doesn’t free the memory while this wrapper exists
§Example
ⓘ
// vLLM allocates KV cache tensors
let tensor_ptr = tensor.data_ptr();
let tensor_size = tensor.size_bytes();
let device_id = tensor.device.index;
// Wrap without taking ownership
let external = unsafe {
ExternalDeviceMemory::new(tensor_ptr as *const u8, tensor_size, device_id as u64)
};
// Register with NIXL for RDMA
let registered = register_with_nixl(external, &agent, None)?;Implementations§
Source§impl ExternalDeviceMemory
impl ExternalDeviceMemory
Sourcepub unsafe fn new(ptr: *const u8, size: usize, device_id: u64) -> Self
pub unsafe fn new(ptr: *const u8, size: usize, device_id: u64) -> Self
Create a wrapper for external device memory.
§Safety
Caller must ensure:
ptrpoints to valid GPU memory on CUDA devicedevice_id- The memory remains valid for the lifetime of this wrapper
- The memory size is exactly
sizebytes - The external framework doesn’t free the memory while this wrapper exists
Trait Implementations§
Source§impl Debug for ExternalDeviceMemory
impl Debug for ExternalDeviceMemory
Source§impl MemoryDescriptor for ExternalDeviceMemory
impl MemoryDescriptor for ExternalDeviceMemory
Source§fn storage_kind(&self) -> StorageKind
fn storage_kind(&self) -> StorageKind
Type of storage backing this region.
Source§fn nixl_descriptor(&self) -> Option<NixlDescriptor>
fn nixl_descriptor(&self) -> Option<NixlDescriptor>
Get the NIXL descriptor for this memory region.
impl Send for ExternalDeviceMemory
impl Sync for ExternalDeviceMemory
Auto Trait Implementations§
impl Freeze for ExternalDeviceMemory
impl RefUnwindSafe for ExternalDeviceMemory
impl Unpin for ExternalDeviceMemory
impl UnsafeUnpin for ExternalDeviceMemory
impl UnwindSafe for ExternalDeviceMemory
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
Mutably borrows from an owned value. Read more