Skip to content

Commit f9f215b

Browse files
committed
perf(recipe): tune Moonlight SFT communication
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
1 parent 2b26f8f commit f9f215b

2 files changed

Lines changed: 34 additions & 10 deletions

File tree

src/megatron/bridge/recipes/moonlight/h100/moonlight_16b.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,19 +549,32 @@ def moonlight_16b_sft_8gpu_h100_bf16_tp1_config() -> ConfigContainer:
549549
cfg.mixed_precision.grad_reduce_in_fp32 = False
550550
cfg.ddp.grad_reduce_in_fp32 = False
551551

552-
# Plain all-to-all is the correctness-first single-node EP8 path. Clear
553-
# inactive flex-dispatcher settings so the execution fingerprint is exact.
554-
cfg.model.moe_token_dispatcher_type = "alltoall"
555-
cfg.model.moe_flex_dispatcher_backend = None
552+
# Reuse the tuned single-node HybridEP transport and expert-communication
553+
# overlap from the bounded pretraining topology.
554+
cfg.model.moe_token_dispatcher_type = "flex"
555+
cfg.model.moe_flex_dispatcher_backend = "hybridep"
556+
cfg.model.moe_deepep_num_sms = None
556557
cfg.model.moe_hybridep_num_sms = None
557-
cfg.model.moe_flex_dispatcher_num_sms = None
558+
cfg.model.moe_flex_dispatcher_num_sms = 32
558559
cfg.model.moe_a2a_overlap = False
559560
cfg.model.moe_shared_expert_overlap = False
560-
cfg.comm_overlap = None
561+
cfg.model.high_priority_a2a_comm_stream = True
562+
cfg.comm_overlap = CommOverlapConfig(
563+
tp_comm_overlap=False,
564+
overlap_moe_expert_parallel_comm=True,
565+
delay_wgrad_compute=True,
566+
)
561567

562568
# Keep the complete process environment visible on the recipe.
563569
cfg.env_vars = {
564570
**COMMON_RECIPE_ENV_VARS,
571+
"CUDA_DEVICE_MAX_CONNECTIONS": 32,
572+
"NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN": 8,
573+
"NUM_OF_TOKENS_PER_CHUNK_COMBINE_API": 128,
574+
"NVLINK_DOMAIN_SIZE": 8,
575+
"NVTE_BWD_LAYERNORM_SM_MARGIN": 20,
576+
"NVTE_FWD_LAYERNORM_SM_MARGIN": 20,
577+
"USE_MNNVL": 0,
565578
}
566579
return cfg
567580

tests/unit_tests/recipes/test_moonlight_recipes.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,24 @@ def test_moonlight_16b_sft_convergence_contract(monkeypatch: pytest.MonkeyPatch)
434434
'++hf_tokenizer_kwargs.revision="476b36a473d4467f94469414bef6cee75c9c8172"' # pragma: allowlist secret
435435
],
436436
)
437-
assert cfg.model.moe_token_dispatcher_type == "alltoall"
438-
assert cfg.model.moe_flex_dispatcher_backend is None
437+
assert cfg.model.moe_token_dispatcher_type == "flex"
438+
assert cfg.model.moe_flex_dispatcher_backend == "hybridep"
439+
assert cfg.model.moe_deepep_num_sms is None
439440
assert cfg.model.moe_hybridep_num_sms is None
440-
assert cfg.model.moe_flex_dispatcher_num_sms is None
441+
assert cfg.model.moe_flex_dispatcher_num_sms == 32
441442
assert cfg.model.moe_a2a_overlap is False
442443
assert cfg.model.moe_shared_expert_overlap is False
443-
assert cfg.comm_overlap is None
444+
assert cfg.model.high_priority_a2a_comm_stream is True
445+
assert cfg.comm_overlap.tp_comm_overlap is False
446+
assert cfg.comm_overlap.overlap_moe_expert_parallel_comm is True
447+
assert cfg.comm_overlap.delay_wgrad_compute is True
448+
assert cfg.env_vars["CUDA_DEVICE_MAX_CONNECTIONS"] == 32
449+
assert cfg.env_vars["NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN"] == 8
450+
assert cfg.env_vars["NUM_OF_TOKENS_PER_CHUNK_COMBINE_API"] == 128
451+
assert cfg.env_vars["NVLINK_DOMAIN_SIZE"] == 8
452+
assert cfg.env_vars["NVTE_BWD_LAYERNORM_SM_MARGIN"] == 20
453+
assert cfg.env_vars["NVTE_FWD_LAYERNORM_SM_MARGIN"] == 20
454+
assert cfg.env_vars["USE_MNNVL"] == 0
444455
assert cfg.model.recompute_granularity is None
445456
assert cfg.model.recompute_modules is None
446457
assert cfg.model.recompute_method is None

0 commit comments

Comments
 (0)