nemo_automodel.components.speculative.eagle.parallel_reconsideration
nemo_automodel.components.speculative.eagle.parallel_reconsideration
Native EAGLE-3.1 Parallel Reconsideration training (arXiv:2611.05724v1).
Module Contents
Classes
Functions
API
Bases: LlamaEagle3DraftModel
The EAGLE-3.1 layer and LM head with a feature query and a shared halt gate.
Run the shared M with explicit positions and a branch-owned cache.
Parameters:
Token embeddings or self-queries of shape [batch, origin, hidden].
Features of shape [batch, origin, hidden].
Additive base attention mask of shape [batch, 1, origin, origin].
Absolute RoPE indices of shape [batch, origin].
Base keys/values followed by one diagonal block per prior speculative position. Blocks have shape [batch, heads, origin, head_dim].
Returns: ReconsiderationStep
Updated features [batch, origin, hidden] and this pass’s key/value
Training options for the paper’s Eq. (6).
Coefficient for entropy of the minibatch halt marginal.
Positive cap on additional passes at a position.
Build the trainer with the configured reconsideration loss.
Parameters:
Draft that owns the shared decoder, query, and gate.
Target token IDs of shape [draft_vocab] in draft order.
Eligibility mask of shape [target_vocab].
Maximum rollout length in positions.
Returns: ParallelReconsiderationTrainerModule
The trainer with its own target-vocabulary mapping buffers.
Bases: Module
Train two feature rollouts over the same recorded token sequence.
Resolve hard teacher labels in the aligned EAGLE frame.
Parameters:
Eligible teacher rows of shape [batch, origin].
Live logits of shape [batch, origin, target_vocab].
Cached probabilities of shape [batch, origin, draft_vocab].
Cache eligibility of shape [batch, origin, 1].
Returns: tuple[Tensor, Tensor]
Draft IDs and a boolean eligibility mask, each of shape [batch, origin].
Compute the native trainer’s loss and one-pass metrics.
Parameters:
EAGLE-shifted recorded token IDs [batch, origin], shared by both rollouts.
Original real-token mask [batch, origin].
Aligned teacher supervision mask [batch, origin].
Target taps [batch, origin, concatenated_hidden].
Aligned live teacher logits [batch, origin, target_vocab].
Aligned cached probabilities [batch, origin, draft_vocab].
Cached supervision eligibility [batch, origin, 1].
Optional original RoPE indices [batch, origin].
Packed document lengths [num_documents]. Must be absent.
Packed positions remaining [batch, origin]. Must be absent.
Returns: Eagle3StepMetrics
Scalar loss, accuracy and supervised-token count in the recipe’s metric record.
Rotated keys and values of shape [batch, heads, origin, head_dim].
One pass’s features [batch, origin, hidden] and uncommitted KV.
Compute the hard target loss for each origin.
Parameters:
Tensor of shape [batch, origin, draft_vocab].
Integer draft IDs of shape [batch, origin].
Returns: Tensor
FP32 cross entropy of shape [batch, origin].
Select the same depth for the feature and its cache.
Parameters:
Candidate features [batch, origin, hidden] with projected keys and values [batch, heads, origin, head_dim], ordered by depth.
Sampled depth indices of shape [batch, origin].
Returns: ReconsiderationStep
A gathered feature and KV block with the same layouts as a single level.
Apply the shared gate’s stick-breaking distribution.
Parameters:
Tensor of shape […, depth_cap] with one logit per optional halt.
Returns: Tensor
FP32 halt masses of shape […, depth_cap + 1], including forced halt.
Apply Eq. (6)‘s token terms with separate gate and CE gradients.
Parameters:
Cross entropy of shape […, depth], with depth zero first.
Halt probabilities of shape […, depth].
Returns: Tensor
Combined loss of shape […] before the marginal entropy term.