bridge.models.glm.glm45_bridge#

Module Contents#

Classes#

GLM45Bridge

Megatron Bridge for GLM 4.5 Models.

API#

class bridge.models.glm.glm45_bridge.GLM45Bridge#

Bases: megatron.bridge.models.conversion.model_bridge.MegatronModelBridge

Megatron Bridge for GLM 4.5 Models.

This bridge handles the conversion between HuggingFace Glm4MoeForCausalLM (used for GLM 4.5 models) and Megatron-Core GPTModel formats.

.. rubric:: Example

from megatron.bridge import AutoBridge bridge = AutoBridge.from_hf_pretrained(“zai-org/GLM-4.5”) model_config = bridge.get_model_config()

MODEL_CONFIG_CLASS#

None

USE_MODEL_CONFIG_FOR_CONVERSION#

True

hf_config_to_model_config_kwargs(
hf_config: transformers.PretrainedConfig,
) → dict[str, Any]#

Convert a Hugging Face GLM-4.5 config to builder config kwargs.

The builder’s default MoE layer spec already uses the GPT decoder block spec, which honors the mixed dense/MoE moe_layer_freq.

hf_config_to_provider_kwargs(
hf_config: transformers.PretrainedConfig,
) → dict[str, Any]#

Adapt the canonical builder mapping to the deprecated provider path.

mapping_registry() → megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#
_hf_state_source()#

Return HF state source when mappings can inspect checkpoint weights.

_uses_fused_experts() → bool#
_hf_expert_suffix(base_name: str) → str#