Commit Graph
11 Commits
Author SHA1 Message Date
Niko1221 e5806740a6 DeepSeek out (6/7): the DeepSeek engine's sources, tests, lab and CMake go
- src/dsv41, include/strata/dsv41, tests/dsv41, tools/dsv41_lab and data/dsv41 are deleted (no other target
  compiled or included them: checked with git grep for includes and CMake references).
- CMake: the STRATA_BUILD_DSV41 block of cmake/strata_gpu_engine.cmake (strata_dsv41_kernels, strata-dsv41, the
  ds4_* benches and tests, the hip_extra.h force-include), the CPU-only bench macro (cpu.cmake, CMakeLists.txt),
  the DeepSeek default architectures of cuda.cmake and the BMI2-off branch of strata_ggml.cmake. All were behind
  STRATA_BUILD_DSV41 (default OFF; the release scripts pass their architectures), so every other target is
  configured as before.
- Mac, the two pieces that cannot wait: metal/CMakeLists.txt no longer builds strata_ds4 (it compiled src/dsv41),
  and metal/src/engine/exl3_legacy_stub.cpp goes (a member of the strata_metal_kernels glob that included
  include/strata/dsv41/exl3.hpp). The other DeepSeek Metal files stay for the separate Metal commit.
- CI: the Metal job builds strata only.
- data/settings-register.json: the 42 names only the DeepSeek engine read go; STRATA_FORCE_AVX2,
  STRATA_METAL_KEEP_FREE_GB and STRATA_METAL_LEAVE_SHARE keep their other readers. Every other entry is unchanged
  (tools/settings_register.py --check: no difference).
- tests/quant/check_no_ggml.sh: no ds4_gg_cpu pattern.
2026-11-11 11:44:22 +01:00
Niko1221 07df437326 tests/quant/golden_x86.txt: the oracle's reference, and comments that state the contract
The golden file: 891 lines, 54 KB. Family gcc: every group of the
three x86 flavours (avx2 291, avx 291, generic 283 groups) as GCC 13.3
builds ggml-cpu. Family msvc: 14 lines, the avx2 Q5_K and IQ1_S dot
groups at n = 512..2048, where MSVC 19.44's reference (and the layer
under MSVC) differs from GCC's because MSVC does not contract the
intrinsics' add-of-mul into FMA (1-512 ulp, max relative 3.3e-5 for
Q5_K; 1-16 ulp, 1.6e-6 for IQ1_S). Every other group, and every input
digest, is the same under both toolchains. ggml pin 3cf03257f.

The comments next to the IQ4_NL tail pin (x86_dots.inc) and the tier
flags (quant.cmake) now say what is pinned, against which reference,
and what was measured under GCC 13.3, 14.3, 15.2 and MSVC 19.44.

golden_merge.py writes the MSVC version as 19.44.35228.
2026-11-10 20:40:28 +01:00
Niko1221 a215f95d52 quant_parity: a gate leg against stored reference digests, the live ggml compare for information
ggml-cpu's own results move with the compiler that builds the oracle:
GCC 14.3 fuses the IQ4_NL odd-block tail into an FMA, GCC 15.2 that and
the generic Q2_0 dot, where GCC 13.3 does not (55 and 238 rows of the
oracle, 1-4 ulp). The layer's results are the same bytes under all
three. A live compare alone therefore fails on a newer GCC for a change
in ggml, not in the layer.

Leg 1, the gate: every group (flavour, section, type, n) of the layer's
results against tests/quant/golden_x86.txt, the digests of the
reference that GCC 13.3's ggml-cpu computes for the same inputs (input
digest checked too). A toolchain family can carry its own line for a
group (msvc: MSVC does not contract the intrinsics' add-of-mul).
Leg 2, information: the row-by-row compare with the ggml-cpu linked
here; its summary names the compiler and the groups where that ggml
differs from the golden reference. QUANT_PARITY_LIVE_STRICT=1 makes it
fail too. Without golden lines for a flavour (arm64, or --rows other
than 24) leg 2 stays the gate.

The digest is FNV-1a 64, written in the test, with its published test
vectors checked at start. --dump-group KEY prints every row of a group
(ours per kernel and ggml's) for a diff against a GCC 13 run;
--write-golden FILE writes a flavour's lines; --regen-check (ctest
quant_golden_regen, only when the golden file exists) regenerates the
stored lines byte for byte under GCC 13.x (family gcc) or MSVC 19.4x
(family msvc) and skips elsewhere. tests/quant/make_golden.sh and
golden_merge.py make the file.
2026-11-10 20:25:56 +01:00
Niko1221 2d2773239d quant_parity: the same test inputs under every compiler
Two random draws in one expression have no evaluation order in C++: the
activation test's tie rows got other inputs under MSVC 19.44 than under
GCC (20 rows per group). Every draw of the test is now its own statement
(Rng::gauss, the tie rows, the boundary scales).

The activation and boundary quantizer tests pre-fill both output
buffers: Q8_K leaves an all-zero block's 16 block sums unwritten (ggml
and the layer alike), so those bytes carried an earlier row's contents.

No kernel changes; the inputs change once, so the golden digests that
follow are made from this version.
2026-11-10 20:06:15 +01:00
Niko1221 0a93813361 Merge f-own-2n (ead5a32ae) into f-own-int: the Arm NEON tier of the quant layer
Conflicts (f-own-2n branched from f-own-2a 6213c0839; f-own-2a's later
commits and f-own-2n both added a tool called quant_bench):
- cmake/backends/quant.cmake: f-own-2n's ${_sq}-rooted paths (for the
  Metal project) applied to f-own-2a's AVX-512 tier lines (MSVC and GCC
  options), the Arm tier block from f-own-2n kept as is.
- tests/quant/quant_bench.cpp (add/add): f-own-2a's no-ggml one-thread
  bench keeps the name quant_bench (built always, ${_sq}/ path now);
  f-own-2n's ggml A/B bench is renamed to tests/quant/quant_bench_ggml.cpp,
  target quant_bench_ggml (test builds only, links ggml-cpu); its usage and
  banner lines say the new name.
src/quant/isa.cpp merged by itself (2a: Avx512 needs VNNI; 2n: Neon needs
dotprod).
2026-11-09 22:04:04 +01:00
Niko1221 9063d81bd0 quant layer: ue4m3 scale decode through a table (the NVFP4 dots were 5x slower than ggml's with ldexp); quant_bench --rows 2026-11-09 05:27:43 +01:00
Niko1221 a550fd71f1 quant layer: STRATA_OWN_CPU_QUANT defaults ON on arm64; quant_parity skips ggml-cpu flavours that are not the Neon contract; quant_bench (rows against ggml-cpu); run_oracle arm flavours 2026-11-09 05:07:04 +01:00
Niko1221 2fe91fddd7 quant layer: AVX-512 VL+VNNI build of the AVX2-contract dots (Q4_0/1, Q5_0/1, Q8_0, IQ4_NL, MXFP4), quant_bench, check_no_ggml.sh
dot_avx512.cpp compiles the same ported ggml dots as dot_avx2.cpp with -mavx512vl -mavx512vnni so the helper's VPDPBUSD branch (ggml's own, for
__AVX512VNNI__ && __AVX512VL__) replaces maddubs + madd.  Integer sums are exact either way and the float order is the AVX2 one, so the bits are the
AVX2 tier's: quant_parity runs these kernels against ggml's AVX2 dots (19097 comparisons, 0 differences, p2006).  Isa::Avx512 now means AVX-512
F/DQ/BW/VL + VNNI (isa_ok / best_isa).  One thread, Zen 4 (p2006), GB/s of weights, DRAM set / L2 set, avx2 -> avx512 build:
q4_0 15.98/16.27 -> 16.73/17.03, q4_1 16.20/16.55 -> 17.02/17.44, q5_0 15.36/15.69 -> 16.87/17.26, q5_1 15.49/15.84 -> 16.63/17.03,
q8_0 37.42/39.55 -> 38.07/40.41, iq4_nl 14.93/15.30 -> 15.19/15.58, mxfp4 11.39/11.88 -> 11.65/12.11 (+2% to +10%).

Tried and dropped (not in the tree): a two-block 512-bit decode (nibbles of two blocks, the 5th bit from a mask register, one VPDPBUSD) with the float chain in ggml's
order: 14.94 vs 15.35 (Q5_0), 12.6 vs 15.9 (Q4_0), no gain; and 4-rows-at-a-time kernels (bit-exact, R chains in flight): L2-resident +15-20%, DRAM-streamed
-30% (four streams per core), so a loss where the pool lives.

