Claude Code agents beat torch.compile on CUDA kernels: 2.5x fused GELU, 1.57x matmul via fp32-splitting trick
lmoroney · x · 2026-10-10
Chien Vu tested whether fresh Claude Code agents could write CUDA kernels that beat PyTorch on an NVIDIA DGX Spark, and the most useful part is the measurement methodology:
- Setup: four common ops — softmax, layernorm, fused GELU with bias+residual, matmul with bias+ReLU — each validated against an fp64 reference.
- Results: the fused GELU ran 2.50x faster than eager PyTorch but only 1.01x vs torch.compile (which already fuses it). The surprise was matmul: the agent split each fp32 value into two fp16 halves and did three tensor-core multiplies, landing 1.57x faster than torch.compile while passing fp32 accuracy checks. Three more agents independently found the same trick.
- Pitfall: timing without a GPU sync measured softmax at 0.006 ms; the real number was 1.158 ms.
Advice: benchmark against torch.compile, time with CUDA events plus explicit synchronize, and test multiple tensor shapes before believing a speedup.
Related event: Claude Code Writes CUDA Kernels That Beat PyTorch in Tests(2 posts)→
More from coding & agent
- Anchor Browser lands in Hermes Agent: cloud browser handles logins without pasting passwords — ghumare64 · 2026-12-02
- Developer uses Neon to fix the weirdest bugs Opus left in centrifuge controllers — jonathanberte · 2026-12-02
- NVIDIA launches Nemotron 4, built for long-running coding agents that work for days — nvidia · 2026-12-02
- Solo filmmaker makes 3.5-min AI short film: 21 shots with Midjourney, Seedance 2.5 and ElevenLabs — DavidmComfort · 2026-12-02
- Claude Code + ARIA via MCP: debugging agent evals from 4/12 to 9/12 — CoreWeaveDevs · 2026-12-02
- GitHub Copilot Fusion Max reportedly tops Terminal-Bench at 71.2% while undercutting rivals — DanWahlin · 2026-12-02