MtpWeights

Struct MtpWeights 

Source
pub struct MtpWeights {
Show 18 fields pub pre_fc_norm_embedding: DenseWeight, pub pre_fc_norm_hidden: DenseWeight, pub fc: DenseWeight, pub input_layernorm: DenseWeight, pub q_proj: DenseWeight, pub k_proj: DenseWeight, pub v_proj: DenseWeight, pub o_proj: DenseWeight, pub q_norm: DenseWeight, pub k_norm: DenseWeight, pub post_attn_layernorm: DenseWeight, pub moe_gate: DenseWeight, pub shared_expert: DenseExpertWeight, pub shared_expert_gate: DenseWeight, pub experts: Vec<DenseExpertWeight>, pub dense_ffn: Option<DenseExpertWeight>, pub norm: DenseWeight, pub fp8_experts: Option<MtpFp8Experts>,
}
Expand description

2026-09-25: MTP (multi-token prediction) head weights: one decoder layer plus the concat projection fc.

Every DenseWeight here is BF16 (load_mtp dequantizes FP8 or NVFP4 projections). MtpHead::new quantizes the projections when it builds the head.

Fields§

§pre_fc_norm_embedding: DenseWeight

2026-09-25: RMSNorm weight for the token embedding before the concat.

§pre_fc_norm_hidden: DenseWeight

2026-09-25: RMSNorm weight for the target hidden state before the concat.

§fc: DenseWeight

2026-09-25: Concat projection [hidden_size, 2*hidden_size] BF16.

§input_layernorm: DenseWeight

2026-09-25: RMSNorm weight before attention.

§q_proj: DenseWeight

2026-09-25: Attention projections, BF16.

§k_proj: DenseWeight§v_proj: DenseWeight§o_proj: DenseWeight§q_norm: DenseWeight§k_norm: DenseWeight§post_attn_layernorm: DenseWeight

2026-09-25: RMSNorm weight after attention (fused with the residual add).

§moe_gate: DenseWeight

2026-09-25: MoE router gate, BF16. NULL when dense_ffn is Some.

§shared_expert: DenseExpertWeight

2026-09-25: Shared expert, BF16. NULL fields when dense_ffn is Some.

§shared_expert_gate: DenseWeight

2026-09-25: Shared-expert gate [1, hidden_size] BF16. NULL when dense_ffn is Some.

§experts: Vec<DenseExpertWeight>

2026-09-25: One BF16 entry per expert. Empty when dense_ffn is Some.

§dense_ffn: Option<DenseExpertWeight>

2026-09-25: Dense FFN (gate_proj, up_proj, down_proj) of an MTP head without a router. When Some, MtpHead::new builds no MoE and the MoE fields above are unused.

§norm: DenseWeight

2026-09-25: Final RMSNorm weight.

§fp8_experts: Option<MtpFp8Experts>

2026-09-25: The routed and shared experts as the checkpoint’s own FP8 block-scaled tables (mtp.layers.0.mlp.experts.{e}.*_proj.{weight,weight_scale_inv}). When Some, experts and shared_expert above are fresh BF16 dequants of the same tensors; a head that builds its MoE from these tables calls Self::release_bf16_expert_dequants. None when the experts are not FP8 on disk, are stacked, or the variant is Bf16Raw.

Implementations§

Source§

impl MtpWeights

Source

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

2026-09-25: Free the BF16 dequants of the routed and shared experts once an FP8 MoeLayer serves them. Returns an error when Self::fp8_experts is None. load_mtp attaches the tables only for unstacked FP8 experts and a variant other than Bf16Raw; every expert entry is then a fresh dequant allocation, never a store pointer. Leaves experts empty and shared_expert NULL.

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> Same for T

Source§

type Output = T

Should always be Self
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,