Profile and tune a CUDA kernel with an agent
They used a LangGraph agent to test CUDA kernel tweaks, verify results, and profile candidates with Nsight.
- What they did
- They started with a workload description or their own kernel, reference, and test cases. The agent suggested changes to the kernel and launch settings, while a C++ harness compiled each version with NVRTC and ran it through the CUDA Driver API. Python then compared results with NumPy and timed each candidate; if a version failed, the agent tried to repair it within the allowed iteration budget. Optional steps added Nsight Compute profiling and checks against NVIDIA documentation.
- How it went
- The README showed float32 GEMM running on an RTX 3060 Laptop GPU, and a second run picked up from the best kernel found earlier. It did not report speedup figures or compare the result with cuBLAS.
- Tips
- Be careful with generated scripts: they run on your machine without sandboxing, and API calls are billed to you. Treat any generated reference output as a helpful check, not as a full proof of correctness.
Try it yourself with Claude Code
I want to improve a CUDA kernel in [file path] for [operation]. Use a test harness to compile candidate versions with NVRTC, run them through the CUDA Driver API, compare outputs against [reference check, e.g. NumPy], and benchmark each one. Propose one change at a time, run Nsight Compute profiling when useful, and keep only versions that pass correctness. If a candidate fails, try to fix it within the current iteration limit. Pause and ask for my approval before any step that would send code, submit jobs, delete files, or make other irreversible changes. Finish by summarizing the best kernel, launch settings, and measured timings.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Trace C# symbol usage with a Roslyn-backed index
Graphify C# helps agents map real C# usages, including overrides and implementations, from compiler-resolved project data.
Turn a docs site into Markdown files with an agent
They used a custom crawler so Claude could save a 60-page docs site as Markdown without crowding the chat.
Revive old apps and sketch new ones with a coding agent
Terence Tao used a coding agent to port old Java applets to JavaScript and to build two new math visualizations in conversation.
Use agents to benchmark and tune Rust performance
Have an agent measure Rust code, make one optimization at a time, and keep only changes that improve runtime.
Break one goal into a sequenced coding plan
Ordewell turns a single objective into a step-by-step task list for coding agents, with dependencies, review, and parallel runs.
Let your agent patch its own repo
A developer reported that their custom agent made its first code edit in its own repository.