AI News AI资讯 4d ago Updated 4d ago 更新于 4天前 52

ByteDance Seed and Tsinghua AIR Introduces CUDA Agent: A Large-Scale Agentic RL System for CUDA Kernel Generation 字节跳动 Seed 与清华 AIR 推出 CUDA Agent:用于 CUDA 内核生成的大规模智能体强化学习系统

CUDA Agent uses agentic reinforcement learning to train LLMs to write CUDA kernels that outperform torch.compile by 2.11× geometric mean speedup, closing the gap between correctness and performance in AI-generated GPU code The system achieves 98.8% pass rate and 96.8% faster-than-compile rate on KernelBench's 250-task benchmark, dramatically outperforming frontier models like Claude Opus 4.5 and Gemini 3 Pro on Level-3 tasks Training employs PPO for 150 steps with a 131,072-token context on Seed CUDA Agent通过agentic RL训练LLM编写比编译器更快的CUDA内核,在KernelBench上达到98.8%通过率、96.8%超越torch.compile、2.11×几何平均加速 基础模型Seed1.6(23B活跃参数MoE)原始仅27.2%比compile快,经150步PPO训练(131K token上下文)后性能飞跃 系统构建真实CUDA开发环境(profiling、正确性检查、权限锁定沙箱),采用离散奖励{-1,1,2,3}和五种反reward-hacking机制 开源CUDA-Agent-Ops-6K数据集(6000样本)、SKILL.md规范和奖励设计,但模型权重

72
Hot 热度
78
Quality 质量
75
Impact 影响力

Analysis 深度分析

TL;DR

  • CUDA Agent uses agentic reinforcement learning to train LLMs to write CUDA kernels that outperform torch.compile by 2.11× geometric mean speedup, closing the gap between correctness and performance in AI-generated GPU code
  • The system achieves 98.8% pass rate and 96.8% faster-than-compile rate on KernelBench's 250-task benchmark, dramatically outperforming frontier models like Claude Opus 4.5 and Gemini 3 Pro on Level-3 tasks
  • Training employs PPO for 150 steps with a 131,072-token context on Seed1.6 (23B active / 230B total parameters MoE), using a discrete reward system with anti-hacking safeguards
  • The CUDA-Agent-Ops-6K dataset (6,000 samples) is publicly released along with SKILL.md specifications and reward recipes, though the trained agent weights remain proprietary
  • Ablation studies reveal the agent loop is critical: removing it drops faster-than-compile rate from 96.8% to 14.1%, while warm-up stages prevent training collapse

Why It Matters

This work demonstrates that agentic RL can systematically close the performance gap in AI-generated GPU code, transforming LLMs from correct-but-slow kernel writers into competitive alternatives to hand-tuned compiler optimizations. For AI infrastructure teams, this represents a potential pathway to reduce inference costs through automated kernel fusion and optimization without requiring deep CUDA expertise. The methodology also provides a template for applying RL agents to other low-level systems programming domains where correctness and performance must be jointly optimized.

Technical Details

  • Architecture: Built on Seed1.6, a proprietary Mixture-of-Experts model with 23B active and 230B total parameters, trained with PPO for 150 steps at 131,072-token context length
  • Environment: ReAct-pattern agent loop with OpenHands-style tools (Bash, Read/Write, Edit/MultiEdit, Glob, Grep, NotebookEdit) operating within a permission-locked sandbox with separate CPU compilation and GPU profiling pools (128 NVIDIA H20 GPUs)
  • Reward Design: Discrete reward system (r ∈ {-1, 1, 2, 3}) where -1 indicates correctness failure, 3 rewards kernels faster than both eager and torch.compile by >5%, 2 for eager-only improvement, and 1 otherwise; includes five anti-reward-hacking countermeasures
  • Dataset: CUDA-Agent-Ops-6K contains 6,000 samples synthesized by composing up to 5 torch operator classes, filtered for determinism, non-trivial execution (1-100ms), and AST dissimilarity to existing KernelBench tasks (83.77% are two-operator compositions)
  • Performance: Level-2 operator sequences achieve 100% pass and 2.80× speedup over compile; Level-3 complex tasks reach 94.0% pass rate and 1.52× speedup, approximately 40 percentage points ahead of Claude Opus 4.5 and Gemini 3 Pro

Industry Insight

  • Organizations with GPU cloud infrastructure or large-scale inference deployments should evaluate adopting the released dataset and reward methodology to optimize their operator fusion pipelines, particularly for latency-critical workloads in autonomous driving, quantitative trading, and recommendation systems
  • The 128-H20 profiling requirement for full replication positions this primarily for frontier labs and well-funded teams, but mid-size organizations can still leverage the open dataset, SKILL.md spec, and milestone reward design on top of open base models
  • As fused operator sequences become increasingly important for inference cost reduction, this agentic RL approach may establish a new paradigm for automated systems optimization that complements rather than replaces traditional compiler toolchains

TL;DR

  • CUDA Agent通过agentic RL训练LLM编写比编译器更快的CUDA内核,在KernelBench上达到98.8%通过率、96.8%超越torch.compile、2.11×几何平均加速
  • 基础模型Seed1.6(23B活跃参数MoE)原始仅27.2%比compile快,经150步PPO训练(131K token上下文)后性能飞跃
  • 系统构建真实CUDA开发环境(profiling、正确性检查、权限锁定沙箱),采用离散奖励{-1,1,2,3}和五种反reward-hacking机制
  • 开源CUDA-Agent-Ops-6K数据集(6000样本)、SKILL.md规范和奖励设计,但模型权重未发布,完整复现需128个H20 GPU

为什么值得看

本文首次证明通过agentic RL可让LLM在GPU内核手写任务上系统性超越编译器优化,填补了"正确CUDA"与"高性能CUDA"之间的关键空白。对AI基础设施、推理服务和高性能计算领域具有直接参考价值,展示了RL训练代码生成模型的新范式。

技术解析

  • 数据合成:从torch和transformers库挖掘参考算子,LLM采样最多5个算子类组合成融合层,经严格过滤(eager/compile双模式运行、确定性、非平凡输出、1-100ms执行时间、AST相似度<0.9)得到6000样本,83.77%为双算子组合
  • Agent循环架构:遵循OpenHands工具集(Bash、Read/Write、Edit、Glob、Grep等)和ReAct模式,SKILL.md定义标准CUDA工作流(profile→写kernel→compile→迭代),CPU沙箱编译,128 H20 GPU池验证和profiling
  • 离散奖励设计:r∈{-1,1,2,3},-1表示正确性失败,3表示同时超越eager和compile(>5%),2表示仅超越eager,1为其他;避免原始加速比奖励导致的easy kernel偏好和outlier爆炸
  • 反reward-hacking五重保障:权限锁定验证/profiling脚本、context manager禁止torch.nn.functional回退、5个随机输入正确性检查、设备同步+warm-up profiling、禁用web search工具
  • 训练稳定性:CUDA代码仅占预训练数据<0.01%,PPO importance ratio易波动爆炸;通过actor RFT和critic value pretraining双warm-up,训练150步保持稳定reward增长,无warm-up则17步后collapse

行业启示

  • AI编程范式升级:LLM代码生成正从"功能正确"迈向"性能最优",agentic RL结合真实开发环境是突破编译器优化瓶颈的有效路径,值得在代码生成、性能调优场景推广
  • 基础设施门槛与开源策略:完整复现需128 H20 GPU,主要利好头部实验室和云厂商;但数据集、奖励设计、防作弊约束等开源组件可被中小团队基于开源基座模型复用,降低 adoption 门槛
  • 高价值应用场景:AI推理服务(融合torch.compile处理不佳的算子序列、降低token成本)、自动驾驶、量化交易、医疗影像等延迟敏感领域可直接受益;跨GPU代际kernel重调也是持续优化方向

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

LLM 大模型 Code Generation 代码生成 GPU GPU Benchmark 基准测试 Research 科学研究