Repository navigation
[ROCm] Use get_cycles_per_ms for the symm-mem lifecycle test hold - #203291
pablo-garay wants to merge 2 commits into
Conversation
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.
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 FailuresAs of commit 49d968a with merge base 67b78d6 ( NEW FAILURE - The following job has failed:
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:
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. |
|
@pytorchbot merge |
|
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. |
|
@pytorchbot merge |
Merge startedYour 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 |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchbot merge -i |
Merge startedYour 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 |
Merge failedReason: 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 teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour 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 |
…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]>
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 existingget_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,
NCCLSymmetricMemoryLifecycleTesthas been flaky on the ROCm CI MI350 runners (about 161 failures in 5000 runs; MI300 0 in about 500). Thewatchdog_abortvariants fail with "watchdog never aborted the comm" and thewait_timeoutvariants 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 totorch.cuda._sleepcycles by timing one 10^7-cycle launch with hostsynchronize()calls, and that launch was the first one, so launch overhead inflatedseconds_per_cycleand 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()fromcommon_utils, as other distributed tests do (test_c10d_nccl2.py,test_c10d_fault_tolerance.py). It times_sleepwith 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:
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