fix(zero3): Add focused lifecycle coverage for the ZeRO retained-backward fix. - #28
Merged
nathon-lee merged 4 commits intoJul 15, 2026
Conversation
nathon-lee
force-pushed
the
feature/zero-multi-loss-separate-backward-test
branch
2 times, most recently
from
July 15, 2026 04:13
99beea8 to
f647a07
Compare
Signed-off-by: nathon-lee <leejianwoo@gmail.com> fix(zero3): defer retained param release and flush after follow-up backward Signed-off-by: nathon-lee <leejianwoo@gmail.com> fix: add retain_graph_state_clears_after_followup_backward and retained_backward_does_not_contaminate_next_step Signed-off-by: nathon-lee <leejianwoo@gmail.com> fix: fix some format errs by tool Signed-off-by: nathon-lee <leejianwoo@gmail.com>
nathon-lee
force-pushed
the
feature/zero-multi-loss-separate-backward-test
branch
from
July 15, 2026 04:17
f647a07 to
e4c7eca
Compare
…status assertions Signed-off-by: nathon-lee <leejianwoo@gmail.com>
…kward - Reset output backward preprocess state after each autograd graph completes. - Ensure preprocess_once runs once per backward graph task, including repeated backward on retained graphs. - Keep backward lifecycle consistent for manual scale(...).backward() flows. - Relax ZeRO-3 retained-graph status assertions from strict NOT_AVAILABLE to no INFLIGHT. Signed-off-by: nathon-lee <leejianwoo@gmail.com>
…st flow - Reset output-backward preprocess state at graph completion so retained-graph backward can re-enter preprocess/prologue correctly. - Keep preprocess_once execution scoped to each autograd graph task. - Relax ZeRO-3 retained-graph status checks to require no INFLIGHT params instead of forcing all NOT_AVAILABLE. - In cross-step contamination test, use engine.backward path for the retained pair to validate step isolation without manual-path lifecycle interference. Signed-off-by: nathon-lee <leejianwoo@gmail.com>
nathon-lee
merged commit Jul 15, 2026
467d869
into
feature/zero-multi-loss-separate-backward
9 of 12 checks passed
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.
deepspeedai#8135
Summary
This PR stabilizes retained-graph backward behavior and makes the related regression tests more robust across ZeRO stages.
Background
The retained-graph test subset exposed two instability patterns:
What Changed
Runtime hook lifecycle hardening
Updated output-backward preprocess lifecycle handling to avoid stale preprocess state across retained-graph backward executions.
ZeRO-3 assertion semantics in tests
Relaxed retained-graph status checks from “must be NOT_AVAILABLE” to “must not be INFLIGHT” to better match valid runtime behavior.
Cross-step contamination test path stabilization
In the contamination-across-step scenario, switched the retained pair to
engine.backward(...)so the test focuses on step-isolation semantics rather than manual backward lifecycle internals.Why
Validation
Executed retained-graph regression subset:
two_losses_separate_backward_gas1two_losses_separate_manual_backward_gas1retain_graph_state_clears_after_followup_backwardretained_backward_does_not_contaminate_next_stepResult:
12 passed, 55 deselectedRisk / Follow-up