1313# limitations under the License.
1414"""GB200 performance recipes for DeepSeek V3."""
1515
16+ from megatron .bridge .perf_recipes ._common import _enable_ncclep
1617from megatron .bridge .perf_recipes .deepseek .common import (
1718 ConfigContainer ,
1819 _benchmark_common ,
2627from megatron .bridge .perf_recipes .environment import COMMON_PERF_ENV_VARS
2728
2829
29- def deepseek_v3_pretrain_256gpu_gb200_bf16_config () -> ConfigContainer :
30- """DeepSeek V3 pretrain: 256× GB200, BF16."""
30+ def _build_deepseek_v3_gb200_bf16 () -> ConfigContainer :
31+ """Shared HybridEP BF16 base for the DeepSeek V3 256-GPU GB200 BF16 and NVFP4 recipes ."""
3132 cfg = deepseek_v3_pretrain_config ()
3233 cfg .mixed_precision = _perf_precision ("bf16" )
3334 _deepseek_v3_common (cfg )
@@ -52,6 +53,16 @@ def deepseek_v3_pretrain_256gpu_gb200_bf16_config() -> ConfigContainer:
5253 set_deepseek_v3_pipeline_model_parallel_layout (cfg .model )
5354
5455 _benchmark_common (cfg )
56+ return cfg
57+
58+
59+ def deepseek_v3_pretrain_256gpu_gb200_bf16_config () -> ConfigContainer :
60+ """DeepSeek V3 pretrain: 256× GB200, BF16, NCCL EP."""
61+ cfg = _build_deepseek_v3_gb200_bf16 ()
62+ _enable_ncclep (cfg )
63+ # Device-side expert token counts: the legacy grouped MLP path syncs tokens_per_expert to the
64+ # host every layer, which serializes the CPU behind the GPU when dispatch is fast.
65+ cfg .model .moe_use_grouped_tensor = True
5566 # Keep process settings next to the recipe so users can see the exact benchmark environment.
5667 cfg .env_vars = {
5768 ** COMMON_PERF_ENV_VARS ,
@@ -67,11 +78,8 @@ def deepseek_v3_pretrain_256gpu_gb200_bf16_config() -> ConfigContainer:
6778 "TORCH_CPP_LOG_LEVEL" : "ERROR" ,
6879 # NCCL user-buffer and launch settings.
6980 "NCCL_NVLS_ENABLE" : 0 ,
70- # HybridEP topology for the target system.
71- "NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN" : 64 ,
72- "NUM_OF_TOKENS_PER_CHUNK_COMBINE_API" : 128 ,
73- "NVLINK_DOMAIN_SIZE" : 72 ,
74- "USE_MNNVL" : 1 ,
81+ # NCCL EP dispatcher mode.
82+ "NCCL_EP_HT_EM_PULL_PUSH" : 1 ,
7583 # Transformer Engine overlap settings for this model.
7684 "NVTE_BWD_LAYERNORM_SM_MARGIN" : 20 ,
7785 "NVTE_FWD_LAYERNORM_SM_MARGIN" : 20 ,
@@ -133,7 +141,7 @@ def deepseek_v3_pretrain_256gpu_gb200_fp8cs_config() -> ConfigContainer:
133141
134142
135143def deepseek_v3_pretrain_256gpu_gb200_fp8mx_config () -> ConfigContainer :
136- """DeepSeek V3 pretrain: 256× GB200, MXFP8."""
144+ """DeepSeek V3 pretrain: 256× GB200, MXFP8, NCCL EP ."""
137145 cfg = deepseek_v3_pretrain_config ()
138146 cfg .mixed_precision = _perf_precision ("fp8_mx" )
139147 _deepseek_v3_common (cfg )
@@ -161,6 +169,10 @@ def deepseek_v3_pretrain_256gpu_gb200_fp8mx_config() -> ConfigContainer:
161169 _enable_deepseek_full_iteration (cfg )
162170 cfg .model .fp8_output_proj = True
163171 cfg .mixed_precision .fp8_dot_product_attention = False
172+ _enable_ncclep (cfg )
173+ # Device-side expert token counts: the legacy grouped MLP path syncs tokens_per_expert to the
174+ # host every layer, which serializes the CPU behind the GPU when dispatch is fast.
175+ cfg .model .moe_use_grouped_tensor = True
164176 # Keep process settings next to the recipe so users can see the exact benchmark environment.
165177 cfg .env_vars = {
166178 ** COMMON_PERF_ENV_VARS ,
@@ -172,11 +184,8 @@ def deepseek_v3_pretrain_256gpu_gb200_fp8mx_config() -> ConfigContainer:
172184 "TORCH_NCCL_AVOID_RECORD_STREAMS" : 0 ,
173185 # NCCL user-buffer and launch settings.
174186 "NCCL_NVLS_ENABLE" : 0 ,
175- # HybridEP topology for the target system.
176- "NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN" : 64 ,
177- "NUM_OF_TOKENS_PER_CHUNK_COMBINE_API" : 128 ,
178- "NVLINK_DOMAIN_SIZE" : 72 ,
179- "USE_MNNVL" : 1 ,
187+ # NCCL EP dispatcher mode.
188+ "NCCL_EP_HT_EM_PULL_PUSH" : 1 ,
180189 # Transformer Engine overlap settings for this model.
181190 "CUDNNFE_CLUSTER_OVERLAP_MARGIN" : 8 ,
182191 "NVTE_BWD_LAYERNORM_SM_MARGIN" : 20 ,
@@ -192,8 +201,8 @@ def deepseek_v3_pretrain_256gpu_gb200_fp8mx_config() -> ConfigContainer:
192201
193202
194203def deepseek_v3_pretrain_256gpu_gb200_nvfp4_config () -> ConfigContainer :
195- """DeepSeek V3 pretrain: 256× GB200, NVFP4 with optimizer CUDA graph."""
196- cfg = deepseek_v3_pretrain_256gpu_gb200_bf16_config ()
204+ """DeepSeek V3 pretrain: 256× GB200, NVFP4 with optimizer CUDA graph, NCCL EP ."""
205+ cfg = _build_deepseek_v3_gb200_bf16 ()
197206 cfg .mixed_precision = _perf_precision ("nvfp4" )
198207 _enable_deepseek_full_iteration (cfg )
199208 cfg .model .fp8_output_proj = False
@@ -204,6 +213,10 @@ def deepseek_v3_pretrain_256gpu_gb200_nvfp4_config() -> ConfigContainer:
204213 cfg .model .mla_down_proj_fusion = True
205214 cfg .model .moe_paged_stash_buffer_size_factor_cuda = 1.1
206215 cfg .model .recompute_modules = ["mla_up_proj" , "mlp" ]
216+ _enable_ncclep (cfg )
217+ # Device-side expert token counts: the legacy grouped MLP path syncs tokens_per_expert to the
218+ # host every layer, which serializes the CPU behind the GPU when dispatch is fast.
219+ cfg .model .moe_use_grouped_tensor = True
207220 # Keep process settings next to the recipe so users can see the exact benchmark environment.
208221 cfg .env_vars = {
209222 ** COMMON_PERF_ENV_VARS ,
@@ -215,11 +228,8 @@ def deepseek_v3_pretrain_256gpu_gb200_nvfp4_config() -> ConfigContainer:
215228 "TORCH_NCCL_AVOID_RECORD_STREAMS" : 1 ,
216229 # NCCL user-buffer and launch settings.
217230 "NCCL_NVLS_ENABLE" : 0 ,
218- # HybridEP topology for the target system.
219- "NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN" : 64 ,
220- "NUM_OF_TOKENS_PER_CHUNK_COMBINE_API" : 128 ,
221- "NVLINK_DOMAIN_SIZE" : 72 ,
222- "USE_MNNVL" : 1 ,
231+ # NCCL EP dispatcher mode.
232+ "NCCL_EP_HT_EM_PULL_PUSH" : 1 ,
223233 # Transformer Engine overlap settings for this model.
224234 "NVTE_BWD_LAYERNORM_SM_MARGIN" : 20 ,
225235 "NVTE_FWD_LAYERNORM_SM_MARGIN" : 20 ,
@@ -235,7 +245,7 @@ def deepseek_v3_pretrain_256gpu_gb200_nvfp4_config() -> ConfigContainer:
235245
236246
237247def deepseek_v3_pretrain_256gpu_gb200_fp8mx_large_scale_config () -> ConfigContainer :
238- """DeepSeek V3 pretrain: 256× GB200, MXFP8, large-scale proxy (GBS=256)."""
248+ """DeepSeek V3 pretrain: 256× GB200, MXFP8, large-scale proxy (GBS=256), NCCL EP ."""
239249 cfg = deepseek_v3_pretrain_256gpu_gb200_fp8mx_config ()
240250 cfg .train .global_batch_size = 256
241251 # Keep process settings next to the recipe so users can see the exact benchmark environment.
@@ -249,11 +259,8 @@ def deepseek_v3_pretrain_256gpu_gb200_fp8mx_large_scale_config() -> ConfigContai
249259 "TORCH_NCCL_AVOID_RECORD_STREAMS" : 0 ,
250260 # NCCL user-buffer and launch settings.
251261 "NCCL_NVLS_ENABLE" : 0 ,
252- # HybridEP topology for the target system.
253- "NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN" : 64 ,
254- "NUM_OF_TOKENS_PER_CHUNK_COMBINE_API" : 128 ,
255- "NVLINK_DOMAIN_SIZE" : 72 ,
256- "USE_MNNVL" : 1 ,
262+ # NCCL EP dispatcher mode (inherited from the 256-GPU MXFP8 recipe).
263+ "NCCL_EP_HT_EM_PULL_PUSH" : 1 ,
257264 # Transformer Engine overlap settings for this model.
258265 "CUDNNFE_CLUSTER_OVERLAP_MARGIN" : 8 ,
259266 "NVTE_BWD_LAYERNORM_SM_MARGIN" : 20 ,
0 commit comments