Skip to content

Commit ace1b77

Browse files
cuichenxNeMo Bot
authored andcommitted
fix(recipe): prevent Qwen3.5-VL FSDP SFT OOM (#5508)
Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: NeMo Bot <nemo-bot@nvidia.com>
1 parent 5796c06 commit ace1b77

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎src/megatron/bridge/recipes/qwen_vl/h100/qwen35_vl.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,9 @@ def qwen35_vl_35b_a3b_sft_2gpu_h100_bf16_fsdp_config() -> ConfigContainer:
951951
cfg.model.attention_backend = "auto"
952952
cfg.model.gradient_accumulation_fusion = True
953953
cfg.model.cross_entropy_loss_fusion = True
954-
cfg.model.cross_entropy_fusion_impl = "native"
954+
# Native fused cross entropy materializes a full FP32 vocabulary-sized
955+
# softmax buffer. Use the TE kernel to keep the 248K-token loss bounded.
956+
cfg.model.cross_entropy_fusion_impl = "te"
955957

956958
# MoE settings
957959
cfg.model.moe_token_dispatcher_type = "alltoall"
@@ -965,10 +967,12 @@ def qwen35_vl_35b_a3b_sft_2gpu_h100_bf16_fsdp_config() -> ConfigContainer:
965967
cfg.model.moe_router_padding_for_fp8 = False
966968

967969
# Memory saving
968-
cfg.model.recompute_granularity = None
970+
# Full SFT retains FP32 optimizer state alongside the FSDP communication
971+
# pools, so recompute each transformer layer to bound live activations.
972+
cfg.model.recompute_granularity = "full"
969973
cfg.model.recompute_modules = None
970-
cfg.model.recompute_method = None
971-
cfg.model.recompute_num_layers = None
974+
cfg.model.recompute_method = "uniform"
975+
cfg.model.recompute_num_layers = 1
972976
cfg.model.fine_grained_activation_offloading = False
973977
cfg.model.offload_modules = None
974978

‎tests/unit_tests/recipes/qwen_vl/test_qwen35_vl_recipes.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ def test_qwen35_vl_35b_a3b_fsdp_sft_defaults(monkeypatch: pytest.MonkeyPatch):
431431
assert cfg.model.sequence_parallel is False
432432
assert cfg.model.moe_token_dispatcher_type == "alltoall"
433433
assert cfg.model.moe_router_fusion is True
434+
assert cfg.model.cross_entropy_loss_fusion is True
435+
assert cfg.model.cross_entropy_fusion_impl == "te"
436+
assert cfg.model.recompute_granularity == "full"
437+
assert cfg.model.recompute_modules is None
438+
assert cfg.model.recompute_method == "uniform"
439+
assert cfg.model.recompute_num_layers == 1
434440
assert cfg.ddp.use_megatron_fsdp is True
435441
assert cfg.ddp.fsdp_double_buffer is True
436442
assert cfg.ddp.megatron_fsdp_max_pool_double_buffer is True

0 commit comments

Comments
 (0)