nemo_automodel.components.models.glm4_moe.state_dict_adapter

View as Markdown

Module Contents

Classes

NameDescription
Glm4MoeStateDictAdapterConverts between HF GLM4-MoE checkpoints and our grouped-experts native format.

Data

logger

API

class nemo_automodel.components.models.glm4_moe.state_dict_adapter.Glm4MoeStateDictAdapter(
config: typing.Any,
moe_config: nemo_automodel.components.moe.config.MoEConfig,
backend: nemo_automodel.components.models.common.BackendConfig,
dtype: torch.dtype = torch.float32
)

Bases: MoESplitExpertsStateDictMixin, StateDictAdapter

Converts between HF GLM4-MoE checkpoints and our grouped-experts native format.

nemo_automodel.components.models.glm4_moe.state_dict_adapter.Glm4MoeStateDictAdapter.convert_single_tensor_to_hf(
fqn: str,
tensor: typing.Any,
kwargs = {}
) -> list[tuple[str, typing.Any]]

Convert a single tensor from native format to HuggingFace format.

Parameters:

fqn
str

Fully qualified name of the tensor in native format

tensor
Any

The tensor to convert

**kwargs
Defaults to {}

Additional arguments for conversion

Returns: list[tuple[str, Any]]

List of (fqn, tensor) tuples in HuggingFace format

nemo_automodel.components.models.glm4_moe.state_dict_adapter.Glm4MoeStateDictAdapter.from_hf(
hf_state_dict: dict[str, typing.Any],
device_mesh: typing.Optional[torch.distributed.device_mesh.DeviceMesh] = None,
kwargs = {}
) -> dict[str, typing.Any]
nemo_automodel.components.models.glm4_moe.state_dict_adapter.Glm4MoeStateDictAdapter.to_hf(
state_dict: dict[str, typing.Any],
exclude_key_regex: typing.Optional[str] = None,
quantization: bool = False,
kwargs = {}
) -> dict[str, typing.Any]
nemo_automodel.components.models.glm4_moe.state_dict_adapter.logger = logging.getLogger(__name__)