$100 of Claude doubles the throughput of Qwen3-0.6B on an RTX PRO 6000 Blackwell — no human intervention required.
A minimal scaffold that lets Claude Code iteratively optimize an LLM inference engine across sequential trials. Over 10 trials, Claude evolved mini-sglang from 512 → 1,016 tok/s (+98%) — writing fused Triton/CUDA kernels, adding INT8 quantization, restructuring CUDA graphs, and tuning the scheduler — all autonomously.
The scaffold has four components:
- Fresh sessions — each trial is a new Claude Code session with no conversation history carried over. The agent starts clean every time.
- Frozen benchmark —
mini-sglang/benchmark/offline/bench_simple.pyis the single source of truth. The agent cannot modify it. This prevents the agent from gaming the metric. - Scalar signal — the only optimization target is throughput (tokens/second). Correctness is enforced by requiring output tokens to match the baseline. You are free to change the sampling configurations depending on your use case.
- Shared
learning.md— the agent's memory between sessions. Each trial reads prior learnings, runs experiments, and appends what it discovered. Over time this file accumulates a growing "do NOT try" list alongside proven techniques.
| Phase | Trials | Throughput | Gain | Key techniques |
|---|---|---|---|---|
| Baseline | — | 512 tok/s | — | Vanilla mini-sglang |
| Kernel fusion | 1–3 | 676 tok/s | +32% | Fused RMSNorm+GEMV, fused QKNorm+RoPE+KV, split-K attention |
| Quantization | 4–6 | 860 tok/s | +27% | INT8 weight quantization, fused dequant |
| System-level | 7–10 | 1,016 tok/s | +18% | Multi-step CUDA graphs, in-graph argmax, decode metadata pre-allocation |
See the evolved code on the trial-10 branch.
# Clone (with submodule)
git clone --recurse-submodules https://github.com/smth-fun/self-evolving-inference-system.git
cd self-evolving-inference-system
# Set up the environment
bash setup.sh
# (Optional) Edit run_trial.sh to configure GPU, number of trials, budget per trial
# Run the evolution
bash run_trial.shRequirements:
- NVIDIA GPU with CUDA support
- Python 3.12+
- uv (for venv/package management)
- Claude Code CLI installed and authenticated
- Self-Evolving Inference: When AI Agents Write GPU Kernels — technical analysis of the 3,700 lines of Triton/CUDA code Claude wrote, including 8 clever optimizations and 3 significant bugs
- Optimizing Mini-Sglang Inference as an Evolution Problem — analysis of the optimization process itself: emergent behaviors, failure memory, and why scaffold design matters more than orchestration
This project was inspired by Andrej Karpathy's autoresearch, which demonstrated the potential of letting AI agents autonomously drive research and optimization loops.
MIT