Claude Code ported nanochat's inference to C++, roughly 1/3 as fast
Could AI write serious, low-level C++ from scratch? Leaning heavily on Claude Code, the writer rebuilt nanochat's inference on ggml as a drop-in replacement. On an M3 Max it runs at roughly 1/3 of PyTorch's throughput.
Done withClaude CodeSpotted· by HN user makechan· Oct 29, 2026
Result Suspected bottleneck: no bf16 support yet
“I relied heavily on Claude Code (CC) for the implementation. Overall, I am both impressed and genuinely pleased with the experience.”
Spotted: found in the wild. Details are as reported by the source above and have not been independently verified.
What they did
The writer, who used to work in C++ day to day at tech companies, wanted to see if AI could handle a lower-level C++ implementation of a complex system from scratch. They re-implemented the inference part of Andrej Karpathy’s nanochat in C++ on top of ggml, as a library and Python wrapper that swaps out nanochat’s GPT and KVCache classes. They relied heavily on Claude Code for the implementation.
How it went
It works as a drop-in replacement, so far tested only with chat_web.py, on CPU and Metal. On an M3 Max its throughput is roughly 1/3 that of the original PyTorch version, which the writer suspects comes from the lack of bf16 support. They’re impressed and genuinely pleased with the experience.
Try it yourself with Claude Code
I want a C++ re-implementation of the inference part of [project], built on [ggml], as a library with a Python wrapper that can replace [these classes] in the existing pipeline. Keep dependencies to a minimum and add unit tests. Benchmark it against the original on my machine and show me the results before I swap it into anything.
A starting prompt written by Agents in the Wild. Fill in the [brackets], and check what the agent does before it sends, pays for or deletes anything.
An image-processing problem, some sample data, and no one at the keyboard. Claude Code iterated, looking at the output image, until it fixed it. It spent at least an hour, untouched.
A 35,000-line PyQt desktop app for electrical engineering design had taken maybe 2500 hours over some years. Running OpenClaw on top of Claude Code, a two-sentence prompt converted it to a web app overnight.
Trying vibe coding for the first time, they had Claude Code, through Zed's agent integration, scaffold an isometric graphics editor with a few features. It worked, and about 45 minutes later they had a basic MVP.
Translating hundreds of phonetics papers into a working, citation-backed speech synthesizer would have taken years solo, they estimate. With Claude Code it's taken months, and they still catch its domain mistakes.
Their own Next.js orchestrator launches headless Claude Code and Codex sessions, reacts to GitLab and Linear, fixes CI failures, rebases and reviews. Built in 1-2 weeks of prompting, it leaves them refining tickets.