Skip to content

[ROCm][inductor][UT] Adjust MI200 addmm OpInfo tolerance - #186407

Closed
naromero77amd wants to merge 4 commits into
pytorch:mainfrom
naromero77amd:mi200-addmm-opinfo-tolerance
Closed

naromero77amd wants to merge 4 commits into
pytorch:mainfrom
naromero77amd:mi200-addmm-opinfo-tolerance

Conversation

@naromero77amd

@naromero77amd naromero77amd commented Jun 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This addresses the UT regression exposed after #183766 routed MI200 FP16 backward GEMMs through rocBLAS to preserve subnormals.

  • Add an MI200-only tolerance override for Inductor addmm FP16 OpInfo coverage.
  • Keep the existing FP32 eager reference while allowing FP16-scale absolute/relative differences.

Test plan

  • python test/inductor/test_torchinductor_opinfo.py -k test_comprehensive_addmm_cuda_float16

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @pragupta @jerrymannil @xinyazhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben

@pytorch-bot

pytorch-bot Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 5 New Failures

As of commit 4f0f14c with merge base 2ab78d8 (image):

NEW FAILURES - The following jobs have failed:

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

@naromero77amd
naromero77amd force-pushed the mi200-addmm-opinfo-tolerance branch from cec515f to 1d6d406 Compare June 5, 2026 20:02
@naromero77amd naromero77amd changed the title Adjust MI200 addmm OpInfo tolerance [ROCm][inductor][UT] Adjust MI200 addmm OpInfo tolerance Jun 5, 2026
@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Jun 5, 2026
@naromero77amd
naromero77amd requested a review from jeffdaily June 5, 2026 20:04
@naromero77amd naromero77amd added the ciflow/inductor-rocm-mi200 Trigger "inductor" config CI on ROCm MI200 label Jun 5, 2026
@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@pytorchbot fix-lint

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully applied lint patches in https://github.com/pytorch/pytorch/actions/runs/27038436764. Please pull locally before pushing more changes.

@naromero77amd
naromero77amd requested a review from jataylo June 5, 2026 22:53
@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@claude did the test_comprehensive_addmm_cuda_float16 UT pass on MI200?

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Claude finished @naromero77amd's task in 14m 8s —— View job


MI200 CI Results for test_comprehensive_addmm_cuda_float16

  • Understand the request
  • Check CI status for the MI200 job
  • Analyze job logs for the test result
  • Report findings

Answer: Yes, test_comprehensive_addmm_cuda_float16 passed on MI200.

The MI200 inductor CI runs test_torchinductor_opinfo split across 9 sub-shards distributed between 2 CI jobs. The addmm_cuda_float16 test falls in the even-numbered sub-shards which ran in shard 2/2 (job link) — that job completed successfully.

The shard 1/2 job (job link) did fail, but that failure is unrelated to addmm. It ran odd-numbered sub-shards (1, 3, 5, 7, 9) of test_torchinductor_opinfo — I confirmed shard 3 contains test_comprehensive_addmm_cuda_float64 (not float16) and those sub-shards all passed. The job-level failure appears to be a test artifact upload issue ("Upload test artifacts" step failed).

Summary: Your tolerance override is working correctly — test_comprehensive_addmm_cuda_float16 passed on MI200, and the CI failure in shard 1 is an unrelated infrastructure issue.


@naromero77amd
naromero77amd marked this pull request as ready for review June 8, 2026 16:02
@malfet malfet added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 8, 2026
@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@claude did the test_comprehensive_addmm_cuda_float16 UT pass on MI200 in the latest round of CI testing?

@claude

claude Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Claude finished @naromero77amd's task in 2m 35s —— View job


MI200 CI Results for test_comprehensive_addmm_cuda_float16

  • Check CI status for the latest MI200 job run
  • Analyze job logs for the test result
  • Report findings

Answer: No, test_comprehensive_addmm_cuda_float16 failed on MI200 in the latest CI run (commit 137c2e6).

Error: ValueError: Both 'rtol' and 'atol' must be either specified or omitted, but got no atol.

The tolerance override at line 1341 only specifies rtol:

overridden_kwargs.update({"rtol": 2e-2})

But PyTorch's assertEqual / not_close_error_metas requires both rtol and atol to be specified together. The fix is to add an atol value alongside rtol, e.g.:

overridden_kwargs.update({"rtol": 2e-2, "atol": 2e-2})

CI job: test (inductor, 2, 2, linux.rocm.gpu.mi210.1) — Test step failed.


@jansel

jansel commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@claude review these changes

@claude

claude Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

Claude finished @jansel's task in 1m 37s —— View job


Code Review: MI200 addmm OpInfo Tolerance

  • Read PR diff and changed files
  • Analyze the tolerance override logic
  • Check for correctness and best practices
  • Provide review feedback

Overall: The change is correct and solves the problem. The runtime arch check approach is well-motivated (avoiding import-time HIP init), the tolerance values are reasonable for the expected divergence, and both rtol/atol are properly paired.

