glm5.3_flash训练dsa报oom
Maintainers usually reply within 1 day
@hjh0119 is already working on this.
Since Oct 19, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- machine-learning
Research direction
Start with packages/megatron/core/transformer/experimental_attention_variant/dsa.py around line 145 and the reported dsa_masking.py masked_softmax call around line 373. Check how the DSA attention computation handles the reported 16,384 token sequence and masking, then reproduce with the supplied training configuration. Done when training completes without the reported 4 GB CUDA allocation failure or a reproducible workaround is documented.
Written by the indexing model from the issue text.
Description
Checklist / 检查清单
- I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述
训练过程中,64卡L20X,dsa的attention计算始终报oom,有办法绕过去吗?
packages/megatron/core/transformer/experimental_attention_variant/dsa.py", line 145, in _unfused_absorbed_dsa_fn
[rank38]: scores_chunk = dsa_masking.masked_softmax(scores_chunk.float(), valid_chunk, dim=-1)
[rank38]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank38]: File "/opt/nas/p/conda/envs/tcxia_swift_head/lib/python3.12/site-packages/megatron/core/transformer/experimental_attention_variant/dsa_masking.py", line 373, in masked_softmax
[rank38]: return probs.masked_fill(~valid_mask, 0.0)
[rank38]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank38]: torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 4.00 G
How to Reproduce / 如何复现
训练配置如下
python -m mcore_bridge.tools.apply_megatron_patch &&
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 megatron sft
--model $MODELPATH
--tuner_type full
--dataset $data
--loss_scale ignore_empty_think
--agent_template glm5_1
--tensor_model_parallel_size 2
--pipeline_model_parallel_size 2
--context_parallel_size 1
--expert_model_parallel_size 16
--moe_grouped_gemm true
--moe_aux_loss_coeff 1e-3
--micro_batch_size 1
--global_batch_size 64
--recompute_granularity full
--recompute_method uniform
--recompute_num_layers 2
--num_train_epochs 3
--finetune true
--cross_entropy_loss_fusion true
--lr 1e-5
--lr_warmup_fraction 0.05
--min_lr 1e-6
--save_total_limit 5
--output_dir $OUTPUTDIR
--save_steps 50
--max_length 16384
--packing true
--sequence_parallel true
--bf16 true
--dataloader_num_workers 8
--dataset_num_proc 8
--no_save_optim true
--no_save_rng true
--report_to swanlab
--swanlab_project $project_name
--swanlab_exp_name $exp_name
--attention_backend flash
--language_model_only true
--vit_attn_impl sdpa \
环境参数如下
megatron-core 0.19.0+ee743d3ef
mcore_bridge 1.7.0.dev0
transformers 5.19.0
ms_swift 4.6.0
Additional Information / 补充信息
No response
- Dominant language
- Python
- Stars
- 16.2k
- Forks
- 1.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 68
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelscope/ms-swift
-
get_multimodal_target_regex(..., exclude_router=True) does not exclude shared_expert_gatePossibly taken @KonnyakuMatcha claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelscope/ms-swift#10696 ·
Maintainers usually reply within 1 day
-
[BUG] GRPO REAL loss crashes with beta>0 and kl_in_reward=True (NoneType * Tensor)Possibly taken @newcloud123 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
modelscope/ms-swift#10690 ·
Maintainers usually reply within 1 day
-
[BUG] GRPO REAL loss divides by all groups instead of valid groups, silently scaling gradientsPossibly taken @newcloud123 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelscope/ms-swift#10688 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 Half a day Newbie friendliness 62/100
modelscope/ms-swift#10621 ·
Maintainers usually reply within 1 day
-
[Bug] `get_seed` consumes a draw from the shared RandomState even when decision augmentation is disabled, changing the train/val split and dataset shufflePossibly taken @ryznren claimed this 38 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelscope/ms-swift#10466 · 1 comment ·
Maintainers usually reply within 1 day
All issues in modelscope/ms-swift
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day