MTP loss increasing during train
Describe the bug
when training deepseek with MTP (gsm8k), the mtp loss will converge to a higher value than the initial value
using same model and gsm8k with other megatron-based framework results in following loss curve:
SImilar behaviour was observed When training with Qwen-next lora(using the example script in the repo)
[2025-12-26 16:44:40] iteration 1/ 228 | consumed samples: 64 | elapsed time per iteration (ms): 112789.8 | memory(GiB): 24.9 | elapsed time: 1m 52s | remaining time: 7h 6m 43s | throughput per GPU (TFLOP/s/GPU): 131.7 | learning rate: 9.999573E-05 | global batch size: 64 | lm loss: 8.659112E-01 | load_balancing_loss: 3.304209E+00 | mtp_1 loss: 6.761752E-01 | loss scale: 1.0 | grad norm: 5.172 | number of skipped iterations: 0 | number of nan iterations: 0 |
....
[2025-12-26 20:28:46] iteration 228/ 228 | consumed samples: 14592 | elapsed time per iteration (ms): 52341.7 | memory(GiB): 25.69 | elapsed time: 3h 18m 45s | remaining time: 0s | throughput per GPU (TFLOP/s/GPU): 283.9 | learning rate: 1.000000E-05 | global batch size: 64 | lm loss: 2.463827E-02 | load_balancing_loss: 3.289405E+00 | mtp_1 loss: 1.617394E+00 | loss scale: 1.0 | grad norm: 1.234 | number of skipped iterations: 0 | number of nan iterations: 0 |
Your hardware and system info Write your system info like CUDA version/system/GPU/torch version here(在这里给出硬件信息和系统信息,如CUDA版本,系统,GPU型号和torch版本等) cuda 12.8 H20 torch 2.8.0 megatron 0.14 swift branch is master
Additional context training script:
megatron sft
--train_type full
--num_workers 8
--dataset_num_proc 8
--no_save_optim true
--no_save_rng true
--sequence_parallel true
--dataset []
--save []
--pipeline_model_parallel_size 12
--tensor_model_parallel_size 8
--expert_model_parallel_size 16
--expert_tensor_parallel_size 1
--context_parallel_size 1
--cross_entropy_loss_fusion true
--sequence_parallel true
--micro_batch_size 1
--global_batch_size 64
--streaming false
--max_epochs 2
--split_dataset_ratio 0.05
--finetune true
--lr 1e-05
--min_lr 1e-06
--lr_warmup_iters 0
--eval_interval 50
--save_interval 100
--max_length 32000
--tensorboard_dir $TB
--packing false
--use_flash_attn true
--recompute_granularity selective
--recompute_modules core_attn moe_act
--mtp_num_layers 1
--model $PATH
--load_safetensors true
--save_safetensors true
--model_type deepseek_v3_1
--decoder-first-pipeline-num-layers 6
--decoder-last-pipeline-num-layers 5
+1 https://github.com/NVIDIA/Megatron-LM/issues/2417
+1 have you solved it ?
is it fixed?
same
Same here, any clue? I used LoRA finetuning with mtp_loss_scaling_factor=0.1/1.0, both yield increasing loss.
use ms-swift 3.12.6 or >=4.0