6.2 KiB
Q6_K / Q2_0 CPU reference parity
GGUF kind 14 (Q6_K) and kind 42 (Q2_0) preparation decoding gains explicit independent Rust routes. This does not replace the full inference engine. Other unported preparation formats still use the C bridge; no GPU, model or user-agent data is accessed by these synthetic CPU gates.
Pinned reference and layout
Expected numeric output comes from the unchanged vendored GGML C implementation,
llama.cpp 3cf03257f219afbe7334045ff7c6a06ac68c627d and imported Strata
d9ab8435f654c368c586340d490915f6addf56a3. Source hashes and original MIT notice
remain in GGML provenance and
the crate notice. The C bridge production
code, compiler arithmetic flags, nineteen previous oracle tests and eleven
previous visitor test functions remain unchanged.
Q6_K is 210 bytes / 256 outputs: low nibble bank 0–127, high two-bit bank
128–191, sixteen signed int8 subscales 192–207, little-endian FP16 header
208–209. Each 128-output half uses separate low/high/scale offsets; each has
four 32-output quadrants and two 16-lane subscale positions per quadrant.
Arithmetic keeps (d * signed_subscale) * (six_bit_code - 32) in C order.
Q2_0 is 18 bytes / 64 outputs: little-endian FP16 header 0–1 and sixteen
packed bytes 2–17. Four consecutive two-bit fields in each byte map to
{-1, 0, 1, 2} and multiply as (code - 1) * d, matching pinned C order.
Both formats admit every FP16 encoding as the old C consumers do. Inf times zero subscale or zero signed quant yields NaN; all non-NaN values including signed zero and infinity signs use exact bits. NaN payload/sign equivalence is outside this classification contract. Bulk shape errors must not write caller output.
Independent synthetic coverage
The input generators and coverage bookkeeping never call Rust unpack helpers. Every expected numeric value is actual C output, not a Rust-derived expectation.
- Every 63,488 finite FP16 encoding: one Q6_K block and four Q2_0 blocks per header. The four Q2 patterns put each code at every output position. This contributes 32,505,856 finite comparisons.
- Every 256 signed subscale × 64 quant code pair at each of Q6_K's 256 output positions with one fixed finite header; assertions cover both halves, all quadrants/lanes and every subscale location. This contributes 4,194,304 comparisons.
- Independent byte bijections exercise every one of 256 byte values at all 208 Q6 packed-field positions and all sixteen Q2 packed-byte positions. Q2 coverage additionally requires every code at all 64 consecutive outputs. These contribute 81,920 comparisons.
- Sixteen-block finite boundary batches through aligned and deliberately unaligned bulk slices contribute 10,240 comparisons. Empty/truncated source and short/long output shapes reject before modifying sentinel output, in both Rust and C APIs.
- Every 2,048 nonfinite FP16 encoding is tested for Q6 generated fields, explicit zero subscales and explicit zero signed quants, and Q2's four code-position patterns. NaN class agrees; every non-NaN output matches bits.
Total finite comparisons: 36,792,320, with zero tolerance. This exhausts separate domains, not the full FP16 × signed-subscale × quant joint space, all arbitrary packed-field combinations or NaN payloads.
Bounded visitor
Only kinds 14 and 42 gain routes; geometry agreement is checked before seek. The source cap and other routes are unchanged. Synthetic tensors cross two callbacks: exact C bytes, source offsets/slices, bounded derived buffers and F32 byte receipts are checked. Malformed shapes do not seek or call back; early/late truncation cannot deliver partial chunks; callback failure at the first or second callback stops further reads. Nonfinite and signed-zero headers with explicit zero factors retain C output semantics.
cargo test --locked -p leleka-quant-core
cargo clippy --locked -p leleka-quant-core --all-targets -- -D warnings
cargo test --locked -p strata-control --lib ggml_bridge::tests -- --test-threads=2
cargo test --locked -p strata-control --lib gguf_f32_stream::tests
Actual results
Local CPU gates on 2026-10-07:
- Rust
1.99.0 (b940084d7 2026-09-28), Darwin arm64, Apple Clang 21.0.0 (clang-2100.1.1.101); unchanged C arithmetic flags and zero tolerance. - Actual pinned C oracle: 24 passed, 0 failed, including five new tests and nineteen previous tests byte-preserved. All 36,792,320 new finite comparisons and every field/per-position scale-code coverage assertion passed with zero numerical mismatch. All nonfinite, zero-factor, bulk and sentinel gates passed. The complete oracle runtime was 16.63 seconds, a test duration rather than an inference performance result.
- Visitor: 13 passed, 0 failed, including two new tests and eleven previous functions byte-preserved. Q6 used raw chunks 28,140 / 3,570 bytes, derived chunks 137,216 / 17,408 bytes. Q2 used raw 28,152 / 306 bytes, derived 400,384 / 4,352 bytes. Offset, bounded-buffer, receipt, early/late truncation, malformed-shape, first/second callback abort and nonfinite/zero-factor tests passed.
- Control-plane library/tests Clippy with warnings denied, full workspace formatting, diff checks, all ten vendored GGML source hash checks and quant-core normal dependency tree passed. The tree contains only the independent Rust crate, with no production dependencies.
- Standalone quant-core: 28 passed, 0 failed (eight new: five Q6 and three Q2 tests), all-target Clippy with warnings denied, formatting and normal dependency tree passed. The initial 28/28 test run also passed; a test-only temporary-vector lint was corrected to equivalent stack storage before the final gate, with no arithmetic or assertion change. The final owned temporary target was cleaned (359 files, 16.1 MiB) and removed; the earlier Clippy target was also removed.
- Existing coordinated shared control-plane target cache retained; no new private control-plane build target or test artifact was created.
Linux/compiler qualification, model/GPU inference, quality and paired end-to-end performance are separate gates. No performance or inference-readiness claim is made.