bridge.models.hybrid.model_config#
Serializable Bridge extension of Megatron-LM’s Hybrid model config.
Module Contents#
Classes#
Hybrid model config with strict overrides and callable serialization. |
|
Hybrid model config with Multi-Latent Attention (MLA) in its attention layers. |
Data#
API#
- bridge.models.hybrid.model_config.logger#
‘getLogger(…)’
- class bridge.models.hybrid.model_config.BridgeHybridModelConfig#
Bases:
megatron.bridge.models.common.base.ModelConfigOverrideMixin,megatron.bridge.models.hybrid.hybrid_builder.HybridModelConfig,megatron.bridge.models.common.base.ModelConfigHybrid model config with strict overrides and callable serialization.
This is the
HybridModelcounterpart ofBridgeGPTModelConfig. Outer Hybrid build fields and nested transformer fields keep one declared owner. Flat assignment remains convenient, but unknown names fail instead of silently creating phantom configuration. Subclasses can select a specialized transformer config, such as an MLA config, throughtransformer_config_class.It keeps the construction contract of
HybridModelProvider.validate()checks the settings without changing them, andfinalize()runs it before appendingmtp_hybrid_override_patterntohybrid_layer_patternonce per MTP depth and derivingnum_layersfrom the pattern. :class:~megatron.bridge.models.hybrid.BridgeHybridModelBuilderresolves stack-spec factories, the local attention backend andmamba_chunk_size.Hugging Face source provenance is recorded in the inherited
extra_checkpoint_metadatamapping, as forBridgeGPTModelConfig.hf_model_text_onlyrecords that the source checkpoint was projected to its language model, so a restored config reopens the same projection.- builder: ClassVar[str]#
‘megatron.bridge.models.hybrid.BridgeHybridModelBuilder’
- transformer_config_class: ClassVar[type[megatron.bridge.models.transformer_config.TransformerConfig]]#
None
- _mirrored_transformer_fields: ClassVar[frozenset[str]]#
‘frozenset(…)’
- hybrid_stack_spec: megatron.core.transformer.ModuleSpec | Callable[[], megatron.core.transformer.ModuleSpec] | Callable[[bridge.models.hybrid.model_config.BridgeHybridModelConfig], megatron.core.transformer.ModuleSpec] | None#
None
Stack spec, or a factory that takes no arguments or this config.
Noneselects Bridge’s default.
- mamba_chunk_size: int#
None
Chunk size of the Mamba scan.
- hf_model_text_only: bool#
False
Whether the source HF checkpoint was projected to its language model.
- validate() None#
Check the Hybrid settings without changing the config.
- Raises:
ValueError – If
mamba_chunk_sizeis not positive or both pattern fields are set.
- finalize() None#
Validate, combine the hybrid layer patterns and derive
num_layers, then finalize the transformer config.- Raises:
ValueError – If :meth:
validaterejects the config ornum_layersdisagrees withhybrid_layer_pattern.
- get_builder_cls() type#
Resolve the configured builder through Bridge’s target allowlist.
- as_dict() dict[str, Any]#
Serialize the config with a symbolic activation function and a restorable pipeline layout.
- classmethod from_dict(
- data: dict[str, Any],
Deserialize a config while restoring its activation callable.
- class bridge.models.hybrid.model_config.BridgeHybridMLAModelConfig#
Bases:
megatron.bridge.models.common.base.MLAModelConfigMixin,bridge.models.hybrid.model_config.BridgeHybridModelConfigHybrid model config with Multi-Latent Attention (MLA) in its attention layers.
The nested transformer config is an
MLATransformerConfig. It alone stores and serializesrotary_baseandrotary_percent, because MLA attention applies RoPE from them; on this config they are constructor arguments and views of the nested values (seeMLAModelConfigMixin). Hybrid MLA families such as DeepSeek-V4 and GLM-5 subclass it, as their providers combineHybridModelProviderwith an MLA config.
- bridge.models.hybrid.model_config.__all__#
[‘BridgeHybridMLAModelConfig’, ‘BridgeHybridModelConfig’]