Repository navigation
fix(intrinsics): admit scalar math on sm_75 - #1670
Open
praveenperera wants to merge 1 commit into
Open
praveenperera wants to merge 1 commit into
praveenperera wants to merge 1 commit into
Conversation
The scalar_math recipe floored every F32/F64 form at PTX 7.0 / sm_80, so `ex2_approx_f32`, `rcp_rn_f32`, `sqrt_rn_f32` and the rest failed target gating on sm_75. The PTX ISA admits all 40 forms on sm_20 or older, except `tanh.approx.f32` at PTX 7.0 / sm_75. sm_75 is also the oldest target CUDA 13 ptxas assembles, so it is the lowest floor the evidence can attest. The family floor is now PTX 7.0 / sm_75, matching `ex2_approx_f16`. The LLVM evidence is re-probed at sm_75 / +ptx70 with the pinned llc and ptxas 13.3.73. The libNVVM evidence is re-captured at compute_75, assembled with ptxas 13.3.33 and linked with nvJitLink at sm_75. The regenerated outputs change only the scalar_math floors and the catalog digest banners. A generator test pins the sm_75 floor and rejects sm_80 and sm_72. A codegen test checks every scalar_math target on both backends and the `ex2_approx_f32` repro at CUDA_OXIDE_TARGET=sm_75. The new scalar_math_sm75 example calls all 40 forms and checks them against the PTX ISA error bounds. examples-compile builds it at sm_75 as PTX and as a libNVVM + nvJitLink cubin. scalar_arithmetic keeps its sm_80 floor here; NVIDIA#1512 covers it. Refs NVIDIA#1462 Signed-off-by: Praveen Perera <me@praveenperera.com>
praveenperera
requested review from
binarybana,
cryos,
elibol,
kkraus14,
roivanov and
rparolin
as code owners
October 29, 2026 20:45
This branch has not been deployed
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
The 40 F32/F64
scalar_mathintrinsics (ex2_approx_f32,rcp_rn_f32,sqrt_rn_f64,tanh_approx_f32, ...) carried a family-wide PTX 7.0 / sm_80 floor, so an sm_75 build that calls any of them fails target gating. The PTX ISA admits every one of them on Turing. This lowers the family floor to PTX 7.0 / sm_75, re-records the LLVM and libNVVM evidence at sm_75, and adds sm_75 build regressions.Part of #1462. This PR covers
scalar_math; #1512 coversscalar_arithmetic(fma_rn_f32,mul_rn_f32, ...). Neither depends on the other. Both regenerate the catalog digest banners, so whichever merges second needs acuda-intrinsics-gen generateafter rebasing.Floors
sin,cos,lg2,ex2.approx[.ftz].f32rcp.approx.ftz.f32,rsqrt.approx[.ftz].f32,sqrt.approx[.ftz].f32rcp/sqrt.{rn,rz,rm,rp}[.ftz].f32rcp.rn.f64,sqrt.rn.f64,rsqrt.approx.f64rcp/sqrt.{rz,rm,rp}.f64,rcp.approx.ftz.f64tanh.approx.f32ex2_approx_f16(unchanged)sm_72is not defined), so it is the lowest floor the evidence can attest.tanh.approx.f32needs it, and the evidence fixtures put every form in one module, where ptxas checks unreferenced functions too (Feature 'tanh' requires PTX ISA .version 7.0).ex2.approx.ftz.bf16at sm_90, the f16/bf16tanhforms, and the deferredrsqrt.approx.ftz.f64).Changes
resolve/families/scalar_math.rsis PTX 7.0 / sm_75, with the ISA rule in a comment. The policy, both backend lowerings, the catalog, the generated target tables, the stub docs and the reference table follow by regeneration.rust-llvm-23.1.3-aab11ee0-scalar-math.json): the three F32/F64 fixtures are renamed to*_sm75_ptx70and their backend_codegen and ptx_assembly stages are re-captured atsm_75/+ptx70with the nightly-2026-10-11 llc and ptxas 13.3.73. The declaration-canonicalization stages are target-independent and unchanged.scalar_math_ex2_f16_sm75_ptx70is untouched.cuda-13.3-libnvvm-13.3.33-scalar-math.json): onecompute_75fixture covers all 40 forms. It records libNVVM PTX and LTOIR,ptxas -arch=sm_75, and an nvJitLink-arch=sm_75 -ltolink. The fixture keeps its kernel with@llvm.used. Without it, nvJitLink drops the unreferenced kernel; the previous appended sm_80 record linked a 1,464-byte cubin, most likely that empty module. The new link produces a 31,912-byte cubin with the expected MUFU instructions.refresh-2026-10-11/stages.jsonlsm_80 captures they replace. Those captures still reproduce at sm_80, and the ledger is left as the historical record.catalog.jsonchanges only the 40 F32/F64scalar_mathrecords. The generated target tables change onlyscalar_math; other files change only the catalog digest banner. The book catalog stamp is refreshed.abi-v1.tomland the overlay are unchanged.Testing
checked_in_scalar_math_floors_are_turing_and_fail_closed: everyscalar_mathpolicy and both lowerings carry PTX 7.0 / sm_75, and policies at sm_80 or sm_72 are rejected. It fails against the old recipe.generated_scalar_math_floors_admit_turing: on both backends, all 41nvvm.scalar_mathtargets require PTX 7.0, are refused at sm_72 and accepted at sm_75 and sm_80, and a module using all of them validates at sm_75. It also resolvesex2_approx_f32withCUDA_OXIDE_TARGET=sm_75(LLVM) and throughresolve_nvvm_target_with_generated(libNVVM). It fails against the old generated table.scalar_math_sm75: one kernel calls all 40 forms throughcuda_device::float, and the host checks the results against the PTX ISA bounds.rnmust match the host exactly, andrz/rm/rpmust bracket the exact result by residual sign. The ISA gives no bound forrcp.approx.ftz.f64andrsqrt.approx.f64, so those two get a 2^-16 sanity check, plus the documented zero low word forrcp.examples-compile.ymlbuilds the example at sm_75 as PTX (artifact kind 256) and as a libNVVM + nvJitLink cubin (kind 512).smoketest.shalways builds it at--arch=sm_75, so newer GPUs run JIT-compiled sm_75 PTX.Checked at the head of this branch:
just -f cuda-oxide/Justfile checkpasses (fmt-check, clippy, test, test-cuda, check-guards including cargo-deny, check-intrinsics, doc-check)cargo oxide run scalar_math_sm75 --arch sm_75passes on an RTX 5090 (sm_120, the sm_75 PTX JIT-compiled by the driver). No Turing GPU was available, so the sm_75 cubin route was built and inspected but not executed.scalar_math_sm75)cargo oxide build scalar_math_sm75 --materialize-cubin --arch sm_75embeds an sm_75 cubin; its SASS contains every expected MUFU op.Checklist
git commit -s)