12 functions over a limit in crates/igpu test and example code -> 0 (3 example mains, src/tests.rs threaded_repacking,
tests/attention.rs attention_case, tests/gemm.rs check and the epilogue test, tests/moe.rs router and grouped products,
tests/norm.rs check, tests/real_weights.rs compare and the real-weights test). Split into arrange/run/compare helpers;
test names, module paths, assertions, messages and example output lines unchanged. The allowlist entry of
src/tests.rs threaded_repacking_equals_the_plain_definition is removed. Only src/shaders/gemm.rs (WGSL text) stays
allowlisted and is untouched.
The helpers split out of dot_multi512_impl, dot_single_iq3, iq4xs, dot_multi256, dot_multi512 and the K-block dot wrap their
bodies in `unsafe { }` as the surrounding code does; each now carries a SAFETY line (target features cover the intrinsics and
helpers called, loads follow the file's Bounds note). Comments only; harness re-run identical.
The Q4_K helper split made rust_kq.rs 404 lines (architecture gate: 400). The helpers (Q4kBlock, q4k_scales_mins,
q4k_spread_scales, q4k_expand, q4k_add_mins, q4k_sum, q4k_reduce) move verbatim into the private sibling module
rust_kq::q4_k_block; q4_k_dot stays in rust_kq with the same pub(super) path. rust_kq.rs 404 -> 311 lines. No code change
otherwise; the differential harness (q4_k_dot 960 cases, small_dot, bf16) re-run identical. codegen not A/B-measured.
29 more cases (159 cases, 318 captures), recorded on 08afbf216 in a temporary worktree and checked against the new code; none
differs. New cases: the request's max_output_tokens reached (text, reasoning, closed reasoning, tools, structured, gpt-oss);
Qwen reasoning on with json_schema valid and violated; gpt-oss json_schema, tools with structured output, effort none with
tools; Qwen reasoning plus tools at the length limit with calls inside the unclosed reasoning, and without; namespaced tools
through the stream and the buffered reading (Qwen with and without reasoning, gpt-oss); DONE before the first token and an error
after DONE (all four readings); a worker that reports fewer generated tokens than the reasoning took (the reasoning_tokens
clamp, usage output_tokens).
New tests of the binary (15 pass on 08afbf216 and on the new code): the stored response equals the one the client was sent
(streamed and not, six cases); a client that leaves at DONE closes the source (five cases, among them the final preview
flush); what reaches the worker: gpt-oss gets none of the server defaults for the samplers it lacks (top_k 20 and
penalty_last_n 64 included), accepts neutral values, Qwen keeps all five samplers and penalty_last_n, own and default.
In the lib: BufferedRun finishing its generation twice returns the shared GENERATION_ENDED error and fail() sends
response.failed; a token after the end fails the stream.
regenerate_output_golden now refuses unless OUTPUT_GOLDEN_RECORD names the pre-S23 commit and the tree has no output module
(checked: it panics on this tree); output_events.recorded_on names 08afbf216 and a test pins it.
probe (48 lines, cx26) becomes probe -> probe_cpu (CPUID leaf 0/1, XGETBV, leaf 7 in the same order, each early return kept)
over the pure predicates leaf1_ok / wide_state_ok / fp16_ok / vnni512_ok / subleaf1_ok; the sub-leaf 1 CPUID is still read only
when a BF16 / AVX-VNNI / AVX-VNNI-INT8 branch is compiled in and leaf 7 EAX allows it. float_dot (cx12, match guards) becomes a
match on the kind over f32_dot_native / f16_dot_native / bf16_dot_native with the same branch priority (FP16 before F, BF16
before F). The test comment that was over 120 columns is re-wrapped. Functions over a limit in the file: 2 -> 0 (+1 wide line).
Differential check old vs new on the AVX-512 WSL host, per RUSTFLAGS build: default (all branches off: float_dot None, 1120
cases), +avx512f/vl/vnni/bw (F32, F16-F, BF16-F branches run: 1120 cases, 672 Some, identical bits), and +avx512bf16 / +avx512fp16 /
+avxvnni / +avxvnniint8 (this CPU lacks them: probe() and compiled_admitted() agree on false). The BF16-native and FP16-native
float_dot branches could not run on this host; they are covered by review only (the selector order is unchanged).
codegen not A/B-measured.
ternary (69 lines, cx13, nesting 6) becomes tq2_half / tq2_sums (TQ2_0) and tq1_main_products / tq1_tail_product / tq1_sums
(TQ1_0, powers as TQ1_POWERS) with the final FMA-free accumulate in ternary. iq1 (84 lines, cx21, nesting 8) becomes
iq1_block_scale / iq1_block_sums / iq1_pair / iq1_group_s / iq1_group_m (+ iq1m_sign) / iq1_group_terms; the IQ1_S scalar
correction is returned per group and summed in the same order instead of mutated in place. Bounds comment re-wrapped.
Functions over a limit in the file: 2 -> 0 (+1 wide line). New unsafe blocks carry SAFETY comments; vector helpers keep
target_feature and are #[inline].
Bitwise old-vs-new check (AVX2 path ran on the AVX-512 WSL host): ternary 800 cases (TQ1_0 and TQ2_0 x 0..9 blocks x 80
rounds incl. non-finite scales), iq1 800 cases (IQ1_S and IQ1_M likewise), 0 payload differences; mxfp4/nvfp4 unchanged code
as control (300 cases). codegen not A/B-measured.
Functions over a limit in rust_ggml.rs and rust_ggml/: 10 -> 0 (plus 1 wide-only test and 6 wide comment lines -> 0).
- Kind::from_original / original_id / block read one KIND_TABLE (new rust_ggml/kind_table.rs, one row per variant, compile-time
check that row i is variant i); every mapping is the previous one.
- Activation::quantize split by encoding (encode_f32/f16/bf16/zero/one/k); bf16 rounding shared by quantize and quantize_raw.
- NativeFormat::new split into activation_sizes and bank_layout (same error order); dot split into dot_storage,
dot_zero_blocks, dot_k_blocks, iq4nl_dot, iq4nl_tail (shared with dot_raw).
- float_dot / q1_dot split into #[inline] #[target_feature] helpers with the same arithmetic and accumulation order.
- quantize_raw split into assert_destination and write_half; dot_raw uses the shared block dispatchers.
Bitwise identity old vs new proven by a differential harness (AVX2 and AVX-512 builds); codegen not A/B-measured.
q4_k_dot (68 lines) becomes q4k_scales_mins / q4k_expand (+ q4k_spread_scales) / q4k_add_mins / q4k_sum / q4k_reduce, the
per-token FMA order unchanged (min correction first, then the block accumulator). small_dot (49 lines, cx16) becomes
small_block_bytes / small_activation (returns the Q8One min term instead of mutating `sums`; the caller adds it in the same
position) / small_weights / small_products. bf16_rows and bf16_rows_multi: the one-line SAFETY block comments become line
comments before the unsafe call; header comment re-wrapped. Functions over a limit in the file: 4 -> 0. New unsafe blocks
carry SAFETY comments; vector helpers keep target_feature and are #[inline].
Bitwise old-vs-new check (AVX2 path ran on the AVX-512 WSL host): q4_k_dot 960 cases (1..8 tokens x 1/2/3/8 blocks, incl.
non-finite scales; 3 token results where both are NaN differ in NaN payload/sign only, an fadd of two NaNs keeps the first
operand and LLVM may commute it), small_dot 3000 cases (kinds 2/3/6/7/8 x Q8Zero/Q8One x 0..10 blocks, empty row, missing
activation panic), bf16_rows/bf16_rows_multi 3168 cases incl. shape errors, q8_zero_dot/q5_one_dot/quant_one unchanged code
run as a control. codegen not A/B-measured.
Renames: ReasoningSplit to ReasoningPreview, Bytes to TokenBytes, Split and Cut to the one CutGeneration (the tokens are
counted from its extent by Generation::count_tokens), split_reasoning to cut_reasoning_for_corpus. AtEndDecoder::read_answer
returns the events and the notes, and build_events keeps the notes (two steps). decode_lossy has its doc comment. The
message of a decode error after the generation ended is one constant, output::GENERATION_ENDED, used by the decoders and by
the buffered stream. The sampler types and the admission functions move from codec.rs and effort.rs to sampler_limit.rs
(with their tests); lib.rs no longer names TokenDecoder.
TextCodec::live_decoder returns Option and defaults to None: a model that always reasons is read at its end, so the
gpt-oss live arm and LiveDecoder::harmony are deleted; the two live streams fail the response with NO_LIVE_READING if they
ever get None. harmony_family tests pin reasoning_enabled(effort none, gpt-oss) = true and the missing live reading.
New unit tests: preview off with an unclosed block at the length limit, and the same reasoning tokens with preview on and
off when the marker is split over two multi-byte tokens.
Proof: golden (260 captures recorded on 08afbf216) identical, strata-control lib 316, gateway-domain 36, tool corpus 4.