Repository navigation
Studio: key Triton and Inductor caches on the 8-bit prefetch fix state (sm_8x) - #17793
Conversation
A compiler-stage patch does not enter Triton's cache key, so kernels compiled without the prefetch skip (an older Studio, or the kill switch) were reused with the fix on, and fixed kernels survived the kill switch. Salt the CUDA backend hash on sm_8x while the fix is active, and tag Inductor's FX graph cache key the same way, keeping one cache entry per fix state. Other cards and the kill switch keep their stock keys, so nothing else recompiles.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
#17669 skips Triton's sm_8x prefetch pass for 8-bit
tt.dotmodules by wrappingCUDABackend.make_ttgir. A compiler-stage patch does not enter Triton's cache key, so with the persistent<studio root>/cache/tritondirectory:UNSLOTH_TRITON_8BIT_PREFETCH_FIX=0) keep being loaded with the fix on, so sm80 / sm89 keep running the spilling kernel;Studio's own int8 GEMM already carries a
PREFETCH_FIXconstexpr for this; Inductor-generated and other Triton kernels do not.Why the key ignores it
compiler.pycompile()buildskey = get_cache_key(src, backend, options, env_vars)fromtriton_key(),src.hash(),backend.hash(),options.hash()and the cache-invalidating env vars, then returns the cachedCompiledKernelon a metadata hit beforebackend.add_stagesruns. A patched stage never runs on a hit.CUDABackend.hash()(backends/nvidia/compiler.py) isf"{ptxas_version}-{target.arch}".FxGraphHashDetails(torch/_inductor/codecache.py, torch 2.10 through main) hashestriton_key()but not the backend hash, and storestorch.compiler.config.cache_key_tag. An FX graph cache hit can reload bundled kernels without a Triton cache lookup.Fix
CUDABackend.hash()appends a salt for sm_8x targets unless the kill switch is set. The salt is applied before the stage swap, and also to an install left by an older copy of this module.torch._inductor.codecache,FxGraphHashDetailsappends the same salt to itscache_key_tagwhen the fix is installed, the current CUDA device is sm_8x, and the kill switch is off. ROCm is skipped.This gives one cache entry per fix state. sm_9x / sm_10x / sm_12x keys are unchanged, and the kill switch maps back to the stock key and finds the stock entries again, so nothing outside sm_8x recompiles. On sm_8x each kernel recompiles once with the fix on. No cache directory is moved or wiped.
Tests
studio/backend/tests/test_triton_8bit_prefetch_fix.py: 10 new cases, all failing on main and passing here.prmt.b32(352 before). sm90 keeps its hash. The kill switch finds the stock entry again.compiled_fx_graph_hashchanges with the salt and returns to stock under the kill switch.Cross-compile check, warm cache,
hash[:12]/prmt.b32:4c1a6aefd815/ 3524c1a6aefd815/ 352fec229049be7/ 04c1a6aefd815/ 3524ee39f9d5d70/ 3524ee39f9d5d70/ 352baef9a4de4d0/ 04ee39f9d5d70/ 352GPU, Colab L4 (sm89), Triton 3.8.0, torch 2.14.1+cu130. A 4096^3 int8
tl.dotGEMM (128x128x64 tile, 4 warps, 3 stages), one process per row, one sharedTRITON_CACHE_DIR; output checked against a CPU matmul in every row:bb6b0c885581bb6b0c885581e158c16fab21e158c16fab21bb6b0c885581bb6b0c885581bb6b0c885581bb6b0c885581Not covered: an A100 (sm80) run, and an end-to-end Inductor FX graph cache hit on a GPU. The FX tag is covered by the CPU key test only.