nemo_automodel.components.models.ergo.state_dict_adapter
nemo_automodel.components.models.ergo.state_dict_adapter
Read and write Ergo checkpoints in the tensor names and layouts of the published weights.
Module Contents
Classes
Functions
Data
API
Bases: typing.TypedDict
Options the checkpoint code passes to to_hf.
Bases: MoESplitExpertsStateDictMixin, StateDictAdapter
Rename between the native module names and the names of the published Ergo weights.
The published weights load as downloaded and checkpoints are written under the same names. No tensor is
copied or cast. Three matrices are published as [input, output] and are exchanged as transposed views of the
module weights: the router gate_kernel and the shared expert’s shared_up_proj and
shared_down_proj. The expert projections up_proj [experts, hidden, expert_hidden] and down_proj
[experts, expert_hidden, hidden] have the layout of the grouped expert parameters and are exchanged whole,
so a rank that holds a shard of the experts reads and writes only its own rows. Expert LoRA weights keep the
shared expert LoRA layouts, and other names pass through unchanged.
Rename one native tensor to its published name and layout.
Parameters:
Native state-dict name.
Native tensor of arbitrary shape, optionally a DTensor.
Conversion options; see ErgoConversionOptions.
Returns: list[tuple[str, torch.Tensor]]
Published name and tensor pairs. A base weight gives one pair whose tensor is the input or its
Rename a state dict with published names to native names and layouts.
Parameters:
Published names mapped to tensors of arbitrary shape, optionally DTensors: the
destinations to_hf handed to a checkpoint read, or tensors read from the files.
Expert-parallel mesh, unused because tensors keep their own placements.
Returns: dict[str, torch.Tensor]
Native names mapped to the input tensors or transposed views of them. Expert LoRA weights are
Rename a native state dict to the published names and layouts.
Parameters:
Native names mapped to tensors of arbitrary shape, optionally DTensors.
Conversion options; see ErgoConversionOptions.
Returns: dict[str, torch.Tensor]
Published names mapped to the input tensors or transposed views of them, so a checkpoint read that
Map a published tensor name to its native name; the inverse of _published_name.
Parameters:
Checkpoint tensor name.
Returns: tuple[str, bool] | None
The native state-dict name and whether the published matrix is the transpose of the native one, or
Map a native base-weight name to its published name.
Parameters:
Native state-dict name.
Returns: tuple[str, bool] | None
The published name and whether the published matrix is the transpose of the native one, or None when