11 Commits
Author SHA1 Message Date
Niko1221 0420a656e1 fix(artifact): read the 16 KiB-aligned .strata v1.1 layout (SQ-20 re-adjusted), keep the 4 KiB one exactly as before
The re-adjusted Inkling-2-Mini-SQ-20 and Vision files have their section table at 0x20 (a u16 tile_layout_id
at 0x10), sections 16 KiB aligned and Section 3 padded to 16 KiB. Every reader of 0.2.22 reads the table at 0x10, so
it sees six empty sections and an empty manifest: StrataFileReader::open succeeds and the loader fails later with
"manifest parse error: JSON: unexpected char", with a Vision file refused as profile 2.

strata_layout.hpp (new, header only) is the one place that tells the layouts apart: both section tables are checked
(section_id equals the index, 4 KiB / 16 KiB alignment, inside the file, no overlap) and a header that is neither, or
both, is refused with a message that says why. A u64 below 4096 at 0x10 is not used for the decision. Section 3
of the 16 KiB layout takes its entry count from the manifest (top-level num_physical_layers x num_experts_per_layer,
found by walking the JSON, with each factor capped so the arithmetic cannot wrap), so a padded length that happens to be a
multiple of 34 is not miscounted, and a nested key or a chat template that spells the key is not taken for it.

Callers: StrataFileReader (CUDA, HIP, CPU Inkling, Hy4 CUDA/HIP/SYCL/CPU), the no-zstd Mac reader, the Metal and SYCL Inkling
loaders (header, Section 3 count), the Metal and SYCL vision loaders, the Hy4 CPU expert directory. The Inkling
Vision shard is recognised by header profile 3 or by arch inkling2_vision in the manifest (the new file has profile 2).

