Repository navigation
Don't cache ptxas PTX-verification passes - #2809
Conversation
|
cc @mbrobbel @sylvestre please review |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2809 +/- ##
==========================================
- Coverage 78.53% 73.79% -4.74%
==========================================
Files 74 74
Lines 43991 43938 -53
==========================================
- Hits 34547 32425 -2122
- Misses 9444 11513 +2069 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Could you please add a test to make sure we don't regress? thanks |
|
@mbrobbel i am confused why you approved this change? it doesn't have tests :/ |
Oh you are right, I'm sorry about that. Can I suggest the following patch for the regression test? diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs
index 8f618efd..d455ce94 100644
--- a/src/compiler/nvcc.rs
+++ b/src/compiler/nvcc.rs
@@ -1592,6 +1592,9 @@ mod test {
#$ cl -D__CUDA_ARCH__=800 -D__CUDACC__ -E -x c++ "kernel.cu" > "kernel.cpp1.ii"
#$ cicc --device-c -arch compute_80 --module_id_file_name "kernel.module_id" --gen_c_file_name "kernel.cudafe1.c" --stub_file_name "kernel.cudafe1.stub.c" --gen_device_file_name "kernel.cudafe1.gpu" "kernel.cpp1.ii" --simt-only -o "kernel.ptx"
#$ ptxas -arch=sm_80 --compile-only "kernel.ptx" -o "kernel.cubin"
+#$ cl -D__CUDA_ARCH__=1200 -D__CUDACC__ -E -x c++ "kernel.cu" > "kernel.compute_120.cpp1.ii"
+#$ cicc --device-c -arch compute_120 "kernel.compute_120.cpp1.ii" -o "kernel.compute_120.ptx"
+#$ ptxas -arch=compute_120 -m64 "kernel.compute_120.ptx"
#$ fatbinary --create="kernel.fatbin" "--image3=kind=elf,sm=80,file=kernel.cubin" --embedded-fatbin="kernel.fatbin.c" --device-c
#$ cl -D__CUDA_ARCH__=800 -D__CUDACC__ -c -x c++ "kernel.cudafe1.cpp" -Fo"kernel.o"
"#
@@ -1604,6 +1607,9 @@ mod test {
#$ gcc -D__CUDA_ARCH__=800 -D__CUDACC__ -E -x c++ "kernel.cu" -o "kernel.cpp1.ii"
#$ cicc --device-c -arch compute_80 --module_id_file_name "kernel.module_id" --gen_c_file_name "kernel.cudafe1.c" --stub_file_name "kernel.cudafe1.stub.c" --gen_device_file_name "kernel.cudafe1.gpu" "kernel.cpp1.ii" --simt-only -o "kernel.ptx"
#$ ptxas -arch=sm_80 --compile-only "kernel.ptx" -o "kernel.cubin"
+#$ gcc -D__CUDA_ARCH__=1200 -D__CUDACC__ -E -x c++ "kernel.cu" -o "kernel.compute_120.cpp1.ii"
+#$ cicc --device-c -arch compute_120 "kernel.compute_120.cpp1.ii" -o "kernel.compute_120.ptx"
+#$ ptxas -arch=compute_120 -m64 "kernel.compute_120.ptx"
#$ fatbinary --create="kernel.fatbin" "--image3=kind=elf,sm=80,file=kernel.cubin" --embedded-fatbin="kernel.fatbin.c" --device-c
#$ gcc -D__CUDA_ARCH__=800 -D__CUDACC__ -c -x c++ "kernel.cudafe1.cpp" -o "kernel.o"
"#
@@ -1647,7 +1653,7 @@ mod test {
.find(|group| {
group
.iter()
- .any(|cmd| cmd.exe.file_stem().and_then(|stem| stem.to_str()) == Some("cicc"))
+ .any(|cmd| cmd.args.iter().any(|arg| arg == "kernel.cubin"))
})
.expect("missing device compile group");
@@ -1671,6 +1677,17 @@ mod test {
.find(|cmd| cmd.exe.file_stem().and_then(|stem| stem.to_str()) == Some("ptxas"))
.unwrap();
assert!(ptxas.args.iter().any(cicc::is_ptxas_input));
+ assert_eq!(Cacheable::Yes, ptxas.cacheable);
+
+ let virtual_ptxas = groups
+ .iter()
+ .flatten()
+ .find(|cmd| {
+ cmd.exe.file_stem().and_then(|stem| stem.to_str()) == Some("ptxas")
+ && cmd.args.iter().any(|arg| arg == "kernel.compute_120.ptx")
+ })
+ .expect("missing virtual-only ptxas command");
+ assert_eq!(Cacheable::No, virtual_ptxas.cacheable);
}
#[test] |
|
We hit this in java-llama.cpp (Java bindings for llama.cpp; its CI builds the CUDA natives through sccache) with sccache 0.18.0 and CUDA 13.4.3 (V13.4.92), building ggml-cuda at llama.cpp b11815 with ggml's default With this PR applied to v0.18.0 (27261de, applies cleanly) the same build succeeds: six ggml-cuda TUs, 204 s cold, 23 s warm with 78/78 hits; host code and device SASS of the objects are identical to nvcc's own output (only nvcc's Would mbrobbel's regression-test patch from the comment above be enough to get this merged? Happy to open a PR with #2809 plus that test if that helps. |
|
Hi, will review the comments and get this PR merged soon. Thanks |
|
Hi @sylvestre, could you approve the workflow run? CI is not triggered yet. Thanks |
For a virtual-only gencode such as -gencode arch=compute_120,code=compute_120 there is no SASS to emit, so nvcc runs ptxas purely to syntax-check the PTX and passes no -o at all: ptxas -arch=compute_120 -m64 kernel.compute_120.ptx group_nvcc_subcommands_by_compilation_stage marks every ptxas sub-command Cacheable::Yes, and the caching path requires an "obj" output that only -o populates, so the whole compile dies in cicc::generate_compile_commands with `Missing "cubin" file output`. Any target carrying a +PTX architecture can hit this; it surfaced building torchao's mxfp8 extension, which appends compute_120,code=compute_120 alongside a real compute_100,code=sm_100 gencode. Decide cacheability at the grouping stage instead. Cacheable::No routes the sub-command to the path nvcc.rs already uses for non-cacheable steps: build the command and run it directly. Returning CompilerArguments::CannotCache from cicc::parse_arguments does not work, because the sub-command dispatch turns CannotCache into an error rather than falling back to running the command, so it only moves the failure to "Cannot cache(no output file)". Cacheable::No with a group is already how the host preprocessor steps are handled. Test Plan: Carried as a source patch in PyTorch CI, where it fixes the inductor build that compiles torchao against CUDA 13.2: ``` python .ci/pytorch/smoke_test/smoke_test.py --package=torchonly ``` No unit test here: reproducing it needs a mocked nvcc --dryrun emitting the virtual-only sub-command shape, which is worth adding separately once the shape can be captured from real nvcc output rather than hand-written. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
d1cdc39 to
4b491d3
Compare
|
Hi @sylvestre, does this PR look good to merge? Thanks |
|
Thanks for your PR |
…new releases sccache leaves the hub's 0.19.0 build. Linux (x86_64, aarch64, riscv64) and Windows install mozilla's release. 0.20 carries the PTX-only ptxas pass that the ORT CUDA build needs (mozilla/sccache#2809). - versions.env: SCCACHE_LINUX_VERSION and SCCACHE_WINDOWS_VERSION are 0.20.1. The four digests come from GitHub's release-asset digests. - A Renovate github-releases hint sits above SCCACHE_LINUX_VERSION. `bump_versions.py --write --only SCCACHE_LINUX_VERSION` applies a new release and moves its digests with it. - bump_tools.py: spec_sccache (newest stable tag, asset digests). - windows/Dockerfile.base ARG mirror, deps table, SBOM and website licenses regenerated. - Tests: the bump spec and the installer pins. The Pester assertion accepts 0.20 and later. - Docs and CHANGELOG follow the change. shared/upstream/sccache is no longer installed; its source pins remain. Not run here: image builds, the CUDA canary on 0.20.1, the riscv64 binary, Pester (no pwsh), Renovate's own run. The first build after this bump rebuilds the C/C++ cache entries once. Co-Authored-By: Claude Haiku 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01E5kGgD7mjYi7ay9b3s1gNb
The sccache commit left three gates red on develop: - test-bump-versions.sh was 817 lines. The spec_sccache case moves to test-bump-sccache.sh; the old file is 797 lines. - bump_versions.py: spec_sccache sorts after spec_rust (ruff I001). - Mutation sccache.ptx-only-pass-runs-uncached now retargets the Windows pin (0.20.1 -> 0.19.0). The ptxas patch is redundant with 0.20.x and installed by nothing, so the old target guarded nothing. The Pester comment cites the merged fix (mozilla/sccache#2809); #2862 is an open bug report. develop stays red on code-duplication: a token-shingle hit on two one-line helpers in test-sccache-evict.sh and test-sccache-launcher.sh, present on 9662d20 too. It needs an owner decision. Co-Authored-By: Claude Haiku 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01E5kGgD7mjYi7ay9b3s1gNb
When nvcc emits a PTX-only target, it can run ptxas without an output file to verify the PTX. sccache currently marks that command cacheable and then fails with
Missing "cubin" file output.Mark ptxas commands without an explicit output as non-cacheable so they run directly. Keep cubin-producing commands cacheable for all supported output forms:
-o file,-o=file,--output-file file, and--output-file=file. Extend the ptxas argument parser to recognize these forms.The regression test extends the existing nvcc dry-run fixture for both Windows and Unix. It checks that a virtual-only
compute_120verification pass is non-cacheable and that a normal SASS compile remains cacheable. Additional cases cover the alternate output flags and their parsed output paths.Follow-up to #2722. Originally observed while building the torchao extension in https://github.com/pytorch/pytorch/actions/runs/30797328141/job/91700085985 with mixed real and virtual targets.
Validation:
cargo fmt --all -- --checkpassed.cargo test --locked --no-default-features --lib compiler::passed: 304 tests, on macOS arm64 with Rust 1.91.0.Cacheable::Yes.The original fix was also carried as a source patch in PyTorch CI, where it fixed the torchao build against CUDA 13.2.