Skip to content

[CI] Fix the two failing multi-GPU unit tests - #6354

Merged
acisseJZhong merged 1 commit into
mainfrom
acisseJZhong/fix-gpu-unit-tests
Nov 24, 2026
Merged

acisseJZhong merged 1 commit into
mainfrom
acisseJZhong/fix-gpu-unit-tests

Conversation

@acisseJZhong

@acisseJZhong acisseJZhong commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Fix failing CI test.

Agent details (AI-generated, to be reviewed by @acisseJZhong)

AI-generated by an AI agent on behalf of @acisseJZhong.

Why. GPU Unit Tests has failed on main since 2026-11-23, in two multi-GPU tests:

Test Failure Cause
TestDistMuonCpuOffload::test_accelerator_ns_device_matches_gpu_resident_run No backend type associated with device type cpu pytorch/pytorch#205504 (nightlies from 2026-11-23) renamed the DTensorTestBase backend hook from backend to backend_str. The test's backend property is now ignored, so the PG is NCCL-only and the CPU all_gather in _validate_bucket_plans_across_ranks fails. First red run (#6285) has no DistMuon change.
TestAdamCPUOffloadedMoments::test_rounded_pinned_memory_raises (new in #5881) 300 s timeout The first _build result is dropped, so its exact-size pinned blocks can go back to the host allocator cache and get reused by the second build, which then sees no rounding and does not raise. When this happens on one rank only (rank 0 locally: AssertionError: ValueError not raised), the other rank waits in destroy_pg's barrier and the test hangs.

What changed. Test-only:

  • test_dist_muon.py: pass the backend through @with_comms(backend="cpu:gloo,cuda:nccl"), which works with PyTorch before and after #205504, instead of overriding the hook.
  • test_adam_cpu_offloaded_moments.py: keep the first build alive so the second build has to allocate new, rounded blocks.

Testing (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 in 5/5 runs.
pytest tests/unit_tests/gpu -m multi_gpu on 8x H100: these two pass. The 5 other local failures are unrelated: they need FA3 (flash_attn_interface), which is not installed locally and not selected on the A10G CI runners.

Not changed. Several CPU tests still override backend (returning "gloo"). Those overrides are now dead code, but they don't change behavior on CPU runners, so they are left for a separate cleanup.

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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2026
@acisseJZhong acisseJZhong changed the title [tests] Fix the two failing multi-GPU unit tests [CI] Fix the two failing multi-GPU unit tests Nov 24, 2026
@acisseJZhong

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @acisseJZhong's task in 1m 11s —— View job


Approve -- please fill in the human-written summary before merging. Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

  1. test_dist_muon.py: the class used to set the process-group backend by overriding the backend property. pytorch/pytorch#205504 renamed that hook to backend_str, so the override is now ignored and the PG is NCCL-only. The PR passes the backend through with_comms(backend=...) instead, which works before and after the rename.
  2. 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

  1. 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) takes backend as a keyword in upstream common_dtensor.py, so the decorator form doesn't depend on the hook name.
  • _first stays referenced until the test function returns, so its pinned blocks can't be freed before the second _build. Each DTensorTestBase test 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).

@acisseJZhong
acisseJZhong marked this pull request as ready for review November 24, 2026 06:47
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 24, 2026
@acisseJZhong
acisseJZhong merged commit bc0e80c into main Nov 24, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants