Files
leleka/docs/upstream-colibri.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 c1444d98ac perf: run the CPU kernels from Rust std::arch instead of C (STRA-214)
The MXFP4, Q8_0, int8 and int4 kernels, the Q8_0 quantizer and the half conversions are now Rust
(cpu-sys/src/simd.rs), written operation for operation after the C versions. The C code stays only behind
the test-only feature c-reference, and tests/rust_vs_c.rs checks bit-identical results at the portable,
AVX2 and AVX-VNNI levels. A runtime build compiles no C.

Paired decode on gpt-oss-20b (40 tokens, 10 threads, 5 alternating rounds): median 98 ms per token for
both builds, identical tokens and first-step log-probabilities.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 18:32:31 +02:00

9.7 KiB

Colibri upstream provenance and port ledger (STRA-200)

Status: reference snapshot taken; no Colibri code is in this repository, in any build, or in any shipped artifact.

Colibri is an upstream source, not a dependency (owner decision, 2026-10-14). Leleka ports selected units into Leleka-owned sources and records each one below. Strata has its own record in upstream.md, which this file does not change. The architecture decision is design authority 280d0c42 on STRA-199 (amends STRA-105's b8462fc8).

Pin

Field Value
Upstream repository https://github.com/JustVugg/colibri
Commit bf2442915d6e3dd4cdfd2eb9c2a3d2aa44a25850 (merge of PR #1966, committed 2026-10-06 22:02 +02:00)
Branch at capture main, shallow clone (depth 1) on 2026-10-14
Licence Apache-2.0, copyright 2026 Vincenzo Fornaro
Files in the commit 1191
Size 33 MB working tree, 12 MB .git
git archive HEAD SHA-256 5ad2cac5052e27a1c5f29203d56983737bab06a9f4bc52f84fac28c4935bcf59
LICENSE SHA-256 fb9b97e1cc193452870025f6cf501003130561681659e265e5fdf6c023f71325
NOTICE SHA-256 c8a3ae98b85c30294ac8adeea94360dc25264dea0786a3d1ab0b48a4bc31b001
THIRD_PARTY_NOTICES.md SHA-256 283fa1a9c27a8930340add500f2f0453dd15568ec38c21a1fff4f3d1f716ebc7
Snapshot location outside Git, in a local folder next to the work area (work/upstream/colibri); never committed

To update, fetch, pick a specific commit, diff it against this pin, and record a new pin here. Do not follow main.

Rules for porting

  1. A unit is ported only after its ledger row says adopt or adapt and names the oracle it will be compared against.
  2. Every ported file keeps the upstream copyright and licence notice, adds a line naming the upstream path and commit, and lists local changes. NOTICE obligations of Apache-2.0 section 4 are met in the distribution notices.
  3. Non-lossy ports must match the upstream result bit for bit, or within a tolerance recorded in the ledger before the port starts. Lossy ones are experimental and need their own quality gate (charter Gate C).
  4. Nothing from this snapshot is built or linked as-is. No model weights, request captures, or generated files are committed.

Ledger

Counts come from keyword searches of the snapshot and are leads, not coverage claims. not read means the file was listed and sized only. Decisions are proposals until a port starts.

Upstream path (lines) What it is (evidence) Decision Oracle / notes
c/idot.h (1028) Integer dot kernels shared by every engine. Header says: AVX2 maddubs, vpdpbusd on AVX-VNNI and AVX-512 VNNI, NEON sdot/smmla, an AMX tile kernel; exact int32 sums, so each ISA path is stated to be bit-identical to the scalar reference. Keyword hits: avx2 136, avx512 46, vnni 77, neon 54. adapt Port the scalar reference, the AVX2 path and the AVX-VNNI path first; compare each against the scalar path in the same file. AVX-512 and AMX stay unported until a host to test them exists. Whether this laptop has AVX-VNNI is UNVERIFIED.
c/idot.h ported units dot_i8i8 and dot_i4i8: scalar, AVX2 and AVX-VNNI branches, split into one translation unit per level. See "Ported units". ported (slice 1, STRA-202) Not ported yet: dense_act_i8, qrow_i8, the paired and multi-row kernels, AVX-512, AMX, NEON, VSX.
c/fused_simd.h (156) AVX2 int8 per-row dot with two accumulator chains, AVX2 activation quantization stated bit-identical to the scalar loop, gate/up pair that quantizes the shared input once. Guarded by __AVX2__. adapt Header cites a memcmp test in tests/bench_fused3.c; that file is not in the snapshot, so the claim is UNVERIFIED until our own test reproduces it.
c/gsgemv.h (212) Group-scaled GEMV; avx2 hits 23. not read Read before deciding.
c/expert_ffn.h (438) Expert feed-forward; avx2 44, avx512 3, vnni 12. not read Read before deciding.
c/expert_store.h (103) Expert store API: lookup returns a lease that must be released once; counters for requests, hits, misses, prefetched, prefetch hits, bytes read, resident and capacity bytes. adapt (design) The lease contract and counters are the telemetry STRA-204 needs. The implementation is not ported.
c/expert_store_registry.c/.h (115 / 78) Pluggable store backends selected by COLI_EXPERT_STORE; its open function takes DeepSeek-V4 types. reject Tied to the DeepSeek-V4 engine.
c/tier.h Small pure functions for hot/cold promotion: 25 percent margin plus 4 to stop ping-pong, heat decay by halving, LFRU score where one frequency count outweighs recency. adapt Pure integer logic, easy to unit-test against upstream.
c/compat_prefetch_win.h (88) Windows readahead hint: at most 4 jobs and 64 MiB, uses PrefetchVirtualMemory when present, drops excess hints instead of queueing. Included by compat.h. adapt Needs an I/O test on the NVMe of the reference laptop; STRA-204.
c/compat.h (688), c/omp_tune.h (167), c/pin_pool.h (147) Portability, OpenMP tuning and thread pinning. not read Mine for pieces; do not port whole.
c/backend_xdna.c/.h (1656 / n/a) AMD XDNA NPU lane: optional helper DLL loaded by absolute path, shape registry pinned by SHA-256, prepared weight images, refusal falls back to the caller. reject (code), reference (structure) AMD hardware; no Intel NPU code exists in Colibri. STRA-207.
c/qwen38.c (3536), c/qwen38_core.h (4153) Qwen3.8-Flash-Next engine: Qwen Sparse Attention, Gated-Residual streams, PLE rows read from disk, one prefix cache. reference Layout reference for STRA-201; not a port unit.
c/olmoe.c (3529) OLMoE engine, small MoE. reference Candidate bring-up model engine for STRA-201.
c/rans.h (1151), c/fse_coli.h Entropy coders; README mentions an experimental ANS-compressed expert tier. not read Compare with KAR in STRA-205 before any decision.

Ported units

Leleka file Upstream source Local changes Oracle and result
crates/cpu-sys/csrc/dot_scalar.c c/idot.h scalar tails of dot_i8i8, dot_i4i8 size_t lengths, one function per level, no compile-time ISA selection Compared with an independent i64 computation in crates/cpu-kernels/tests/parity.rs
crates/cpu-sys/csrc/dot_avx2.c c/idot.h AVX2 branches of both functions own translation unit, size_t, shared tail semantics Equal to the scalar level and to the i64 oracle for lengths 0 to 300 and eight larger sizes up to 131,072; also at four worst-case value pairs and for seven unaligned offsets. Windows MSVC 19.50 and Linux GCC 14.2, debug and release
crates/cpu-sys/csrc/dot_avxvnni.c c/idot.h __AVXVNNI__ branches of both functions own translation unit; _mm_dpbusd_avx_epi32 (VEX) instead of _mm_dpbusd_epi32, because MSVC defines no __AVXVNNI__ and the EVEX name would not select VNNI; size_t Same tests as AVX2; ran on the Core Ultra 7 265U and inside the Docker VM

Rust port (2026-10-14). The rows above name the C translation units, which were the first port. The kernels the runtime runs are now Rust (crates/cpu-sys/src/simd.rs, std::arch), written operation for operation after the C versions: same accumulation structure, same horizontal sums, same rounding. The C files remain only behind the test-only feature c-reference (crates/cpu-sys/src/c_reference.rs), and crates/cpu-sys/tests/rust_vs_c.rs checks that every Rust kernel (portable, AVX2 and AVX-VNNI; dot products, per-block integer sums, quantizer, half conversions) gives bit-identical results to the C one, including the float dot products, on lengths 0 to 2,880 and random data (run: cargo test -p leleka-cpu-sys --features c-reference --test rust_vs_c). The adaptation lineage to c/idot.h is unchanged. Paired decode on the real model (40 tokens, 10 threads, 5 alternating rounds): median 98 ms per token for both builds, same tokens and same first-step log-probabilities.

Finding from the port: the AVX2 and AVX-VNNI paths compute |w| * sign(x, w), and sign(-128, negative) wraps, so an activation of -128 gives a different result from the scalar level. Upstream's quantizer scales by amax/127, so it never produces -128; Leleka states "activations in [-127, 127]" in leleka_cpu.h and a test (activation_minus_128_is_outside_the_contract_...) fails if that behaviour ever changes. Weights may be any int8 value. Also stated: sums are exact int32 only up to 131,072 elements.

Not verified yet: the port against Colibri's own compiled kernels, and against ggml (the comparison STRA-202 asks for); the oracle used so far is a scalar C reference and an independent i64 computation. No timing was measured.

Facts that affect the plan

  • Windows build: Colibri's Makefile builds Windows with MinGW gcc and OpenMP (-march=$(ARCH) -fopenmp), not MSVC. The headers use GNU-style code, so MSVC compatibility is UNVERIFIED and is settled in STRA-202.
  • Upstream claim, not ours: the README lists Qwen3.8-Flash-Next (125B plus a 51B n-gram) at a 186 GB download with 24 GB minimum and 32 GB recommended RAM, experts streamed from disk, and 1.91 to 2.56 tok/s with 32 to 96 experts per layer, 3.99 with optional int4 experts, on a machine the README labels "A, CPU" (its specification was not read). This is not the Qwen3.8 IQ3_S artifact used by Leleka (83.6 GB). Nothing here is measured by this project and none of it is a performance claim.
  • Expert streaming in Qwen path: qwen36_tier.h states full RAM residency for the CUDA expert tier; the disk streaming described in the README is a separate mechanism. Which engine file implements it for Qwen3.8 is not yet traced.

Revision history

Date Change
2026-10-14 First pin and ledger (STRA-200).