Repository navigation
feat: add integer dot product instructions (dp4a, dp2a) for sm_61+ - #275
Merged
Merged
Conversation
honeyspoon
force-pushed
the
upstream-dot-products
branch
from
June 22, 2026 19:04
1950bd6 to
4f65da3
Compare
49 tasks done
Add dp4a (4-element byte dot product) and dp2a (2-element half-word dot product) intrinsics in signed and unsigned variants, lowered to pure inline PTX assembly with AsmKind::Pure. These single-thread, non-convergent instructions perform packed-integer multiply-accumulate in a single cycle and are the building blocks for INT8/INT4 quantised inference on sm_61+ GPUs (Pascal and later). Part of NVIDIA#274 Signed-off-by: abder <[email protected]>
dp4a/dp2a are pure per-thread register arithmetic with no memory or pointer/aliasing contract, so the four device stubs are now safe `pub fn`, matching every sibling pure-arithmetic intrinsic (fma_bf16x2, cvt_f16x2_f32) instead of forcing callers into needless unsafe blocks. Drop the now-unnecessary `# Safety` doc sections (they would also trip clippy::unnecessary_safety_doc on a safe fn). Reflow the dialect-nvvm import list after rebasing onto the TypeHandle-API main.
nihalpasham
force-pushed
the
upstream-dot-products
branch
from
June 24, 2026 04:39
4f65da3 to
38618c0
Compare
Collaborator
|
Thanks for the PR. LGTM 👍🏾
Rebased onto the TypeHandle-API main and layered a small commit:
Reviewer note: no GPU e2e in this env, so ptxas acceptance + numerics on sm_61+ still want a follow-up example. Ticked the dp4a/dp2a box in #274; not closing the tracking issue. |
2 tasks done
honeyspoon
added a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jun 24, 2026
Follow-up to NVIDIA#275, adds the GPU-verified example noted as owed. Part of NVIDIA#274 Signed-off-by: abder <[email protected]>
honeyspoon
added a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jun 26, 2026
Follow-up to NVIDIA#275, adds the GPU-verified example noted as owed. Part of NVIDIA#274 Signed-off-by: abder <[email protected]>
nihalpasham
pushed a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jun 28, 2026
Follow-up to NVIDIA#275, adds the GPU-verified example noted as owed. Part of NVIDIA#274 Signed-off-by: abder <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Jun 28, 2026
* feat: add dp4a/dp2a end-to-end example (sm_61+) Follow-up to #275, adds the GPU-verified example noted as owed. Part of #274 Signed-off-by: abder <[email protected]> * fix: make dot product target explicit Signed-off-by: nihalp <[email protected]> --------- Signed-off-by: abder <[email protected]> Signed-off-by: nihalp <[email protected]> Co-authored-by: nihalp <[email protected]>
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
Retain tensor storage and device access leases through submission completion, independently of borrowed or projected outputs. Forgotten futures leak these owners rather than freeing in-flight memory or permitting conflicting cross-stream accesses. Cover kernels, views, copies, partial errors and panics, and graph replay. Preserve the f8 nearest-even rounding and i32 Latency generic fixes in this PR. Document the runtime contracts for 0.4.0. Validation: full CPU and GPU test scripts, nine gated GPU regressions, example builds, formatting, and Clippy with warnings denied. The borrowed-copy and mapped-view lifetime regressions fail on the previous PR head. Signed-off-by: Melih Elibol <[email protected]>
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
…submissions (NVIDIA#302) Per launch, each tensor argument cost two heap allocations (an Arc<()> access id and a Box<dyn Send> owner); access ids are now u64 counters and leases are stored inline in the submission. Graph replays walked every recorded context and re-registered every recorded resource; the recorded resources are now frozen and deduplicated by storage at capture time, and a replay reacquires each distinct buffer once. Lifetime and cross-stream conflict semantics are unchanged: every in-flight access is still registered on its storage and released when the submission completes. Host-only enqueue cost (RTX 5090, benches/host_overhead): tiny 4-tensor launch 1.954 -> 1.884 us (pre-NVIDIA#275: 1.640) 32-node graph replay 14.68 -> 1.67 us (pre-NVIDIA#275: 1.139) Signed-off-by: Melih Elibol <[email protected]>
elibol
added a commit
that referenced
this pull request
Nov 14, 2026
Transplant of NVlabs/cutile-rs#270 (NVlabs/cutile-rs#270) onto cuda-rust after the repository move: one commit, original author and sign-off, host-crate paths following the move to the repository root. Documentation only. #275 made graph replay sound at runtime: every storage recorded during capture stays alive while the graph can replay, each launch re-leases those accesses on its own submission, a replay that conflicts with an in-flight access on another stream is rejected before it is enqueued, and a forgotten launch future leaks rather than frees. The public docs still described only the capture-time safety argument. This adds a "Replay safety" section to `CudaGraph`, a matching section to `Scope`, notes on `take_output`, `launch`, and `scope`, and one paragraph in the host API reference. No API or code changes; `cargo test --doc` passes and the new docs build without rustdoc warnings.
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.
Add dp4a (4-element byte dot product) and dp2a (2-element half-word dot product) intrinsics in signed and unsigned variants, lowered to pure inline PTX assembly.
Summary
Implements the PTX
dp4aanddp2ainteger dot-product-with-accumulate family across the full compiler pipeline. These single-thread, non-convergent instructions perform packed-integer multiply-accumulate in a single cycle and are the building blocks for INT8/INT4 quantised inference on sm_61+ GPUs (Pascal and later).Each operation takes three 32-bit inputs
(a, b, c)and produces one 32-bit outputd = c + dot(a, b). Fordp4a,aandbare treated as 4 packed bytes; fordp2a,ais 2 packed 16-bit values and the lower 2 bytes ofbare used. Both come in signed (s32) and unsigned (u32) flavors. The lowering uses pure inline PTX assembly (no LLVM intrinsic exists for these), tagged withAsmKind::Pure(non-convergent, no side effects), matching the pattern used byfma_bf16x2.dp4a_s32(a, b, c)dp4a.s32.s32 %d, %a, %b, %c;dp4a_u32(a, b, c)dp4a.u32.u32 %d, %a, %b, %c;dp2a_s32(a, b, c)dp2a.lo.s32.s32 %d, %a, %b, %c;dp2a_u32(a, b, c)dp2a.lo.u32.u32 %d, %a, %b, %c;Part of #274
Changes
dotprodmodule (dp4a_s32,dp4a_u32,dp2a_s32,dp2a_u32), each#[inline(never)]withunreachable!host-side fallback.Dp4aS32Op,Dp4aU32Op,Dp2aS32Op,Dp2aU32Op), each with 3 operands (a, b, c) and 1 result, registered in the NVVM dialect.emit_dp*translation functions dispatched fromtry_dispatch_intrinsicfor thecuda_device::dotprod::*call paths.convert_dp*functions lowering NVVM ops toInlineAsmOpwithAsmKind::Pure; 4MirToLlvmConversiontrait impls wiring them up.InlineAsmOp.mir-lower/tests/lowering_test.rsverifying each op produces the expected PTX mnemonic in the inline asm output.Testing
cargo test -p mir-lower --test lowering_testpasses (4 new + 9 existing = 13/13)cargo check -p dialect-nvvm -p mir-lowerpassescargo fmt --checkandcargo clippy --workspace -- -D warningscleanChecklist
git commit -s)cuda-bindings/modified