Repository navigation
Support typed NVVM IR for pre-Blackwell libNVVM targets - #101
Merged
nihalpasham merged 4 commits intoJun 27, 2026
Merged
Conversation
Collaborator
|
Thanks for the PR. This one actually has a larger scope.
But we'd need to land a couple of other things first, such as migrating from I'll keep this PR open till those land and will layer them on top of this one. |
Signed-off-by: Mohamed Samir <[email protected]>
Select the NVVM dialect from one validated target, legalize current LLVM operations to the supported LLVM 7 subset, and export erased pointers through a canonical byte-pointer representation with exact per-use and ABI adapters. Verify modules with libNVVM, persist target identity through artifacts, fail closed on ambiguous routing, and bridge unsuffixed legacy LTOIR through PTX for forward execution on Blackwell. Add the issue NVIDIA#98 community math regression, adversarial pointer-shape coverage, and soundness tests for address spaces, control-flow merges, extern boundaries, and legacy intrinsic rewrites. Signed-off-by: nihalpasham <[email protected]>
nihalpasham
force-pushed
the
typed-nvvm-ir-pre-blackwell
branch
from
June 27, 2026 08:02
a315b72 to
4b9fd56
Compare
Signed-off-by: nihalpasham <[email protected]>
nihalpasham
force-pushed
the
typed-nvvm-ir-pre-blackwell
branch
from
June 27, 2026 08:52
e1fc138 to
b7cf185
Compare
Signed-off-by: nihalpasham <[email protected]>
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
Fixes #98.
Kernels that call
sin,exp,sqrt,atan2, or other CUDA libdevicefunctions use the NVVM IR path. Pre-Blackwell libNVVM parses LLVM 7 syntax with
typed pointers, while Blackwell and newer targets parse modern opaque-pointer
IR. cuda-oxide now emits, verifies, and loads the correct form for each target.
The ordinary LLVM IR →
llc→ PTX path remains unchanged.What changed
Target-selected NVVM IR
CudaArchparser forsm_*andcompute_*targets,including suffixes such as
sm_90a.sm_90andsm_90a.--arch, uses thenormal target order: explicit target, compatible
runGPU hint, then thecompiler's feature-based target. Basic headless builds select
sm_80.nvJitLink, embedded metadata, and
.targetfiles.Complete LLVM 7 pointer export
i8 addrspace(N)*.calls, and other pointer producers back to that neutral form.
calls, and other typed uses.
type-consistent without assuming that every address has one pointee type.
addrspacecastmay cross address spaces.Structured ABI boundaries
declarations after the function body has moved to opaque pointers.
non-C or unwinding ABIs, variadics, unsupported small by-value values,
scalar
f16, and arrays passed by value.Dedicated NVVM transform crate
Adds
nvvm-transformsbetween MIR lowering and text export:Keeps
mir-lowerfocused ondialect-mir→ LLVM conversion.Rewrites
fnegby toggling the IEEE sign bit, preserving signed zero andNaN payload bits.
Expands integer and float-to-integer saturation, modern shuffle/vote
signatures, LLVM 7 memory intrinsic names, unsupported
nnegflags, andwide bit operations.
Validates the module before changing it and returns an error when no
equivalent legacy operation is available.
Verification and artifact handling
nvvmVerifyProgrambefore compilation and queries the toolkit's NVVMIR/LLVM versions when available.
alone.
unless a component-specific path override is set.
library error values remain valid across the FFI boundary.
Blackwell forward execution
sm_86can be converted tooriginal-target PTX and JIT-compiled by the CUDA driver on Blackwell.
error 222 now points users to a compatible toolkit or driver upgrade.
such as
sm_90aare not forwarded to another compute capability.Capability coverage
sm_75,sm_86,sm_90, andsm_90aLLVM 7 outputsm_100andsm_120modern outputRegression examples
libdevice_math— the issue nvvmCompileProgram fails with "parse expected type" when libdevice calls (__nv_expf) trigger NVVM IR mode #98/community kernel shapes, SwiGLU, andsin,exp,sqrt,atan,atan2,acos, andtan, with CPU numericalchecks. This replaces the issue-number-based
issue98_reproname.legacy_nvvm_pointer_shapes— pointers across branches, a loop,non-inlined calls, nested structs, an array of pointers, and
f32/u32views of the same address.
primitive_stress— wide bit operations, saturation, and 50 floatingpoint checks through both NVVM dialects.
Compile-only smoke tests use
emit-ltoir, so all three examples pass throughthe real libNVVM verifier and compiler instead of stopping after text export.
Testing
cargo fmtfor the root workspace, backend, and changed examplescargo test --workspace --all-targetscargo deny checksm_80, emit typed-pointer IR, and record.targetlibdevice_math, pointer shapes, and primitive stresssm_75,sm_86,sm_90,sm_90a,sm_100,sm_120sm_86LLVM IR contains typed pointers and no opaqueptrlibdevice_mathsm_86execution with CUDA 13.0: all three regression examplessm_120execution: all three regression examplesCurrent limits
toolkit. The legacy modules were accepted by the real LLVM 7 parser selected
by CUDA 13 libNVVM and executed through the forward PTX path on Blackwell.
The contributor's original CUDA 12.4 / T1200 report establishes the failure
on
main; native pre-Blackwell and CUDA 12 validation remain useful follow-uphardware checks.
compiler reports this instead of emitting unverified legacy debug IR.
supports a defined subset, but the required validation and lowering have not
yet been implemented.
f16is not supported by the CUDA 12 LLVM 7 dialect. Both are rejectedinstead of being emitted with incorrect semantics.
UnsupportedPayloadKind(272)is a separate artifact-handling problem and isintentionally deferred to another PR.
Checklist
Signed-off-bycrates/cuda-bindings/are modified