Skip to content

Migrate legacy fp32 matmul precision readers to per-backend API - #189955

Closed
jeffdaily wants to merge 3 commits into
mainfrom
jeffdaily/fp32-precision-legacy-readers
Closed

jeffdaily wants to merge 3 commits into
mainfrom
jeffdaily/fp32-precision-legacy-readers

Conversation

@jeffdaily

@jeffdaily jeffdaily commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Reading torch.get_float32_matmul_precision() or torch.backends.cuda.matmul.allow_tf32 raises a mixed-API TORCH_CHECK error whenever fp32 precision was last written through the new per-backend torch.backends.cuda.matmul.fp32_precision API, because the new-style setter intentionally does not update the legacy global enum. Several framework-internal hot paths still read through the legacy getters, so a single new-style write poisons inductor compilation (cache keys in codecache and select_algorithm), ROCm CK instance gating, flex attention precision selection, and the benchmark compile util. This blocks migrating tests and user code to the new API, as suggested in review on #185236.

This PR converts those framework-internal readers to the resolved per-backend getter (torch._C._get_fp32_precision_getter), which never throws and is the same source of truth the aten matmul paths already consult. The converted readers are the two inductor cache keys (now keyed on the (cuda, mkldnn) matmul precision pair via a shared fp32_matmul_precision_key() helper; the pair carries exactly the information of the legacy string: "highest" -> ieee/ieee, "high" -> tf32/tf32, "medium" -> tf32/bf16), ROCm CK instance gating, flex attention's set_float32_precision() (its legacy fallback for the unset "none" state still threw on new-style writes to other backends; a resolved "none" means unset at every level of the per-backend hierarchy, which is exactly the legacy default "highest", so the fallback collapses to "ieee"), and torch/utils/benchmark/utils/compile.py, which previously called the legacy getter at import time and now snapshots lazily. The legacy API surface itself keeps its consistency check by design, and legacy writers are untouched since the legacy setters keep both representations in sync. A regression test (test_fp32_precision_new_api_internal_readers in test_cuda.py) exercises the converted readers under the mixed state that makes the legacy getters raise.

The TunableOp TypeName and dynamo get_global_state_key() readers this PR originally also migrated were converted upstream in the meantime by #195301, so they dropped out of the diff when rebasing.

#196860 landed a narrower workaround at the two autotune cache-key sites this PR migrates: it reads the new-style per-backend value and only falls back to the legacy getter when that value is not bfx9. That dodges the throw for bfx9 specifically, but the legacy getter still throws for every other precision written through the new API. fp32_matmul_precision_key() supersedes it, because it never consults the legacy getter at all and so covers bfx9 along with the rest; merging main therefore drops that workaround. test_precompile_cache_key_handles_bfx9 is updated for the pair-format key and tightened to assert the legacy getter is never called for any precision.

Compatibility note: the autotune/precompile cache-key component changes format (e.g. "high" becomes "cuda:tf32,mkldnn:tf32"), which invalidates existing on-disk autotune caches once on upgrade; this causes a one-time re-benchmark and has no correctness impact.

An alternative was to relax the TORCH_CHECK in Context::allowTF32CuBLAS() / Context::float32MatmulPrecision(), but that check is the only guard alerting users to genuinely inconsistent mixed usage, so migrating the internal readers is strictly safer.

