HighSpeedSwap

Struct HighSpeedSwap 

Source
pub struct HighSpeedSwap { /* private fields */ }

Implementations§

Source§

impl HighSpeedSwap

Source

pub fn offload_block( &mut self, ctx: &CudaCtx, layer: u32, block: u32, k_block_dev: u64, k_block_host: &[bf16], v_block_host: &[bf16], ) -> Result<()>

2026-09-25: Write a KV block to the tier and project its K for the predictor. k_block_dev, k_block_host and v_block_host are BF16 [block_size, num_kv_heads, head_dim]; the device K feeds the projection, the host copies the per-kv_head groups.

Source

pub fn offload_block_on_stream( &mut self, stream: u64, layer: u32, block: u32, k_block_dev: u64, k_block_host: &[bf16], v_block_host: &[bf16], ) -> Result<()>

2026-09-25: offload_block on stream, which must belong to the current thread’s CUDA context.

Source

pub fn offload_block_no_predict_on_stream( &mut self, stream: u64, layer: u32, block: u32, k_block_host: &[bf16], v_block_host: &[bf16], ) -> Result<()>

2026-09-25: offload_block_on_stream without the predictor projection, for callers whose device K is not BF16. The host buffers are still BF16.

Source

pub fn attend_layer( &mut self, ctx: &CudaCtx, layer: u32, seq_block_ids: &[u32], q_dev: u64, output_dev: u64, ) -> Result<()>

2026-09-25: Streaming attention for one (layer, sequence). q_dev is the step’s BF16 query [num_q_heads × head_dim], seq_block_ids the sequence’s blocks, and output_dev receives the BF16 output [num_q_heads × head_dim].

Source

pub fn attend_layer_on_stream( &mut self, stream: u64, layer: u32, seq_block_ids: &[u32], q_dev: u64, output_dev: u64, ) -> Result<()>

2026-09-25: attend_layer on stream, which must belong to the current thread’s CUDA context, with no causal mask: every slot of the last block is attended. A query that must not see later tokens of its own block uses attend_layer_on_stream_with_q_pos.

Source

pub fn attend_layer_on_stream_with_q_pos( &mut self, stream: u64, layer: u32, seq_block_ids: &[u32], q_dev: u64, output_dev: u64, last_block_valid_slots: i32, ) -> Result<()>

2026-09-25: Only the first last_block_valid_slots token slots of the last block in seq_block_ids are attended; for a query at position q_pos, pass (q_pos % block_size) + 1.

Source

pub fn pool(&self) -> &ScratchPool

Source

pub fn predictor(&self) -> &Predictor

Source

pub fn config(&self) -> &HighSpeedSwapConfig

Source§

impl HighSpeedSwap

Source

pub fn new( ctx: &CudaCtx, cfg: HighSpeedSwapConfig, model: ModelDims, ) -> Result<Self>

Source

pub fn new_on_stream( stream: u64, cfg: HighSpeedSwapConfig, model: ModelDims, ) -> Result<Self>

2026-09-25: Build on stream, which must belong to the current thread’s CUDA context. The stream carries only the construction-time upload of the predictor’s projection; per-step methods take their own stream.

Source

pub fn alloc_disk_block_id(&mut self) -> Option<u32>

Source

pub fn inc_disk_ref(&mut self, id: u32)

Source

pub fn dec_disk_ref(&mut self, id: u32) -> u32

Source

pub fn disk_refcount(&self, id: u32) -> u32

Source

pub fn disk_free_count(&self) -> usize

Source

pub fn diagnostic_summary(&self) -> HighSpeedSwapDiagnostic

2026-09-25: Disk-id and scratch-pool occupancy.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,