bridge.models.deepseek.deepseek_v3_bridge#
Module Contents#
Classes#
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.MegatronModelBridgeMegatron Bridge for DeepSeek-V3.
DeepSeek-V3 ships its linear weights as FP8 with per-block
<name>_scale_invscales. The base_load_hf_weightsdequantizes them on import with the checkpoint’squantization_config.weight_block_size.- static generate_pipeline_layout(
- num_layers: int,
- pp: int,
- mtp_layers: int = 1,
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
ppstages.
- provider_bridge(
- hf_pretrained: megatron.bridge.models.hf_pretrained.causal_lm.PreTrainedCausalLM,
- classmethod megatron_to_hf_config(
- provider: megatron.bridge.models.mla_provider.MLAModelProvider,
- 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],
Preserve source-required shared MTP aliases and rotary frequencies.