Minor feedback

  1. Comment verbosity (lines 1330-1340): 11 lines of comment for a 1-line code change is heavy. The doc link and the core explanation ("eager uses rocBLAS alt-impl for denormals, inductor doesn't") are valuable, but the rest could be condensed. Suggestion:
# MI200 eager backward uses the rocBLAS alt-impl to preserve FP16
# denormals; inductor's compiled GEMM does not, causing ~9*eps divergence.
# See: https://docs.pytorch.org/docs/stable/notes/numerical_accuracy.html#reduced-precision-fp16-and-bf16-gemms-and-convolutions-on-amd-instinct-mi200-devices
overridden_kwargs.update({"rtol": 2e-2, "atol": 1e-3})

The notes about "why runtime not dict" and "atol required by PyTorch" are minor implementation details that the code structure already makes clear. That said, this is a style nit — the existing comment is not wrong, just verbose.

  1. Missing blank line after the if-block: The diff shows overridden_kwargs.update(...) immediately followed by func = op.get_op() with no separator. The surrounding code uses blank lines between logical sections. Adding one would improve readability:
            overridden_kwargs.update({"rtol": 2e-2, "atol": 1e-3})

        func = op.get_op()

Fix this →

  1. Tolerance justification looks correct: Observed relative diff of ~9 * FP16 eps (~8.8e-3) with rtol=2e-2 provides ~2.3x headroom. atol=1e-3 is a sensible absolute floor for FP16.

No blocking issues — LGTM with optional style nits.


@naromero77amd
naromero77amd requested a review from jansel June 9, 2026 17:21
@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@claude did the test_comprehensive_addmm_cuda_float16 UT pass on MI200 in the latest round of CI testing?

@claude

claude Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

Claude finished @naromero77amd's task in 1m 42s —— View job


MI200 CI Results for test_comprehensive_addmm_cuda_float16

  • Check CI status for the latest MI200 job run
  • Analyze job logs for the test result
  • Report findings

Answer: Yes — test_comprehensive_addmm_cuda_float16 passed on MI200 in the latest CI run (commit 5c33346, the one that added the atol fix).

Details

The latest inductor-rocm-mi200 run (27171578046) splits test_torchinductor_opinfo into 10 sub-shards across 2 CI jobs:

  • Shard 2/2 (job 80215891076) — runs the even sub-shards, which contain addmm_cuda_float16. This job passed.
  • Shard 1/2 (job 80215891065) — runs the odd sub-shards (1, 3, 5, 7, 9). All five test_torchinductor_opinfo sub-shards reported was successful, and none of them contain addmm_cuda_float16.

About the shard 1 failure (unrelated to your change)

Shard 1's "Test" step did fail, but not on addmm. After all test_torchinductor_opinfo sub-shards passed, the job moved on to inductor/test_origami and that step timed out after 270 minutes:

##[error]The action 'Test' has timed out after 270 minutes.

A follow-on "Upload test artifacts" step then also failed with an unrelated infra error (PermissionError: [Errno 13] ... test-jsons-...zip).

Summary

