NgramRowCache

Struct NgramRowCache 

Source
pub struct NgramRowCache {
    pub hits: u64,
    pub misses: u64,
    pub evictions: u64,
    /* private fields */
}
Expand description

One table’s on-NVMe backing file plus its resident row cache.

Fields§

§hits: u64§misses: u64§evictions: u64

Implementations§

Source§

impl NgramRowCache

Source

pub fn open( path: &Path, scale_path: Option<&Path>, rows_total: u64, row_stride: usize, slots: usize, ) -> Result<Self>

Open path as the backing store for a table of rows_total rows of row_stride bytes, caching slots of them in pinned GPU-addressable memory. scale_path supplies the per-row f32 scales of an FP8 table.

Source

pub fn open_at( path: &Path, base_offset: u64, scale_path: Option<&Path>, rows_total: u64, row_stride: usize, slots: usize, ) -> Result<Self>

As Self::open, but the table starts at base_offset inside the file — the safetensors-shard case (data_offsets[0] + the header length), which needs no re-save of the checkpoint.

Source

pub fn open_segmented( shards: &[(PathBuf, u64)], rows_per_shard: u64, scale_path: Option<&Path>, row_stride: usize, slots: usize, ) -> Result<Self>

As Self::open_at, but for a table split across equal-sized shards at SCATTERED file offsets — Qwen3.8-Flash-Next’s PLE table, whose 128 shard tensors are not laid out consecutively inside the safetensors file. bases[i] is shard i’s first row; every shard holds rows_per_shard rows.

Source

pub fn table_dev_va(&self) -> Result<u64>

Device VA of the cache’s row table — the embed_table argument of the gather kernels, which then index it by SLOT.

Source

pub fn set_constant_scale(&mut self, scale: f32) -> Result<()>

Give every slot the same scale, for an FP8 table quantized with ONE factor rather than per row.

Filled once here instead of faulted per row: the value does not depend on which row landed in the slot, so a per-fault read would be the same four bytes fetched again for every miss. The gather kernel is the FP8 one either way — it multiplies by scales[slot] and does not care where that came from.

§Errors

If the scale arena cannot be allocated.

Source

pub fn scale_dev_va(&self) -> Result<Option<u64>>

Device VA of the [slots] f32 scale array (FP8 tables only).

Source

pub fn stats(&self) -> (u64, u64, u64)

Source

pub fn resolve( &mut self, row_ids: &[u64], out_slots: &mut Vec<u32>, ) -> Result<()>

Resolve row_ids to slot indices, faulting misses in from NVMe.

Every returned slot is PINNED for the caller’s batch: the gather runs after this returns, so a later resolve in the same batch must not evict a row the kernel is about to read. Call Self::end_batch once the gather has been issued.

Source

pub fn end_batch(&mut self)

Release the batch’s pins (call after the gather kernels are issued).

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