nemo_automodel.components.speculative.eagle.target
nemo_automodel.components.speculative.eagle.target
Target-model wrapper for minimal EAGLE-3 training.
Module Contents
Classes
Functions
API
Target-model supervision for one draft-training batch.
Carries exactly one supervision encoding (validated in __post_init__),
both consumed directly by Eagle3TrainerModule.forward:
logits— the target’s full-vocab logits; the draft-vocab projection happens trainer-side. Used by the co-located backend, where the tensor never leaves the GPU.target_probs+position_mask— the already-projected draft-vocab distribution, so a backend that computes it itself (e.g. a remote server) only transfers draft-vocab-sized tensors.
Return kwargs for Eagle3TrainerModule.forward, dispatching on
whichever supervision encoding this batch carries.
Bases: Eagle3TargetBackend
Co-located backend that captures three auxiliary hidden states from a causal LM.
Return decoder layers as an ordered list indexable by integer.
Supports both the HuggingFace layouts (where layers is a
ModuleList) and AutoModel’s custom-impl layouts (where
layers is a ModuleDict keyed by str(i)). Returning a
plain list normalizes the access pattern for downstream
register_forward_hook calls.
Validate aux-layer selection before any forward hooks are registered.
Run the target model and capture aux hidden states plus logits.
With seq_lens (packing), the target runs with a [B, 1, T, T]
block-causal mask and per-document position_ids so its outputs respect
document boundaries; the packing metadata is forwarded unshifted to the
trainer. seq_lens=None keeps the original 2D-mask path.
Return the target model input embeddings.
Shift a batched sequence tensor left and zero-fill the tail.
This matches the reference EAGLE-3 target preparation used by SpecForge:
sequence-aligned tensors are shifted with padding(..., left=False).
See SpecForge eagle3_target_model.py around the target preparation
logic referenced by the user.