Add gdn_in_proj_conv wide selective recompute for GatedDeltaNet - #5982
Open
maxyzhu wants to merge 1 commit into
Open
Add gdn_in_proj_conv wide selective recompute for GatedDeltaNet#5982maxyzhu wants to merge 1 commit into
maxyzhu wants to merge 1 commit into
Conversation
maxyzhu
marked this pull request as ready for review
July 27, 2026 17:31
maxyzhu
marked this pull request as draft
July 27, 2026 18:10
Author
|
@NVIDIA/mcore-oncall PR is ready for review whenever you get a chance, thanks! |
maxyzhu
force-pushed
the
gdn-inproj-conv-selective-recompute
branch
from
July 27, 2026 18:52
acb87d3 to
0243671
Compare
maxyzhu
force-pushed
the
gdn-inproj-conv-selective-recompute
branch
3 times, most recently
from
August 7, 2026 03:39
2eba70a to
80f182e
Compare
maxyzhu
marked this pull request as ready for review
August 7, 2026 03:39
This was referenced Aug 8, 2026
Signed-off-by: Mingxi Zhu <mingxi_zhu@berkeley.edu>
maxyzhu
force-pushed
the
gdn-inproj-conv-selective-recompute
branch
from
August 9, 2026 16:40
80f182e to
3da8c65
Compare
Author
|
hi @NVIDIA/mcore-oncall PR ok to add label and test/merge. Thanks! |
This was referenced Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a fine-grained selective activation-recompute option,
gdn_in_proj_conv, to the GatedDeltaNet (GDN) module. It recomputes the front-end region of the GDN layer — input projection, CP all-to-all, split, and the causalconv1d— as a single activation checkpoint, instead of stashing its (large) intermediate activations for the backward pass.On a 20-layer GDN stack this saves ~20.3% peak memory and ~27.9% activation memory at ~17.6% iteration-time overhead, versus the no-recompute baseline.
Enable with
recompute_granularity="selective"andrecompute_modules=["gdn_in_proj_conv"].How we arrived at this boundary (measured on a 4×GPU environment)
Activation recompute trades compute for memory; the memory it saves is whatever the checkpointed region would otherwise retain across the forward→backward boundary. The interesting question was which region to recompute. All numbers below are per single GDN layer unless stated otherwise (bf16, hidden=2048, seq=8192, batch=2, TP=CP=1);
act= activation memory retained after forward,peak= full fwd+bwd step peak.1. Recomputing any single sub-module alone does not pay off
The large tensor in this region is
qkvzba(the in_proj output,in_proj_dimwide). A narrow checkpoint cannot free it, becauseqkvzbais the checkpoint's output and is stashed by the downstream ops regardless.2. Widening the region from in_proj toward the delta-rule input
We swept the checkpoint end-point (region always starts at the layer input):
The step change at W3 is because once
conv1dis inside the region,qkvzbabecomes an internal activation and is freed; the region now retains only the small layer input (hidden_states) plus the narrower post-conv output. W3 gives the cleanest saving-per-overhead ratio, so this PR ships W3.3. End-to-end check on a 20-layer GDN stack
Per-layer savings compound across depth (each layer frees its front-end activations early, lowering the whole-forward peak). On a 20-layer GDN stack (seq=2048, batch=1, TP=CP=1):
Correctness
gdn_in_proj_convrecomputes a region that contains a CP collective (all-to-all); the recompute re-issues it symmetrically across ranks (same pattern as the existinggdn_norm_outrecompute). Verified by unit tests over TP/CP ≤ 2:torch.equal). Hard gate on all architectures.What's included
gdn_in_proj_convselective-recompute option (config validation guard: requiresexperimental_attention_variant="gated_delta_net").test_selective_recompute_in_proj_conv_deterministicandtest_selective_recompute_in_proj_conv_within_kernel_noise(parametrized over TP/CP ≤ 2).What's deferred (follow-ups)
gdn_gated_delta_rulerecompute — deterministic mode is counterproductive (peak rises) and non-deterministic mode is redundant with the FLA kernel's internal recompute; a genuinely useful variant needs a memory-efficient non-deterministic recompute path (e.g. a bwd-friendly GDN kernel). Tracked separately.thd) sequences — the non-packed path is covered and tested; thethdpath is structurally supported but not yet validated, so it is guarded.Reproducibility
Measurement scripts and the boundary-sweep data are kept out of this PR (they are measurement-only and decoupled from the feature), preserved on branch
archive/local-boundary-bench/ tagevidence/gdn-boundary-sweep.Issue tracking
Linked issue: New Feature: fine-grained selective recompute for
in_proj,conv1d,gated delta rulein [2026 Q3] Megatron Core Roadmap #5676Contribution process
Pre-checks