Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/performance/utils/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _set_common_perf_overrides(recipe: ConfigContainer) -> ConfigContainer:
if hasattr(recipe.model, "apply_rope_fusion"):
recipe.model.apply_rope_fusion = True
if hasattr(recipe.model, "cross_entropy_fusion_impl"):
recipe.model.cross_entropy_fusion_impl = "te"
recipe.model.cross_entropy_fusion_impl = "native"

# TODO: This needs to be adjusted when overlapping HybridEP with computation or
# the number of SMs for HybridEP is reduced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _nemotron_labs_diffusion_common(
model_cfg.recompute_num_layers = 1

model_cfg.cross_entropy_loss_fusion = True
model_cfg.cross_entropy_fusion_impl = "te"
model_cfg.cross_entropy_fusion_impl = "native"

if lr_decay_style == "WSD":
opt_cfg, scheduler_cfg = distributed_fused_adam_with_cosine_annealing_dllm(
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/models/deepseek/deepseek_v2_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def provider_bridge(self, hf_pretrained: PreTrainedCausalLM) -> MLAModelProvider
provider.gradient_accumulation_fusion = True
provider.bias_activation_fusion = True
provider.bias_dropout_fusion = True
provider.cross_entropy_fusion_impl = "te"
provider.cross_entropy_fusion_impl = "native"
provider.cross_entropy_loss_fusion = True
provider.masked_softmax_fusion = True
provider.persist_layer_norm = True
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/models/deepseek/deepseek_v3_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def provider_bridge(self, hf_pretrained: PreTrainedCausalLM) -> MLAModelProvider
provider.gradient_accumulation_fusion = True
provider.bias_activation_fusion = True
provider.bias_dropout_fusion = True
provider.cross_entropy_fusion_impl = "te"
provider.cross_entropy_fusion_impl = "native"
provider.cross_entropy_loss_fusion = True
provider.masked_softmax_fusion = True
provider.persist_layer_norm = True
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/models/deepseek/deepseek_v4_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def provider_bridge(self, hf_pretrained: PreTrainedCausalLM) -> MLAModelProvider
provider.share_embeddings_and_output_weights = bool(hf_config.tie_word_embeddings)
provider.gradient_accumulation_fusion = True
provider.bias_dropout_fusion = True
provider.cross_entropy_fusion_impl = "te"
provider.cross_entropy_fusion_impl = "native"
provider.cross_entropy_loss_fusion = True
provider.masked_softmax_fusion = True
provider.persist_layer_norm = True
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/models/kimi/kimi_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def provider_bridge(self, hf_pretrained: PreTrainedCausalLM) -> MLAModelProvider
provider.gradient_accumulation_fusion = True
provider.bias_activation_fusion = True
provider.bias_dropout_fusion = True
provider.cross_entropy_fusion_impl = "te"
provider.cross_entropy_fusion_impl = "native"
provider.cross_entropy_loss_fusion = True
provider.masked_softmax_fusion = True
provider.persist_layer_norm = True
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/models/kimi_vl/kimi_k25_vl_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def provider_bridge(self, hf_pretrained: PreTrainedVLM) -> KimiK25VLModelProvide
provider.apply_rope_fusion = False
provider.bias_activation_fusion = True
provider.bias_dropout_fusion = True
provider.cross_entropy_fusion_impl = "te"
provider.cross_entropy_fusion_impl = "native"
provider.cross_entropy_loss_fusion = True
provider.masked_softmax_fusion = True
provider.persist_layer_norm = True
Expand Down
4 changes: 2 additions & 2 deletions src/megatron/bridge/models/sarvam/sarvam_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SarvamMoEModelProvider(GPTModelProvider):
attention_softmax_in_fp32: bool = True
persist_layer_norm: bool = True

cross_entropy_fusion_impl: str = "te"
cross_entropy_fusion_impl: str = "native"
cp_comm_type: str = "p2p"
recompute_granularity: str = "selective"
recompute_modules: List[str] = field(default_factory=lambda: ["layernorm", "shared_experts", "mlp", "moe_act"])
Expand Down Expand Up @@ -192,7 +192,7 @@ class SarvamMLAModelProvider(MLATransformerConfig, GPTModelProvider):
attention_softmax_in_fp32: bool = True
persist_layer_norm: bool = True

cross_entropy_fusion_impl: str = "te"
cross_entropy_fusion_impl: str = "native"
cp_comm_type: str = "p2p"
recompute_granularity: str = "selective"
recompute_modules: List[str] = field(default_factory=lambda: ["moe"])
Expand Down
4 changes: 2 additions & 2 deletions src/megatron/bridge/recipes/deepseek/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def deepseek_v2_lite_pretrain_config() -> ConfigContainer:
True # MoE-specific: Use grouped GEMM for experts (default from DeepSeekModelProvider)
)
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te" # Default from DeepSeekModelProvider
cfg.model.cross_entropy_fusion_impl = "native" # Default from DeepSeekModelProvider

# Memory saving (recompute & offloading) - ENABLED for V2-Lite
cfg.model.recompute_granularity = "full"
Expand Down Expand Up @@ -202,7 +202,7 @@ def deepseek_v2_pretrain_config() -> ConfigContainer:
True # MoE-specific: Use grouped GEMM for experts (default from DeepSeekModelProvider)
)
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te" # Default from DeepSeekModelProvider
cfg.model.cross_entropy_fusion_impl = "native" # Default from DeepSeekModelProvider

