NVIDIA发布CUDA Rust:cuda-oxide与cutile-rs实
NVIDIA Announces CUDA Rust with cuda-oxide (SIMT) and cutile-rs (Tile) for Compile-Time-Safe GPU Kernels
Rust在AI基础设施层的渗透已成趋势,NVIDIA官方提供原生GPU内核支持是重大工程利好。做底层推理优化的同学值得重点关注其所有权模型如何消除竞态条件。
NVIDIA has announced CUDA Rust, a push to make Rust a first-class language for writing GPU kernels. Rust code could already launch CUDA kernels, but the kernel body usually had to be written elsewhere. CUDA Rust closes that gap with two NVlabs open-source projects: cuda-oxide for the SIMT model and cutile-rs for the newer Tile model. Both compile Rust kernels natively and use Rust’s ownership rules to reject aliasing bugs at compile time.
NVIDIA 已宣布 CUDA Rust,旨在使 Rust 成为编写 GPU 内核的一等语言。Rust 代码此前即可启动 CUDA 内核,但内核主体通常需在别处编写。CUDA Rust 通过两个 NVlabs 开源项目填补了这一空白:针对 SIMT 模型的 cuda-oxide 和针对较新的 Tile 模型的 cutile-rs。两者均原生编译 Rust 内核,并利用 Rust 的所有权规则在编译时拒绝别名错误。
Is it deployable? Partially. cutile-rs is published on crates.io, runs on stable Rust 1.89+, and is already used in Hugging Face’s Grout inference engine and in mistral.rs. cuda-oxide is early alpha. The both projects are in alpha phase and not confirmed for production.
是否可部署?部分可以。cutile-rs 已发布在 crates.io 上,支持稳定版 Rust 1.89+,并已在 Hugging Face 的 Grout 推理引擎和 mistral.rs 中使用。cuda-oxide 处于早期 alpha 阶段。这两个项目均处于 alpha 阶段,尚未确认可用于生产环境。
Why Rust for the GPU Kernel
为何选择 Rust 用于 GPU 内核
The systems layer of AI, from inference engines to drivers and agent runtimes, is increasingly written in Rust. NVIDIA’s Nova Linux driver is in Rust, NVIDIA Dynamo has a Rust core, and NVTX has Rust bindings. The GPU kernel was the exception.
AI 的系统层,从推理引擎到驱动和代理运行时,正越来越多地使用 Rust 编写。NVIDIA 的 Nova Linux 驱动采用 Rust 编写,NVIDIA Dynamo 拥有 Rust 核心,NVTX 也有 Rust 绑定。GPU 内核曾是例外。
The two tracks mirror the two programming models CUDA already offers. SIMT is the model used in CUDA C++ and numba-cuda: you describe what one thread does and launch thousands of them. Tile is the newer model, also available in C++ and Python: you describe what one tile of data does, and the Tile IR compiler handles thread mapping and memory layout. NVIDIA recommends Tile first, with SIMT for explicit thread and memory control. Planned inter-language interop means choosing Rust will not lock developers out of C++ or Python.
这两条技术路线对应了 CUDA 目前已提供的两种编程模型。SIMT 是 CUDA C++ 和 numba-cuda 中使用的模型:你描述单个线程的行为,然后启动数千个线程。Tile 是较新的模型,同样提供 C++ 和 Python 版本:你描述一个数据块(tile)的行为,Tile IR 编译器负责处理线程映射和内存布局。NVIDIA 建议优先使用 Tile,仅在需要显式控制线程和内存时使用 SIMT。计划中的跨语言互操作性意味着选择 Rust 不会将开发者排除在 C++ 或 Python 之外。
The SIMT Track: cuda-oxide
SIMT 技术路线:cuda-oxide
cuda-oxide is a custom rustc codegen backend. It routes #[kernel] functions through Rust MIR, the community Pliron IR framework, and LLVM IR down to PTX, then hands everything else to the standard backend. NVIDIA wrote the GPU dialects on top of Pliron.
cuda-oxide 是一个自定义的 rustc codegen 后端。它将 #[kernel] 函数通过 Rust MIR、社区 Pliron IR 框架和 LLVM IR 路由至 PTX,然后将其他所有内容交给标准后端处理。NVIDIA 在 Pliron 之上编写了 GPU 方言。
Requirements: Linux, a GPU with compute capability 8.0 or later, CUDA 12.x or newer, clang with libclang, and a pinned nightly toolchain (nightly-2026-04-03). cargo oxide doctor checks the setup and cargo oxide new scaffolds a vector addition program, with host and device code in one file.
要求:Linux 系统、计算能力 8.0 或更高的 GPU、CUDA 12.x 或更高版本、带有 libclang 的 clang,以及固定的 nightly 工具链(nightly-2026-04-03)。cargo oxide doctor 命令检查设置情况,cargo oxide new 命令生成向量加法程序的脚手架,主机代码和设备代码位于同一个文件中。
The safety argument sits in the kernel signature. Inputs a and b are ordinary shared slices. The output c is a DisjointSlice<f32>, a type that gives each thread exclusive access to its own element. A plain &mut [f32] would need every thread to hold the same mutable borrow, which Rust refuses. c.get_mut(idx) returns an Option, so out-of-bounds access becomes a handled branch. A #[launch_contract] attribute declares the block shape, and the generated prepare_vecadd method validates the launch configuration against it before the safe launch runs.
安全论证位于内核签名中。输入 a 和 b 是普通的共享切片。输出 c 是一个 DisjointSlice<f32>,该类型赋予每个线程对其自身元素的独占访问权。普通的 &mut [f32] 需要每个线程持有相同的可变借用,而 Rust 拒绝这样做。c.get_mut(idx) 返回一个 Option,因此越界访问变成了可处理的分支。#[launch_contract] 属性声明了块形状,生成的 prepare_vecadd 方法会在安全启动运行之前,根据该形状验证启动配置。
The Tile Track: cutile-rs
Tile 赛道:cutile-rs
cutile-rs works one level higher. Each tile block runs the kernel body once as a single logical thread over one sub-tensor, and the compiler decides how many real GPU threads back it. The #[cutile::module] macro embeds the kernel’s AST in the host binary and JIT-compiles it through CUDA Tile IR when the kernel is first launched.
cutile-rs 在更高层级工作。每个 tile 块作为单个逻辑线程在一个子张量上运行一次内核主体,编译器决定由多少个真实的 GPU 线程来支持它。#[cutile::module] 宏将内核的 AST 嵌入主机二进制文件中,并在首次启动内核时通过 CUDA Tile IR 进行 JIT 编译。
Requirements are lighter: compute capability 8.0 or later, CUDA 13.3, stable Rust 1.89 or newer, and Linux, with no nightly and no custom LLVM. Setup is cargo new, then cargo add cutile.
要求更轻:计算能力 8.0 或更高版本,CUDA 13.3,稳定版 Rust 1.89 或更新版本,以及 Linux 系统,无需 nightly 版本和自定义 LLVM。设置步骤为 cargo new,然后 cargo add cutile。
The host-side .partition([128]) call does 3 jobs. It gives each tile exclusive ownership of its 128-element chunk, fixes the grid at 1,024 / 128 = 8 tiles, and supplies the const tile width B. Input tensors use -1 as a dynamic dimension resolved at launch. The generated launcher takes ownership of all tensors and returns them when the GPU finishes. Nothing executes until .sync_on(&stream); everything before it is a lazy description recorded in one chain.
主机端的 .partition([128]) 调用执行三项工作。它使每个 tile 独占拥有其 128 个元素的块,将网格固定为 1,024 / 128 = 8 个 tile,并提供常量 tile 宽度 B。输入张量使用 -1 作为动态维度,该维度在启动时解析。生成的启动器接管所有张量的所有权,并在 GPU 完成后将它们返回。在 .sync_on(&stream) 之前没有任何执行;在此之前的一切都是记录在单一链中的惰性描述。
What the Compiler Catches
编译器捕获的内容
Passing the SIMT kernel’s output buffer as one of its own inputs fails with error[E0502]: cannot borrow c_dev as mutable because it is also borrowed as immutable. The same aliasing on the Tile side fails with error[E0382]: use of moved value: z. cuda-oxide checks each launch call; cutile-rs’s ownership follows tensors across the launch boundary, which NVIDIA calls the stronger guarantee.
将 SIMT 内核的输出缓冲区作为其自身的输入之一传递会失败,并报错 error[E0502]: cannot borrow c_dev as mutable because it is also borrowed as immutable(无法将 c_dev 借为可变,因为它也被借为不可变)。Tile 侧的相同别名问题会失败,并报错 error[E0382]: use of moved value: z(使用了移动的值:z)。cuda-oxide 检查每次启动调用;cutile-rs 的所有权遵循跨越启动边界的张量,NVIDIA 称之为更强的保证。
Tile exposes no shared memory or thread indexing to misuse. SIMT keeps that control, but shared memory in cuda-oxide currently requires unsafe.
Tile 不暴露共享内存或线程索引以防误用。SIMT 保留该控制权,但 cuda-oxide 中的共享内存目前需要 unsafe。
Key Takeaways
关键要点
- CUDA Rust adds 2 native GPU kernel tracks in Rust: cuda-oxide (SIMT) and cutile-rs (Tile).
- cuda-oxide compiles Rust MIR through Pliron and LLVM to PTX; it needs a pinned nightly.
- cutile-rs runs on stable Rust 1.89+ with CUDA 13.3 and JIT-compiles via CUDA Tile IR.
- Both reject buffer aliasing at compile time using Rust’s borrow checker and ownership.
- cutile-rs already powers Grout and mistral.rs; neither project is production-ready yet.
- CUDA Rust 在 Rust 中添加了 2 种原生 GPU 内核赛道:cuda-oxide (SIMT) 和 cutile-rs (Tile)。
- cuda-oxide 通过 Pliron 和 LLVM 将 Rust MIR 编译为 PTX;它需要一个固定的 nightly 版本。
- cutile-rs 在稳定版 Rust 1.89+ 上运行,配合 CUDA 13.3,并通过 CUDA Tile IR 进行 JIT 编译。
- 两者都利用 Rust 的借用检查器和所有权机制在编译时拒绝缓冲区别名。
- cutile-rs 已为 Grout 和 mistral.rs 提供支持;这两个项目目前尚未达到生产就绪状态。
Check out the Technical details here. Also, feel free to follow us on Twitter and don’t forget to join our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.
在此查看技术细节。此外,欢迎在 Twitter 上关注我们,别忘了加入我们拥有超过 15 万成员的 ML SubReddit 并订阅我们的新闻通讯。等等!你也在 Telegram 上吗?现在你也可以加入我们的 Telegram 群组。
Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us
需要与我们合作推广您的 GitHub 仓库、Hugging Face 页面、产品发布或网络研讨会等?请与我们联系
The post NVIDIA Announces CUDA Rust with cuda-oxide (SIMT) and cutile-rs (Tile) for Compile-Time-Safe GPU Kernels appeared first on MarkTechPost.
本文最初发表于 MarkTechPost,标题为《NVIDIA 宣布推出用于编译时安全 GPU 内核的 CUDA Rust:cuda-oxide(SIMT)与 cutile-rs(Tile)》
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力