r/CUDA • • 1h ago

I'm attempting to remake cuda-x libraries with vulkan shaders instead of actual cuda

2 Upvotes

I'm using it as a learning project so don't flame me https://github.com/billyblackburn/vkdata


r/CUDA • • 27m ago

Blackwell tcgen05 + tensor memory in practice: lessons from porting WGMMA kernels (B200/B300)

1 Upvotes
  • We ported a set of linear-attention kernels from Hopper WGMMA to Blackwell tcgen05 (B200/B300). They're written in JAX's Pallas Mosaic GPU, which compiles to PTX, but everything below is about the hardware side, the same tcgen05/TMEM mechanics you'd hit in CUDA C++ or CUTLASS. Notes in case they help anyone doing the same:
  • Accumulators move to tensor memory. For M=64 single-CTA MMAs, the TMEM half-lane layout loads straight into the WGMMA register layout. That let us keep all the Hopper register-side code (gating, decays, masks) unchanged, with only the product calls swapped behind one helper.
  • There are no register A operands. tcgen05 reads A from SMEM, or from TMEM only at M=128. So register operands are staged through SMEM, which means a store, a fence and the MMA. Where a value already sits in a committed SMEM tile, the MMA reads it directly. That alone took 3–5% off the serial state kernels.
  • Swizzle. An M=64 MMA splits N into halves, so any 16-bit tile used as a 64-wide RHS has to use a swizzle of at most 32 elements.
  • Warp-specialized kernels. You can't allocate TMEM with a scoped allocation inside a single warpgroup's branch (it's a CTA-wide collective). We trace the kernel twice: once to record every warpgroup's TMEM and barrier needs, once with per-warpgroup pools allocated up front.
  • A stall worth knowing about. Issuing a tcgen05 commit when no MMA was outstanding hung kernels with more than one CTA. One-CTA tests passed, so small unit tests missed it. Our rule now: commit only when an MMA is pending, and test helpers on grids of 2 and 1000 CTAs. We saw the hang reliably; we don't know the mechanism.
  • Occupancy. On B200's 148 SMs, calls with only 64 CTAs ran 9–10% faster when each sequence was split into two pieces.

Gated DeltaNet: 1.55–1.98x on B200, 1.54–2.00x on B300 KDA: 1.43–1.53x on B200 What's still slow: B200 trails our own Hopper kernels on an H200 by 4–20%. The products in the serial loops are synchronous, where Hopper's WGMMA overlaps them. Moving to M=128 tiles and asynchronous commits is the obvious next step.

Repo (opt-in with JLA_BLACKWELL=1): https://github.com/jla-org/jax-linear-attention

Happy to answer questions about the Pallas Mosaic GPU side.


r/CUDA • • 2h ago

Replacing float32/float64 with exact integer and rational arithmetic in open-channel hydraulics and shallow-water solvers (verified in Lean 4)

1 Upvotes

Hi everyone, Over millions of time steps in river and open-channel flow simulations, standard float32/float64 arithmetic often introduces small volume drift, subtractive cancellation in shallow trapezoidal beds, and slight discrepancies between CPU and parallel GPU runs. I have been developing an integer-first hydrodynamics and scientific computing framework (UNIQUANT) that replaces floating-point updates with exact integer and rational arithmetic, and I formally verified 40 of its core modules in Lean 4 (0 sorry):

- Backlog-free donor-limited volume ledgers: Proportional outflow apportionment so cell inventories never overdraw and blocked zero-flow channels leave no unphysical backlog.

- Cancellation-free trapezoidal channel geometry: Algebraic depth inversion h = 2A / (b + sqrt(b^2 + 4mA)), exact hydrostatic pressure moment identities (I1'(h) = A(h)), and cut-cell ramp integrals.

- Tridiagonal M-matrix integer solvers: Strictly row-dominant integer solvers with dyadic grid refinement invariance (K to 2K), tie-to-even rounding to prevent solver oscillation, and certified L_infinity error bounds.

- Coupled sediment and momentum conservation: Exact two-phase suspended/bed sediment mass conservation, equilibrium Rusanov fluxes, and 128/256-bit multi-limb arithmetic for bit-exact CPU/CUDA execution.

The reference code (including Elbe hydraulic core headers and Python implementations) and Lean 4 proofs are open source here:

Primary repo & code: https://github.com/joesen88/Uniquant23 (DOI: 10.5281/zenodo.24570873)

Lean 4 formalization: https://github.com/joesen88/UNIQUANT-Formal (DOI: 10.5281/zenodo.24629562)

Would love to hear feedback from anyone working on shallow-water solvers, well-balanced schemes, or deterministic CFD!


r/CUDA • • 3h ago

Day 14 of writing Hopper kernels!

Thumbnail x.com
1 Upvotes

r/CUDA • • 11h ago

[Open Source] Virtualizing a 16 TB FP16 cuFFT into 450 MB VRAM (71.1x speedup, 1.03 ms/batch) + Tensor-Core Beam-CVP on a 4 GB RTX 3050 Laptop

1 Upvotes

I built an open-source CUDA benchmark suite (MIT License) exploring extreme memory virtualization and mixed-precision GPU computing on a **4 GB VRAM RTX 3050 Laptop** (`sm_86`, 15 GB RAM), applied to the 256-bit ECDSA Hidden Number Problem (Bleichenbacher Fourier + Albrecht–Heninger lattice CVP, synthetic test vectors only).

**GitHub Repo:** https://github.com/jcube2024/secp256k1-gpu-audit

### Key CUDA / Systems Optimizations

  1. **`v4 FP16 cuFFT` (`71.1×` speedup over v1 FP32, `1.03–1.16 ms` per `2^22` batch):**

    - Virtualizes a **`2^40`-point (`16 TB`)** DFT into **`~450 MB` VRAM** via CSR binning (`4 B/pair`: 18-bit high index + 14-bit quantized phase).

    - `K = 8` register-level complex phase recurrence (eliminates redundant `__sincosf` calls).

    - Mixed-precision accumulation in FP32 registers + `1/32` pre-scaling into `CUDA_C_16F` (`__half2`) avoids FP16 overflow while preserving exact FP32 SNR (`8.99`).

  2. **GPU `CUB DeviceRadixSort` + Merge Wagner (`30.0×` vs 16-core CPU):**

    - `32M`-element Wagner merge round drops from `1.354 s` (`__gnu_parallel::sort`) to **`0.045 s`** on RTX 3050 (100% bit-exact).

  3. **5-Bucket NVMe Streaming Merge (`< 5 GB` RAM):**

    - Processes `600M` virtual pairs on a 15 GB RAM laptop with monotonically shrinking SSD footprint (`19.2 GB → 9.6 GB → 0 GB`).

  4. **cuBLAS TF32 Tensor-Core `Beam-Sieve-CVP` + GPU 256-bit Predicate:**

    - Solves batched nearest-neighbor search over `G6K` lattice sieve databases (`R @ U^T`) + FP64 GPU Babai-lifting in `0.21 s`.

Includes 8 standalone `.cu` engines (`make -j4 all`), a patched CUDA 12 `G6K-GPU-Tensor`, and a 4-part technical writeup. Happy to discuss any of the CUDA kernel details!


r/CUDA • • 1d ago

Compiling Python to SASS

Thumbnail a-r-r-o-w.github.io
11 Upvotes

r/CUDA • • 1d ago

Remote Async CUDA/GPU Kernel, Open-Source GitHub Maintainer & Algorithmic Coding Contracts ($50-$200/hr USD)

10 Upvotes

For GPU/CUDA kernel engineers, active GitHub open-source maintainers, and competitive programmers (Codeforces/Kaggle)

I started a side project that tracks remote work on 15+ platforms, and there's currently roles offering $50-$120/hr USD for CUDA/GPU kernel engineering, and $45-$120/hr USD for algorithmic problem setters and Kaggle medalists.

Basically if you send me a brief blurb with your country, degree, years of experience, tGitHub/CUDA/CP (i.e. technologies) background (no personal information please), I'll send you a custom Google doc with a list of referrals to roles that match your information. I also provide guides for each of the platforms to help with onboarding.


r/CUDA • • 1d ago

One kernel addressing a VRAM region and a pinned system-RAM region at once

6 Upvotes

Repo: https://github.com/Furox-Art/vram-stream - MIT, 0.4.0.

Install: python -m pip install vram-stream or npm install -g vram-stream - both registries carry 0.4.0.

The pattern this wraps is the mapped-memory one: allocate a pinned host buffer with the device-mapped flag, get its device pointer, and pass it to the kernel alongside a normal device allocation. Two addresses, one kernel, no explicit memcpy between them. The library turns that into a workspace object so you are not hand-rolling the attribute flags and the context bookkeeping each time.

The self-check is the part I would run first, since mapped memory is where driver and platform differences show up:

vram-stream memory --device 0 --vram-mib 16 --ram-mib 16

It allocates both regions in the selected context, launches one kernel that combines values read from VRAM and system RAM, writes results back to both, synchronises, and verifies the first and last aligned 32-bit word of each region. The bundled PTX kernel is compiled by the driver at run time, so nothing is precompiled against a specific CUDA version. From Python, open_cuda_workspace(vram_bytes=..., ram_bytes=...) exposes vram_device_pointer, ram_device_pointer and gpu_accessible_bytes, releases both on exit and restores the calling thread's previous context.

For repeated reads there is a block cache (open_cuda_cache): one pinned RAM buffer and one VRAM buffer per slot, copies and kernels on separate streams, CUDA events protecting the pinned buffer while a prefetch is in flight.

The limit is the link. Mapped RAM traffic crosses PCIe or NVLink at that link's bandwidth and latency, and the driver and OS cap how much you can pin, so this pays off for read-mostly data with locality you can plan for - not as a general replacement for keeping a working set in VRAM.


r/CUDA • • 2d ago

How do you test CUDA code on a remote GPU when using Claude Code or Codex?

11 Upvotes

I use Claude Code on my laptop, but my GPU is in Colab. I used to copy each kernel change into the notebook, run it, and paste the error or benchmark numbers back into Claude.
How does that work in your setup? Can your agent launch the GPU run and read the output itself? If so, how did you connect the two?


r/CUDA • • 2d ago

How to get a job?

28 Upvotes

Hey guys, I want to get a job as an Inference Engineer/ CUDA Programmer. I’m currently working as an AI and Data Engineer at a Vehicle Parts company in USA. I have been learning CUDA since the beginning of this year, I started with Metal(Apple) then shifted to CUDA, have a few good PRs and have 3 open PRs in vLLM. I would like your suggestion on what I can do differently and what I should do to get a job in Inference. My target is May-June next year as it will be 1 year at my current company.


r/CUDA • • 2d ago

Scaling from a single GPU to multi-GPU and multi-node systems | Free webinar

13 Upvotes

We're hosting a free technical webinar with Henry Wu, Henry Wu, Executive Director on ML/AI at Wells Fargo and bestselling author of Distributed AI Systems on December 5 at 11 AM ET.

The session will explore:

  • Scaling workloads across multiple GPUs and nodes
  • Inter-GPU communication and performance bottlenecks
  • Data, tensor and pipeline parallelism
  • GPU memory management and utilization
  • Experimenting with distributed workloads using affordable cloud GPUs

Thought this might be useful to those working with GPU computing and distributed systems.

Free registration: From One GPU to Thousands


r/CUDA • • 2d ago

Compiler explorer now supports Java to CUDA and cuTile with Tornadovm

Post image
7 Upvotes

r/CUDA • • 2d ago

Does HIP add overhead on NVIDIA? I timed two CaRtGS builds on one RTX 4090

3 Upvotes

I expected the benchmarks to settle whether I should worry about the HIP source path on NVIDIA. What I came away with was a better question about how to measure sub-percent differences.

We replayed six captured CaRtGS rasterizer backward workloads on one RTX 4090. Both builds used CUDA 12.8, CUDA LibTorch, and CCCL 2.8.2. The HIP source path still builds with nvcc and uses the CUDA runtime on this card. CaRtGS upstream · AMD HIP compilation and platforms

Saved workloadCUDA median (ms)HIP median (ms)Median paired change
Replica room0 · step 1000.197090.19661−0.28%
Replica room0 · step 5000.329360.32893−0.11%
Replica room0 · step 1,5000.356270.35701+0.24%
TUM fr1/desk · step 1000.130100.12956−0.42%
TUM fr1/desk · step 5000.208250.20815−0.04%
TUM fr1/desk · step 1,5000.216270.21621+0.02%

The metric is synchronized host wall time around one backward API call, including host-side launch work, any allocations inside the call, and synchronization. Four interleaved pairs per workload, 30 samples per mode per pair after warm-up. The percentages are medians of the paired ratios. Negative favors HIP. One early Replica pair came out at −15.47% and stayed in the calculation.

As a sanity check, the 300-frame Replica mapping run took 12.28–12.31 s with the HIP source path and 12.33–12.35 s with the CUDA source path. Two runs per mode, 2,900 mapper updates each. That’s a small pilot, so I’m treating the sub-percent differences as descriptive.

The reason I care is maintenance. CaRtGS and RTG-SLAM both build on Graphdeco’s original differentiable rasterizer. Their implementations share the same CUB inclusive scan and radix-sort calls for binning splats by image tile and depth. That gives us a concrete place to share a HIP wrapper and test, while keeping each project’s specialized kernels. CaRtGS rasterization code · RTG-SLAM depth rasterization code · My RTG-SLAM ROCm port

If you’re writing a new custom GPU kernel for a paper or side project, try starting with HIP and adding both build targets while the kernel is still small. On NVIDIA you can still use nvcc, CUDA libraries, and your usual profiling tools. Keep vendor-specific primitives behind a small interface, and check the same saved inputs on both GPUs.

I’m sharing the project with a few GPU communities. I’m posting here specifically for feedback on how we measured the NVIDIA builds.

For those who benchmark this kind of change, would you start with CUDA events around the individual GPU stages, longer interleaved batches, or both?


r/CUDA • • 3d ago

Why the gap with Mac?

5 Upvotes

Doing generative video (like ComfyUI + MiniMax) on Mac seems to be much slower than running on a similarly-priced Nvidia GPU.

Is this just an inherent tradeoff in how Apple is architecting their chips, and what they’re optimizing for?

Or is the gap likely to be closed over time as the kernels and other software elements mature for Metal, etc?

Local AI is a very exciting space, and Mac + generative media seem like a very natural fit. But their current performance with gen video seems much more limited thank what RTX cards can do.

This isn’t intended to bash on Mac - I love the Mac. I just want to better understand how likely it is to achieve parity with Nvidia/CUDA, specifically for video. Any insights from CUDA/Metal peeps?


r/CUDA • • 3d ago

Learning CUDA @ 16 yrs w/ 8gb 50 series

Post image
32 Upvotes

I just bought my first NVIDIA card in hopes of learning cuda programming, I'm already knowledgeable in C and C++ but is this a good choice? 5060 Ti 8gb (sadly not the 16gb) and I think it'd be a decent card for basic stuff related to cuda or other things like LLM hosting.

I plan on taking some free courses to earn some certifications and do my own studies about the coding languages and CUDA as a whole, opinions on the matter, tips, or questions?

PM on Discord for more info: someoneresides
Email: r2wosolution@gmail.com
Icloud: r2wosolution@icloud.com


r/CUDA • • 4d ago

PSA: NVIDIA DGX Spark has terrible CUDA & software compatibility; and seems like a handheld gaming chip.

Thumbnail reddit.com
0 Upvotes

r/CUDA • • 6d ago

Sm_120 RTX 5070 causal conv1d and Ssm wheels

6 Upvotes

RTX 5070/5080/5090 (sm_120, compute 12.0) currently fails with "no kernel image is available" because setup.py only builds for 70;80;90.

I built working wheels for Blackwell:

\- Patch: TORCH_CUDA_ARCH_LIST=12.0 and replace sm_70/sm_80/sm_90 with sm_120 in setup.py

\- Tested on 5070 WSL2 + torch 2.11.0+cu128 + py3.10

\- Wheels here for anyone stuck: https://github.com/Rapa2026/mamba-ssm-5070-blackwell-wheels

Happy to PR the sm_120 fix if you want it.

Test: Mamba2(d_model=64).cuda() -> OK


r/CUDA • • 6d ago

Replaced most inline PTX with MLIR ops, cutting asm regions from 499 to 81 across 20 kernels.

12 Upvotes

While building a high-level language with a rich type system, a core goal is reducing the need for low-level escape hatches like inline asm.

In glm-vx(GLM-5.3 serving engine with kernels in Vx-lang, checkpoint loading, and streaming HTTP), we replaced most inline PTX with MLIR ops, cutting asm regions from 499 to 81 across 20 kernels.

When LLVM sees the surrounding code, it can simplify logic and cut spills thus generating better code.

e.g., A bf16 store. The epilogue of the GEMM converts each f32 result to bf16 and stores 16 bits. The asm converted into a 16-bit register and then widened it to 32 bits with cvt.u32.u16, only for the store to use the low 16 bits again. Now the store takes the 16-bit register, and fp8_gemm_m64 has 64 fewer instructions:

// before
{ .reg .b16 h; cvt.rn.bf16.f32 h, %r393; cvt.u32.u16 %r199, h; }
st.global.b16  [%rd65], %r199;

// after
cvt.rn.bf16.f32  %rs1, %r327;
st.global.b16    [%rd74], %rs1;

But when hoisting/reordering hurts (like %laneid or mma scheduling on H200), we have no option to keep the asm. Link to the full writeup in comments.

EDIT:

the generated SASS was also better in the topk examples from the post but in the above case it was identical.


r/CUDA • • 6d ago

Built a ternary (BitNet-style) inference engine in Rust/CUDA: 8x faster than dense f32 on one CPU core. Looking for GPU testers

Thumbnail reddit.com
1 Upvotes

r/CUDA • • 7d ago

why it's so hard to make SASS assembler?

Thumbnail redplait.blogspot.com
17 Upvotes

summary:

  • only ~80% of ELF sections currently known
  • ~50% of EIATTRs
  • instruction scheduler is highly gpu specific and can't be implemented based on llvm machine scheduler. And np-hard

r/CUDA • • 7d ago

Tencent gave Google's Guetzli a GPU. I volunteered to keep it alive. v3.0.0 is out.

Thumbnail reddit.com
3 Upvotes

r/CUDA • • 8d ago

exact-gpu-jpeg: CUDA JPEG decode/encode that’s byte-identical to libjpeg-turbo and Pillow

8 Upvotes

GPU JPEG decoders are fast, but their pixels differ from the CPU libraries'. On 102 public test images, nvJPEG matched libjpeg-turbo on none of them, by up to 110 levels at 4:2:0. That quietly breaks reproducible ML pipelines, test baselines and caches whenever decoding moves between CPU and GPU.

exact-gpu-jpeg decodes on the GPU and returns libjpeg-turbo's pixels byte for byte (accurate IDCT, fancy upsampling), and its encoder writes the same bytes as Pillow. Anything it can't reproduce exactly, progressive files for example, goes to libjpeg-turbo itself, so the output is always the reference.

On a 2016 GTX 1070: a 30 MP camera photo decodes in 11.3 ms, against 185 ms for libjpeg-turbo on one core and 164 ms for nvJPEG on the same card. Batches of small images: 7,310 images/s. Encoding: 5.5x faster than Pillow with identical files.

Where it loses is listed near the top of the README: one small image at a time, small encodes against 8 CPU threads, progressive files. Everything so far is from one machine, so results from other GPUs are very welcome: `python bench/reproduce.py --quick`, and there's a pinned issue for them.

The parallel Huffman stage (Weißenberger & Schmidt's self-synchronising method) is drawn in docs/huffman-sync.md, and there's a white paper in docs/ covering the method, the evidence and the limits.

https://github.com/mrluker/exact-gpu-jpeg