feat(train): add --gradient-checkpointing for DFlash/DSpark - #992
feat(train): add --gradient-checkpointing for DFlash/DSpark#992WindChimeRan wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughChangesThe training configuration now exposes disabled-by-default gradient checkpointing. DFlash models advertise support, training and benchmark scripts apply the setting, benchmark metadata records it, and unit tests verify recomputation and gradient equivalence. Gradient checkpointing
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge Protections🔴 1 of 1 protections blocking · waiting on 👀 reviews
🔴 Require approval from approved reviewers listWaiting for any of
This rule is failing.All pull requests must have at least one approving review from a member of the approved reviewers list before merging.
|
ec9d5f5 to
01760b1
Compare
|
I feel like Still I think this is useful to have as an option for users if not difficult to maintain |
Qwen3DFlashDecoderLayer already extends GradientCheckpointingLayer, but nothing ever turned it on, so draft-layer activations were always kept for the backward pass. They are the single largest consumer of training memory. Opt DFlashDraftModel (and DSpark, which inherits it) into supports_gradient_checkpointing and expose the flag on the training CLI, off by default. use_reentrant=False is passed explicitly rather than relying on the transformers default: the draft layers are called with every input as a keyword argument, and GradientCheckpointingLayer forwards only positional args to the checkpoint function, so the reentrant implementation receives no tensor inputs and silently produces no gradients at all. The added test is the regression guard for that. Signed-off-by: Ranran Haoran Zhang <ranzhang@redhat.com>
Signed-off-by: Ranran Haoran Zhang <ranzhang@redhat.com>
ca06f07 to
007c7c1
Compare
Signed-off-by: Ranran Haoran Zhang <ranzhang@redhat.com>
007c7c1 to
b9f5e1e
Compare
Summary
Adds opt-in
--gradient-checkpointingfor DFlash and DSpark. It recomputes draft-layer activations during backward, reducing peak memory at the cost of step time.The flag remains off by default. EAGLE-3, P-EAGLE, and MTP are unchanged.
H100 results
DFlash with a Qwen3-8B verifier,
--total-seq-len 8192, and current defaults (--num-layers 5 --block-size 16, CE, Muon) on one H100 80GB. Values are medians of three interleaved runs after warmup.The added time is in backward recomputation; forward and optimizer times were effectively unchanged.
Benchmark command and environment
Implementation
DFlashDraftModel(inherited by DSpark).Non-reentrant checkpointing is required because draft layers pass inputs as keyword arguments; the reentrant wrapper forwards only positional arguments and would break draft-layer gradients.
Validation
main