Repository navigation
[CI] Fix the two failing multi-GPU unit tests - #6354
Conversation
GPU Unit Tests on main fail in two tests since 2026-11-23. TestDistMuonCpuOffload sets its gloo+nccl backend through a `backend` property. pytorch/pytorch#205504 (in nightlies since 2026-11-23) renamed the DTensorTestBase hook to `backend_str`, so the override is ignored, the process group is NCCL-only, and the CPU all_gather in `_validate_bucket_plans_across_ranks` raises "No backend type associated with device type cpu". Pass the backend to `with_comms` instead, which works with both old and new PyTorch. test_rounded_pinned_memory_raises (added in #5881) builds the model twice and expects the second build to raise because its pinned moments are rounded up. The first build's result is dropped, so its exact-size pinned blocks can return to the host allocator cache and be reused by the second build, which then sees no rounding. When that happens on one rank only, that rank fails while the other waits in the barrier, and the test times out after 300s. Keeping the first build alive makes the second build allocate new blocks. Test plan (torch 2.16.0.dev20261123+cu132, 2x H100): ``` pytest tests/unit_tests/gpu/components/optim/test_adam_cpu_offloaded_moments.py \ "tests/unit_tests/gpu/distributed/flex_shard/test_dist_muon.py::TestDistMuonCpuOffload" ``` Before: both tests fail (the Adam test hung in 3/3 runs). After: 4 passed, 5/5 runs. This PR was authored with an AI assistant.
|
@claude review |
|
Claude finished @acisseJZhong's task in 1m 11s —— View job Approve -- please fill in the human-written summary before merging. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging -- both fixes are test-only, minimal (+3/-6), and fix the root cause of each CI failure. The only must-fix is the missing human-written summary.
What this PR does. It fixes two red multi-GPU unit tests on main.
test_dist_muon.py: the class used to set the process-group backend by overriding thebackendproperty. pytorch/pytorch#205504 renamed that hook tobackend_str, so the override is now ignored and the PG is NCCL-only. The PR passes the backend throughwith_comms(backend=...)instead, which works before and after the rename.test_adam_cpu_offloaded_moments.py: the test now keeps the first build's result alive. Before, it was dropped.
Example (Adam test).
before: _build(threshold=1MB) -> exact-size 3 MiB pinned blocks, result dropped -> blocks go to the host cache
_build(threshold=1GB) -> can reuse the cached blocks, so active_bytes grows by about requested_bytes
-> no ValueError on that rank; the other rank waits in destroy_pg's barrier -> 300 s timeout
after: _first = _build(...) -> blocks stay in use, so nothing is in the cache
_build(threshold=1GB) -> new blocks rounded to a power of two (4 MiB), reserved > requested + slack -> raises on both ranks
This matches _check_cuda_pinned_host_rounding (torchtitan/components/optim/offloading.py:78). That check measures active_bytes.current growth, so a block from the cache with no rounding hides the rounding the test is checking for.
Must fix
- PR description -- "Summary (human-written)" is empty. Per
CONTRIBUTING.md/.claude/CLAUDE.md(PR Expectations 2), the author writes it before merge.
Should consider
- The CPU tests that still override
backend(tests/unit_tests/cpu/components/optim/test_ema_resharding.py:44,109,216,280,tests/unit_tests/cpu/models/qwen3_8_flash_next/test_owned_table.py:44,test_row_sharded_embedding.py:35,tests/rl/unit_tests/cpu/test_model_state_dict_transport.py:365,tests/rl/unit_tests/cpu/test_generator_model.py:232) are now dead code. Leaving them for a follow-up PR is fine (one concern per PR). Please make sure that follow-up happens: anyone who copies the pattern into a GPU test will hit the same silent NCCL-only PG.
Details
- Gate: the failures are real on main and the PR describes them. Both fixes target the cause (the renamed upstream hook, and reuse of cached pinned blocks), not the symptom. No tolerance or timeout was loosened, and no test was skipped. Searching open PRs found no overlap.
with_comms(eager_init=False, backend=None)takesbackendas a keyword in upstreamcommon_dtensor.py, so the decorator form doesn't depend on the hook name._firststays referenced until the test function returns, so its pinned blocks can't be freed before the second_build. EachDTensorTestBasetest runs in fresh spawned processes, so no cached pinned blocks or allocator settings carry over from other tests.- The first build at threshold 1 MB also implicitly checks that the check does not raise when rounding is disabled.
Not verified: I didn't run the tests (no GPU here). The pass rates are the author's (5/5 runs on 2x H100).
Summary (human-written)
Fix failing CI test.
Agent details (AI-generated, to be reviewed by @acisseJZhong)