Editorial illustration for AI Agent Translates CUDA Tile Operations From Python to Rust
AI Agent Translates CUDA Code Python to Rust
An engineering team just ported 24 GPU operators, roughly 40 kernels in total, from Python to Rust without a human rewriting a single one by hand. The work relied on an AI agent built specifically to translate CUDA tile kernels from the TileGym library, which already holds a large stock of production kernels written in cuTile Python and Triton-TileIR. The target was cuTile Rust, a tile-based system for writing GPU kernels that extends Rust's ownership model to handle mutable outputs and preserve host-side ownership across kernel launches, while still letting programmers drop down to raw Tile IR when they need that control.
The kernels involved aren't simple. They span element-wise math, flash-attention decode, Multi-head Latent Attention, and mixture-of-experts models, some requiring several variants apiece. Converting them means running each one through a multi-agent pipeline that handles analysis, device kernel logic, host and FFI code, and benchmarking, with validator scripts and Tile IR diffs checking every stage before it moves forward.
The result, after all 24 operators were converted, reached 99.5% of the original Python performance on average. The harder problem sits in a language-level mismatch that the team had to solve directly.
The TileGym CUDA tile kernel library has accumulated a large library of production kernels written in CUDA Tile Python (cuTile Python) and Triton-TileIR (nvtriton ).
Why this matters
The interesting part here isn't that an AI agent can translate Python to Rust. It's that the translation gets checked against something concrete: the Tile IR diff. When cuTile Rust and the original Python kernel compile down to the same op inventory (same view load, same reduce_max, same reduce_sum on the right axis), that's a verifiable claim, not a vibe.
For teams maintaining libraries like TileGym, that changes the calculus on porting work. Rust's ownership model has always been a hard sell for GPU kernel authors who need low-level control over memory layout, and the ability to opt out locally when the abstraction gets in the way matters more than the port itself.
We'd push back on treating this as a solved problem. One IR diff matching on one kernel type doesn't tell you what happens at scale, across a full kernel library with edge cases in broadcast and reshape logic. But as a template for how agentic AI should prove its translation work, checking against intermediate representations instead of just "it compiles and passes tests", this is worth watching. Anyone building code-migration tooling should be asking why they're not doing the same.
Common Questions Answered
How many GPU operators and kernels were translated from Python to Rust by the AI agent?
The engineering team ported 24 GPU operators, roughly 40 kernels in total, from Python to Rust without any human manual rewriting. This translation was accomplished using an AI agent specifically built to handle CUDA tile kernel conversions from the TileGym library.
What are the source and target languages for the CUDA tile kernel translation in this project?
The source languages were CUDA Tile Python (cuTile Python) and Triton-TileIR, which contained production kernels already accumulated in the TileGym library. The target language was cuTile Rust, a tile-based system for writing GPU kernels that extends Rust's ownership model to handle mutable outputs and preserve specific behaviors.
How does the Tile IR diff verification ensure the accuracy of the translated kernels?
The translation gets verified by checking if the cuTile Rust and original Python kernel compile down to the same op inventory, meaning they produce identical tile load, reduce_max, reduce_sum operations on the correct axes. This provides a verifiable, concrete claim rather than relying on subjective assessment, making it a reliable validation method for production kernels.
Why is this AI-powered translation approach significant for library maintenance teams?
For teams maintaining libraries like TileGym, this approach changes the economics of porting work by eliminating the need for manual human translation of GPU kernels. The ability to automatically translate and verify kernels against the Tile IR diff makes large-scale language migrations feasible without the traditional time and resource investment required for hand-written ports.
Further Reading
- Introducing CUDA Rust: Two Tracks for Writing GPU Kernels - NVIDIA Technical Blog
- cuTile Rust - NVIDIA NVLabs
- cuTile Python - NVIDIA Docs
- An AI agent ported our codebase from Python to Rust - AboutCode Blog
- Benchmark-Driven Evolution of a Production AI Agent from ... - arXiv