bridge.models.deepseek.deepseek_v4_config#

Builder-backed model config for DeepSeek-V4 expressed as a Megatron-Core HybridModel.

Module Contents#

Classes#

DeepSeekV4TransformerConfig

MLA transformer config with the DeepSeek-V4 settings that every supported Megatron Core pin needs.

DeepSeekV4ModelConfig

DeepSeek-V4 config, the builder counterpart of DeepSeekV4HybridModelProvider.

DeepSeekV4ModelBuilder

Build DeepSeek-V4 with its DSA metric hook.

Data#

API#

class bridge.models.deepseek.deepseek_v4_config.DeepSeekV4TransformerConfig#

Bases: megatron.bridge.models.transformer_config.MLATransformerConfig

MLA transformer config with the DeepSeek-V4 settings that every supported Megatron Core pin needs.

cp_partition_mode: Literal[zigzag, contiguous]#

‘zigzag’

Token assignment across context-parallel ranks on Megatron Core’s dev pin.

Megatron Core’s dev pin declares this field; its main pin does not. On the main pin, dsv4_step selects contiguous packed context parallelism through attention_cp_layout and linear_cp_layout instead and does not read this field.

class bridge.models.deepseek.deepseek_v4_config.DeepSeekV4ModelConfig#

Bases: megatron.bridge.models.hybrid.model_config.BridgeHybridMLAModelConfig

DeepSeek-V4 config, the builder counterpart of DeepSeekV4HybridModelProvider.

Each logical DeepSeek-V4 block is an attention-only Hybrid layer (W, C or H) followed by a MoE-only layer (E), and each MTP depth appends WE. Like the provider, it uses Hybrid construction and finalization with the DeepSeek-V4 MLA config and registers DSA metric setup after wrapping. It also rebuilds native pipeline segments after PP/VPP overrides and rejects segments that do not match the topology.

builder: ClassVar[str]#

‘megatron.bridge.models.deepseek.deepseek_v4_config.DeepSeekV4ModelBuilder’

transformer_config_class: ClassVar[type[megatron.bridge.models.transformer_config.TransformerConfig]]#

None

_pipeline_model_parallel_layout_builder(
pipeline_model_parallel_size: int,
virtual_pipeline_model_parallel_size: int | None,
) → list[list[str]] | None#

Rebuild this config’s pattern and layout after runner PP/VPP overrides.

validate() → None#

Check the Hybrid settings and that the native pipeline segments match PP x VPP.

get_builder_cls() → type#

Use DSA setup when restoring an older config that saved the generic Hybrid builder.

class bridge.models.deepseek.deepseek_v4_config.DeepSeekV4ModelBuilder#

Bases: megatron.bridge.models.hybrid.BridgeHybridModelBuilder

Build DeepSeek-V4 with its DSA metric hook.

build_distributed_models(
pg_collection: megatron.core.process_groups_config.ProcessGroupCollection,
*args: Any,
**kwargs: Any,
) → list[megatron.core.models.hybrid.hybrid_model.HybridModel]#

Register DSA metric setup for the complete list of wrapped model chunks.

bridge.models.deepseek.deepseek_v4_config.__all__#

[‘DeepSeekV4ModelBuilder’, ‘DeepSeekV4ModelConfig’, ‘DeepSeekV4TransformerConfig’]