Don't retain returned work in ProcessGroupDummy #376
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 · 334 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.348
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #376"
general
weight: 0.35
d4l3k
Summary
ProcessGroupDummyappended every_DummyWorkit returned to aself._worklist that nothing ever read or cleared.torchft.ddp.DistributedDataParallelbuilds torch DDP on aProcessGroupDummywithfind_unused_parameters=True, so the reducer allreduces itslocal_used_mapthrough the dummy group on every gradient-syncing backward, and each step retained one_DummyWork(its tensor list plus a donetorch.futures.Future, about 1.3 KB) for the life of the model. Modules with buffers retained two more per forward, each holding a freshly flattened copy of the buffers.This drops the list and returns the work directly. Nothing in the repo referenced
ProcessGroupDummy._work.Why the list is no longer needed
The list dates from e4f512e (Oct 2024) and acted as a keep-alive: at the time, a Python
Workreturned to C++ through thePyProcessGrouptrampoline could be collected while the C++Reducerstill held it, and the nextwait()fell back to the baseWork::wait()and hung. pytorch/pytorch#146376 (torch 2.7) fixed that by wrapping returned Python works inPyWorkHolder, which keeps the Python object alive as long as the C++intrusive_ptris held. torchft requirestorch>=2.7, so the dummy group no longer needs to pin the works itself. Verified on torch 2.14: after each backward exactly one_DummyWork(the reducer's currentlocal_used_work_) is alive, and the reducer'swait()still dispatches to the Python override.Test plan
test_dummy_does_not_retain_work: weakrefs the work returned byallreduce, drops it and asserts it is collected. Fails on main, passes with this change.Linear(1, 1), CPU, 20k steps): on mainlen(pg._work)grows 4 -> 20004; with this change live_DummyWorkobjects stay at 1 and RSS is flat after warm-up.pytest torchft/process_group_test.py torchft/ddp_test.py torchft/manager_test.pyandtorchft/manager_integ_test.py -k ddppass (86 / 4 / 30 / 7 passed);ufmt checkis clean;pyrefly checkand flake8 report nothing new.One note for reviewers: a
ProcessGroupDummythat is registered withtorch.distributedand used by torch DDP insideJoin(divide_by_initial_world_size=False)would now hang, becauseReducer._set_forward_pass_work_handletakes the Python work withoutPyWorkHolder; the leaked list used to mask that. torchft's DDP uses an unregistered dummy group and never usesJoin, and the same hang already affects every other Python-definedWorkon main, so this is a PyTorch-side gap rather than something this change introduces.🤖 Generated with Claude Code