Preserve requires_grad in SimpleFSDP parameter registration - #4282
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
Preserve requires_grad in SimpleFSDP parameter registration#4282sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
sylvesterkaczmarek
requested review from
IvanKobzarev,
SherlockNoMad,
aditvenk,
sanketpurandare,
tianyu-l and
xmfan
as code owners
August 22, 2026 09:43
tianyu-l
approved these changes
Aug 22, 2026
Contributor
|
not sure if the graph trainer error is introduced by this change |
Contributor
Author
Thanks. I checked the current run. Lint passed, while the GraphTrainer integration job is the only failing signal I found. I don't have Actions write permission on the upstream repo to rerun it. Could you rerun the failed job so we can confirm whether this is transient before changing the approved one-line fix? |
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.
Fixes #3885.
Summary
SimpleFSDP re-registers each distributed parameter by wrapping it in
nn.Parameter(...). Becausenn.Parameterdefaultsrequires_grad=True, a parameter that was intentionally frozen before SimpleFSDP wrapping becomes trainable again.This change passes the original parameter's
requires_gradvalue when re-registering the distributed parameter, preserving both frozen and trainable parameter state.Changes
p.requires_gradwhen constructing the replacementnn.Parameterindata_parallel()requires_gradvaluesThe behavior of already-trainable parameters is unchanged.
Validation
Added
test_preserves_parameter_requires_gradtotorchtitan/experiments/graph_trainer/tests/test_simple_fsdp.py. It exercises the existing public SimpleFSDP application path at world size 1 with the CPU/gloo test setup already used by this file.The test suite and
pre-commitwere not run locally in this environment because the repository is not available as a local checkout here. No local test result is claimed; CI should run the updated test file.