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>
impl<'a> StreamedTrunkExecution<'a>
pub fn begin( plan: &'a ModelPlan, globals: &ReferenceWeights, token_ids: &[u32], ) -> Result<Self, ReferenceError>
Sourcepub fn next_layer(&self) -> Option<&'a LayerPlan>
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.
Sourcepub fn step(
&mut self,
weights: &ReferenceWeights,
) -> Result<u32, ReferenceError>
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.
Sourcepub fn finish(
self,
globals: &ReferenceWeights,
) -> Result<ReferenceOutput, ReferenceError>
pub fn finish( self, globals: &ReferenceWeights, ) -> Result<ReferenceOutput, ReferenceError>
Collapse, final-norm, and project the trunk. MTP blocks are skipped by design.