feat(ssm): whole-module 'gdn' selective recompute for GatedDeltaNet
Summary
Adds a whole-module gdn entry to recompute_modules (selective granularity) that recomputes the entire GatedDeltaNet module — in_proj, CP all-to-all, conv1d, the gated delta rule, the gated norm, and out_proj — via normal checkpointing. This mirrors how core_attn recomputes the attention core, and trades the GDN activation memory for a backward-pass recompute.
Changes
transformer_config: add"gdn"to therecompute_moduleschoices + allowed set, document it as a normal-checkpointing module, and guard that it requiresexperimental_attention_variant="gated_delta_net".GatedDeltaNet: extract the forward compute body into_forward_computeand wrap it intensor_parallel.checkpointwhenrecompute_gdnis set and the module is training. Non-tensor arguments are bound via a closure (only the input tensor is passed tocheckpoint, matching the MLP-recompute pattern, sincesave_for_backwardaccepts tensors only).- test:
test_selective_recompute_gdnparity check — same module/input run with recompute off vs on; forward output and all input/parameter gradients must match within bf16 tolerance.
Test / accuracy
Ran on GB200 (oci-hsg) via the CI-faithful flow (mcore-ci-dev container + run_ci_test.sh + torch.distributed.run):
tests/unit_tests/ssm/test_gated_delta_net.py
=========== 42 passed, 4 skipped, 265 warnings in 854.97s (0:14:14) ============
test_selective_recompute_gdn passes for all parametrized combos (tp∈{1,2}, sp∈{F,T}, cp∈{1,2}): output and gradients are bit-for-bit consistent with the non-recompute path within bf16 tolerance.
Draft pending review.
This pull request requires additional validation before any workflows can run on NVIDIA's runners.
Pull request vetters can view their responsibilities here.
Contributors can view more details about this message here.
/ok to test a010f83
/ok to test 2cd9c12
/ok to test 1674328
/ok to test 5251bfd
🔄 Merge queue validation started!
You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/27594703209
🔄 Merge queue validation started!
You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/27595256854