# Memory saving (recompute & offloading) - ENABLED for V2
cfg.model.recompute_granularity = "full"
Expand Down
4 changes: 2 additions & 2 deletions src/megatron/bridge/recipes/deepseek/deepseek_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def deepseek_v3_pretrain_config() -> ConfigContainer:
cfg.model.moe_permute_fusion = True # MoE-specific: Fuse permute operations
cfg.model.moe_grouped_gemm = True # MoE-specific: Use grouped GEMM for experts
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te" # Default from DeepSeekModelProvider
cfg.model.cross_entropy_fusion_impl = "native" # Default from DeepSeekModelProvider

# Memory saving (recompute & offloading) — no recompute by default.
# Setting granularity="selective" with modules=None would cause MCore's
Expand Down Expand Up @@ -326,7 +326,7 @@ def deepseek_v3_pretrain_config_32nodes() -> ConfigContainer:
cfg.model.moe_permute_fusion = True
cfg.model.moe_grouped_gemm = True
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving - FULL recompute for 32 nodes (memory efficiency)
cfg.model.recompute_granularity = "full"
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/recipes/deepseek/deepseek_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def deepseek_v4_flash_pretrain_config() -> ConfigContainer:
cfg.model.moe_aux_loss_coeff = 0.0
cfg.model.moe_router_force_load_balancing = False
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = "selective"
cfg.model.recompute_modules = ["moe_act", "mhc"]
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/recipes/kimi/kimi_k2.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def kimi_k2_pretrain_config(optimizer_type: str = "muon") -> ConfigContainer:
cfg.model.moe_permute_fusion = True
cfg.model.moe_grouped_gemm = True
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading) - already set in model provider
# cfg.model.recompute_granularity = "selective"
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/recipes/kimi_vl/kimi_k25_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def kimi_k25_vl_sft_config() -> ConfigContainer:
cfg.model.moe_permute_fusion = True
cfg.model.moe_grouped_gemm = True
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving
cfg.model.fine_grained_activation_offloading = False
Expand Down
26 changes: 13 additions & 13 deletions src/megatron/bridge/recipes/llama/llama3.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def llama32_1b_pretrain_config() -> ConfigContainer:
# Kernel selections
cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = None
Expand Down Expand Up @@ -182,7 +182,7 @@ def llama32_3b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -268,7 +268,7 @@ def llama3_8b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -349,7 +349,7 @@ def llama3_8b_16k_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -430,7 +430,7 @@ def llama3_8b_64k_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -511,7 +511,7 @@ def llama3_8b_128k_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -614,7 +614,7 @@ def llama3_8b_low_precision_pretrain_config(mixed_precision_recipe: str) -> Conf

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -701,7 +701,7 @@ def llama3_70b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -804,7 +804,7 @@ def llama3_70b_16k_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -893,7 +893,7 @@ def llama3_70b_64k_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -987,7 +987,7 @@ def llama31_8b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def llama31_70b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down Expand Up @@ -1165,7 +1165,7 @@ def llama31_405b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

cfg.model.recompute_granularity = None
cfg.model.recompute_modules = None
Expand Down
6 changes: 3 additions & 3 deletions src/megatron/bridge/recipes/moonlight/moonlight_16b.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def moonlight_16b_pretrain_config() -> ConfigContainer:
cfg.model.moe_permute_fusion = True
cfg.model.moe_grouped_gemm = True
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = "selective"
Expand Down Expand Up @@ -307,7 +307,7 @@ def moonlight_16b_sft_config() -> ConfigContainer:
cfg.model.moe_permute_fusion = True
cfg.model.moe_grouped_gemm = True
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
# recompute_granularity already set in model provider
Expand Down Expand Up @@ -520,7 +520,7 @@ def moonlight_16b_peft_config(
cfg.model.moe_permute_fusion = True
cfg.model.moe_grouped_gemm = True
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving
cfg.model.fine_grained_activation_offloading = False
Expand Down
2 changes: 1 addition & 1 deletion src/megatron/bridge/recipes/nemotronh/nemotron_3_super.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def nemotron_3_super_pretrain_config() -> ConfigContainer:

# Kernel Selections
cfg.model.attention_backend = "fused"
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"
cfg.model.use_te_rng_tracker = True

# MTP Settings (HF config has num_nextn_predict_layers=1 for the shared block;
Expand Down
12 changes: 6 additions & 6 deletions src/megatron/bridge/recipes/qwen/qwen3.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def qwen3_600m_pretrain_config() -> ConfigContainer:
# Kernel selections
cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = None
Expand Down Expand Up @@ -148,7 +148,7 @@ def qwen3_1p7b_pretrain_config() -> ConfigContainer:
# Kernel selections
cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = None
Expand Down Expand Up @@ -229,7 +229,7 @@ def qwen3_4b_pretrain_config() -> ConfigContainer:
# Kernel selections
cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = None
Expand Down Expand Up @@ -310,7 +310,7 @@ def qwen3_8b_pretrain_config() -> ConfigContainer:
# Kernel selections
cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = None
Expand Down Expand Up @@ -391,7 +391,7 @@ def qwen3_14b_pretrain_config() -> ConfigContainer:
# Kernel selections
cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading)
cfg.model.recompute_granularity = None
Expand Down Expand Up @@ -464,7 +464,7 @@ def qwen3_32b_pretrain_config() -> ConfigContainer:

cfg.model.attention_backend = None
cfg.model.cross_entropy_loss_fusion = True
cfg.model.cross_entropy_fusion_impl = "te"
cfg.model.cross_entropy_fusion_impl = "native"

# Memory saving (recompute & offloading) - ENABLED for 32B
cfg.model.recompute_granularity = "full"
Expand Down
Loading
Loading