Skip to content

[ROCm] Use get_cycles_per_ms for the symm-mem lifecycle test hold - #203291

Closed
pablo-garay wants to merge 2 commits into
pytorch:mainfrom
ROCm:jeffdaily/symm-mem-hold-get-cycles-per-ms
Closed

pablo-garay wants to merge 2 commits into
pytorch:mainfrom
ROCm:jeffdaily/symm-mem-hold-get-cycles-per-ms

Conversation

@pablo-garay

@pablo-garay pablo-garay commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue or supporting maintainer

Fixes #202797
Fixes #200247

Supported by @jeffdaily

BC-breaking?

No.

Summary (human written only)

The symmetric-memory lifecycle tests hold rank 0's collective for 10 s with torch.cuda._sleep, but the cycle count was calibrated from a single cold launch timed on the host, so the hold came out several seconds short and sometimes under the peer's 2 s timeout. Use the existing get_cycles_per_ms() helper, which times with device events and averages several samples.

Agent details (if applicable)

My agent came up with this analysis, but I've read and approved it.

Since #192524 relanded on 10-28, NCCLSymmetricMemoryLifecycleTest has been flaky on the ROCm CI MI350 runners (about 161 failures in 5000 runs; MI300 0 in about 500). The watchdog_abort variants fail with "watchdog never aborted the comm" and the wait_timeout variants with "RuntimeError not raised"; both mean rank 0's collective reached rank 1 before rank 1's 2 s timeout.

_hold_back_collectives(10) is meant to hold rank 0's collective for 10 s. It converted seconds to torch.cuda._sleep cycles by timing one 10^7-cycle launch with host synchronize() calls, and that launch was the first one, so launch overhead inflated seconds_per_cycle and every hold came out short. On an MI355X the hold measured 6.0-7.0 s (median 6.49 s) with the shader clock steady at about 2385 MHz, and about 4% of calibrations took 13-22 ms instead of 4-7 ms, which gave holds of 1.97 s and 2.35 s; those two runs were the failures. On an MI300X the hold was 4.6-8.6 s, so it stayed above 2 s.

The hold now uses get_cycles_per_ms() from common_utils, as other distributed tests do (test_c10d_nccl2.py, test_c10d_fault_tolerance.py). It times _sleep with device events and takes the trimmed mean of 10 samples, so first-launch overhead and an occasional slow sample drop out. An untimed warm-up launch before the old calibration also fixed it (20 of 20 class runs on the MI355X, median hold 10.01 s), but it kept a single host-timed sample and duplicated the helper.

Test plan:

python test/distributed/test_nccl.py -k NCCLSymmetricMemoryLifecycleTest -v

On an MI355X (SPX) at the same base, the unpatched class failed 8 of 160 tests in 20 runs, all with one of the two signatures above. With the change, 40 of 40 class runs passed (320 tests). In 10 more instrumented runs the 10 s hold measured a median 9.95 s; 36 of 40 holds were 9.87-10.40 s, and the other 4 (4.1-9.2 s, still above the 2 s timeout) happened while an unrelated process from another container was running on rank 0's GPU, which slows every calibration launch.

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

NCCLSymmetricMemoryLifecycleTest._hold_back_collectives(10) delays rank 0's collective past rank 1's 2 s timeout. It converts seconds to torch.cuda._sleep cycles by timing a single 10^7-cycle launch, and that launch was the first one, so its overhead inflated seconds_per_cycle and every hold came out short. On an MI355X the 10 s hold measured 6.0-7.0 s, and the occasional 13-22 ms calibration gave holds of about 2 s, under rank 1's timeout, so rank 1 never saw the abort. That made the class flaky on the ROCm CI MI350 runners (pytorch#202797, pytorch#200247).

Launch one untimed _sleep before the calibration. A longer calibration sample or a large margin would also work; the warm-up removes the bias at its source and adds about 4 ms.

Test Plan:

```
python test/distributed/test_nccl.py -k NCCLSymmetricMemoryLifecycleTest -v
```

Fixes pytorch#202797
Fixes pytorch#200247

Authored with Claude.
get_cycles_per_ms() already does what the hand-written calibration got wrong: it times _sleep with device events instead of host synchronize, and takes the trimmed mean of 10 samples, so first-launch overhead and an occasional slow sample drop out. Other distributed tests use it the same way.

Authored with Claude.
@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203291

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 2 Unrelated Failures

As of commit 49d968a with merge base 67b78d6 (image):

