bridge.models.deepseek.deepseek_v3_bridge#

Module Contents#

Classes#

DeepSeekV3Bridge

Megatron Bridge for DeepSeek-V3.

Data#

API#

bridge.models.deepseek.deepseek_v3_bridge.__all__#

[‘DeepSeekV3Bridge’]

class bridge.models.deepseek.deepseek_v3_bridge.DeepSeekV3Bridge#

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

Megatron Bridge for DeepSeek-V3.

DeepSeek-V3 ships its linear weights as FP8 with per-block <name>_scale_inv scales. The base _load_hf_weights dequantizes them on import with the checkpoint’s quantization_config.weight_block_size.

static generate_pipeline_layout(
num_layers: int,
pp: int,
mtp_layers: int = 1,
) → list[list[str]]#

Generate a pipeline-parallel layout for DeepSeek V3 conversion.

DeepSeek V3 has 61 decoder layers, so the model cannot use ordinary pipeline partitioning for the practical PP sizes needed to hold the full checkpoint. The conversion launcher calls this hook to distribute decoder layers unevenly while keeping embeddings on the first stage and MTP plus loss on the last stage.

Parameters:
  • num_layers – Number of decoder layers.

  • pp – Pipeline parallel size.

  • mtp_layers – Number of MTP layers.

Returns:

A flexible pipeline layout with exactly pp stages.

provider_bridge(
hf_pretrained: megatron.bridge.models.hf_pretrained.causal_lm.PreTrainedCausalLM,
) → megatron.bridge.models.mla_provider.MLAModelProvider#
classmethod megatron_to_hf_config(
provider: megatron.bridge.models.mla_provider.MLAModelProvider,
) → dict#
mapping_registry() → megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#
maybe_modify_converted_hf_weight(
task: megatron.bridge.models.conversion.model_bridge.WeightConversionTask,
converted_weights_dict: Dict[str, torch.Tensor],
hf_state_dict: Mapping[str, torch.Tensor],
) → Dict[str, torch.Tensor]#

Preserve source-required shared MTP aliases and rotary frequencies.