nemo_automodel.components.speculative.eagle.draft_llama_v12
nemo_automodel.components.speculative.eagle.draft_llama_v12
Llama-style dense LLM draft model for EAGLE-1 / EAGLE-2 training.
Config-driven; supports Llama, Phi-3, and Qwen3 dense via standard HF config
fields (attention_bias, mlp_bias, rope_theta/rope_scaling,
rms_norm_eps). Class names are retained for checkpoint-architectures
compatibility.
Module Contents
Classes
Functions
API
Bases: Module
Standard Llama-style self attention for the EAGLE-1/2 draft.
Bases: Module
Single decoder layer for the minimal EAGLE-1/2 draft model.
Bases: Module
Standard SwiGLU MLP used by the EAGLE-1/2 draft.
Bases: PreTrainedModel
Llama-style dense draft that predicts next-step hidden states.
Works with Llama, Phi-3, and Qwen3 dense configs. The class name is retained for backward compatibility with already-trained checkpoints.
Copy the target model token embeddings into the draft embeddings.
When the target is wrapped with FSDP2, its embed_tokens.weight is
a DTensor sharded across ranks. Gather to a local full tensor
before copying into the (unsharded) draft parameter — otherwise
aten.copy_ raises a mixed Tensor/DTensor error.
Predict the next-step target hidden state for each position.
Args (batch B, sequence length T, hidden size H):
input_ids: [B, T] long token ids.
target_hidden_states: [B, T, H] target hidden features fed to the draft.
attention_mask: [B, T] (1 = real, 0 = pad); used on the unpacked path only.
position_ids: [B, T] long, or None to default to arange.
Packing requires per-document positions (reset to range(doc_len)).
seq_lens: [B, max_docs] long (0-padded per-document lengths that sum to
T per row) turns on sequence packing — attention becomes
document-level block-causal via :func:build_block_causal_additive_mask
instead of the plain causal + padding mask, and RoPE uses the per-document
position_ids so each document is rotated from its own origin.
Freeze draft token embeddings.
Build a standard causal + padding mask for eager attention.