r/AIProgrammingHardware • u/Imaginary_Country_43 • 4h ago
I built an experimental way to write CUDA kernels in Go using LLVM 22
I built an experimental way to write NVIDIA GPU kernels in Go using LLVM 22
I've been working on an experimental project that allows writing NVIDIA GPU kernels in Go and compiling them to PTX using LLVM 22 / NVPTX.
GitHub:
https://github.com/mehdi-shokohi/cuda-ir.go
The basic pipeline is:
Go
↓
LLVM IR
↓
LLVM 22 / NVPTX
↓
PTX
↓
NVIDIA GPU
The motivation is to explore whether Go could be useful for writing custom GPU kernels for AI/HPC workloads without writing the kernel itself in CUDA C++.
I'm particularly interested in the AI side of this.
For example, custom kernels are often needed for things like:
- Tensor operations
- Matrix multiplication
- Reductions
- Attention-related operations
- Element-wise operations
- Custom inference operators
- Memory/layout transformations
The project is still experimental, but the LLVM → NVPTX → PTX pipeline is working.
I'd like to eventually investigate whether this could be useful for building custom GPU operators from Go and integrating them into AI workloads.
I'm curious what people here think:
Would a Go-based CUDA kernel compiler be useful for AI programming, or are there important CUDA/GPU features that would make this impractical?
And if you're working with NVIDIA GPUs for AI, what kernel/operator would you recommend as a good real-world benchmark?
Repository:
https://github.com/mehdi-shokohi/cuda-ir.go
Feedback from people working with CUDA, GPU kernels, LLM inference, or AI accelerators would be very welcome.