Repository navigation
Fix pin-memory offload-route test after ZeRO-1/2 optim-state relink - #9148
Merged
delock merged 3 commits intoNov 23, 2026
Merged
Conversation
…eepspeedai#9140) PR deepspeedai#9016 (40a9f40) added a _relink_hp_params_optimizer_state() call to DeepSpeedZeroOptimizer.reload_states(), which now runs whenever hp/lp params or optim states are offloaded. The unit test that borrows the real reload_states for a minimal fake optimizer only stubbed _link_all_hp_params, so reloading hp_params raised AttributeError and the nightly full suite failed on tests/unit/v1/pin_memory/test_offload_route.py. Add the missing collaborator stub to the fake. The pinned-buffer hold-until-sync contract under test is unchanged. Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
jinyouzhi
marked this pull request as ready for review
November 23, 2026 04:37
jinyouzhi
requested review from
loadams,
tjruwase and
tohtana
as code owners
November 23, 2026 04:37
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb431d030e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
delock
approved these changes
Nov 23, 2026
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
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 #9140 (nightly regression, modal-torch-latest full suite at 7681845).
Root cause
PR #9016 (40a9f40) added a
_relink_hp_params_optimizer_state()call to the end ofDeepSpeedZeroOptimizer.reload_states(), which now runs whenever any of hp params / lp params / optim states is offloaded.tests/unit/v1/pin_memory/test_offload_route.py::test_reload_states_holds_pin_buffers_until_syncborrowed the realreload_statesfor a minimal fake optimizer that only stubbed_link_all_hp_params, so reloading hp params raised:and the nightly full suite failed on this file.
Change
Test-only. Instead of adding another private-method stub to the fake (which would break again on the next internal refactor of
reload_states), the test now exercises the contract on a real engine through the public API:_FakeZeroOptimizeris removed; the test is nowTestReloadStatesHoldsPinBuffers(DistributedTest)(world size 1) on aSimpleModelwith ZeRO-2 and a clienttorch.optim.Adam(no FusedAdam JIT dependency).DS_PIN_MEMORY_BACKEND=native,engine.offload_states(include=[hp_params], pin_memory=True)creates pinned host buffers registered with the native pin manager.engine.reload_states(non_blocking=True)is run while recording, at eachaccelerator.synchronize(), that those buffers are still registered; after the call andgc.collect()the ranges must be released.The pinned-buffer hold-until-sync contract under test is unchanged.
Validation (on-device)
tests/unit/v1/pin_memory/50 passed, 1 skipped.-k TestReloadStatesHoldsPinBuffers-> 1 passed.pending_host_buffers.append(self.hp_params_pin_buffers)removed fromreload_states, the test fails as expected.Exclusive_Processcompute mode, so running the whole file there makes thisDistributedTestsubprocess hit "device busy" after the module-level tests have initialized CUDA in the pytest parent; the other 5 tests pass. This is a local-environment limitation, not related to the change (CI uses default compute mode).AI assistance: GitHub Copilot was used to diagnose the regression and prepare the change; the change was reviewed line-by-line and re-validated on device as above.