Repository navigation
fix(jit): refuse sccache < 0.18 (drops cicc/ptxas on CUDA 13.3), remember failed builds - #6502
Merged
Merged
Conversation
…ck log torch >= 2.13 prepends ccache/sccache to every JIT kernel compile when one is on PATH. sccache before 0.18.0 finds cicc's input as the third argument from the end; CUDA 13.3 nvcc appends `--simt-only` after it, so sccache silently drops the cicc and ptxas steps and `fatbinary` fails on the missing `.cubin` (fixed upstream in mozilla/sccache#2722). Every CUDA JIT kernel (GPTQ block update, Marlin, TT blockfloat, ...) then failed to build and quantization fell back to the slower eager path, paying the failed compile again in every process. - Read `sccache --version` and never compile through sccache < 0.18.0 (or one whose version cannot be read); log why and how to override. - New `KernelConfig` / `RuntimeConfig` field `jit_compiler_launcher`: None (default) = the rule above plus one retry without an allowed launcher that fails; False = never use a launcher; True = always, no retry. - Record a failed build in its cache dir so later processes take the fallback at once; the record expires after 24h and is ignored when the toolchain, PATH, CUDA_HOME, launcher policy or a force-rebuild env changes. - The retry clears torch's in-process build record, which otherwise makes the retry skip the compile and load a library that was never produced. - Stale torch build-lock cleanup only runs on torch < 2.14 (FileBaton); the warning no longer prints this process's own pid as the "dead" owner. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium
marked this pull request as ready for review
December 1, 2026 00:58
This was referenced Dec 1, 2026
Qubitium
added a commit
that referenced
this pull request
Dec 1, 2026
…er_cache (#6505) - Rename `jit_compiler_launcher` to `compiler_cache` (#6502 just merged; no release carries the old name). `RuntimeConfig.compiler_cache` is the one public setting; the `KernelConfig` field is only the internal carrier every RuntimeConfig field uses. Log messages point at RuntimeConfig. - Document that an sccache on PATH must be >= 0.18.0 (older drops the cicc/ptxas steps of CUDA 13.3+ builds) in docs/jit-kernel-builds.md, docs/kernel-config.md, README install notes, AGENTS.md and the gptqmodel-agent-workflow skill (check `sccache --version` before building or testing kernels; distro packages ship 0.13). - Make the jit-kernel-builds.md example runnable on a CPU-only, offline host (it referenced an undefined `model_id` and failed the docs test). Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Dec 1, 2026
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.
Summary
On a host with sccache < 0.18 on PATH and CUDA 13.3+, every CUDA JIT kernel build failed and quantization silently fell back to the eager path. The failed build was also retried in every process, costing 6–15 s each time. This PR:
jit_compiler_launchersetting toKernelConfig/RuntimeConfig;Root cause
torch 2.13 started putting ccache or sccache in front of every C++/nvcc JIT compile whenever one is on PATH (pytorch/pytorch#175696). The only opt-out is
TORCH_NO_COMPILER_WRAPPER=1.sccache does not run nvcc as one command. It reads the steps from
nvcc --dryrunand runs them itself. Before 0.18.0 it foundcicc's input file by position: the third argument from the end. CUDA 13.3 appends a new flag after that input:So the lookup returns
--simt-only, and sccache silently dropscicc(CUDA C++ → PTX) andptxas(PTX → cubin).fatbinarythen fails:Upstream fix: mozilla/sccache#2722, released in sccache 0.18.0.
How this was confirmed:
--dryrunoutput reproduces that list..cpp1.iisuffix (the upstream fix) keeps all 7 steps.flowchart TD A[kernel needed] --> B{cached binary loads?} B -- yes --> R[use kernel] B -- no --> C{recent failure recorded<br/>for this environment?} C -- yes --> F[fallback path, no compile] C -- no --> P{KernelConfig<br/>jit_compiler_launcher} P -- False --> N[build without launcher] P -- True --> W1[build through launcher] P -- None --> K{sccache < 0.18<br/>or unknown version?} K -- yes --> N K -- no --> W2[build through launcher] W2 -- failed --> N W2 -- ok --> R W1 -- ok --> R W1 -- failed --> M[record failure] --> F N -- ok --> R N -- failed --> MChanges (
gptqmodel/utils/cpp.py)Refuse old sccache. Read
sccache --versiononce per process. Never compile through sccache < 0.18.0, or one whose version cannot be read, and log the version found plus the override. ccache and sccache ≥ 0.18 are still used.jit_compiler_launcher(KernelConfigandRuntimeConfig):None(default)FalseTrueRemember failed builds. A failed build writes
.gptqmodel_build_failed.jsonin its fingerprinted cache directory, and later processes go straight to the fallback. A successful build deletes it. The record is ignored when any of these holds:TORCH_NO_COMPILER_WRAPPERor the launcher policy changed;GPTQMODEL_KERNEL_REBUILDor the kernel's*_FORCE_REBUILDis set.Retry correctness. torch records the build inputs before compiling, so an unchanged record makes a retry skip the compile and load a
.sothat was never built. The retry clears that in-process record.Stale-lock warning.
lockfile after every build. It is now left alone, with no warning.Docs: new
docs/jit-kernel-builds.md(step table, the bug, the policy);docs/kernel-config.mdgets the field.Test plan
tests/test_torch_ops_jit_extension.py: 11 new tests fail onmainand pass here. More tests were then added for the version gate: sccache 0.13 / 0.17.9 / unknown are refused for .cu and .cpp sources on nvcc 12.9 and 13.3; sccache 0.18.0 / 0.20.1 and ccache are kept; plus policy False/True, a policy change invalidating a recorded failure, theRuntimeConfig→KernelConfigmapping and the version parser.All 25 JIT/config test files, run per file, including the real Marlin/Machete/QQQ/ExLlama builds: 514 passed, 3 skipped.
Real GPTQ block kernel builds on sccache 0.13.0, CUDA 13.3 and A100, from an empty cache each time:
FalseTrueMarlin fp16/bf16 and TT blockfloat CUDA also build with the default policy.
[email protected]lint gate clean.🤖 Generated with Claude Code