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<()>

Persist a freshly-written KV block to disk and update the predictor’s per-block K_lr. K block layout is [block_size, num_kv_heads, head_dim] BF16 in both *_dev (used for projection) and *_host (used for the per-(kv_head) disk stripe).

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<()>

Stream-only variant for production callers (spark-model decode path). stream must already be bound 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<()>

FP8/quantized callers: identical to offload_block_on_stream but skips the predictor’s per-block K projection (since k_block_dev is not BF16-laid-out — running the BF16 kernel on it would OOB-read into adjacent blocks). Eviction policy degrades to LRU-only for these blocks; correctness is preserved.

Source

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

Run streaming attention for one (layer, sequence). q_dev is the full [num_q_heads × head_dim] BF16 query for this step; seq_block_ids is the sequence’s full block list; output_dev receives the [num_q_heads × head_dim] BF16 attention output.

Source

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

Stream-only variant for production callers (spark-model decode path). stream must already be bound to the current thread’s CUDA context.

Backwards-compat: defaults last_block_valid_slots to block_size, i.e. no causal masking — appropriate for decode where the active block’s stale slots are zero-init from zero_block. For prefill, callers MUST use attend_layer_on_stream_with_q_pos to pass the query’s absolute position, otherwise future tokens within the active block leak into past queries.

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<()>

Causal-masking variant: last_block_valid_slots controls how many slots of the LAST block in seq_block_ids are consumed by the attention kernel. For prefill query at absolute position q_pos, pass (q_pos % block_size) + 1 to mask out future positions in the active block.

Source

pub fn pool(&self) -> &ScratchPool

Test/diag accessors.

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>

Stream-only constructor for production callers that already own a CUDA context (spark-model). The provided stream is used only for init-time copies (uploading the projection matrix P); subsequent per-step calls take their own stream argument.

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

Aggregated diagnostic summary across all layers (Phase 6.1.j). Use to log periodic state during long-running decode loops; the scheduler can call this once per N steps to verify HBM-shrink behavior is on track.

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