Test: engine/tests/quant/strata_reader_layout_test.cpp (CMake: strata_reader_layout_test), with the real 0.2.22 headers of
SQ-20, SQ-10 and Vision as golden frames.
2026-11-26 10:30:41 +01:00
Niko1221 e187fff726 rc1: merge f-0221-inkcpu (c25b0fddd: AVX-512 host kernels for the CUDA fast lane, run-time SIMD tiers for the S_K codecs, dense dot tier; ink_host_avx2.cpp is INKPLACE's) 2026-11-23 20:21:23 +01:00
Niko1221 c25b0fdddd inkling2 CPU backend: AVX2 / AVX-512 / NEON dense dot, and matmul parallel over the weight rows
The q / k / v / o / gate projections of the CPU backend (matmul_f32) were `parallel for` over the activation rows with `if (M * N >= 4096)`: a one-token decode step
ran most of them on ONE thread, and a prompt read every weight row M times from memory. They are parallel over the weight rows now (threshold on M * N * K), each row is
read once and reused for all M activation rows from L1; every y[m][n] is the same dot call as before, so the result does not depend on the thread count.

The dot itself (CPU backend, attention scores, inkling2_loop.cpp's helpers) is strata::quant::sk::dot_f32, one more function of the run-time tiers: 4 accumulators of the
tier's vector width (AVX-512 / AVX2 with FMA / NEON), plain 4-accumulator C++ in the base tier (bit-identical to the sum it replaces: sk_tier_test checks it). The vector
tiers sum in lane order, so a CPU-only run differs from 0.2.20 by float rounding (SQ-10 teacher-forced KL(old||new) 4e-4, repeatable run to run).

Measured, CPU backend, SQ-10 prefill 128 / decode 8, alternating pairs: Apple M5 Max prefill 3.2 -> 7.7 ppts, decode 1.6 -> 2.5 tok/s (spread under 1 %);
Zen 4 16 threads, UD-Q2_K_XL: prefill 11.1 -> 13.0, decode 2.7 -> 4.3.
2026-11-23 20:09:19 +01:00
Niko1221 accfd7ace3 inkling2: AVX-512 for the fast lane's CPU experts, and run-time AVX2 / AVX-512 tiers for the S_K / SF4 / MX8 codecs
1. CUDA fast lane (cold experts computed on the CPU): new ink_host_avx512.cpp has the three host kernels (SF4 row, MX8 row, S1.5..S8_K sub-group) for
   AVX-512 F/DQ/BW/VL (no VNNI, so Skylake-X runs it too). The file is built with the AVX-512 flags and nothing else is; its gate, host_avx512::available(),
   is in ink_host_avx512_gate.cpp, a baseline-flag file (a compiler may use AVX-512 anywhere in a file built with -mavx512f, so the gate cannot live there):
   caps().avx512, closed by STRATA_FORCE_ISA=avx2. ink_hybrid.cuh tries AVX-512, then AVX2, then plain C++.
   ink_host_avx2.cpp unpacked the S2_K / S3_K / S5_K / S6_K fields with scalar loops (0.7 to 1.1 GB/s of weights per thread): shuffles now, integer sums exact.

2. The CPU backend and the HIP / SYCL CPU-expert lane (eval_inkling2_expert_batch -> sk_codecs.cpp) ran plain x86-64 C++: strata_quant builds sk_codecs.cpp with
   no ISA flag (its AVX2 / AVX-512 code is selected by __AVX2__ at build time). It is now compiled three times (sk_codecs_base.cpp, x86/sk_codecs_avx2.cpp,
   x86/sk_codecs_avx512.cpp) into strata::quant::sk::{base,avx2,avx512} and sk_dispatch.cpp picks the tier from caps() (AVX-512 needs VNNI there, as strata_quant's
   own tier does). A CPU without AVX2 never executes an AVX2 instruction of it, and a -march=native host cannot leak wide code into the base tier. Tier files are
   -ffp-contract=off: the integer sums are exact and the float steps are the base tier's, so every S_K result is bit-identical across tiers (the aarch64 path and the
   builds that compile sk_codecs.cpp themselves (hy4flash, Metal, the SYCL script) are unchanged). AVX2 gets vector unpackers and an abs/sign int8 dot.
   SF4 / MX8 sum in lane order, so they differ from the scalar tier by float rounding.

Tests: tests/core/ink_host_simd_test.cpp (all formats, scalar reference, AVX2 and AVX-512, F8_E4M3 decode on all 256 codes), tests/quant/sk_tier_test.cpp (tiers
against each other: S_K bit-identical, dispatcher = reported tier), benches ink_host_simd_bench / sk_tier_bench. Run on Zen 4 and Zen 5 (AVX-512 + VNNI), Zen 2 and under
qemu -cpu Nehalem / SandyBridge / IvyBridge (gates closed, nothing executed above the CPU's level), tools/check --only cmake-cpu: 160 passed.

One thread, S_K gemm of a 2304 x 2304 expert matrix, one token, base -> avx2 (Zen 4): S2_K 10x, S3_K 13x, S4_K 2.9x, S5_K 9x, S6_K 8x, S8_K 2.7x. AVX-512 over AVX2: 1.0x on
Zen 4, 1.0 to 1.7x on Zen 5 (ink_host kernels: SF4 1.57x, MX8 1.69x, S3_K 1.35x, S5_K 1.5x).
2026-11-23 19:30:30 +01:00
Niko1221 d290efcdec hip hybrid decode: split GGUF_RAW experts too (quantized-dot kernels and the dequantize fallback)
The first change split SF4, MX8 and S_K experts over the CPU pool. The Unsloth files use other layouts:
UD-Q4_K_XL has NVFP4 experts in layers 0-19 (lossless SF4) and Q8_0 experts in the last four layers (the coda layers
are placed last, so on a 12-16 GB card they are the RAM experts), UD-Q2_K_XL mixes IQ1_S/IQ2_* with NVFP4/MXFP4.

expert_m1_gu_rows / expert_m1_dn_rows now also cover SkCode::GGUF_RAW, with the same 4-row grouping and the same
dot kernels as eval_inkling2_expert_batch, and the same dequantize-then-float-dot code for the types without a
quantized dot (Q8_0, F16, BF16). ink_expert_split_test checks Q4_K, Q5_K, Q6_K, Q8_0, Q3_K, Q2_K, IQ4_XS, Q4_0 and
IQ4_NL gate/up with Q8_0, Q4_0 and IQ4_NL down, interleaved and split layout, bit for bit against the whole expert.
2026-11-23 13:58:05 +01:00
Niko1221 6cb548ffb1 hip hybrid decode: split each RAM expert over the CPU pool; keep unplaced GGUF experts in RAM
A hybrid decode step (some experts in RAM) routes 8 experts, so only 1-4 of them are RAM experts per layer, and the
CPU pool ran each of them as ONE job on ONE thread. With 10-24 pool threads most cores sat idle while the GPU waited
(per token on a Radeon AI PRO R9700, SQ-10 with 38% of the experts in RAM: 52 ms of CPU wait out of 70 ms).

- expert_m1_gu_rows / expert_m1_act / expert_m1_dn_rows (inkling2_loop.cpp): the same per-row code as
  eval_inkling2_expert, callable on a row range, so every output element is computed in the same order and any split
  gives the same bits (SF4, MX8, S2_K..S8_K; GGUF_RAW experts keep the old path). Test: ink_expert_split_test
  (whole-expert result vs six slicings, slices run in reverse order, bitwise).
- The pool splits every single-token job over ceil(threads / jobs) slices in three phases (gate/up rows, SITU, down
  rows) and adds the expert outputs in job order. The old code added per-thread buffers whose content depended on which
  thread took which job, so the sum order changed from run to run. STRATA_HIP_CPU_SPLIT=0 turns the split off.
- STRATA_HIP_HYB_PROF=1 prints the time split of the hybrid decode step.
- A GGUF whose experts need a transcode (IQ1_S, IQ2_*, IQ3_S: no HIP kernel) grows when it is transcoded to S_K, so the
  planner's file-size budget (--vram-experts-gb 7.26 --ram-experts-gb 0 for UD-Q2_K_XL) left experts that fit neither
  VRAM nor RAM; they were re-read and re-transcoded from the file on every token (0.3 tok/s, prefill 3.9 tok/s on
  gfx1201). They now stay in RAM when MemAvailable allows (a line says so), otherwise a warning says why decode is slow.
- INK_LOGITS_HASH=1 (direct generation mode) prints an FNV hash of the logits of every step.

Measured on p620 (gfx1201, Threadripper PRO 3975WX), SQ-10, --vram-experts-gb 5.2 --ram-experts-gb 3.2 --draft off,
bench 128/128, three alternating rounds: 12.8 / 13.0 / 12.9 tok/s before, 32.2 / 32.6 / 32.9 after (all experts in
VRAM: 73.6). UD-Q2_K_XL with the flags of #6729: 0.3 -> 28.8 tok/s (64 tokens, includes warm-up).
2026-11-23 13:48:26 +01:00
Niko1221 7031ccaf95 inkling2+hy4: auto-default L0-V1 for Arc B70 oneMKL & native GPU GGUF/safetensors loading on Metal/SYCL/HIP 2026-11-22 14:24:41 +01:00
Niko1221 1f5f53e140 inkling2: add standalone strata-inkling v1.1 engine, 1..64 batching, vision, and serving
Add .strata v1.1 reader/codecs (SF4, MX8, paired 2-row S_K, vram_load_order), standalone strata-inkling shape-engine binary with 1..64 continuous slot batching (FP16/FP8 paged SWA-1024 + Global KV, compact ShortConv pool, DSpark speculative verify with exact per-step ShortConv rollback), 23-layer Vision ViT shard support, o200k tokenizer + ignore_merges, Jinja generation tag extension, InklingOutputParser, and StrataEngine parallel=64 integration.
2026-11-21 20:27:58 +01:00
Niko1221 4dc362978a [Quant] Add GPU decode_sk_torch (0.5ms/expert), layer-batched Scale-QAT/eval, and cached BF16 eval refs 2026-11-19 00:52:05 +01:00
Niko1221 a2b5af0b6d [Engine] Add native Hy4-Flash .strata v1.0 codecs, reader, 4-module Engram, and tools/squant pipeline 2026-11-19 00:38:14 +01:00
Niko1221 4058aa782b Layout move for 0.2.16: the top level becomes app/, engine/, terminal/, docs/, tools/ and .github/
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
  changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
  Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
  repository paths inside tests.

engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.

No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
2026-11-17 13:19:21 +01:00