Skip to main content

StreamedTrunkExecution

Struct StreamedTrunkExecution 

Source
pub struct StreamedTrunkExecution<'a> { /* private fields */ }
Expand description

Layer-at-a-time trunk execution over the exact per-layer math of execute, for checkpoint-scale runs where all weights cannot be resident at once. The driver materializes only the current layer’s tensors, calls StreamedTrunkExecution::step, and frees them before the next layer.

begin needs TokenEmbedding in globals; finish needs OutputNorm plus OutputProjection (falling back to the embedding for tied heads) and, for a gated-head collapse, the HyperHead* tensors.

Deliberate scope: trunk + final norm + LM head only. MTP blocks are not executed (mtp stays empty) and drafter plans are refused at begin — the streamed path has no per-layer tap capture. The glm5 checkpoint runner’s --self-test mode pins this path against execute bit-for-bit.

Implementations§

Source§

impl<'a> StreamedTrunkExecution<'a>

Source

pub fn begin( plan: &'a ModelPlan, globals: &ReferenceWeights, token_ids: &[u32], ) -> Result<Self, ReferenceError>

Source

pub fn next_layer(&self) -> Option<&'a LayerPlan>

The plan layer the next Self::step call will execute, or None when the trunk is fully executed.

Source

pub fn step( &mut self, weights: &ReferenceWeights, ) -> Result<u32, ReferenceError>

Execute the next trunk layer using only that layer’s tensors. Returns the executed layer’s plan index.

Source

pub fn finish( self, globals: &ReferenceWeights, ) -> Result<ReferenceOutput, ReferenceError>

Collapse, final-norm, and project the trunk. MTP blocks are skipped by design.

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.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.