Commit Graph
5 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Sonnet 5.5 68fcd8de1c perf: use the pre-converted activation layout and 4-accumulator kernels for the MXFP4 experts (STRA-214)
The expert products (62 percent of a decoded token) now read the activation as f32
scales plus contiguous int8 quants, summed with four accumulators per iteration.
Adds the portable reference and the AVX-VNNI kernel for that layout; the AVX2 and
AVX-VNNI kernels are tested bit-identical to each other, and every level is within
the stated tolerance of the ggml-derived f64 reference. The decoder keeps both the
Q8_0 blocks (for the Q8_0 attention and output head) and the converted layout.

Measured on the real model with pre-touched pages, 10 threads, 40 tokens, alternating
old and new binaries (5 repeats; indicative, one burst-state outlier excluded): paired
old/new ratios 1.09, 1.14, 1.08, 1.06, i.e. about 8 percent less time per token (118 to
111 ms median), expert gate+up 41.6 to 37.6 ms. Greedy tokens are identical to
llama.cpp for the first 16 and to the previous build for the first 18; they diverge at
position 18 where the top-two logit gap is 0.009 (a numerical tie).

Also adds a per-step top-two logit margin print to the real-model runner.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 17:03:33 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 fa921a2ced feat: add Q8_0 activation quantizer and Q8_0 x Q8_0 dot kernels (STRA-211)
Completes the Q8_0 side of the CPU runtime's kernel set: a float-to-Q8_0
quantizer (scale = amax / 127 as a half, quants rounded to nearest even and
clamped to [-127, 127]) and the Q8_0 x Q8_0 dot, each at scalar, AVX2 and AVX-VNNI
(the quantizer shares the AVX2 code). Tests: the quantizer is bit-identical across
levels and equal to the vendored ggml reference except on exact .5 ties; per-block
integer sums are exact; float results are within the stated tolerance of an f64
reference built from ggml's dequantizer; the portable half conversion equals the
F16C instruction on over a million values. Windows MSVC and Linux GCC, debug and
release. Replaces _cvtss_sh (not available in MSVC) with the packed conversion.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 16:01:32 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 efd4018a46 feat: add experimental pre-converted activation layout, topology helper and paired benchmarks (STRA-211)
Adds two EXPERIMENTAL AVX2 MXFP4 kernels that take the activation as f32
scales plus contiguous int8 quants (q8r, q8r4). q8r is tested bit-identical to
the ggml-layout kernel; q8r4 against the stated tolerance. Adds Windows core
topology and thread pinning (cpu-sys topology module) and three kernel-level
benchmarks that interleave variants and report paired ratios.

Findings, recorded in docs/experiments/2026-10-14-cpu-kernel-layout-and-pinning.md:
the chip has 2 fast cores and 10 slower ones; the new layout was faster for a
single thread (paired median 1.32x, 15 pairs) and inconclusive with many
threads; thread pinning did not beat the OS default. The machine was not in a
controlled state, so these are not accepted performance results.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:32:30 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 164bfa60b8 feat: add MXFP4 x Q8_0 dot kernels at scalar, AVX2 and AVX-VNNI (STRA-211)
The gpt-oss-20b experts are MXFP4, so the CPU runtime needs this dot product.
Blocks use ggml's byte layout, so GGUF tensors can be read in place. Per-block
integer sums are exact at every level; the float combination is checked against
an f64 reference built from the vendored ggml dequantizers (test-only
ggml-oracle feature) within a tolerance written before the run. Scale
conversion is compared exactly with ggml for every E8M0 code and every finite
half. AVX2 level now means AVX2 + FMA + F16C. ABI version 2.

Adds a kernel-level throughput example (bench_mxfp4); it is not an inference
benchmark and no end-to-end speed claim is made. Records the ggml upstream use
in docs/upstream-ggml.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:17:52 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 37620f1b60 feat: add CPU runtime kernel layer with AVX2 and AVX-VNNI dot products (STRA-202)
leleka-cpu-sys holds the C kernels (one translation unit per ISA level, built
by build.rs with cc) behind a checked FFI; it is the only unsafe code of the CPU
runtime and opts out of the workspace unsafe_code lint with a recorded exception.
leleka-cpu-kernels does safe run-time dispatch with a LELEKA_CPU_ISA override
that fails rather than silently changing level.

Ports the int8xint8 and int4xint8 dot products from Colibri c/idot.h at scalar,
AVX2 and AVX-VNNI. Tests compare every level with the C scalar kernel and an
independent i64 oracle (13 tests; Windows MSVC and Linux GCC 14.2). Activations
must be in [-127, 127]: -128 is outside the contract and a test pins that. No
performance claim: nothing was timed.

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