EngramV41

Struct EngramV41 

Source
pub struct EngramV41 {
    pub dim: usize,
    pub hc: usize,
    pub head_dim: usize,
    pub cols: usize,
    pub eps: f32,
    pub max_tokens: usize,
    /* private fields */
}
Expand description

The GPU side: kernels, per-layer weights, and workspaces for up to max_tokens positions per call.

Fields§

§dim: usize§hc: usize§head_dim: usize§cols: usize§eps: f32§max_tokens: usize

Implementations§

Source§

impl EngramV41

Source

pub fn apply( &self, gpu: &dyn GpuBackend, layer: usize, streams: DevicePtr, tokens: usize, stream: u64, ) -> Result<()>

Project the rows already in the workspace and gate tokens positions of streams ([T, hc, dim] f32) in place, for model layer layer.

Source§

impl EngramV41

Source

pub fn new( gpu: &dyn GpuBackend, dim: usize, hc: usize, head_dim: usize, cols: usize, eps: f32, max_tokens: usize, ) -> Result<Self>

Source

pub fn in_features(&self) -> usize

Source

pub fn out_features(&self) -> usize

Source

pub fn add_layer( &mut self, gpu: &dyn GpuBackend, w: EngramLayerWeights, ) -> Result<()>

Register a layer’s weights; its row workspace is allocated here.

Source

pub fn layer(&self, layer: usize) -> Option<&EngramLayerWeights>

Source

pub fn upload_qk( gpu: &dyn GpuBackend, q: &[f32], k: &[f32], ) -> Result<DevicePtr>

q_weight * k_weight (both [hc, dim], given as f32 values of the stored bf16) uploaded as the gate’s qk.

Source

pub fn rows_from_q2k( &self, gpu: &dyn GpuBackend, layer: Option<usize>, raw_blocks: &[u8], n_rows: usize, stream: u64, ) -> Result<()>

Fill the row input from raw Q2_K blocks (n_rows * 84 bytes, one block per row in [token][col] order): upload, dequantise on the device.

Source

pub fn rows_from_bf16( &self, gpu: &dyn GpuBackend, layer: Option<usize>, rows_bf16: &[u16], n_rows: usize, ) -> Result<()>

Fill the row input from already-dequantised bf16 rows (bits), for oracles and for tables held resident in bf16.

Source

pub fn rows_ptr(&self) -> DevicePtr

The dequantised rows as the GEMM sees them ([n_rows, head_dim] bf16): the shared workspace (layer = None).

Source

pub fn kv_ptr(&self) -> DevicePtr

The projected [tokens, dim * (hc + 1)] bf16 buffer after apply.

Source

pub fn free(self, gpu: &dyn GpuBackend) -> Result<()>

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,