Skip to content

About

End-to-end inference system evolving

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Self-Evolving Inference System

$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.

How it works

The scaffold has four components:

  1. Fresh sessions — each trial is a new Claude Code session with no conversation history carried over. The agent starts clean every time.
  2. Frozen benchmark — mini-sglang/benchmark/offline/bench_simple.py is the single source of truth. The agent cannot modify it. This prevents the agent from gaming the metric.
  3. 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.
  4. 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.

Results

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.

Reproducing

# 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.sh

Requirements:

  • NVIDIA GPU with CUDA support
  • Python 3.12+
  • uv (for venv/package management)
  • Claude Code CLI installed and authenticated

Blog posts

Acknowledgments

This project was inspired by Andrej Karpathy's autoresearch, which demonstrated the potential of letting AI agents autonomously drive research and optimization loops.

License

MIT

About

End-to-end inference system evolving

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages