Fix pin-memory offload-route test after ZeRO-1/2 optim-state relink #9148
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 338 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.349
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9148"
general
weight: 0.35
jinyouzhi
Fixes #9140 (nightly regression, modal-torch-latest full suite at 7681845b3).
Root cause
PR #9016 (40a9f40b3) 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.- Negative check: with
pending_host_buffers.append(self.hp_params_pin_buffers)removed fromreload_states, the test fails as expected.- Note: the L20 GPUs are in
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.