Your tolerance override is working: test_comprehensive_addmm_cuda_float16 passed on MI200. The shard 1 job-level failure is a test_origami timeout plus an artifact-upload permission error — neither involves addmm.
• Branch: mi200-addmm-opinfo-tolerance

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

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

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: inductor-rocm-mi200 / linux-jammy-rocm-py3.10-mi200 / test (inductor, 1, 2, linux.rocm.gpu.mi210.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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10-mi355 / test (distributed, 2, 4, linux.rocm.gpu.gfx950.2)

Details for Dev Infra team Raised by workflow job

@jansel

jansel commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

naromero77amd and others added 4 commits June 9, 2026 21:20
Follow-up to the inline MI200 FP16 addmm tolerance override. Three
adjustments based on review:

- Widen rtol from 10*eps (~9.8e-3) to 2e-2. The previous value cleared
  the observed worst-case relative diff (~9*eps, 8.76e-3) by only ~11%,
  which is too thin for an unstable MI200 shard given the full
  comprehensive sample sweep and rocBLAS solver-version variation.
- Drop the atol override. At the failing magnitudes (|ref| ~ 0.78) the
  rtol*|ref| term dominates by two orders of magnitude, so atol=tiny
  never affected pass/fail; leaving atol at its default keeps the test
  as strict as possible where the absolute term matters.
- Rewrite the comment to record why the check is inline rather than in
  inductor_override_kwargs (the arch query forces import-time HIP init
  that this module otherwise avoids; reference_in_float=True is inherited
  from the existing ("addmm", f16) cuda entry).

Test Plan:
On an AMD Instinct MI200 (gfx90a):

```
PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 PYTORCH_TEST_WITH_ROCM=1 \
  python test/inductor/test_torchinductor_opinfo.py \
  TestInductorOpInfoCUDA.test_comprehensive_addmm_cuda_float16
```

Not run in this environment (no MI200 available here); requires gfx90a
hardware to exercise the override branch.

Authored with assistance from an AI coding assistant (Claude Code).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pair the widened rtol override with an FP16-scale atol so the OpInfo comparison satisfies PyTorch tolerance requirements without overly relaxing near-zero checks.

Co-authored-by: Cursor <[email protected]>
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased mi200-addmm-opinfo-tolerance onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout mi200-addmm-opinfo-tolerance && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the mi200-addmm-opinfo-tolerance branch from 5c33346 to 4f0f14c Compare June 9, 2026 21:20
@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@claude Are the failures related or can this PR be merged?

@claude

claude Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Claude finished @naromero77amd's task in 1m 32s —— View job


Are the failures related? Can this PR be merged?

  • Pull CI status for the latest commit (4f0f14c, after rebase)
  • Identify which jobs failed and why
  • Determine if failures are related to this PR

Answer: No, the failures are not related to your change. This PR can be merged.

CI summary

Of 10 workflows on the latest commit, 9 passed and only trunk failed. The relevant ROCm jobs are green:

  • inductor-rocm-mi200 — ✅ success (this is the workflow that actually exercises test_comprehensive_addmm_cuda_float16)
  • inductor, pull, Lint, docs-build, etc. — ✅ success

What failed in trunk

All 5 failures are the win-vs2022-cpu-py3 test shards (default 1-4 + openreg). They die at import time, before any test runs:

File ".../torch/testing/_internal/common_utils.py", line 71, in <module>
    from torch._logging.scribe import open_source_signpost
  ...
    import aiohttp
  ...
    sslcontext = ssl.create_default_context()
  ...
    self._load_windows_store_certs(storename, purpose)
ssl.SSLError: [ASN1: NOT_ENOUGH_DATA] not enough data (_ssl.c:4040)

This is a Windows runner SSL/cert-store infra failure — aiohttp (pulled in via fbscribelogger) fails to load the Windows certificate store while run_test.py is merely importing test utilities. It is environment-level, hits a CPU-only Windows config, and never touches addmm or your Inductor OpInfo change (the only file modified is test/inductor/test_torchinductor_opinfo.py).

Why it doesn't block

  • Your change only affects the FP16 addmm tolerance for MI200 (ROCm), which is covered by inductor-rocm-mi200 — and that passed.
  • The Windows CPU job wouldn't run this test anyway, and it failed during setup, not in the test body.

This is exactly the class of unrelated infra flake that @pytorchbot merge -i (merge ignoring failures) is meant for. The earlier merge attempt failed on an MI355 distributed job, which is similarly unrelated; a re-attempt with -i (or a force merge) should go through.
• Branch: mi200-addmm-opinfo-tolerance

@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -i

1 similar comment
@naromero77amd

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -i

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "unrelated infra issues"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

@naromero77amd
naromero77amd deleted the mi200-addmm-opinfo-tolerance branch June 10, 2026 17:01
jemitche1 pushed a commit to jemitche1/pytorch that referenced this pull request Jun 13, 2026
)

## Summary
This addresses the UT regression exposed after pytorch#183766 routed MI200 FP16 backward GEMMs through rocBLAS to preserve subnormals.

- Add an MI200-only tolerance override for Inductor `addmm` FP16 OpInfo coverage.
- Keep the existing FP32 eager reference while allowing FP16-scale absolute/relative differences.

## Test plan
- `python test/inductor/test_torchinductor_opinfo.py -k test_comprehensive_addmm_cuda_float16`

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

Co-authored-by: Cursor <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
Co-authored-by: Jeff Daily <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
)

## Summary
This addresses the UT regression exposed after pytorch#183766 routed MI200 FP16 backward GEMMs through rocBLAS to preserve subnormals.

- Add an MI200-only tolerance override for Inductor `addmm` FP16 OpInfo coverage.
- Keep the existing FP32 eager reference while allowing FP16-scale absolute/relative differences.

## Test plan
- `python test/inductor/test_torchinductor_opinfo.py -k test_comprehensive_addmm_cuda_float16`

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

Co-authored-by: Cursor <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
Co-authored-by: Jeff Daily <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
)

## Summary
This addresses the UT regression exposed after pytorch#183766 routed MI200 FP16 backward GEMMs through rocBLAS to preserve subnormals.

- Add an MI200-only tolerance override for Inductor `addmm` FP16 OpInfo coverage.
- Keep the existing FP32 eager reference while allowing FP16-scale absolute/relative differences.

## Test plan
- `python test/inductor/test_torchinductor_opinfo.py -k test_comprehensive_addmm_cuda_float16`

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

Co-authored-by: Cursor <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
Co-authored-by: Jeff Daily <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/inductor-rocm-mi200 Trigger "inductor" config CI on ROCm MI200 ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor 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

Development

Successfully merging this pull request may close these issues.

6 participants