Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/196860
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 1 PendingAs of commit ef8c7eb with merge base be01834 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Skylion007
approved these changes
Sep 12, 2026
Collaborator
Author
|
@pytorchmergebot merge |
Collaborator
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 |
jeffdaily
added a commit
that referenced
this pull request
Sep 18, 2026
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.
This was referenced Sep 18, 2026
pytorchmergebot
pushed a commit
that referenced
this pull request
Sep 18, 2026
) 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). Pull Request resolved: #189955 Approved by: https://github.com/drisspg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the mode is
bfx9we should avoid try trying to get it from the legacy getter which doesn't know about itauthored with codex
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo