- Python 89.6%
- Shell 10.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| neon | ||
| opus | ||
| scripts | ||
| .gitignore | ||
| FORMAT_SPEC.md | ||
| golden_refs.json | ||
| README.md | ||
Qwen3-0.6B in raw x86-64 machine code: Gemini 4 Neon vs Claude Opus 5.5
Two frontier models got the same task in isolated sandboxes:
Write a complete Linux x86-64 inference engine for Qwen3-0.6B (Q8_0) in raw machine code. The only source file is
engine.hex. No compiler, no assembler, no linker, no libc. Match the reference greedy output token for token and beat CPUllama.cpp.
The binary is built with one line:
sed 's/#.*$//' engine.hex | tr -d ' \t\r\n' | xxd -r -p > build/engine # scripts/build_hex.sh
Every ELF64 header byte, VEX prefix, ModR/M byte and jump offset was typed into engine.hex by the model. Comments in the hex files show the mnemonic for each instruction.
Results (AMD EPYC 7642, 48 cores, AVX2/FMA/F16C, no AVX-512)
Decode speed, tok/s, 34-token prompt / 64 generated tokens, mean of 3 runs. llama.cpp = Qwen3-0.6B-Q8_0.gguf, llama-bench -ngl 0.
| Threads | llama.cpp | Claude Opus 5.5 | Gemini 4 Neon |
|---|---|---|---|
| 1 | 16.63 | 21.44 (+28.9%) | 22.27 (+33.9%) |
| 4 | 51.08 | 61.99 (+21.4%) | 78.49 (+53.7%) |
| 8 | 80.79 | 100.17 (+24.0%) | 124.11 (+53.6%) |
| 16 | 103.03 | 123.50 (+19.9%) | 171.05 (+66.0%) |
| 24 | 104.11 | 123.11 (+18.3%) | 167.85 (+61.2%) |
| 32 | 103.82 | 125.13 (+20.5%) | 188.35 (+81.4%) |
| 40 | 105.08 | 116.05 (+10.4%) | 181.04 (+72.3%) |
| Claude Opus 5.5 (xhigh, Claude Code) | Gemini 4 Neon (xhigh, Antigravity) | |
|---|---|---|
| Static ELF size | 7,331 bytes | 10,752 bytes |
| Accuracy | 16/16 exact (4 prompts x 1/4/8/16 threads) | 16/16 exact |
| Time to finish | ~65 min | 1 h 43 min |
| Turns | 175 | 90 |
| API cost (list price) | $21.40 | $16.72 |
Both engines reproduce the reference greedy tokens exactly on all 4 prompts and are bit-exact across thread counts.
What each model did
Claude Opus 5.5 (opus/REPORT.md): f32 activations against Q8_0 weights, 4-row matvec kernel, software prefetch, weights copied into a transparent-hugepage buffer with pread64, spin-barrier thread pool pinned per CCX. Smallest binary, first to finish.
Gemini 4 Neon (neon/REPORT.md): int8 activations missed one token whose top-2 logit gap is 0.0005, so it switched to per-32-block Q15 (int16) activations with vpmovsxbw + vpmaddwd. It keeps 15 weight layers (239 MiB) resident in the 256 MiB L3 using prefetcht0 for those layers and prefetchnta for the rest, uses 2 MiB hugepages, and balances threads across CCXs around an offline core.
Layout
FORMAT_SPEC.md byte-level .asmbin v2 format + Qwen3-0.6B forward pass
golden_refs.json 4 reference prompts with exact greedy token ids
scripts/build_hex.sh hex -> ELF (sed + xxd only)
scripts/verify_battle.py accuracy check + speed benchmark
opus/engine.hex Claude Opus 5.5 engine source
neon/engine.hex Gemini 4 Neon engine source
Reproduce
- Export the weights with
scripts/export_weights.pyfrom alesha-pro/llm.asm (--scale-dtype fp16, givesqwen3-0.6b-q8_0-fp16s.asmbin). - Build and verify on Linux x86-64 with AVX2/FMA/F16C:
./scripts/build_hex.sh neon/engine.hex build/engine
python3 scripts/verify_battle.py --hex neon/engine.hex --out build/engine --model qwen3-0.6b-q8_0-fp16s.asmbin --bench
./build/engine -m qwen3-0.6b-q8_0-fp16s.asmbin -p "Explain L1, L2, and L3 CPU caches." -n 64 -t 32
The thread pinning in both engines is tuned for the EPYC 7642 topology. On other CPUs the engines still run and match, but speed numbers will differ.