pub struct CpuModel<'a> {
pub p: &'a Packed,
pub embed: QLinear<'a>,
pub layers: Vec<Layer<'a>>,
pub final_mixer: HcWeights<'a>,
pub lm_head: QLinear<'a>,
pub mtp: Option<MtpWeights<'a>>,
}Fields§
§p: &'a Packed§embed: QLinear<'a>§layers: Vec<Layer<'a>>§final_mixer: HcWeights<'a>§lm_head: QLinear<'a>§mtp: Option<MtpWeights<'a>>Implementations§
Source§impl<'a> CpuModel<'a>
impl<'a> CpuModel<'a>
pub fn new_state(&self) -> State
Sourcepub fn mtp_forward(
&self,
token: u32,
hyper_in: &[f32],
pos: usize,
state: &mut State,
) -> Result<(Vec<f32>, Vec<f32>)>
pub fn mtp_forward( &self, token: u32, hyper_in: &[f32], pos: usize, state: &mut State, ) -> Result<(Vec<f32>, Vec<f32>)>
MTP draft head at trunk position pos: pairs the trunk’s wide
residual for that position (hyper_in) with the embedding of the
token that follows it, appends to the head’s KV cache (which must
hold exactly pos entries) and returns (logits for the token after
token, the head’s wide residual for chained drafting).
Sourcepub fn forward_token(&self, token: u32, state: &mut State) -> Result<Vec<f32>>
pub fn forward_token(&self, token: u32, state: &mut State) -> Result<Vec<f32>>
Forward one token at state.pos; returns logits.
Sourcefn gated_residual(
&self,
w: &HcWeights<'_>,
hyper: &[f32],
eps: f32,
) -> (Vec<f32>, Vec<f32>)
fn gated_residual( &self, w: &HcWeights<'_>, hyper: &[f32], eps: f32, ) -> (Vec<f32>, Vec<f32>)
Gated residual read: returns the mixed hidden input for the block and the per-stream injection weights (empty for the final mixer).
fn moe(&self, w: &MoeWeights<'_>, x: &[f32]) -> Vec<f32>
fn attention( &self, w: &AttnWeights<'_>, x: &[f32], cache: &mut KvCache, pos: usize, ) -> Result<Vec<f32>>
Sourcefn select_tokens(
&self,
w: &AttnWeights<'_>,
iq: &[f32],
cache: &KvCache,
pos: usize,
) -> Vec<usize>
fn select_tokens( &self, w: &AttnWeights<'_>, iq: &[f32], cache: &KvCache, pos: usize, ) -> Vec<usize>
QSA indexer for one query at pos over the causal prefix: blocks of
compress_ratio tokens scored by relu(q . pooled_key) summed over
index heads; the top budget / ratio blocks plus the incomplete tail
are visible. Returns visible token indices in ascending order.
Sourcefn deltanet(
&self,
w: &DeltaWeights<'_>,
x: &[f32],
state: &mut DeltaState,
) -> Vec<f32>
fn deltanet( &self, w: &DeltaWeights<'_>, x: &[f32], state: &mut DeltaState, ) -> Vec<f32>
Gated DeltaNet, recurrent form, f32 state; sigmoid output gate.
fn ngram_ids(&self, w: &PleWeights<'_>, tokens: &[u32]) -> Vec<u64>
Sourcepub fn ngram_ids_from(
c: &Qwen4ExpConfig,
multipliers: &[i64],
head_offsets: &[u64],
head_sizes: &[u64],
tokens: &[u32],
) -> Vec<u64>
pub fn ngram_ids_from( c: &Qwen4ExpConfig, multipliers: &[i64], head_offsets: &[u64], head_sizes: &[u64], tokens: &[u32], ) -> Vec<u64>
Hashed n-gram ids for the current (last) token: bigram heads then trigram heads. A token before the current segment (past an EOS, or before the start) reads as EOS. Multiplication wraps like torch int64.
Auto Trait Implementations§
impl<'a> Freeze for CpuModel<'a>
impl<'a> RefUnwindSafe for CpuModel<'a>
impl<'a> Send for CpuModel<'a>
impl<'a> Sync for CpuModel<'a>
impl<'a> Unpin for CpuModel<'a>
impl<'a> UnsafeUnpin for CpuModel<'a>
impl<'a> UnwindSafe for CpuModel<'a>
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more