tests/quant/quant_bench.cpp: one-thread GB/s of every kernel (no ggml), interleaved rounds, medians.
tests/quant/check_no_ggml.sh: nm -u over the pool's objects (strata_kernels_cpu, strata_quant, mtp.cpp, ds4_gg_cpu.cpp): none may reference ggml
(own build: 29 objects, clean; ggml build: ggml_cpu_init, ggml_get_type_traits_cpu, ggml_row_size, ggml_cpu_has_* found, as it must).
2026-11-09 05:04:42 +01:00
Niko1221 9740a09628 quant layer: Arm NEON tier (ggml's NEON dots and Q8_0/Q8_1 quantizers ported, Arith::Neon), arm64 contraction of the Q8_K/Q4_0/dequant references, boundary-value oracle test 2026-11-09 04:59:30 +01:00
Niko1221 e5af60da09 quant layer: AVX2 and AVX tiers (ggml's x86 dots and Q8_0/Q8_1/Q8_K quantizers ported), dequantizers; bit-exact against ggml-cpu in all three flavours
x86 tiers of the layer, one translation unit per flavour compiled with that flavour's instruction-set flags, so the #if __AVX2__ / __AVX__ branches of
ggml's own x86 code (arch/x86/quants.c at the pin, ported to C++ in x86_helpers.inc, x86_dots.inc, x86_act.inc) select what ggml-cpu selects:
- Arith::Avx2 (dot_avx2.cpp, act_avx2.cpp: -mavx2 -mfma -mf16c): the release flavour.  21 dot types + Q2_0 (generic code under this contract, as in ggml),
  Q8_0 / Q8_1 round-half-even quantizers, Q8_K quantizer in AVX2 (the engine's q8k_quant_avx2 moved into the layer, byte-identical to the scalar _ref).
- Arith::Avx (dot_avx.cpp, act_avx.cpp: -mavx, AVX2/FMA/F16C off, #error if they leak in): the STRATA_ISA_FLOOR=avx flavour.
- -ffp-contract=fast on the tier files (ggml-cpu is gnu11 C, which contracts; this is -std=c++20) and STRATA_NOFUSE on the one scalar tail ggml's GCC does
  not fuse (IQ4_NL), found by the oracle test; STRATA_QUANT_AVX2_EXTRA is a cache variable for such experiments.
- dequant.hpp / dequant.cpp: ggml's dequantize_row_* for the 22 types the host side reads back; quantize_q4_0_ref was already in.
- quant_parity covers dequant_row and quantize_q4_0_ref against ggml-base's to_float and ggml_quantize_chunk(Q4_0) too.

Oracle (tests/quant/run_oracle.sh avx2 avx none), 15065 / 15065 / 14489 comparisons, 0 differences, on boston (AVX2 host) and p2006 (AVX-512 host,
the AVX-512 hardware is not used yet).  The Windows (MSVC) run is still to do.
2026-11-09 04:26:42 +01:00
Niko1221 8a2b0f5f00 quant layer: type table, CPU probe, Q8_0/Q8_1/Q8_K/Q4_0 reference quantizers, Generic-contract dots for every pool type, self-checks, ggml oracle test
New static library strata_quant (include/strata/quant/, src/quant/), no ggml dependency: block layouts and codebooks come from the quant header.
- types.hpp: ggml's type ids and block geometry (type_info, row_bytes), activation type per weight type; unknown ids answer nullptr.
- isa.hpp: Isa (hardware) and Arith (arithmetic contract: Generic, Avx, Avx2, Neon), Caps probe with the STRATA_FORCE_ISA cap, default_arith().
- act.hpp / dot.hpp: kernel tables with best-kernel lookup per (type, contract, hardware); references: ggml's _ref quantizers and _generic dots
  ported to C++ (22 dot types: Q2_0, Q4_0/1, Q5_0/1, Q8_0, IQ4_NL, MXFP4, NVFP4, Q2_K..Q6_K, IQ1_S/M, IQ2_XXS/XS/S, IQ3_XXS/S, IQ4_XS).
- selfcheck.hpp: every kernel against the reference on exact synthetic data (powers-of-two scales, small activations), once per process.
- tests/quant/quant_parity.cpp (the only program that links ggml-cpu) compares the layer with ggml-cpu bit for bit; run_oracle.sh builds it in the
  three flavours (portable AVX2, STRATA_ISA_FLOOR=avx, none).  Generic tier vs the none flavour: 13825 comparisons, 0 differences
  (Q4_0 excluded there: ggml's SSE4.2 flavour has an SSSE3 branch that is not the generic C code).
2026-11-09 04:11:27 +01:00