r/CUDA • • Oct 21 '26

Hackathon: Implement PTX Compiler

We're running a hackathon to build a simplified PTX compiler running from October 21st to October 27th, 2026.

The goal is to generate efficient PTX from an internal kernel representation. The parser is provided, so you don't need to implement the full CUDA compiler frontend, and you don't need to find an efficient schedule. The goal is to generate efficient PTX code to run the program.

Here is an example of IR for RMSNorm:

    Tile[a0, a1_co] (N=8192)
        for a1 in a1_co..1024:128
            in2 = load x[a0, a1]
            f32 v1 = multiply(in2, in2)
            f32 acc0 <- add(acc0, v1)
        WarpShuffle(acc0, length=32)
        Smem float acc0_smem[4]
        if ((lane == 0)):
            acc0_smem[warp] = acc0
        Sync
        TreeHalve(acc0, length=4, tid=warp)
        in1 = load mean_count[0]
        f32 v0 = reciprocal(in1)
        f32 v2 = multiply(acc0, v0)
        in0 = load add_c1[0]
        f32 v3 = add(in0, v2)
        f32 v4 = sqrt(v3)
        f32 v5 = reciprocal(v4)
        for a2 in a1_co..1024:128
            in3 = load x[a0, a2]
            f32 v6 = multiply(in3, v5)
            in4 = load w[a2]
            f32 v7 = multiply(in4, v6)
            mul_1[a0, a2] = v7    Tile[a0, a1_co] (N=8192)
        for a1 in a1_co..1024:128
            in2 = load x[a0, a1]
            f32 v1 = multiply(in2, in2)
            f32 acc0 <- add(acc0, v1)
        WarpShuffle(acc0, length=32)
        Smem float acc0_smem[4]
        if ((lane == 0)):
            acc0_smem[warp] = acc0
        Sync
        TreeHalve(acc0, length=4, tid=warp)
        in1 = load mean_count[0]
        f32 v0 = reciprocal(in1)
        f32 v2 = multiply(acc0, v0)
        in0 = load add_c1[0]
        f32 v3 = add(in0, v2)
        f32 v4 = sqrt(v3)
        f32 v5 = reciprocal(v4)
        for a2 in a1_co..1024:128
            in3 = load x[a0, a2]
            f32 v6 = multiply(in3, v5)
            in4 = load w[a2]
            f32 v7 = multiply(in4, v6)
            mul_1[a0, a2] = v7

The prize pool is $ 2,750, and we offer internship opportunities to participants with interesting submissions.

Info: https://riftstack.ai/hackathon

Intro lectures:

30 Upvotes

14 comments sorted by

4

u/tilingSmith Oct 22 '26 edited Oct 23 '26

I really do not see the point of this competition to be about compile time: The end goal for all of the CUDA system is basically generate as efficient kernel to run on (racks of) NVGPU(s) as possible. In terms of compile time, compiling CUDA using nvcc is basically template metaprogrammed C++ compilation which is deemed to be slow, and if I want fast compile speed, I would just write CUTE DSL python to (almost) 1-to-1 match to sass by their own mlir python binding from python to sass. (assuming I know how the cute dsl python ops corresponds with sass)
As for performance, if you do not have their propriety SASS knowledge, most of your observed optimization would be just "coincidence" or "magick", considering their SIMT hardware can do additional handling unlike VLIW ASICs which I work on and have full control even on the MLIR level.

2

u/NoVibeCoding Oct 22 '26

The competition aims to give participants an opportunity to learn about PTX, GPU architecture, and the fundamentals of compilers. The competition primarily targets students seeking internship opportunities. We don't expect high-performing, production-grade compiler submissions. However, we encourage participants to do their best.

As for the business need that inspired this competition: we need a fast compiler for the internal IR. This IR is much closer to hardware than CUDA, and as you've pointed out, that would enable faster compilation times because we don't need to do as much work as nvcc.

1

u/checkmydoor Oct 26 '26

Im not the technical portion but I think this is what youre looking for

https://mbuchel.github.io/projects/sass2mlir/

1

u/c-cul Oct 22 '26

btw I have zero ideas why they invented their own dialect https://github.com/NVIDIA/cutlass/blob/main/cutlass_compiler/cute_ir/include/cute_ir/Dialect/Cute/IR/CuteOps.td instead of standard linalg/tensor/tosa

2

u/tilingSmith Oct 23 '26 edited Oct 23 '26

Speaking from my experience, those dialected ops are easier to lower to actual SASS correspondent dialect/llvm ir ops (Maybe there are other reasons, but I think this is the most likely one). What I can confirm is that the open sourced cute ir compiler is an extremely shallow version of NV's own proprietied one, the passes that actually matters are all hidden, and this tablegen is designed with those passes in mind.

1

u/c-cul Oct 23 '26

why do you think that those DSL compiling directly to SASS? I've checked _cutlass_ir.cpython-313-x86_64-linux-gnu.so and seems that it contains standard NVPTX backend

llvm-mc (based on LLVM 20.0.0git)

1

u/tilingSmith Oct 26 '26 edited Oct 26 '26

My probe is that their open sourced repo is very different from what they proprietied. I also work in software stacks (not for GPU, but for ASIC) and if they want a python writing tool to be able to absolute maximize the performance on the python level I do not see a reason why they would do python to nvptx to sass instead of directly to sass. I do not have as much backend knowledge on simt as on vliw so maybe mlir to ptx to sass would still work since llvm/nvcc can do the ptx to sass heavy lifting.

1

u/c-cul Oct 28 '26

while doing some RE I found whole ptxas inside cute dsl compiler: https://www.reddit.com/r/CUDA/comments/1xfvigv/machineir_passes_mlir_dialects_from_nvidia/

so it first lowering to ptx via standard NVPTX backend

1

u/c-cul Oct 28 '26

btw do you planning to disclose results? no personal data - just what perf winner(s) achieved comparing to nvcc/cute dsl?

1

u/NoVibeCoding Oct 28 '26

Yes, we will post results on our social media accounts.

1

u/c-cul Oct 21 '26

2

u/NoVibeCoding Oct 21 '26

We don't expect participants to beat nvcc, ha-ha. It would be nice, though. The main problems we want to address with this exercise are compiler performance (sometimes nvcc takes about 30 seconds to compile the kernel) and a better understanding of the generated kernels.

2

u/c-cul Oct 21 '26

> The goal is to generate efficient PTX

> The main problems we want to address with this exercise are compiler performance

choose one thing

nvcc compilation time slow bcs it has 42 closed-source opt passes not presented in clang

1

u/NoVibeCoding Oct 21 '26

For hackathon participants, the goal is to generate efficient PTX. At RiftStack, however, we want the PTX backend to be a fast compiler that gives us rich information about generated kernels and whose internals we understand.

What is your argument? Don't work on the PTX compiler because it is hard to beat nvcc?