A follow-up will migrate the module-level precision setup in the test suite to the per-backend API (the follow-up promised in the #185236 review thread).

Authored with an AI assistant (Claude Code).

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98

@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ You can merge normally! (4 Unrelated Failures), 1 Unclassified Failure

As of commit a9e20c9 with merge base 6341c24 (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

  • rocm-mi300 / linux-noble-rocm-py3.11-mi300 / test (default, 4, 8, linux.rocm.gpu.mi300.1) (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)
    test/dynamo/test_regional_inductor_config.py::NestedRegionInductorConfigTests::test_nested_region_inductor_config_max_autotune_parent_max_autotune_True_nested_max_autotune_False

    AI verdict: AI verdict: not related (uncertain)

    The same test family (test_nested_region_inductor_config_max_autotune) was already failing on trunk before the suspect commit, just with a different parametrization (True_True on trunk vs True_False on the suspect). This pre-existing pattern indicates ROCm MI300-specific flakiness in autotune template selection, not a regression introduced by this PR.

    Full reasoning on HUD →

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

CRCR (non-blocking) - The following CRCR downstream CI jobs failed but are non-blocking:

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

@jeffdaily
jeffdaily requested a review from albanD July 14, 2026 23:58
@jeffdaily jeffdaily added the ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 label Jul 15, 2026
@zou3519 zou3519 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 15, 2026
@jansel

jansel commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@claude review these changes

@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

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


PR Review: #189955

Summary: Migrates framework-internal legacy fp32-matmul-precision readers (inductor cache keys, dynamo region tracking, TunableOp naming, ROCm CK gating, benchmark util) to the non-throwing per-backend getters. The migration is correct where applied, but it misses at least one internal reader with the same failure mode and ships no regression test.

Full review details

Testing

  • No test is added. This PR is effectively a bug fix (a new-style write poisons legacy readers with a TORCH_CHECK), and per project convention bug fixes need a regression test. A device-generic test that sets torch.backends.cuda.matmul.fp32_precision = "tf32" (and, importantly, a mkldnn-only new-style write) and then exercises the converted readers — get_global_state_key(), PersistentCache.lookup, create_precompile_key, fp32_matmul_precision_key() — asserting they don't raise, would lock in the fix. The commit message documents only manual verification on a ROCm host. This is the main blocker.

Correctness — remaining poison path

  • torch/_inductor/kernel/flex/flex_attention.py:130-142 (get_float32_precision, called at lines 276 and 839) is the same class of framework-internal reader but was not migrated. Its fallback branch still calls torch.get_float32_matmul_precision():
    torch.backends.cuda.matmul.fp32_precision == "ieee"
    if torch.backends.cuda.matmul.fp32_precision != "none"
    else torch.get_float32_matmul_precision() == "highest"   # <-- still legacy
    In the default state torch.backends.cuda.matmul.fp32_precision resolves to "none", so this branch is live. A new-style write to a different backend — e.g. torch.backends.mkldnn.matmul.fp32_precision = "bf16" — leaves cuda/matmul at "none" while making Context::float32MatmulPrecision() inconsistent, so torch.get_float32_matmul_precision() here still throws. This contradicts the PR's stated goal of converting the framework-internal readers, and the flex path is a hot lowering path. Recommend converting it in this PR. Fix this →

Backward Compatibility

  • torch/_inductor/codecache.py:432 and select_algorithm.py:3973: the autotune cache-key component changes from "high"/"highest"/"medium" to "cuda:tf32,mkldnn:tf32"-style strings. This silently invalidates existing on-disk autotune / precompile caches on upgrade (one-time re-benchmark, no correctness impact). Worth a note in the description; not blocking.

Minor

  • torch/utils/benchmark/utils/compile.py:34 — the comment "tf32 being off implies the legacy precision was 'highest'" is correct (both "high" and "medium" set cuda/matmul to TF32), so the hardcoded restore value holds. Note the util still restores via the legacy set_float32_matmul_precision, which rewrites both cuda and mkldnn and would clobber a user's independent per-backend mkldnn setting — pre-existing behavior, flagging only for awareness.

Recommendation

Request Changes — primarily for the missing regression test, and to also migrate the flex-attention reader (flex_attention.py:130) which still hits the legacy throwing getter under the exact mixed-API scenario this PR targets. The migrations that are present are otherwise faithful (allowTF32CuBLAS()/.allow_tf32/get_float32_matmul_precision() all reduce to the same TF32 comparison the per-backend getter performs, minus the consistency TORCH_CHECK).

· branch `jeffdaily/fp32-precision-legacy-readers`

@jeffdaily
jeffdaily requested a review from drisspg as a code owner July 15, 2026 18:28
@jeffdaily

Copy link
Copy Markdown
Collaborator Author

Both review points addressed in eda5fda:

  • get_float32_precision() in flex_attention.py now uses the per-backend getter directly. I verified the flagged scenario empirically: a mkldnn-only new-style write (torch.backends.mkldnn.matmul.fp32_precision = "bf16") throws in the old fallback and works after the fix. Dropping the legacy fallback also loses nothing for the never-set case: TORCH_ALLOW_TF32_CUBLAS_OVERRIDE initializes the per-backend map itself (see the fp32_precision initializer in Context.h), so the resolved getter reflects it.
  • Added test_fp32_precision_new_api_internal_readers to test_cuda.py next to test_invalid_status_for_legacy_api: it puts the process into the exact mixed state that the legacy getters raise on, then asserts the converted readers (get_global_state_key, fp32_matmul_precision_key, flex get_float32_precision) work and return the new-style values. Confirmed the test scenario raises on an unfixed build at get_global_state_key().
  • PR description updated with the cache-key compatibility note.

The TunableGemm.h path is not unit-tested here since it needs TunableOp on MI300 hardware; the existing test_tf32_tunableop exercises it and will pin the new-API behavior once the follow-up test-suite migration switches those tests to per-backend writes.

@jeffdaily

jeffdaily commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

@albanD @jansel the PR failures here are caused by a race introduced by the fp32/tf32 state leak detector PR #185236. Rather than revert, I have a forward fix PR #190285 here if you could take a look.

EDIT: I was operating on stale information. #185236 had been auto-reverted. So I've rolled #190285 into it to fix the reason for the auto-revert. Will rebase this PR once it relands.

@drisspg

drisspg commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

def get_float32_precision():
if (
(
torch.backends.cuda.matmul.fp32_precision == "ieee"
if torch.backends.cuda.matmul.fp32_precision != "none"
else torch.get_float32_matmul_precision() == "highest"
)
or torch.version.hip
or torch.mtia.is_available()
):
return "'ieee'"
else:
return "'tf32'"

does this work correctly with ^^ ?

@jeffdaily

Copy link
Copy Markdown
Collaborator Author

Yes. _get_fp32_precision_getter("cuda", "matmul") returns the resolved per-backend value, which matches the linked logic in every state: highest -> ieee, high/medium -> tf32, and the default unset (none) state -> ieee (the old code reached the same result via the get_float32_matmul_precision() == "highest" fallback). The difference is that the old fallback throws the mixed-API TORCH_CHECK when precision was set through the new per-backend API on another backend (e.g. torch.backends.mkldnn.matmul.fp32_precision = "bf16" leaves cuda/matmul at none and makes the legacy enum inconsistent); the per-backend getter returns the correct value there instead of raising. I verified all of these empirically.

This reply was drafted with an AI assistant (Claude Code).

if torch.backends.cuda.matmul.allow_tf32 is False and torch.cuda.get_device_capability() >= (8, 0):
tf32_off = torch._C._get_fp32_precision_getter("cuda", "matmul") != "tf32"
if tf32_off and torch.cuda.get_device_capability() >= (8, 0):
# tf32 being off implies the legacy precision was "highest"

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.

AI-assisted review note: Could we snapshot and restore the per-backend precision values directly here? The resolved CUDA state being non-TF32 does not imply the legacy state was highest. For example, starting with CUDA ieee and MKLDNN bf16, this sets both backends to tf32, then _disable_tensor_cores() restores both to ieee, silently losing the caller's MKLDNN setting.

Comment thread torch/_inductor/utils.py
# per-backend APIs have been mixed.
getter = torch._C._get_fp32_precision_getter
return f"cuda:{getter('cuda', 'matmul')},mkldnn:{getter('mkldnn', 'matmul')}"

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.

AI-assisted review note: Should this migration also update the nearby XPU path in get_device_tflops()? It still reads torch.backends.mkldnn.allow_tf32, so a new-style torch.backends.mkldnn.matmul.fp32_precision = "tf32" is not reflected in the roofline/device estimate. Using _get_fp32_precision_getter("mkldnn", "matmul") == "tf32" there would keep this path consistent with the new API.

@jeffdaily

Copy link
Copy Markdown
Collaborator Author

Friendly ping on this one. @drisspg I addressed your question about get_float32_precision above (the per-backend getter is behavior-equivalent to the old logic in every state and additionally avoids the mixed-API TORCH_CHECK throw). CI was green on the prior head before I just refreshed the branch onto viable/strict (rerunning now); the diff is scoped to the framework-internal readers of the legacy matmul-precision API. @albanD this is the reader-migration prerequisite for the test-suite fp32_precision migration you suggested on #185236 -- an approval from either of you would let it land and unblock that follow-up.

This message was drafted with an AI assistant (Claude Code).

@eqy
eqy requested a review from lakshayg August 12, 2026 14:57
Comment on lines -132 to -136
(
torch.backends.cuda.matmul.fp32_precision == "ieee"
if torch.backends.cuda.matmul.fp32_precision != "none"
else torch.get_float32_matmul_precision() == "highest"
)

@lakshayg lakshayg Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wow! This was one hard to read conditional ☠️

If it's not too hard to do, it would be nice to have a unit test for this function.

Comment thread test/test_cuda.py
@serialTest()
def test_fp32_precision_new_api_internal_readers(self):
# Framework-internal readers must use the per-backend getters and stay
# usable after new-style writes put the legacy enum out of sync (the

@lakshayg lakshayg Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since it's possible for legacy enums to go out of sync, should we just get rid of them altogether? Doesn't need to be this PR but I would like to understand if there's any good reason to keep them around. If we decide they can be removed then marking them [[deprecated]] would be a good first move.

@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased jeffdaily/fp32-precision-legacy-readers onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout jeffdaily/fp32-precision-legacy-readers && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the jeffdaily/fp32-precision-legacy-readers branch from d7aeb8c to 090bed7 Compare August 19, 2026 21:35
Reading torch.get_float32_matmul_precision() or torch.backends.cuda.matmul.allow_tf32 raises a mixed-API TORCH_CHECK error whenever fp32 precision was last written through the new per-backend torch.backends.cuda.matmul.fp32_precision API, because the new-style setter intentionally does not update the legacy global enum. Several framework-internal hot paths still read through the legacy getters, so a single new-style write poisons inductor compilation (cache keys in codecache and select_algorithm), ROCm CK instance gating, and the benchmark compile util. This blocks migrating tests and user code to the new API, as suggested by review on #185236.

This PR converts those framework-internal readers to the resolved per-backend getter (torch._C._get_fp32_precision_getter), which never throws and is the same source of truth the aten matmul paths already consult. The two inductor cache keys now key on the (cuda, mkldnn) matmul precision pair via a shared fp32_matmul_precision_key() helper; the pair carries exactly the information of the legacy string ("highest" -> ieee/ieee, "high" -> tf32/tf32, "medium" -> tf32/bf16). torch/utils/benchmark/utils/compile.py previously called the legacy getter at import time; the snapshot is now taken lazily and only when the util actually changes the precision. The legacy API surface itself (the bindings behind get_float32_matmul_precision and allow_tf32) keeps its consistency check by design, and legacy writers are untouched since the legacy setters keep both representations in sync.

The TunableOp TypeName and dynamo graph_region_tracker readers this PR originally also migrated were converted upstream in the meantime by #195301, so they dropped out of the diff when rebasing onto viable/strict.

An alternative was to relax the TORCH_CHECK in Context::allowTF32CuBLAS() and Context::float32MatmulPrecision(), but that check is the only guard alerting users to genuinely inconsistent mixed usage, so migrating the internal readers is strictly safer.

Test Plan:

Verified the failure mode and the fix on a ROCm host (gfx90a). Before this change, importing the benchmark util or reading the legacy getters after a new-style write raises; after it, all converted readers work under both APIs:

```
python -c "
import torch
torch.backends.cuda.matmul.fp32_precision = 'tf32'
print(torch._C._get_fp32_precision_getter('cuda', 'matmul'))"
```

Exercised the modified benchmark util end to end (enable sets high, disable restores highest, idempotent, and no throw under mixed state). Verified getter equivalences under the legacy setter: highest -> ieee/ieee, high -> tf32/tf32, medium -> tf32/bf16 for (cuda, mkldnn).

```
python -m py_compile torch/_inductor/utils.py torch/_inductor/codecache.py torch/_inductor/select_algorithm.py torch/_inductor/codegen/rocm/ck_template.py torch/utils/benchmark/utils/compile.py
lintrunner --skip PYREFLY <changed py files>
```

Authored with Claude Code (Claude).
Addresses review: the fp32 precision helper in flex_attention.py (now set_float32_precision() after the BF16x9 rework in #195301) kept a fallback to the legacy torch.get_float32_matmul_precision() for the unset ("none") state, which still throws when a new-style write to another backend (e.g. torch.backends.mkldnn.matmul.fp32_precision = "bf16") makes the legacy enum inconsistent. A resolved "none" means no write at any level of the per-backend hierarchy, which is exactly the legacy default "highest": the legacy setter keeps the per-backend map in sync, and the TORCH_ALLOW_TF32_CUBLAS_OVERRIDE env override initializes the map directly (Context.h fp32_precision initializer). So the fallback collapses to "ieee" and the legacy reader is not needed.

The new test in test_cuda.py locks in the fix: after new-style cuda and mkldnn matmul writes (a state under which the legacy getters raise, as test_invalid_status_for_legacy_api asserts), the converted internal readers must work and return the new-style values.

Test Plan:

Validated on a ROCm host (gfx90a) by overlaying the changed Python files onto the installed torch (pure-Python change, no rebuild):

```
python test/test_cuda.py TestCuda.test_fp32_precision_new_api_internal_readers -v
python test/test_cuda.py -k fp32_precision -v
```

All pass (2 skips: CUDA 12.9 bfx9 test, unrelated cudnn issue). Also verified set_float32_precision() semantics directly: never-set state yields 'ieee', legacy set_float32_matmul_precision('high') yields 'tf32' on CUDA / 'ieee' on hip, and the benchmark util enable/disable round trip works under mixed API state.

```
lintrunner --skip PYREFLY torch/_inductor/kernel/flex/flex_attention.py test/test_cuda.py
```

Authored with Claude Code (Claude).
@jeffdaily
jeffdaily force-pushed the jeffdaily/fp32-precision-legacy-readers branch from 090bed7 to a08ffbb Compare September 9, 2026 16:13
@janbernloehr

janbernloehr commented Sep 11, 2026 •

Copy link
Copy Markdown

Adding concrete downstream impact: this fixes the failure reported in #196728, and the fix has been validated against the original workload.

The reproduction was a DeepSeek-V3 16B pretraining workload with:

  • PyTorch 2.15.0a0+gita56a3a18
  • TorchTitan 0.2.2+gitc215a12
  • Triton 3.8.0
  • CUDA 13.x on aarch64
  • 8x GB200 across 2 nodes (4 GPUs per node)

During distributed initialization, TorchTitan sets

torch.backends.cuda.matmul.fp32_precision = "bfx9"

on compute capability 10.0 and newer. The failure occurs even without explicitly enabling model compilation because TorchTitan's determinism setup compiles FlexAttention. The first compiled FlexAttention call reaches PersistentCache.lookup, calls the legacy torch.get_float32_matmul_precision(), and raises the mixed legacy/new API error before training step 1—even though the FlexAttention inputs are bf16 and the user never called the legacy precision API.

Applying the on-CUDA-path hunks from this PR to the PyTorch installation used by the original workload resolved the failure. All three previously failing runs then trained for 50 steps to completion:

  • Run 1: average loss 6.696
  • Run 2: average loss 6.691
  • Run 3: average loss 6.736

Across the three runs there were 0 OOMs and 0 allocation retries.

The changes here to PersistentCache.lookup and create_precompile_key address exactly that failing path. The resolved (cuda, mkldnn) key is also preferable to the narrower helper proposed in #196737: it preserves the distinction between legacy high and medium, and it avoids falling back to the throwing legacy getter when CUDA is unset but another backend was configured through the new API.

Maybe it is useful to add bfx9 coverage to the regression test, incorporating the motivating case from #196728/#196737.

indrajeetapache added a commit to indrajeetapache/pytorch that referenced this pull request Sep 12, 2026
Address review on pytorch#196737: the CUDA-only helper still fell back to the
legacy getter when cuda was unset but mkldnn used the new API, and it
collapsed legacy high (tf32/tf32) vs medium (tf32/bf16). Use the
resolved per-backend pair via _get_fp32_precision_getter, matching the
approach in pytorch#189955 for the overlapping cache-key sites.

Test Plan:
- test/inductor/test_codecache.py::TestAutotuneCacheFp32Precision

Authored with an AI assistant.
@drisspg

drisspg commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@jeffdaily any blockers here?

Resolves conflicts with #196860, which added a narrower workaround at the two
autotune cache-key sites this PR migrates: read the new-style per-backend
value and only consult the legacy getter when it is not "bfx9". This PR's
fp32_matmul_precision_key() supersedes that, since it never consults the
legacy getter and so covers bfx9 along with every other mixed-API state.

Updates test_precompile_cache_key_handles_bfx9 for the pair-format key and
tightens it to assert the legacy getter is never called for any precision.
@jeffdaily

Copy link
Copy Markdown
Collaborator Author

The blocker was a conflict with #196860, which landed a narrower fix at the same two autotune cache-key sites this PR touches: it reads the new-style per-backend value and only falls back to the legacy getter when that value is not bfx9. That avoids the throw for bfx9, but the legacy getter still throws for any other precision written through the new API.

I resolved it by taking fp32_matmul_precision_key() at both sites and dropping that workaround, since the helper never consults the legacy getter at all and so covers bfx9 along with every other mixed-API state. test_precompile_cache_key_handles_bfx9 is updated for the pair-format key and tightened to assert the legacy getter is never called for any precision, rather than only for bfx9.

@EddieYan flagging you since this removes the workaround from #196860.

Merge is pushed and CI is rerunning. Your approval still stands from 2026-08-12; let me know if you want another look at the conflict resolution given it deletes code from #196860.

This reply was drafted with an AI assistant (Claude Code).

@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -i

The three red checks are all unrelated. Two are inductor_aoti_fallback shards marked unstable. The third, test_nested_region_inductor_config_max_autotune_parent_max_autotune_True_nested_max_autotune_False, fails identically on trunk: the two most recent rocm-mi300 runs on main both fail that test plus the True_True parametrization, while both parent=False cases pass. Dr.CI flagged it unclassified only because the workflow did not run on this PR's merge base.

This comment was drafted with an AI assistant (Claude Code).

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

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 3 checks: inductor / unit-test / inductor-cpu-test / test (inductor_aoti_fallback, 1, 2, mt-l-x86iamx-8-64, unstable), inductor / unit-test / inductor-cpu-test / test (inductor_aoti_fallback, 2, 2, mt-l-x86iamx-8-64, unstable), rocm-mi300 / linux-noble-rocm-py3.11-mi300 / test (default, 4, 8, linux.rocm.gpu.mi300.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 pushed a commit that referenced this pull request Oct 1, 2026
…i-structured test (#199248)

`test_max_autotune_cutlass_backend_sparse_semi_structured_mm` fails with
`KeyError: 'high'` because it reads the autotune local cache with the legacy
precision string. #189955 changed `PersistentCache` to key timings by
`fp32_matmul_precision_key()`, so with the module's
`torch.set_float32_matmul_precision("high")` the bucket is now
`"cuda:tf32,mkldnn:tf32"`. That PR updated `test_codecache.py` but missed
this lookup. The test now indexes the cache with the same helper the cache
writes with.

OSS CI did not catch this because nothing runs the test on hardware where it
executes. It is gated to sm_8x exactly; the only OSS job that runs
`test_cutlass_backend.py` is `h100-cutlass-backend`, where it skips, and the
A10G inductor jobs exclude the file. It fails in fbcode, where the file runs
on A100.

Test Plan:
On an A100 (sm_80), with CUDA 13.0 `nvcc` on PATH:

```
python test/inductor/test_cutlass_backend.py -k test_max_autotune_cutlass_backend_sparse_semi_structured_mm
```

Fails with `KeyError: 'high'` before this change and passes after.

This PR was authored with the assistance of an AI coding assistant (Claude).

Pull Request resolved: #199248
Approved by: https://github.com/pytorchgreenlight
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…i-structured test (pytorch#199248)

`test_max_autotune_cutlass_backend_sparse_semi_structured_mm` fails with
`KeyError: 'high'` because it reads the autotune local cache with the legacy
precision string. pytorch#189955 changed `PersistentCache` to key timings by
`fp32_matmul_precision_key()`, so with the module's
`torch.set_float32_matmul_precision("high")` the bucket is now
`"cuda:tf32,mkldnn:tf32"`. That PR updated `test_codecache.py` but missed
this lookup. The test now indexes the cache with the same helper the cache
writes with.

OSS CI did not catch this because nothing runs the test on hardware where it
executes. It is gated to sm_8x exactly; the only OSS job that runs
`test_cutlass_backend.py` is `h100-cutlass-backend`, where it skips, and the
A10G inductor jobs exclude the file. It fails in fbcode, where the file runs
on A100.

Test Plan:
On an A100 (sm_80), with CUDA 13.0 `nvcc` on PATH:

```
python test/inductor/test_cutlass_backend.py -k test_max_autotune_cutlass_backend_sparse_semi_structured_mm
```

Fails with `KeyError: 'high'` before this change and passes after.

This PR was authored with the assistance of an AI coding assistant (Claude).

Pull Request resolved: pytorch#199248
Approved by: https://github.com/pytorchgreenlight
@github-actions
github-actions Bot deleted the jeffdaily/fp32-precision-legacy-readers branch November 21, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request Merged module: dynamo module: inductor open source release notes: inductor 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.

8 participants