r/CUDA • • 1h ago

I ported a diffusion-based super-resolution model to native C++ and TensorRT on my Jetson Orin Nano

Thumbnail gallery
2 Upvotes

r/CUDA • • 19h ago

14 of 31 AI-written GPU kernels that pass their tests race under the PTX memory model (most often a grid barrier with no fence after the spin)

3 Upvotes

I build syncsan, a race detector for GPU kernels whose thread blocks hand data to each other through global memory. Those handoffs need a release and an acquire under the PTX memory model, and when one is missing the kernel usually still gives the right answer on today's GPUs, so tests don't catch it.

Models now write kernels like this (megakernels with grid barriers, flags, last-block reductions), so I ran syncsan on every public, test-passing, model-written kernel I could find that synchronizes across blocks. The older bulk datasets (Sakana's archive, KernelBench samples, CUDA-L1) had none; all 34 came from kernelbench.com's megakernel track and KernelBench-Hard, and 31 reached a verdict.

14 of the 31 race under the PTX model: 10 miss a release or acquire between blocks (most often a grid barrier that spins on a volatile counter with no fence after the spin), and 4 reuse shared memory without a barrier. In 7, handing the racing loads the stale values the model allows makes the benchmark's own check fail, while a control run passes. None failed in normal runs, so this is about what the memory model permits, not failures seen on hardware. Each bug shape is checked with Dartagnan's formal PTX model, and syncsan's own false positives on this set are listed in the write-up. There are 1 to 3 kernels per model, so this says nothing about which model is better.

Write-up with per-kernel verdicts and source lines: https://github.com/ShreshthRajan/syncsan/blob/main/docs/findings/ai-kernels.md (I'm the author of syncsan.)


r/CUDA • • 1d ago

Need help in deciding a PhD offer

9 Upvotes

Hi Everyone,

I wanted help in deciding whether the university I have a PhD offer from has the necessary infrastructure and resources to conduct research on ML systems and GPU computing. Please let me know if someone's willing to help me out and I can DM you the details. Thank you.


r/CUDA • • 1d ago

TensorLean

Thumbnail tensorlean.ai
6 Upvotes

formal verification of ptx code

github: https://github.com/TensorLean/TensorLean/tree/main

very impressive work


r/CUDA • • 2d ago

Interview Prep for GPU Compiler Engineer roles

26 Upvotes

Essentially the title. I’ve recently been working on gpu compilers but want to eventually transition to a similar role at a bigger company. I was curious what the interviews look like and what references people use to study. I’m especially interested in how different this is compared to standard SWE roles (Leetcode, System Design, etc)


r/CUDA • • 2d ago

I built a race detector for CUDA kernels that sync between thread blocks. It catches DeepGEMM's tensor-map race and found one in SuperLU_DIST

4 Upvotes

I built syncsan while learning the PTX memory model. Fast LLM kernels (megakernels, persistent kernels) pass data between thread blocks through flags and counters in global memory. A missing release or acquire in one of those handoffs rarely fails on today's GPUs, so it survives testing.

syncsan runs the unmodified binary under NVBit, tracks what orders what with vector clocks, and reports every pair of accesses that nothing orders. An adversarial mode then hands each racy load the stale value the model allows, so you can see what the bug does to your output.

What it has found:

  • SuperLU_DIST: a commit that fixed a dropped fence restored the consumer's acquire but not the producer's release. In adversarial mode the solve error was 0.7. The maintainers confirmed it and fixed it the same day.
  • DeepGEMM: the tensor-map race Ivan Komarov fixed in PR #343, which gives 64+ different outputs in 100 runs on an H100. 0.11.0 missed it; 0.11.1 reports 32 races before his fix and none after.
  • Hazy Research's Llama-1B megakernel: with NaN written into the buffer before each step, the original kernel reads the NaN in 1,000 of 1,000 generations, the fixed one in none.

To check the rules themselves, I compared syncsan with Dartagnan's formal PTX model on 81 litmus tests. They agree on 78; the 3 that don't are cases a binary can't show.

Limits: a 4-token Hazy decode takes 54 s under syncsan versus 14 s without, it doesn't check races between lanes of one warp or ordering across kernels and streams, and it only sees the paths your input reaches. It runs on Colab's free T4.

Repo: https://github.com/ShreshthRajan/syncsan (pip install syncsan), and a Colab notebook that runs it on a free T4: https://colab.research.google.com/github/ShreshthRajan/syncsan/blob/main/examples/colab.ipynb

Yesterday I posted PTX Puzzles here, which uses syncsan as its grader. This is the tool itself.


r/CUDA • • 2d ago

How do you guys actually use cloud GPUs? I'm trying to understand what's broken with the current experience.

Thumbnail forms.gle
5 Upvotes

Hey everyone,

I've been building an open-source runtime and a service around it that allows PyTorch to execute tensor operations on remote GPUs while keeping your Python environment local.

One thing I've realized while working on this is that my own frustrations with cloud GPUs might not necessarily reflect what other researchers and developers struggle with.

I'm curious about things like:

  • How much time you spend setting up environments versus actually running experiments.
  • Whether you find yourself paying for GPUs that aren't actively computing.
  • How much performance overhead you'd tolerate for a simpler development workflow.
  • Whether paying for actual computation rather than GPU rental time makes sense to you.

I've put together a survey to better understand these problems. Even if you've never used a cloud GPU service, your responses would be valuable.

It takes around 5–10 minutes, and no sign-up is required.

Thanks!


r/CUDA • • 3d ago

PTX Puzzles: 12 small CUDA kernels with real cross-block sync bugs, graded by a race detector (free on Colab)

4 Upvotes

I made a set of 12 puzzles while learning the PTX memory model. Each is a small kernel where blocks hand data to each other through global memory (a flag, a counter, a grid barrier, a TMA store, a spinlock), and each has a synchronization bug. Most of the bugs come from real code: Hazy Research's Llama-1B megakernel, SuperLU_DIST's triangular solve, CUTLASS Stream-K, Mirage MPK, Lucebox, and CUDA's own threadFenceReduction sample.

The catch is that most of the starters give the right answer when you run them. Your GPU doesn't reorder enough to show the bug, but the memory model allows it. So the grader runs each kernel under a race detector I wrote (syncsan, on NVBit), which reports racing accesses and, in an adversarial mode, hands racy loads the stale values the model allows. A fix passes only if it has no races and the output stays correct with stale values. It's scored by how many fences, acquires, releases and barriers you add, against a par.

It runs on Colab's free T4, no setup: https://colab.research.google.com/github/ShreshthRajan/ptx-puzzles/blob/main/puzzles.ipynb

Repo, with solutions and a paragraph on why each works: https://github.com/ShreshthRajan/ptx-puzzles

The format is borrowed from Sasha Rush's GPU Puzzles. Puzzle 8 (TMA) needs an H100 and is skipped on the T4. Feedback on puzzles that are unclear or too easy is very welcome.


r/CUDA • • 3d ago

Can some Vulkan knowledge help with learning CUDA?

5 Upvotes

r/CUDA • • 3d ago

yields in SASS instructions

Thumbnail redplait.blogspot.com
1 Upvotes

Yields inserted by PTXAS on instruction-specific stall counts threshold


r/CUDA • • 3d ago

Open GPU kernel engineering series: naive GEMM to FlashAttention, H100 and Blackwell (44 sessions, code public)

Thumbnail youtu.be
45 Upvotes

Four sessions already live and next one is releasing soon about writing your first CUDA kernel

Roadmap (44 sessions):

- Foundations: CPU parallelism, GPU architecture, roofline, first CUDA kernels

- Memory hierarchy

- GEMM: naive kernel to optimized, profiling at every step

- Tensor cores

- Profiling and debugging

- PyTorch integration and Triton

- Attention / FlashAttention

- Hopper and Blackwell: TMA, WGMMA, CUTLASS, FP8/quantization, NVFP4, multi-GPU basics, FlashAttention 4, DeepSeek's kernels, AI-written kernels, capstone project

Prerequisites are C/C++, basic linear algebra, and PyTorch.

Caveats: it's in progress, and the later sessions (especially Blackwell/NVFP4) may change as the tooling does.


r/CUDA • • 3d ago

Hayek — AI Inference Engine

Thumbnail reddit.com
1 Upvotes

r/CUDA • • 4d ago

Day 16 of writing a hopper kernel everyday

Thumbnail x.com
1 Upvotes

r/CUDA • • 4d ago

Advent of Kernel Optimization

25 Upvotes

Today is day one of our Advent of Kernel Optimization, covering fused-multiply add. We'll post about one GPU kernel optimization technique every weekday, you can follow along at https://streamhpc.com/blog/tag/advent2026/.


r/CUDA • • 4d ago

Experienced C++ dev looking for the best CUDA learning resources and references

30 Upvotes

Hi everyone!

I'm a C++ developer with around 6 years of experience. I've played around with CUDA casually, enough to write basic kernels and get things running, but I've never studied it properly. I'd now like to go from "it works" to actually understanding what's going on and writing good CUDA.

I'm looking for two kinds of resources:

1. Learning resources

I'm looking for a technically accurate, well-structured course or book to learn CUDA properly. I'm comfortable with C++, but I don't mind revisiting the fundamentals if it's done right. I've seen plenty of crash courses on YouTube and Udemy but it's hard to tell which ones are technically sound. What would you recommend?

2. Reference material

What are the go-to references for CUDA that you keep bookmarked?

Cheers!


r/CUDA • • 6d ago

Sharded matmuls and overlaps

Thumbnail x.com
5 Upvotes

r/CUDA • • 7d ago

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

5 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 • • 7d ago

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

10 Upvotes

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


r/CUDA • • 7d 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 • • 7d ago

Day 14 of writing Hopper kernels!

Thumbnail x.com
7 Upvotes

r/CUDA • • 7d 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

2 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 • • 8d ago

Compiling Python to SASS

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