Skip to content

fix(intrinsics): admit scalar math on sm_75 - #1670

Open
praveenperera wants to merge 3 commits into
NVIDIA:mainfrom
praveenperera:fix/scalar-math-sm75
Open

praveenperera wants to merge 3 commits into
NVIDIA:mainfrom
praveenperera:fix/scalar-math-sm75

Conversation

@praveenperera

@praveenperera praveenperera commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What This PR Does

Lowers the PTX and compute-capability floor of the 40 f32/f64 scalar_math intrinsics (sin_approx_f32, cos_approx_f32, ex2_approx_f32, lg2_approx_f32, rcp_*, rsqrt_*, sqrt_*, tanh_approx_f32) from (PTX 7.0, sm_80) to (PTX 7.0, sm_75) (Turing), re-records LLVM (rust-llvm-23.1.3) and libNVVM (cuda-13.3) evidence at sm_75, and adds the scalar_math_sm75 GPU validation example.

BEFORE:
  cargo oxide build scalar_math_sm75 --arch sm_75
  ──► error: CUDA target sm_75 cannot lower generated intrinsic `sin_approx_f32`; requires sm_80

AFTER:
  cargo oxide run scalar_math_sm75 --arch sm_75
  ──► emits `.version 7.0` / `.target sm_75` PTX; all 40 forms pass PTX ISA bounds

Verification

  • GPU Execution (RTX 5090, sm_120a): cargo oxide run scalar_math_sm75 --arch sm_75 verifies all 40 scalar_math forms against PTX ISA error bounds (compute-sanitizer --tool memcheck: 0 errors).
  • Tests & CI Gates: cargo run -p cuda-intrinsics-gen -- check, cargo test -p cuda-intrinsics-gen -p cuda-oxide-codegen --all-targets, just fmt-check, cargo clippy, and repository guards all pass.

Part of #1462

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>
@copy-pr-bot

copy-pr-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nihalpasham nihalpasham added cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book bug Something isn't working intrinsics Device intrinsics and libdevice math mappings labels Nov 3, 2026
Signed-off-by: nihalpasham <nihalp@nvidia.com>
nihalpasham
nihalpasham previously approved these changes Nov 3, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

/ok to test 105c3a5

@nihalpasham

Copy link
Copy Markdown
Collaborator

Thanks, lowering the 40 f32/f64 scalar_math intrinsics to (PTX 7.0, sm_75) with complete LLVM and libNVVM sm_75 evidence and the scalar_math_sm75 GPU oracle is clean and thorough.

At 105c3a5e, rebased onto main, regenerated the catalog stamp, and verified cuda-intrinsics-gen, cuda-oxide-codegen, and scalar_math_sm75 --arch sm_75 on RTX 5090 (compute-sanitizer clean). Merging once CI is green.

scalar_math_sm75's Cargo.lock resolved bytemuck 1.25.2 and
bytemuck_derive 1.12.1, while every other example pins 1.25.0 and
1.10.2, so sync-example-locks.sh --check failed. Align it with
--align.

The regenerated catalog hashes to 21388d23, so the mlir-dialects page
stamp moves with it. The floor changes leave the counts it guards as
they were: 589 operations and 1058 catalog entries.

Signed-off-by: Praveen Perera <me@praveenperera.com>
@praveenperera

Copy link
Copy Markdown
Contributor Author

Thanks! The two failing checks were mechanical, fixed in 786e37f39 on top of your rebase:

  • compile all examples: scalar_math_sm75/Cargo.lock had drifted to bytemuck 1.25.2 / bytemuck_derive 1.12.1. Aligned with sync-example-locks.sh --align; --check now passes.
  • book catalog stamp: the regenerated catalog hashes to 21388d23, so the mlir-dialects.md stamp moves with it. The counts it guards are unchanged (589 operations, 1058 entries).

smoketest.sh --compile-only passes for scalar_math_sm75 (ptxas sm_75) and the other math examples. Could you /ok to test 786e37f39 when you get a chance?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book intrinsics Device intrinsics and libdevice math mappings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants