Repository navigation
[inductor] Match autotune cache entries to configs by typed kwarg value - #195883
Closed
bobrenjc93 wants to merge 1 commit into
Closed
bobrenjc93 wants to merge 1 commit into
bobrenjc93 wants to merge 1 commit into
Conversation
[ghstack-poisoned]
This was referenced Sep 3, 2026
Closed
Contributor
Author
|
@pytorchbot label "release notes: inductor" |
Contributor
Author
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.
Stack from ghstack (oldest at bottom):
User-defined autotune kernels can carry non-JSON constexpr kwargs (tuples,
plain Enum members). The autotune cache stores kwargs as JSON, so a tuple comes
back as a list and a plain Enum as its raw value, and a warm load that
reconstructs the winning Config from the JSON payload bakes the degraded value
into the kernel; matching a cached entry back to a candidate config by == is
also ambiguous when candidates differ only by type (1 vs 1.0, True vs 1).
Autotune cache matching now returns the real candidate config (preserving tuple
and Enum kwarg values) when the matching configs hold the same typed values --
a unique match or interchangeable duplicates. Distinct candidates that
serialize alike (subset kwargs, int/float or bool/int splits, which are == but
distinct Triton specializations) fall through to reconstruction from the cached
value, as before, with any tuple/Enum kwarg the candidates agree on restored;
the load re-autotunes only when the candidates disagree on the typed value
behind the cached one (MODE=Mode.A vs MODE=1). This fixes duplicate tuple-kwarg
configs re-autotuning on every warm
start.
Behavior note: this depends on the constexpr Enum-unwrapping introduced by
IntEnum and str-mixin enum members compare equal to their unwrapped values, so
they are not degraded by JSON round-tripping and match directly; only plain
Enum members require the reconstruction path.
Coordesc and dynamically added winners are reconstructed with the typed kwarg
values their candidates hold (tuple, Enum) and re-autotune only when no
candidate serializes to the cached value, or when the candidates that do
disagree on the typed value; interchangeable duplicate candidates compare on
every Config attribute, not just kwargs, by type as well as value. The
found_by_coordesc stamp is only written when coordesc will actually refine the
kernel, since the flag makes warm loads skip candidate matching entirely.
Test Plan:
The matching and restoration logic is covered with SimpleNamespace configs
(and a mocked reconstruction) so it runs without Triton; the end-to-end
autotune tests need a GPU and Triton.
Authored with an AI assistant.
Co-Authored-By: Claude Fable 5.1 [email protected]
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo