Claude Code 写 CUDA 算子实测:融合 GELU 快 2.5 倍,还自创 fp32 拆分技巧
lmoroney · x · 2026-10-10
Chien Vu 在 NVIDIA DGX Spark 上测试了全新的 Claude Code agent 能否写出胜过 PyTorch 的 CUDA kernel,最有价值的部分是测量方法论:
- 任务设置:softmax、layernorm、带 bias+残差的融合 GELU、带 bias+ReLU 的 matmul 四个常见算子,全部对照 fp64 参考实现做严格正确性校验。
- 结果:融合 GELU 比 eager PyTorch 快 2.50 倍,但仅比 torch.compile 快 1.01 倍(后者本来就会做该融合)。真正的惊喜是 matmul:agent 把每个 fp32 值拆成两个 fp16 半份、做三次 tensor core 乘法,比 torch.compile 快 1.57 倍且仍通过 fp32 精度校验;另三个从零开始的 agent 独立发现了同样技巧。
- 测量陷阱:不做 GPU 同步的计时会把 softmax 测成 0.006 ms,真实值是 1.158 ms。
作者给出基准测试建议:对照 torch.compile、用 CUDA events 加显式 synchronize 计时、在相信任何加速结论前多测几种张量形状。
所属事件:实测 Claude Code 自动编写 CUDA 算子,部分超越 PyTorch(2 条相关)→
「编程与Agent」频道最新
- 开源终端 agent 工具 ansi:会话即 agent,全程可审计可分叉 — remilouf · 2026-12-02
- NVIDIA 扩展 OpenShell 管理 Agent 权限,Anthropic 等四家已采用 — NVIDIAAI · 2026-12-02
- Weaviate 播客:价格库存等元数据不必进 reranker,交给 XGBoost 更省事 — CShorten30 · 2026-12-02
- 把 LLM 当操作系统用户:在 Plan 9 上用「一切皆文件」造 agent harness — remilouf · 2026-12-02
- Hermes Agent 接入 Anchor Browser:智能体云浏览器免贴密码登录 — ghumare64 · 2026-12-02
- 用 Neon 修复 Opus 写进离心机控制器的诡异 bug — jonathanberte · 2026-12-02