Repository navigation
fix(compile): preserve unused gradients and validate collective usage - #16
Open
yu-chen-code wants to merge 1 commit into
Open
yu-chen-code wants to merge 1 commit into
yu-chen-code wants to merge 1 commit into
Conversation
yu-chen-code
force-pushed
the
feat-graph-unused-gradients
branch
from
November 9, 2026 11:25
e7ed6f4 to
4c52a3e
Compare
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 type of PR is this?
/kind bug
What does this PR do / why do we need it:
Refreshed on 2026-11-09 against fork/upstream master
a6be99d3. PR1421 is now merged upstream, so its duplicate prerequisite has been removed. Current head:4c52a3e1922032fd9f58887c29ecaeab8d637486; retained feature/dependency commits:4c52a3e1. Git range-diff confirms unchanged feature patches. Focused CPU regression on this exact head: 114 JUnit records, 0 failures, 0 errors. The isolated refresh environments now include master-required PEFT 0.21.2 and accelerate 1.13.0; pip check passes. All numerical runs and older source hashes below are pre-refresh evidence. NPU precision training and formal upstream CI were not rerun for this rebase.Keep truly unused trainable parameters out of AdamW updates when replaying a joint graph. The tracer previously replaced every
Nonegradient with a zero tensor. A parameter absent from the loss therefore acquired Adam moments and weight decay in graph mode, although eager training left its gradient and optimizer state absent. With learning rate 0.01 and weight decay 0.1, ten updates changed an unused weight from 0.5 by 0.00497749, a relative error of 0.00995499.Preserve each
Nonein its original gradient-output slot. The existing FSDP pass already skips literal non-node gradients without compacting parameter indices, so later parameters and trailing loss metrics retain their correct positions. The compiler skipsNoneduring accumulation and leaves any earlier microbatch gradient intact. A used parameter with a tensor-valued zero gradient still follows the usual optimizer state creation and decay; zero-token expert-bank gradients remain tensors.When graph FSDP or PP is enabled in distributed training, validate the captured state schema and each trainable FQN/unused flag once across all participating world ranks before parallel graph lowering. All ranks participate, including ranks with no unused parameter. This is a conservative uniform-usage admission check, not a gradient union between distinct EP owners. Rank-dependent trainable sets or usage fail explicitly instead of emitting different collective sequences. PP with unused gradients is explicitly rejected; dynamic unused-parameter recapture and owner-group union are outside this change.
Validation:
0.701689600944519versus0.7016897201538086on this Torch nightly, the same two-FP32-ULP baseline reproduced on the prerequisite. They were not skipped or relaxed; an all-tests-passed result is not claimed.e7ed6f4f: native eager FSDP4 versus graph, ten AdamW updates and two microbatches, 720 tensor comparisons exact. Unused gradients and moments remain absent; used tensor-zero gradients retain moments and decay.Source manifests, full tensors, commands, numerical summaries and original failures are retained in T020
runs/20261106-graph-capability-spikes/unused*; the final summary isunused/final-verification.json. No formal upstream gate is requested or claimed.Which issue(s) this PR fixes:
None.
Code review checklist [illustration]: