Skip to content

[Draft/RFC] cuda-oxide (native CUDA) device build for vortx-shaders#9

Draft
haixuanTao wants to merge 3 commits into
dimforge:mainfrom
haixuanTao:feat/cuda-oxide-device
Draft

[Draft/RFC] cuda-oxide (native CUDA) device build for vortx-shaders#9
haixuanTao wants to merge 3 commits into
dimforge:mainfrom
haixuanTao:feat/cuda-oxide-device

Conversation

@haixuanTao

Copy link
Copy Markdown
Contributor

Draft for discussion — the vortx piece of the native-CUDA (cuda-oxide) stack (companions: dimforge/khal#9 and the dimforge/nexus draft).

What's in here

  • vortx-shaders builds cleanly for the nvptx64-nvidia-cuda device target under the cuda-oxide codegen backend (no spirv-std-only assumptions).
  • A cuda-oxide cargo feature forwarding to khal-std/cuda-oxide, so shader crates depending on vortx-shaders (e.g. nexus's) can enable the device backend uniformly.
  • Device-build fixes keeping the typed reductions intact.

The resulting .ll compiles to a sm_120 cubin via llvm-link(libdevice) → llc → ptxas and is consumed by hosts through khal-builder's CUDA_OXIDE_SHADERS_PTX_VORTX_SHADERS prebuilt escape hatch.

Blocked on upstream cuda-oxide

NVlabs/cuda-oxide #350, #358, #360 — until merged, the codegen backend .so comes from haixuanTao/cuda-oxide branch feat/nexus3d-vortx-native-cuda.

🤖 Generated with Claude Code

haixuanTao and others added 3 commits July 9, 2026 15:21
Two fixes, both needed before vortx-shaders compiles for the native-CUDA
(cuda-oxide -> nvptx64) backend; neither affects the WebGPU/spirv or host
builds.

1. lib.rs: extend `no_std` to nvptx64. The crate only declared
   `#![cfg_attr(target_arch = "spirv", no_std)]`, so under the cuda-oxide
   path (target nvptx64) it implicitly linked `std`, which the target has
   no crate for -> the std prelude failed to load, cascading into ~27
   "can't find `derive`/`step_by`/prelude/std" errors across six modules.
   nvptx64 was already excluded from the host `extern crate std` just
   below, so the GPU/host split was intended; the no_std gate just never
   listed nvptx64. Now: any(spirv, nvptx64).

2. Cargo.toml: pull khal-std with `default-features = false`. khal-std's
   default = ["rust-cuda"] enables cuda_std (and thus `half`), which is
   not no_std-clean on nvptx64 and breaks the device build. The cuda-oxide
   feature is forwarded explicitly, so the rust-cuda default is unwanted
   here. Mirrors how nexus-cuda already declares the same dep.

Verified on an RTX 4090 laptop cuda-oxide build: these two cut the
vortx-shaders device-build errors 62 -> 35, with the remainder isolated
to one file (reduce.rs shared-memory glue), unrelated to no_std.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Workspace [patch.crates-io] redirects + cuda-oxide feature so
vortx-shaders compiles for nvptx64 via the cuda-oxide backend into a
native cubin. Pairs with cuda-oxide branch
feat/nexus3d-vortx-native-cuda-5060-fixes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EvzrSDVTgXiymMWuhT4p5W
…eductions

- reduce: keep the typed decl_reductions! kernels (host consumes
  ReduceAdd{F32,I32,U32} etc.) — now buildable on cuda-oxide thanks to the
  generic SmemBuf; replace StepRng with Range::step_by; take the workspace as
  &mut impl MaybeIndexUnchecked<T> in the tree-reduce helpers so both the
  SPIR-V array param and the CUDA SmemBuf wrapper fit.
- op_assign/contiguous: StepRng -> step_by.
- shape/op_assign: gate bytemuck derives on not(spirv|nvptx64) instead of the
  rust-gpu-only target_arch_is_gpu cfg.
- mod: exclude obs/reward from the nvptx device build (host-side on CUDA).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant