1414
1515"""GB200 pretraining recipe for Nemotron 3 Nano."""
1616
17- from megatron .bridge .recipes .nemotronh .nemotron_3_nano import nemotron_3_nano_pretrain_config
17+ import torch
18+
19+ from megatron .bridge import AutoBridge
20+ from megatron .bridge .recipes .common import _pretrain_common
21+ from megatron .bridge .training .comm_overlap import CommOverlapConfig
1822from megatron .bridge .training .config import ConfigContainer
1923from megatron .bridge .training .mixed_precision import get_mixed_precision_config
2024from megatron .bridge .utils .cuda_graph import set_cuda_graph_modules
2125
2226
27+ _NEMOTRON_3_NANO_MODEL_ID = "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16"
28+
29+
2330def nemotron_3_nano_pretrain_8gpu_gb200_bf16_config () -> ConfigContainer :
2431 """Return the Nemotron 3 Nano BF16 pretraining config for eight GB200 GPUs.
2532
@@ -31,13 +38,21 @@ def nemotron_3_nano_pretrain_8gpu_gb200_bf16_config() -> ConfigContainer:
3138 Returns:
3239 GB200 BF16 pretraining configuration.
3340 """
34- cfg = nemotron_3_nano_pretrain_config ()
41+ cfg = _pretrain_common ()
42+
43+ cfg .model = AutoBridge .from_hf_pretrained (_NEMOTRON_3_NANO_MODEL_ID ).to_megatron_provider (load_weights = False )
44+ cfg .tokenizer .tokenizer_model = _NEMOTRON_3_NANO_MODEL_ID
3545
3646 cfg .model .seq_length = 4096
3747 cfg .dataset .seq_length = 4096
48+ cfg .dataset .blend = None
49+ cfg .dataset .num_workers = 8
50+ cfg .dataset .mmap_bin_files = False
3851
3952 cfg .model .tensor_model_parallel_size = 1
4053 cfg .model .pipeline_model_parallel_size = 1
54+ cfg .model .pipeline_model_parallel_layout = None
55+ cfg .model .pipeline_dtype = torch .bfloat16
4156 cfg .model .virtual_pipeline_model_parallel_size = None
4257 cfg .model .context_parallel_size = 1
4358 cfg .model .sequence_parallel = False
@@ -51,28 +66,68 @@ def nemotron_3_nano_pretrain_8gpu_gb200_bf16_config() -> ConfigContainer:
5166 cfg .model .moe_shared_expert_overlap = False
5267 cfg .model .moe_router_force_load_balancing = False
5368
69+ cfg .train .train_iters = 39735
70+ cfg .train .global_batch_size = 3072
71+ cfg .train .micro_batch_size = 2
72+ cfg .train .manual_gc = False
73+ cfg .train .manual_gc_interval = 0
74+
75+ cfg .model .transformer_impl = "transformer_engine"
76+
5477 # Match the validated GB200 performance recipe's TE-scoped graph set.
5578 cfg .model .cuda_graph_impl = "transformer_engine"
5679 set_cuda_graph_modules (cfg .model , ["attn" , "mamba" , "moe_router" , "moe_preprocess" ])
5780 cfg .model .cuda_graph_warmup_steps = 3
5881 cfg .model .use_te_rng_tracker = True
5982 cfg .rng .te_rng_tracker = True
6083
61- # Retain performance-recipe parity. Nemotron 3 Nano uses no positional
62- # embeddings, so this remains a no-op unless the architecture changes.
84+ cfg .model .attention_backend = "fused"
85+ cfg .model .moe_router_fusion = False
86+ cfg .model .moe_permute_fusion = True
87+ cfg .model .moe_grouped_gemm = True
88+ cfg .model .cross_entropy_loss_fusion = True
6389 cfg .model .apply_rope_fusion = True
6490 cfg .model .cross_entropy_fusion_impl = "native"
91+ cfg .model .recompute_granularity = None
92+ cfg .model .recompute_modules = None
93+ cfg .model .fine_grained_activation_offloading = False
94+ cfg .model .offload_modules = None
95+ cfg .model .moe_router_padding_for_fp8 = False
6596 cfg .rerun_state_machine .check_for_nan_in_loss = False
66- cfg .ddp .check_for_nan_in_grad = False
97+
98+ cfg .optimizer .use_precision_aware_optimizer = False
99+ cfg .optimizer .main_grads_dtype = torch .float32
100+ cfg .optimizer .main_params_dtype = torch .float32
101+ cfg .optimizer .exp_avg_dtype = torch .float32
102+ cfg .optimizer .exp_avg_sq_dtype = torch .float32
103+ cfg .optimizer .lr = 1.6e-3
104+ cfg .optimizer .weight_decay = 0.1
105+ cfg .optimizer .min_lr = 1.6e-5
106+ cfg .scheduler .lr_warmup_iters = 333
67107
68108 # Keep BF16 compute while reducing gradients in BF16 instead of FP32.
69109 cfg .mixed_precision = get_mixed_precision_config (cfg .mixed_precision )
70110 cfg .mixed_precision .grad_reduce_in_fp32 = False
111+
112+ cfg .comm_overlap = CommOverlapConfig (
113+ tp_comm_bootstrap_backend = "nccl" ,
114+ tp_comm_overlap = False ,
115+ )
116+ cfg .comm_overlap .delay_wgrad_compute = False
117+ cfg .comm_overlap .overlap_moe_expert_parallel_comm = False
118+
119+ cfg .checkpoint .save_interval = 200
120+ cfg .checkpoint .ckpt_assume_constant_structure = True
121+ cfg .checkpoint .dist_ckpt_strictness = "log_all"
122+
123+ cfg .ddp .overlap_grad_reduce = True
124+ cfg .ddp .overlap_param_gather = True
125+ cfg .ddp .check_for_nan_in_grad = False
126+ cfg .ddp .use_distributed_optimizer = True
71127 cfg .ddp .grad_reduce_in_fp32 = False
72128
73- # TP communication overlap requires TP > 1 and sequence parallelism.
74- if cfg .comm_overlap is not None :
75- cfg .comm_overlap .tp_comm_overlap = False
129+ cfg .model .init_method_std = 0.0173
130+ cfg .model .use_fused_weighted_squared_relu = True
76131
77132 return cfg
78133
0 commit comments