NEW FAILURE - The following job has failed:

  • trunk / linux-noble-rocm-py3.11-mi350 / test (default, 3, 8, amd-dpx-linux.rocm.gpu.gfx950.1) (gh)
    test/profiler/test_profiler.py::TestMetadataJsonFormatCUDA::test_kernel_metadata_field_types

    AI verdict: AI verdict: probably not related

    The PR only edits a symm-mem test helper in test/distributed/test_nccl.py. The failing test is in test/profiler/test_profiler.py (KeyError 'grid' in ROCm kernel metadataJson), runs in a separate process, and passed at the merge base on the same Docker image digest. Apart from the unrelated test file the source is identical, so the code change cannot reach this failure.

    Full reasoning on HUD →

NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following job failed, but the AI CI Advisor judged the failure not to be evidence against this change:

  • Lint / lintrunner-noclang-all / lint (gh)
    >>> Lint for test/inductor/test_static_triton_launcher.py:

    AI verdict: AI verdict: not related

    The lint failure is RUFF F811 (a test method defined twice) in test/inductor/test_static_triton_launcher.py. The suspect commit only edits test/distributed/test_nccl.py. The merge base already fails the same way, and trunk has since gone green, so the PR branch simply carries a lint error from its stale base.

    Full reasoning on HUD →

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added module: rocm AMD GPU support for Pytorch topic: not user facing topic category labels Nov 3, 2026
@jeffdaily
jeffdaily marked this pull request as ready for review November 5, 2026 07:18
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra.

@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 5, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 5, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team

Raised by workflow job

Failing merge rule: Core Maintainers

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: Lint / lintrunner-noclang-all / lint

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / linux-noble-rocm-py3.11-mi350 / test (default, 3, 8, amd-dpx-linux.rocm.gpu.gfx950.1)

Details for Dev Infra team

Raised by workflow job

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 3 checks: Lint / lintrunner-noclang-all / lint, trunk / linux-jammy-cuda13.2-py3.11-gcc11 / test (pr_time_benchmarks, 1, 1, mt-l-bx86iavx512-94-344-t4-8), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 3, 8, amd-dpx-linux.rocm.gpu.gfx950.1)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…torch#203291)

## Linked issue or supporting maintainer

Fixes pytorch#202797
Fixes pytorch#200247

Supported by @jeffdaily

## BC-breaking?

No.

## Summary (human written only)

The symmetric-memory lifecycle tests hold rank 0's collective for 10 s with `torch.cuda._sleep`, but the cycle count was calibrated from a single cold launch timed on the host, so the hold came out several seconds short and sometimes under the peer's 2 s timeout. Use the existing `get_cycles_per_ms()` helper, which times with device events and averages several samples.

## Agent details (if applicable)

My agent came up with this analysis, but I've read and approved it.

Since pytorch#192524 relanded on 10-28, `NCCLSymmetricMemoryLifecycleTest` has been flaky on the ROCm CI MI350 runners (about 161 failures in 5000 runs; MI300 0 in about 500). The `watchdog_abort` variants fail with "watchdog never aborted the comm" and the `wait_timeout` variants with "RuntimeError not raised"; both mean rank 0's collective reached rank 1 before rank 1's 2 s timeout.

`_hold_back_collectives(10)` is meant to hold rank 0's collective for 10 s. It converted seconds to `torch.cuda._sleep` cycles by timing one 10^7-cycle launch with host `synchronize()` calls, and that launch was the first one, so launch overhead inflated `seconds_per_cycle` and every hold came out short. On an MI355X the hold measured 6.0-7.0 s (median 6.49 s) with the shader clock steady at about 2385 MHz, and about 4% of calibrations took 13-22 ms instead of 4-7 ms, which gave holds of 1.97 s and 2.35 s; those two runs were the failures. On an MI300X the hold was 4.6-8.6 s, so it stayed above 2 s.

The hold now uses `get_cycles_per_ms()` from `common_utils`, as other distributed tests do (`test_c10d_nccl2.py`, `test_c10d_fault_tolerance.py`). It times `_sleep` with device events and takes the trimmed mean of 10 samples, so first-launch overhead and an occasional slow sample drop out. An untimed warm-up launch before the old calibration also fixed it (20 of 20 class runs on the MI355X, median hold 10.01 s), but it kept a single host-timed sample and duplicated the helper.

Test plan:

```
python test/distributed/test_nccl.py -k NCCLSymmetricMemoryLifecycleTest -v
```

On an MI355X (SPX) at the same base, the unpatched class failed 8 of 160 tests in 20 runs, all with one of the two signatures above. With the change, 40 of 40 class runs passed (320 tests). In 10 more instrumented runs the 10 s hold measured a median 9.95 s; 36 of 40 holds were 9.87-10.40 s, and the other 4 (4.1-9.2 s, still above the 2 s timeout) happened while an unrelated process from another container was running on rank 0's GPU, which slows every calibration launch.

Pull Request resolved: pytorch#203291
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>

This branch was previously deployed

1 inactive deployment
bedrock — 49d968a5 Deployed Nov 5, 2026 by jeffdaily
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

4 participants