Skip to main content

Model

Struct Model 

Source
pub struct Model {
    pub cfg: ModelConfig,
    pub embd: EmbedHost,
    pub output_norm: GpuTensor,
    pub output: GpuTensor,
    pub layers: Vec<Layer>,
}

Fields§

§cfg: ModelConfig§embd: EmbedHost§output_norm: GpuTensor§output: GpuTensor§layers: Vec<Layer>

Implementations§

Source§

impl Model

Source

pub fn forward( &self, e: &Engine, tokens: &[u32], ) -> Result<Vec<f32>, Box<dyn Error>>

Run prefill over tokens, return logits [T, n_vocab] (host f32). positions = 0..T.

Source

pub fn forward_last( &self, e: &Engine, tokens: &[u32], ) -> Result<Vec<f32>, Box<dyn Error>>

Logits for just the last token (the decode-relevant row).

Source§

impl Model

Source

pub fn load_dense(e: &Engine, g: &GgufFile) -> Result<Self, Box<dyn Error>>

Load a dense (vanilla-transformer) model from GGUF. Thin wrapper over load_dense_from_source. Panics if the arch has SSM/MoE layers.

Source

pub fn load_dense_from_source( e: &Engine, src: &dyn TensorSource, ) -> Result<Self, Box<dyn Error>>

Load a dense-attention model from any TensorSource — GGUF or a safetensors HF checkpoint. The whole loop speaks ggml names; the source maps them. The FFN is dense SwiGLU OR routed MoE (OLMoE: dense full-attention + MoE FFN). Panics on hybrid (SSM) arches — use the hybrid path.

Source

pub fn embed_tokens( &self, e: &Engine, tokens: &[u32], ) -> Result<CudaSlice<f32>, Box<dyn Error>>

Gather embedding rows into f32 [T, n_embd] (token-major) by dequantizing only the needed rows from the host-side embedding bytes (token_embd is [n_embd, n_vocab], row per token).

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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.

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.