AI Practices AI实践 3h ago Updated 1h ago 更新于 1小时前 46

Introducing CUDA Rust: Two Tracks for Writing GPU Kernels 介绍 CUDA Rust:编写 GPU 内核的两种路径

NVIDIA announced two Rust-based GPU kernel programming tracks: cuda-oxide (SIMT-style) and cutile-rs (Tile-based), closing the gap that previously forced kernel authors to use CUDA C++ or Python cuda-oxide provides a custom rustc codegen backend compiling Rust directly to PTX via the Pliron IR framework and LLVM, requiring a pinned nightly toolchain and custom LLVM cutile-rs enables Tile-based GPU programming on stable Rust 1.89+ with CUDA 13.3 and no custom LLVM, and is already deployed in prod NVIDIA推出CUDA Rust双轨方案:cuda-oxide(SIMT风格)和cutile-rs(Tile风格),允许用Rust原生编写GPU内核并编译为PTX 两个项目均在编译时强制内存安全:cuda-oxide使用DisjointSlice和launch contracts防止别名,cutile-rs通过张量分区和所有权保证独占访问 cutile-rs已发布至crates.io并在HuggingFace Grout推理引擎和mistral.rs中实际应用,cuda-oxide仍处于早期alpha阶段 cutile-rs支持稳定版Rust 1.89+和CUDA 13.3,无需自定义LLV

65
Hot 热度
70
Quality 质量
65
Impact 影响力

Analysis 深度分析

TL;DR

  • NVIDIA announced two Rust-based GPU kernel programming tracks: cuda-oxide (SIMT-style) and cutile-rs (Tile-based), closing the gap that previously forced kernel authors to use CUDA C++ or Python
  • cuda-oxide provides a custom rustc codegen backend compiling Rust directly to PTX via the Pliron IR framework and LLVM, requiring a pinned nightly toolchain and custom LLVM
  • cutile-rs enables Tile-based GPU programming on stable Rust 1.89+ with CUDA 13.3 and no custom LLVM, and is already deployed in production by HuggingFace's Grout inference engine and mistral.rs
  • Both projects enforce compile-time memory safety: cuda-oxide uses DisjointSlice and launch contracts to prevent aliasing, while cutile-rs uses tensor partitioning and ownership guarantees
  • NVIDIA committed to growing CUDA Rust through 2027 and beyond, with planned inter-language interoperability between CUDA Rust, CUDA C++, and CUDA Python

Why It Matters

Rust is rapidly becoming the language of choice for AI systems infrastructure—drivers, inference engines, and serving layers—but GPU kernels have remained a C++/Python stronghold. CUDA Rust eliminates this last barrier, allowing developers to write performant, memory-safe kernels natively in Rust without relying on wrappers or foreign language bindings. This is a strategic move by NVIDIA to align GPU programming with the broader industry shift toward Rust in systems-level AI work.

Technical Details

  • cuda-oxide is a custom rustc codegen backend that intercepts compilation, routes #[kernel] functions through Rust MIR, the Pliron IR framework, and LLVM IR down to PTX, while passing non-kernel code to the standard backend; it requires Linux, a GPU with compute capability 8.0+, CUDA toolkit 12.x+, clang with libclang headers, and a pinned nightly toolchain (cargo +nightly-2026-04-03)
  • cutile-rs uses CUDA Tile IR JIT compilation to manage thread mapping and memory layout automatically, running on stable Rust 1.89+ with CUDA 13.3 and no custom LLVM; it is published on crates.io and already integrated into HuggingFace's Grout and mistral.rs
  • Both tracks mirror CUDA's own dual programming model: SIMT (per-thread programming, drop-down for low-level control) and Tile (compiler-managed tile-level abstraction, recommended as the default starting point for new code)
  • Memory safety is enforced at compile time in both projects: cuda-oxide uses DisjointSlice and launch_contract attributes to prevent pointer aliasing, while cutile-rs leverages tensor partitioning and Rust ownership semantics to guarantee exclusive access
  • NVIDIA plans inter-language interoperability so code written in one CUDA Rust frontend can interoperate with CUDA C++ and CUDA Python ecosystems

