jouleclaw: North decode 3-6x and prefill 6-11x on the CPU, bit-identical #649
Loading…
Reference in a new issue
No description provided.
Delete branch "jouleclaw/north-decode-speed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
North Mini Code 1.0 (Cohere2-MoE, 30B / 3B active, BF16) is the model WAI Quantum's program-writing loop runs on. Its pure-Rust CPU path (
--features rayon) now decodes 3–6× and prefills 6–11× faster, with bit-identical logits.Profile (base,
JOULECLAW_PROF=1, M3 Ultra under load, ~600-token prompt)Changes (each output keeps its exact reduction order)
BF16 kernel: register blocks of up to 4 activation rows × 4 weight rows (16 chains instead of 2), a 1 KiB prefetch, 64 KiB L1 tiles. Threaded GEMVs are split into ~256 KiB chunks; prefill GEMMs into 64 × 64 tiles. The old loop stays as
matmul_bf16_neon_one_rowand is tested against the new one bit for bit.attention_row_f32:attention_forward_f32's exact arithmetic, with 16 keys' scores in NEON lanes (4×4 transposes) and V running sums held in registers.North CPU passes:
spin_pool, whose threads stay awake between dispatches;forward_extend, which batches a follow-up turn into an existing context;JOULECLAW_THREADSoverrides).The old passes stay as
forward_*_reference, which is the fabric path.Token identity
main. That holds on the M3 Ultra and on an M4 Max, and the two machines agree with each other. Every timing repeat produced the same hash sequence.forward_extend: equal to feeding the same 69 tokens one at a time.attention_forward_f32(zero-weight underflow included);Before / after
Medians, base and new interleaved in the same conditions; four runs each (three for base at 12 threads). The M3 Ultra was shared with another North benchmark and CI (load average 30–130); the M4 Max was lightly loaded.
Paired run-for-run ratios and all runs are in
BENCHMARKS.md. The run-to-run spread on the shared host is large; the interleaved pairs are the fair reading.Checks
The crate's tests are green on macOS arm64, natively on the M3 Ultra: 311 with rayon, 304 with no features, and the targeted set under rayon,fabric.
cargo checkis clean for aarch64- and x86_64-unknown-linux-gnu, with and without rayon. The public-names check is clean.🤖 Generated with Claude Code
811ae206f)