|
18 | 18 | import torch |
19 | 19 |
|
20 | 20 | import megatron.bridge.recipes as recipes |
| 21 | +from megatron.bridge.perf_recipes.environment import HYBRID_EP_ENV_NAMES |
21 | 22 | from megatron.bridge.perf_recipes.nemotronh import ( |
| 23 | + nemotron_3_ultra_pretrain_256gpu_gb200_nvfp4_config, |
| 24 | + nemotron_3_ultra_pretrain_256gpu_gb300_nvfp4_config, |
22 | 25 | nemotron_3_ultra_pretrain_256gpu_vrnvl72_fp8mx_config, |
23 | 26 | nemotron_3_ultra_pretrain_256gpu_vrnvl72_nvfp4_config, |
24 | 27 | ) |
|
36 | 39 | nemotron_3_ultra_pretrain_config, |
37 | 40 | nemotron_3_ultra_sft_openmathinstruct2_packed_config, |
38 | 41 | ) |
| 42 | +from megatron.bridge.utils.cuda_graph import cuda_graph_module_names |
39 | 43 | from tests.unit_tests.recipes.recipe_test_utils import ( |
40 | 44 | NEMOTRON_3_ULTRA_HYBRID_LAYER_PATTERN, |
41 | 45 | patch_recipe_module_global, |
@@ -202,23 +206,69 @@ def test_vrnvl72_nvfp4_perf_recipe_uses_nvl72_ultra_topology() -> None: |
202 | 206 | assert cfg.model.expert_model_parallel_size == 64 |
203 | 207 | assert cfg.model.expert_tensor_parallel_size == 1 |
204 | 208 | assert cfg.model.moe_token_dispatcher_type == "flex" |
205 | | - assert cfg.model.moe_flex_dispatcher_backend == "hybridep" |
| 209 | + assert cfg.model.moe_flex_dispatcher_backend == "ncclep" |
| 210 | + assert cfg.model.moe_use_grouped_tensor is True |
206 | 211 | assert cfg.model.moe_router_padding_for_quantization is True |
207 | | - assert cfg.model.cuda_graph_impl == "none" |
| 212 | + assert cfg.model.cuda_graph_impl == "local" |
| 213 | + assert cuda_graph_module_names(cfg.model) == ["attn", "mamba"] |
| 214 | + assert cfg.model.use_te_rng_tracker is True |
| 215 | + assert cfg.rng.te_rng_tracker is True |
208 | 216 | assert cfg.mixed_precision.fp4 == "e2m1" |
209 | | - assert cfg.mixed_precision.fp4_param_gather is False |
| 217 | + assert cfg.mixed_precision.fp4_param_gather is True |
210 | 218 | assert cfg.train.global_batch_size == 256 |
211 | 219 | assert cfg.train.micro_batch_size == 1 |
212 | | - assert cfg.ddp.use_megatron_fsdp is True |
213 | | - assert cfg.ddp.num_distributed_optimizer_instances == 4 |
214 | | - assert cfg.env_vars["NUM_OF_HYBRID_EP_RANKS_PER_NVLINK_DOMAIN"] == 64 |
215 | | - assert cfg.env_vars["NVLINK_DOMAIN_SIZE"] == 72 |
| 220 | + assert cfg.dist.use_megatron_fsdp is False |
| 221 | + assert cfg.ddp.use_megatron_fsdp is False |
| 222 | + assert cfg.model.tensor_parallel_num_weight_shards == 64 |
| 223 | + assert cfg.model.expert_tensor_parallel_num_weight_shards == 1 |
| 224 | + assert cfg.ddp.num_distributed_optimizer_instances == 1 |
| 225 | + assert cfg.env_vars["NCCL_EP_HT_EM_PULL_PUSH"] == 1 |
| 226 | + assert cfg.env_vars.keys().isdisjoint(HYBRID_EP_ENV_NAMES) |
216 | 227 | assert cfg.env_vars["NVTE_CPU_OFFLOAD_V1"] == 1 |
217 | 228 | assert cfg.env_vars["NVTE_CUTEDSL_FUSED_GROUPED_MLP"] == 1 |
218 | 229 | assert cfg.env_vars["NVTE_NORM_BWD_USE_CUDNN"] == 1 |
219 | 230 | assert cfg.env_vars["NVTE_NORM_FWD_USE_CUDNN"] == 1 |
220 | 231 | assert cfg.env_vars["NVTE_USE_FAST_MATH"] == 1 |
221 | | - assert cfg.env_vars["USE_MNNVL"] == 1 |
| 232 | + |
| 233 | + |
| 234 | +@pytest.mark.unit |
| 235 | +@pytest.mark.parametrize( |
| 236 | + ("recipe_factory", "tensor_model_parallel_size", "sequence_parallel"), |
| 237 | + [ |
| 238 | + (nemotron_3_ultra_pretrain_256gpu_gb200_nvfp4_config, 2, True), |
| 239 | + (nemotron_3_ultra_pretrain_256gpu_gb300_nvfp4_config, 1, False), |
| 240 | + ], |
| 241 | + ids=["gb200", "gb300"], |
| 242 | +) |
| 243 | +def test_nvfp4_perf_recipes_use_gtp_partial_cuda_graphs_and_nccl_ep( |
| 244 | + recipe_factory, tensor_model_parallel_size: int, sequence_parallel: bool |
| 245 | +) -> None: |
| 246 | + """GB200 and GB300 Ultra NVFP4 shard dense weights rack-locally with GTP instead of HSDP.""" |
| 247 | + cfg = recipe_factory() |
| 248 | + |
| 249 | + assert cfg.model.tensor_model_parallel_size == tensor_model_parallel_size |
| 250 | + assert cfg.model.sequence_parallel is sequence_parallel |
| 251 | + assert cfg.model.expert_model_parallel_size == 64 |
| 252 | + assert cfg.model.expert_tensor_parallel_size == 1 |
| 253 | + assert cfg.mixed_precision.fp4 == "e2m1" |
| 254 | + assert cfg.mixed_precision.fp4_param_gather is True |
| 255 | + |
| 256 | + assert cfg.dist.use_megatron_fsdp is False |
| 257 | + assert cfg.ddp.use_megatron_fsdp is False |
| 258 | + assert cfg.model.tensor_parallel_num_weight_shards == 64 |
| 259 | + assert cfg.model.expert_tensor_parallel_num_weight_shards == 1 |
| 260 | + assert cfg.ddp.num_distributed_optimizer_instances == 1 |
| 261 | + |
| 262 | + assert cfg.model.cuda_graph_impl == "local" |
| 263 | + assert cuda_graph_module_names(cfg.model) == ["attn", "mamba"] |
| 264 | + assert cfg.model.use_te_rng_tracker is True |
| 265 | + assert cfg.rng.te_rng_tracker is True |
| 266 | + |
| 267 | + assert cfg.model.moe_token_dispatcher_type == "flex" |
| 268 | + assert cfg.model.moe_flex_dispatcher_backend == "ncclep" |
| 269 | + assert cfg.model.moe_use_grouped_tensor is True |
| 270 | + assert cfg.env_vars["NCCL_EP_HT_EM_PULL_PUSH"] == 1 |
| 271 | + assert cfg.env_vars.keys().isdisjoint(HYBRID_EP_ENV_NAMES) |
222 | 272 |
|
223 | 273 |
|
224 | 274 | @pytest.mark.unit |
|
0 commit comments