Industry Insight

  • The emergence of mature, memory-safe GPU kernel programming in Rust will likely accelerate adoption of Rust across the entire AI stack—from inference engines to serving infrastructure—reducing whole classes of memory bugs without sacrificing performance
  • Developers should adopt the Tile-based approach (cutile-rs) as their default for new GPU code, reserving SIMT (cuda-oxide) for cases requiring fine-grained control over thread and memory layout, as the compiler-managed abstractions provide better portability across architectures
  • NVIDIA's commitment to cross-language interoperability signals that CUDA Rust will not fragment the ecosystem; teams can invest in Rust kernel development without risking lockout from existing CUDA C++ or Python codebases, making this a low-risk strategic bet for organizations building on NVIDIA hardware

TL;DR

  • NVIDIA推出CUDA Rust双轨方案:cuda-oxide(SIMT风格)和cutile-rs(Tile风格),允许用Rust原生编写GPU内核并编译为PTX
  • 两个项目均在编译时强制内存安全:cuda-oxide使用DisjointSlice和launch contracts防止别名,cutile-rs通过张量分区和所有权保证独占访问
  • cutile-rs已发布至crates.io并在HuggingFace Grout推理引擎和mistral.rs中实际应用,cuda-oxide仍处于早期alpha阶段
  • cutile-rs支持稳定版Rust 1.89+和CUDA 13.3,无需自定义LLVM;cuda-oxide需锁定nightly工具链和自定义LLVM
  • NVIDIA计划支持CUDA Rust与CUDA C++、CUDA Python的跨语言互操作,确保开发者不会被前端语言锁定

为什么值得看

CUDA Rust填补了Rust生态在GPU内核编程层面的空白,使AI系统栈(推理引擎、服务基础设施、驱动)能够用同一语言全栈开发,同时获得编译时内存安全保证。这标志着NVIDIA正式将Rust纳入核心GPU编程战略,对AI基础设施开发者具有重要参考价值。

技术解析

  • cuda-oxide架构:作为自定义rustc代码生成后端,拦截编译流程,将#[kernel]函数通过Rust MIR → Pliron IR框架 → LLVM IR → PTX的转换链,GPU方言和变换全程在Rust中完成,最终由标准LLVM后端接管
  • cutile-rs架构:基于Tile IR JIT编译,编译器自动管理线程映射和内存布局,开发者只需描述单个tile的数据操作,无需编码架构特定选择,支持稳定版Rust工具链
  • 内存安全机制:cuda-oxide通过DisjointSlice类型和launch contracts在编译期防止内存别名;cutile-rs利用张量分区和所有权系统保证独占访问,两者均能在编译阶段捕获传统CUDA运行时才会暴露的错误
  • 开发环境要求:cuda-oxide需要Linux、Compute Capability 8.0+ GPU、CUDA 12.x+工具包、clang及libclang头文件、锁定nightly工具链(cargo +nightly-2026-04-03);cutile-rs仅需稳定Rust 1.89+和CUDA 13.3
  • 实际部署状态:cutile-rs已集成到HuggingFace Grout推理引擎和mistral.rs项目中,提供生产级验证;cuda-oxide仍处于alpha阶段,需通过cargo oxide doctor检查环境依赖

行业启示

  • Rust在AI系统层的渗透加速:从Nova Linux驱动、NVIDIA Dynamo到GPU内核编程,Rust正从基础设施层向上渗透至计算核心层,AI公司应评估在推理引擎和训练框架中采用Rust的可行性
  • 编程模型抽象化趋势:Tile编程模型通过编译器自动处理线程映射和内存布局,降低GPU编程门槛,未来可能成为主流抽象层,开发者应优先掌握Tile范式而非直接编写SIMT代码
  • 跨语言互操作成为战略重点:NVIDIA明确承诺CUDA Rust与C++/Python的互操作性,表明GPU编程生态正从语言锁定转向模块化选择,企业应关注现有CUDA代码库的Rust迁移路径和混合部署方案

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

GPU GPU Programming 编程 Open Source 开源 Chip 芯片