nemo_automodel.components.speculative.eagle.export_eagle4
nemo_automodel.components.speculative.eagle.export_eagle4
Export a trained Automodel EAGLE-4 draft in the LlamaForCausalLMEagle4 serving layout.
The EAGLE-4 loaders (TokenSpeed’s LlamaForCausalLMEagle4 and the EAGLE-4
engine plugins) refuse unknown config keys and checkpoint tensors that reach no
parameter, while an Automodel checkpoint carries the training-side config (the
target’s config plus recipe keys) and wraps the backbone as model.. The
export writes:
config.json:architectures=["LlamaForCausalLMEagle4"],model_type="llama",num_hidden_layers=1and only the draft-structure keys (sizes, norms, RoPE, sliding window, aux-layer ids, candidate head).model.safetensors: every tensor with themodel.prefix dropped (fc.weight,layers.0.*,norm.weight,embed_tokens.weight) next to the top-levellm_head.weight,efficient_lm_head.weightandefficient_lm_head_down_proj.weight.embed_tokensis the target’s (the recipe keeps it frozen), which the serving adapters load in its place.
Usage::
python -m nemo_automodel.components.speculative.eagle.export_eagle4
<checkpoint>/model/consolidated —output-dir <export_dir>
Module Contents
Functions
Data
API
Return the directory holding the draft config.json (path or its model/consolidated).
Validate a training-side draft config and return the serving config.json.
Raises:
ValueError: if the checkpoint is not a complete EAGLE-4 draft or uses a structure the EAGLE-4 loaders do not build.
Drop the model. prefix and check the tensors match the EAGLE-4 draft exactly.
Parameters:
Mapping from Automodel draft key to tensor; tensor shapes are
those of LlamaEagle3DraftModel and are left unchanged.
The training-side draft config.
Returns: dict[str, torch.Tensor]
Mapping from serving key to the same tensors (no copies).
Write the serving config.json and model.safetensors of an Automodel EAGLE-4 draft.
Parameters:
The consolidated checkpoint directory (or the step
directory that contains model/consolidated).
Where to write the export; must differ from the checkpoint.
Returns: Path
The output directory.
CLI entry point; see the module docstring.