Skip to content

Fix pin-memory offload-route test after ZeRO-1/2 optim-state relink - #9148

Merged
delock merged 3 commits into
deepspeedai:masterfrom
jinyouzhi:fix-9140-offload-route-test
Nov 23, 2026
Merged

delock merged 3 commits into
deepspeedai:masterfrom
jinyouzhi:fix-9140-offload-route-test

Conversation

@jinyouzhi

@jinyouzhi jinyouzhi commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 of DeepSpeedZeroOptimizer.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_sync borrowed the real reload_states for a minimal fake optimizer that only stubbed _link_all_hp_params, so reloading hp params raised:

AttributeError: '_FakeZeroOptimizer' object has no attribute '_relink_hp_params_optimizer_state'

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:

  • _FakeZeroOptimizer is removed; the test is now TestReloadStatesHoldsPinBuffers(DistributedTest) (world size 1) on a SimpleModel with ZeRO-2 and a client torch.optim.Adam (no FusedAdam JIT dependency).
  • With 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 each accelerator.synchronize(), that those buffers are still registered; after the call and gc.collect() the ranges must be released.
  • Skips when the native pin manager is unavailable or the accelerator is CPU.

The pinned-buffer hold-until-sync contract under test is unchanged.

Validation (on-device)

  • Original fix-up (fake + stub), 8x NVIDIA H20, torch 2.9.1+cu129: unpatched nightly commit -> 1 failed (the AttributeError above), 5 passed; patched -> 6 passed, tests/unit/v1/pin_memory/ 50 passed, 1 skipped.
  • Real-engine rewrite, NVIDIA L20 (1 GPU used):
    • -k TestReloadStatesHoldsPinBuffers -> 1 passed.
    • Negative check: with pending_host_buffers.append(self.hp_params_pin_buffers) removed from reload_states, the test fails as expected.
    • Note: the L20 GPUs are in Exclusive_Process compute mode, so running the whole file there makes this DistributedTest subprocess 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).
  • pre-commit clean on the modified file.

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.

…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>
@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 22, 2026
@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. and removed skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. labels Nov 22, 2026
@jinyouzhi
jinyouzhi marked this pull request as ready for review November 23, 2026 04:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T04:40:11.004571Z eb431d0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot removed the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 23, 2026
@delock
delock enabled auto-merge November 23, 2026 08:09
@delock
delock added this pull request to the merge queue Nov 23, 2026
Merged via the queue into deepspeedai:master with commit 101d83e Nov 23, 2026
19 checks passed
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nightly regression: modal-torch-latest full suite failed

2 participants