Commit Graph
351 Commits
Author SHA1 Message Date
Niko1221 9ac2b10705 Merge commit '1f18a1386f' into f-0226-q4-kv
# Conflicts:
#	engine/src/q4lite/q4_engine.hpp
#	engine/src/q4lite/q4_main.cpp
2026-12-04 09:47:51 +01:00
Niko1221 1f18a1386f Merge f-0226-q4-gguf (d0d5d573b7): packaging of the strata-q4-lite shape, gguf_reader compress_ratios made explicit
450e9c7071: build_cuda_windows.py takes SHAPE=<geometry> (additive, off without SHAPE). 355b7629c5: gguf_reader.hpp accepts the compress_ratios list "longer by the MTP layers" only where the compiled
shape has n_mtp_layers > 0 (`kMtpTail ? n_layers + n_mtp : n_layers`; behaviour was already equal, now it is explicit). d0d5d573b7: with SHAPE=q4_lite, build_cuda_linux.sh and build_cuda_windows.py
also build engine/src/q4lite, check `strata-q4-lite --version`, and ship it as the second program of the strata-q4-lite component; Linux shape builds get the RUNPATH $ORIGIN flags elf_check.py needs.
2026-12-04 09:46:54 +01:00
Niko1221 8d3f6e511c Merge f-0226-q4-prefill (c42156a88e) into f-0226-q4-hip 2026-12-04 09:33:32 +01:00
Niko1221 355b7629c5 gguf_reader: the compress_ratios "list longer by the MTP layers" is accepted only where the compiled shape has an MTP block
read_geometry accepted a compress_ratios list one entry per in-file MTP layer
longer than block_count. The accepted length is now n_layers + n_mtp_layers only
when the compiled geometry has n_mtp_layers > 0 (q4_lite); every other shape
accepts exactly one entry per layer, as before.
2026-12-04 09:28:54 +01:00
Niko1221 7e94c3e0c7 KV fp8: compiled only where STRATA_KV_FP8 is defined (every geometry except the default flash_next)
cmake/strata_geometry.cmake defines STRATA_KV_FP8 for the non-default geometries.  Without it: the
QsaAttnPools::fp8 member does not exist, kv_fp8_enabled() is constexpr false, the extra append / gather
kernel parameters and the mode-5 prompt-attention launch are preprocessed away, so the Flash-Next
kernels and their parameter lists are the text they were.  --kv fp8 on such an engine is refused with a
message.  strata-q4-lite and the q4_lite `strata` build have the format.
2026-12-04 08:44:31 +01:00
Niko1221 b0c4b5deb9 Merge int-0226 (6795dc829a) into the Loop branch 2026-12-04 08:38:00 +01:00
Niko1221 82131a2c8d Merge branch 'f-0226-q4-core' into f-0226-q4-mtp
# Conflicts:
#	engine/src/q4lite/CMakeLists.txt
2026-12-04 08:32:20 +01:00
Niko1221 5c5b93a0b2 KV cache: --kv fp8 (E4M3 K and V, int8 pool layout, one fp16 scale per 64 values)
Additive and guarded: QsaAttnPools::fp8 and the process-wide kv_set_fp8() default to false, so every
existing kernel keeps its arithmetic.  New header kernels/kv_fp8.hpp (integer/float E4M3 conversion,
no cuda_fp8.h, so the same code runs on CUDA of every architecture and on HIP).

- kv_q8.cu: append (scale amax/448, E4M3 code) and gather read the switch.
- prefill/kernels.cu: the prompt path's kv_append kernel takes it as a parameter.
- qsa_decode_attn.cu: load8_q8 and the three V dequant sites decode E4M3 when pools.fp8.
- qsa_prompt_attn.cu: KV_MODE 5 = mode 0's fp16 shared-memory layout filled from E4M3 x scale at the
  gather; the int8 tensor-core kernels, split decode and the HIP int8 wmma are skipped for fp8.
- qsa_pattn.cu: not used for fp8 (the usual path).
- conversation_snapshot.cpp: snapshot format +32 for fp8 (an INT8 state never restores an FP8 image).
- generate.cpp: --kv fp8 (also sets the INT8 pool switch), help text.
2026-12-04 08:30:42 +01:00
Niko1221 1b0e6a2ba5 loop: the looped-core code is compiled only into the q4_lite build (STRATA_WITH_LOOP)
Every hunk that #7673 and the Loop lane added to the shared engine sources (verify, prefill, session, generate, conversation
cache / spill / snapshot / file / state, shared_expert, the Metal stub list) is wrapped in
#ifdef STRATA_WITH_LOOP <new> #else <old> #endif, so a build without the macro compiles exactly the text f-0226-q4-gguf
c3fefe0caa had (checked mechanically: the macro-off text of every file equals c3fefe0caa, the macro-on text equals the
unguarded file). cmake/strata_geometry.cmake defines STRATA_WITH_LOOP for -DSTRATA_GEOMETRY=q4_lite only; loop_adapter.cu,
its cuBLAS link, loop_adapter_test and the stub sources are added only then. Flash-Next, Qwen3.6, Ling, Hy4, Inkling, the
Metal and the SYCL builds are unchanged. Not guarded: the hip_compat cublasSgemm alias (a macro nobody expands), the Python
server flags (inert without --loop-adapter), docs.
2026-12-04 08:16:16 +01:00
Niko1221 27adf14a15 Merge f-0226-q4-loop (59d682c535): the Qwen4 Loop (2 steps) on the qwen4exp engine, CUDA, opt-in
The owner's Qwen4-35B-A3B-Loop.safetensors (strata_dual_coda_loop_v1) as an opt-in loop in the qwen4exp engine at q4_lite: --loop-adapter FILE --loop-passes 2|3 --loop-coda universal|compact. Default off; without
--loop-adapter no loop code runs. The math is pinned to the owner's trainer (03_train_dual_coda_loop.py). Scope: this Loop runs on the qwen4exp engine (the Unsloth GGUF / UD-Q4_K_XL path) with CUDA only; the owner's
.strata builds run on the standalone strata-q4-lite host, which has no Loop yet; Metal and HIP Loop are separate branches. History: the community PR #7673 (Dave3991 / Alexey Fateev, CUDA) with the contributors'
commits kept, the loader and user_args (--loop-coda is a kept user flag), the Q4-GGUF merge and the clamp.
2026-12-04 08:12:00 +01:00
Niko1221 2ca0a5a27a q4lite: MTP drafter (Qwen4-35B-A3B-MTP.strata) and greedy speculative decoding
q4_mtp.{hpp,cu}: loader (BF16 trunk widened to fp32, the 256 routed experts through the
KEXP kernels with the sidecar's own Section 3/4), the one-layer drafter (own KV cache and
indexer state through q4_attn), K = 1..3 draft chain, spec_generate_greedy.
Engine: forward() argmax_out, forward_spec / spec_commit (mixer rollback, PLE conv history
and context snapshot), streams_dev(), stream().  CLI: --mtp, --spec K, --prompts.
2026-12-04 08:10:25 +01:00
Niko1221 12561dbcb3 Merge f-0226-q4-core (6420ce855c): strata-q4-lite, the Qwen4-35B-A3B engine for the owner's .strata quants (Compact / Balanced / Ultra)
New standalone engine strata-q4-lite (shape component strata-q4-lite; engine/src/q4lite, engine/include/strata/q4lite, engine/tests/q4lite): the expert kernels (f-0226-q4-kexp lineage) and the attention mixers (f-0226-q4-attn).
Not built by default (its own CMake; engine/CMakeLists.txt, src/core and src/ling32 are untouched). The shared edits are additive and under a new switch: include/strata/kernels/gdn_pairing.hpp (new) and the
GDN kernels (fused_gdn.cu, gdn.cu, native_gdn.cu, verify_kernels.cu, prefill/gdn_chunk.cu) use STRATA_GDN_QH(head, h_k, h_v), which expands to the expression they always had (head % h_k) unless
-DSTRATA_GDN_PAIR_GROUPED is defined (Qwen4: the HF checkpoint order, repeat_interleave), so the default device code is unchanged. Compact and Balanced reproduce the owner's quant-vs-BF16 numbers on the golden (see the merge log).
2026-12-04 07:40:14 +01:00
Niko1221 17a7b174f6 Merge f-0226-q4-gguf (c3fefe0caa): the Q4-GGUF guard commit 2026-12-04 07:06:17 +01:00
Niko1221 bfeaf60291 merge f-0226-q4-core (lead's engine, model, mixers interface) 2026-12-04 07:05:20 +01:00
Niko1221 781d9ab621 loop: strata_dual_coda_loop_v1 (the owner's Qwen4-35B-A3B-Loop.safetensors) on the looped-core mechanics of #7673
The format is read from the safetensors metadata (core 12..27, coda 28..39) and its math follows the owner's trainer
(03_train_dual_coda_loop.py): attn / mlp LoRAs (hidden -> 128 -> hidden, scale 0.25) added to the block outputs, the
cross-pass mixer R = x + sigmoid(gate) * up(silu(down(rms(m_prev - x) * (1 + norm)))), the entry of every extra pass is
the core's input state, and the coda LoRA delta is scaled by cd_omega[layer] from the first </think> token on.

New: LoopTarget::kAttn / kMlp, loop_lora_add_gated, loop_adapter_set_coda, --loop-coda universal|compact, a sticky
</think> flag (kLoopStickyClose) in the existing per-token flag vector. Without a loop adapter nothing runs.
2026-12-04 07:01:39 +01:00
Niko1221 c3fefe0caa qwen4exp: the in-file MTP tail and the qsa_pattn scalar path only exist where the compiled shape needs them
PR 7774 changed shared code for every geometry: the in-file MTP layer-count
check was dropped from compiled_geometry_mismatch, nextn_predict_layers was
read and subtracted from block_count for every qwen4exp file, and the
qsa_pattn float4 weight loads were replaced by a scalar loop.

Now those paths depend on the compiled geometry: a shape with n_mtp_layers > 0
(q4_lite) reads the key, subtracts the tail and does not compare the MTP
count; every other shape (Flash-Next and the other q4 shapes) keeps the code
it had, including the three float4 loads at G = 12 and the old error text.
2026-12-04 06:56:09 +01:00
Niko1221 613f42346e Merge refs/pr/7673 (e3f62bfe9c, Dave3991 / Alexey Fateev): looped recurrent-core adapter mechanics for the qwen4exp engine (CUDA) 2026-12-04 06:54:18 +01:00
Niko1221 a4f5be2c0d Merge refs/pr/7774 (22a9714c9b, saatvik-viniak): Qwen4-35B-A3B on the qwen4exp engine at q4_lite
Community PR taken with the contributor's commits and authorship unchanged:
the 41-block file (trunk = block_count - nextn_predict_layers), the GGUF
trunk-view splitter, the qwen4 pre-tokenizer, qsa_pattn G from the geometry,
the MTP sidecar runtime, and the docs/bench results.
2026-12-04 06:51:48 +01:00
Niko1221 a20c3b9738 GDN kernels: STRATA_GDN_PAIR_GROUPED switch for the q/k head pairing (additive)
New include/strata/kernels/gdn_pairing.hpp: STRATA_GDN_QH(head, h_k, h_v) is head % h_k (the expression every kernel had)
unless -DSTRATA_GDN_PAIR_GROUPED, which gives head / (h_v / h_k), the HF repeat_interleave order of Qwen4.
Used at the pairing sites of fused_gdn.cu, native_gdn.cu, gdn.cu, verify_kernels.cu and prefill/gdn_chunk.cu.
Default builds are unchanged.
2026-12-04 06:51:04 +01:00
Niko1221 34973822be q4lite: Qwen4-35B-A3B .strata manifest/file reader, GPU model loader, glue kernels, PLE hash
New standalone engine directory engine/src/q4lite (Ling-family, no change to src/ling32 or src/core):
manifest parser, Q4File (reader + expert directory check), GpuModel (trunk arena + resident experts),
hyper-connection / router / shared-expert merge / PLE kernels, PLE n-gram hash.
2026-12-04 06:48:42 +01:00
Niko1221 87a7e7ec7d Inkling CUDA: the hybrid lane probe keeps the CPU pool under the container quota and decides on the best round with a 0.95 margin; the FP8 one-token step uses the tensor-core attention by default from 64K
1. Cold-expert lane probe (hybrid starts). A rented RTX 3070 8 GB (SQ-20, container CPU quota of 15.36 CPUs on 32 visible CPUs) showed the 0.2.25 rule on the edge: CPU lane
67 to 72 ms against 79 ms for the copy-in lane (ratio 0.87 to 0.91 against the 0.9 line); one start in eight crossed it (COPY lane, 11.7 tok/s instead of 16), and the 16 spinning
worker threads were more than the quota allowed. Now: the worker pool of the CPU lane stays below the container's CPU quota (one CPU left for the main thread; no quota = no change;
STRATA_INK_THREADS still wins); the rule compares the best of three rounds of each lane and gives a noisy lane (slowest round 25 % over its best) three more rounds; the CPU lane
is kept below 0.95 of the copy-in lane's time (kCpuClearlyFaster, was 0.9). The log has one more line with all rounds. Measured (8 alternating fresh starts each, same card, SQ-20 hybrid,
drafter off): 0.2.25 7 CPU lane at 15.6-16.3 tok/s and 1 COPY lane at 11.7; this change 8 of 8 CPU lane, CPU reading 57.5-63 ms, 17.8-18.7 tok/s (+13 %). RTX 5070 (owner PC, SQ-10):
6 of 6 copy-in lane quiet and 6 of 6 with 12 busy background processes, 71-74 tok/s, unchanged. ink_cold_lane_test covers the 5070, 3070, A4000 and 145 ms cases.

2. Tensor-core attention default (worker B's numbers, PR2 of 0.2.25 left it opt-in). The one-token decode step (no tree, no chain, M = 1) of an FP8 K/V whose capacity is at least
65536 positions runs through ink_attn_tc.cuh on a card whose set does not carry TC_ATTN, when it is not COMPACT, one slot, sm_80 or newer, and no drafter is loaded (a drafter's
12-row verify lost 4 to 6 %). K8V8 / K8V4 stay opt-in (STRATA_INK_TC_ATTN_KV8=1), a card whose set carries TC_ATTN is unchanged, the memory plan only grows by the scratch the part
already needs. STRATA_INK_TC_ATTN_DEFAULT=0 takes the rule out (register entry, docs). Measured on the RTX 5070 (old non-COMPACT plan, SQ-10, FP8, same exe rule on/off and the
0.2.25 exe, alternating): 128K decode 45.3 / 45.2 against 41.5 / 41.5 tok/s (+9 %), 32K 59.6 / 59.4 against 59.7 / 59.5 (no change below the floor), greedy tokens identical to
0.2.25 on prose, doc32k and doc128k (2 of 2 rounds). CTest gates on the 5070: default, kv8, minctx and the new rule gate (FP8 only, M = 1 only, nothing below 65536 positions).
2026-12-04 04:10:29 +01:00
Saatvik Viniak 8edd104839 qwen4exp: read nextn_predict_layers in the artifact guard
read_geometry took block_count at face value, so Qwen4-35B-A3B's 41 blocks (40 trunk + the in-file MTP block)
were compared against the compiled 40 and refused - including when the same file was only the --ple-gguf source.
Derive the trunk (block_count - nextn_predict_layers), and let compress_ratios list either the trunk or the
blocks.  The kernels never see the MTP tail.
2026-12-03 21:05:21 -06:00
Saatvik Viniak 3e862df6e8 qwen4exp: an in-file MTP block is file layout, not a kernel shape
compiled_geometry_mismatch compared n_mtp_layers, so a q4_lite build (declaring the
published file's blk.40) refused the 40-block trunk view and vice versa.  The kernels
do not see the MTP block; the trunk is what they run.  Drop the comparison (as with
n_expert/top-k, which are runtime values).
2026-12-03 20:59:27 -06:00
Saatvik Viniak 89561aaaf1 qwen4exp: support Qwen4-35B-A3B (q4_lite) in the engine and packer
The published Unsloth Q4_K_M GGUF is the same architecture as Flash-Next but
a new shape: 40 trunk layers (plus an in-file MTP block, nextn_predict_layers=1),
hidden 2048, 16:2 query/KV heads, 30 GDN + 10 QSA layers, 256 experts top-8,
ff 512, hyper-connection low rank 256, and 1M native context.

- q4_lite: declare the in-file MTP layer (n_mtp_layers=1) so the geometry reads
  block_count 41 as 40 trunk layers.
- geometry_from_gguf: read nextn_predict_layers for every family.  Flash-Next
  files do not carry the key, so they keep n_mtp_layers=0.
- qsa_pattn: derive G (query heads per KV head) from the compiled geometry
  instead of pinning 12, and build the per-cell weight vector without reading
  past a shorter row (G=8 on this shape).
- iq_pack: split the official GGUF's merged tensors (attn_qkv_gate,
  ssm_beta_alpha, hc_*_down_inject) into the engine's layout, in llama.cpp's
  order (src/models/qwen4exp.cpp); exclude the in-file MTP block from
  native_experts.txt (the trunk is 40 routing layers).
- strata_tokenizer: recognize tokenizer.ggml.pre 'qwen4' - qwen35's split rule
  with ignore_merges on, as llama.cpp reads it.
2026-12-03 20:51:41 -06:00
Niko1221 8c8ed5cd0b scratch: + KDA scan 2026-12-03 03:59:50 +01:00
Niko1221 a521ae94e0 ling32 sycl: per-kernel profiling build (-DSTRATA_SY_PROFILE: sy::launch records every kernel by caller:line, totals printed at exit; compiled out by default) 2026-12-03 03:39:58 +01:00
Niko1221 64e49101d5 Merge f-ling32-int (de6f7bb0d4): k=2 prefetch default for the tier B pool layout 2026-12-03 02:47:47 +01:00
Niko1221 de6f7bb0d4 ling32 tier B pool layout: k=2 prefetch predictor by default
The pool layout (every card byte is a dynamic slot, no hot prefix) now plans lookahead_k = 2 instead of 4. The main program then loads and evaluates only the k=2 predictor (lookahead_ks bit 0) and the tier store prefetches from the k=2 list. The old layout (--tier-pool off) and tier C keep k=4.

Measured (quiet host, ABAB, plain decode, same job file, output ids identical on all 22 jobs against the k=4 arm and against plain):
- RTX 3090 (PCIe 4.0): k=2 54.3 against k=4 53.0 tok/s, +2.0 %.
- RTX 5090 (PCIe 5.0, 47 GB/s): k=2 110.2 / 110.3 / 110.1 against k=4 107.5 / 107.5 tok/s, +2.6 %.
- Recall of the true top-8 experts: k=2 64.6 %, k=4 54.0 %; the k=2 lead is 0.8 ms against 1.7 ms for k=4, and the better recall wins.

Env STRATA_L32_LA_KS and STRATA_L32_PF_K still override the choice. The tier planner test expects lookahead_k 2 for the pool layout.
2026-12-03 02:41:04 +01:00
Niko1221 3bdcefe4d2 Merge f-qfn-b70 (aa7379dac8) into int-0225
QFN on B70: Windows build of engine/sycl (icx, no oneMKL, own XMX dense GEMM), Windows free-RAM fix, Intel --spec 2 default for one Arc B-series card without a draft layer, opt-in --vram-reserve-floor-mib. Not taken: 1109ad7b3e (ESIMD GEMM on by default, not gated). Conflicts: docs/SETTINGS.md and terminal/data/settings-register.json (generated): three-way merge of names and hand-kept fields from both sides, regenerated (check clean, no empty status), docs/SETTINGS.md regenerated with --docs. Open gate for QFN-B70: B70 token-identity of the --spec 2 default against spec off on their 7-prompt set; if it fails they send a one-line commit reverting the default.
2026-12-03 02:14:43 +01:00
Niko1221 633631b7db Merge f-ling32-sycl (920badbe8a): SYCL port of prune_experts so strata-ling32 links on Intel 2026-12-03 02:11:30 +01:00
Niko1221 577f851f00 Merge f-ling32-prod (7c95c85fce) into int-0225
Ling on Intel ships (SYCL_ENGINE_SHIPPED = True), with L32-SYCL's f-ling32-sycl efddd28358 and L32-CUDA's f-ling32-int ed115c6300 / 78a15b86bd (via f-ling32-prod); GUI-LING's map-experts fix b9e7b3e2b1 arrives as the same change (2f6b1cc5b8), merged cleanly. Conflicts: terminal/data/settings-register.json and docs/SETTINGS.md: three-way merge of names and hand-kept fields from both sides, regenerated with tools/settings_register.py (check clean, no empty status), docs/SETTINGS.md regenerated with --docs.
2026-12-03 01:33:39 +01:00
Niko1221 ed115c6300 Merge commit 'efddd28358' into f-ling32-int 2026-12-03 01:07:58 +01:00
Niko1221 bc07468544 Merge commit 'efddd28358' into f-ling32-prod 2026-12-03 01:07:31 +01:00
Niko1221 ba2ed8d2a5 ling32 sycl tier: cudaFree lowers the shim's free-memory estimate, int's lazy-KV and MTP-auto regressions in the SYCL ctest block, tier suite script
- sycl_compat: every cudaMalloc block's size is tracked so that cudaFree (the tier store's lazy-KV give-back) raises the cudaMemGetInfo fallback (no driver query on Windows) again
- CMake: ling32_mtp_auto_regress and ling32_kv_grow_regress in the SYCL block
- l32sy_tiersuite.sh: build, 11 tier shapes on the narrow and wide fixture, the tier regressions, every spec-span leg in one job
2026-12-03 00:05:51 +01:00
Niko1221 d31625ca6f Merge f-ling32-int (217f218bb0) into int-0225: HIP stub for volta_extra_smem, corrected --mtp-auto rule 2026-12-02 23:43:48 +01:00
Niko1221 37071f3596 Merge f-ling32-prod (b2cd949401) into int-0225
f-ling32-prod b2cd949401 carries eight Python files saved with CRLF on every line (terminal/setup.py, strata_control/ling32_fit.py, serve/test_ling32_mtp.py, tests/terminal/test_ling32_fit.py, test_ling32_launch.py, tools/test_setup_ling32.py, tools/packaging/collect_libs.py, tools/packaging/ling32/build_windows.py; base and int-0225 are LF), which makes terminal/setup.py one whole-file conflict. Resolved by converting their side to LF before the three-way merge (terminal/setup.py merged without conflict: +57 lines) and converting the other seven files to LF; the Intel oneAPI licence texts and the Metal files keep their upstream CRLF. Second conflict: terminal/data/settings-register.json, three-way merge of names and hand-kept fields, regenerated (check clean, no empty status), docs/SETTINGS.md regenerated.
2026-12-02 23:41:55 +01:00
Niko1221 81e5e72729 ling32 --mtp-auto: with the pool size known the pool decides (>= 4500 experts on the card), the link only has to clear a 16 GB/s floor
The first version (link >= 32 GB/s AND >= 4500 card experts) would switch MTP off on the AMD R9700 (about 5958 slots, 24-26 GB/s
link), where it was measured winning: L32-PREFILL 4K decode 38.6 against 33.8 plain, 32K 36.3 against 32.8; L32-HIP short set about
58 with K=1.  All measured cards agree with the pool size alone: RTX 5090 5466 slots +4..11 %, R9700 5958 slots +11..14 %, RTX 5070 Ti
2413 slots -0.7 %, RTX 3090 / 4090 about 4000 slots never (forced K=1: 1.83 tokens per verify at 48.0 tok/s against 49.0 plain).  With the
pool size known the rule is: pool >= 4500 and link >= 16 GB/s (PCIe 3.0 x16 measures about 12 GB/s and has no measurement with a big
pool); without it (-1) the old link-only rule (>= 32 GB/s) stays.  Tests: planner table (R9700, 3090, PCIe 3.0, unmeasured link rows),
ling32_mtp_auto_regress legs (3090-like small pool not loaded, R9700-like big pool loaded, 12 GB/s not loaded, 46 GB/s both ways).
z440 CTest planner + mtp_auto pass.  To be A/B-checked on the R9700 by L32-HIP (auto against forced-on against plain, 4K and 32K).
2026-12-02 23:35:57 +01:00
Niko1221 875d0ec86a ling32 --mtp-auto: tier B also needs at least 4500 experts on the card (pool slots + card prefix); STRATA_L32_MTP_AUTO_MIN_CARD is the test hook
A verify batch of 2 tokens needs the experts of both tokens and consecutive tokens share only about 19 % of
their expert uses, so with an LRU pool the misses of a 2-row verify are 2.0x those of one row (cache simulation
on 2810 real decode tokens, L32-MID2): 1.8 tokens per verify then run at 0.90x on a link-bound card.  Measured:
RTX 5090 (PCIe 5.0, 5466 slots) +4..11 %; RTX 5070 Ti 16 GB (PCIe 5.0, 2413 slots) -0.7 %, 12 GB emulation
(1485 slots) -2.4 %; RTX 4090 and 3090 (PCIe 4.0, about 4000 slots): forced MTP never gains (K=1: 1.83 tokens per
verify at 48.0 tok/s against 49.0 plain; the adaptive controller runs plain).  No measurement between 2413 and
5466 slots on a fast link: 4500 (22 % of the 20480 routed experts) is the conservative side of the cut.
mtp_auto_pays takes the card expert count (-1: unknown, rule unchanged); tier A and unified memory ignore it.
Tests: ling32_tier_planner_test table, ling32_mtp_auto_regress (pool cut off / small pool legs); z440 CTest 19/19 apart
from this leg's first version (the fixture's pool holds many fixture experts: the leg moves the cut by hand).
2026-12-02 23:33:07 +01:00
Niko1221 86e1ad5d51 Merge f-ink-evmm (4b6c028fb9) into int-0225
Only conflict: terminal/data/settings-register.json. Three-way merge of names and hand-kept fields from both sides (the 8 new STRATA_INK_* names keep their hand fields from INK-EVMM's commit), regenerated with tools/settings_register.py (check clean, no empty status), docs/SETTINGS.md regenerated with --docs.
2026-12-02 22:59:44 +01:00
Niko1221 6509cb7232 Merge branch 'f-ling32-int' into f-ling32-sycl
# Conflicts:
#	engine/src/ling32/ling32_tier_store.cu
2026-12-02 22:56:41 +01:00
Niko1221 cdbe2c27e7 Inkling elastic experts: a live VRAM pressure guard and the launcher fit estimate for the elastic expert pool
Guard (strata/platform/vram_guard.hpp, src/platform/vram_guard.cpp, vram_guard_driver.hpp): tells the runner the headroom of one card and, with hysteresis
(low < target < high, dwell, quiet time after pressure, step cap), when to shed experts (Shed N) and when it may take them back (MayReclaim N). poll() is one clock
read until the period has passed; spare_for_growth() samples once per call. Windows: the adapter of the device's LUID through dxgi.dll and the adapter-wide
"GPU Adapter Memory" counters through pdh.dll (both loaded at run time, no link dependency); on WDDM the driver free and the DXGI budget are the process's own view and do
not follow other programs, the adapter counters do. Linux and TCC: the driver query. Integrated GPUs on shared memory leave the guard off. Linked into strata_inkling_core.
Tests: vram_guard_test (CTest, no GPU), vram_guard_live (real card, a second process allocating in steps).

Launcher fit (terminal/strata_control/inkling_fit.py): an engine that reports "elastic_experts": true in its BUILD.json is planned with the elastic pool (K/V grows in the
experts' pool down to STRATA_INK_ELASTIC_MIN_EXP_MIB, 1536 MiB; no host K/V; how much of the pool the context lent). Any other engine is planned as before; 128K stays the default context.
2026-12-02 21:47:43 +01:00
Niko1221 993666eef9 Inkling CUDA: the elastic expert pool for hybrid loads (the adaptive tier's slot pool lives in virtual memory) and router heat for the pool that gives experts up
Hybrid loads (the adaptive tier is on: part of the experts in slots on the card, every expert with a host copy): the slot pool is placed in the elastic
pool's virtual memory when STRATA_INK_ELASTIC_EXPERTS is on. When the global K/V needs more than the card has free, the slots at the top of the pool are
switched off (InkExpertPolicy::kill_slot: the expert goes back to its host copy, its table entry is rewritten, no round puts anything in the slot), the card
is synchronised and the chunks go to the K/V; when a conversation ends the K/V returns to its start size and the chunks map behind the pool again
(revive_slot: the slots come back empty and the next rounds fill them). No device-to-host copy is needed: the host copies exist already.
The K/V sizing branch of the runner takes this case too (the whole K/V stays on the card, no mapped host K/V).

Router heat for the d_sec4 pool (all-resident loads): k_ink_heat_add, one 128-thread block per decode / verify MoE visit after the router (prefill chunks,
M >= 16, are skipped), keeps a decayed pick count per expert on the card (a token decays a layer's row by 0.5^(1/32) in all, so the looped core is not
decayed three times). The experts that leave first are chosen by those counts (rate in picks per token, which is the cold hits per token an expert would
cost), the pack's order until about 128 tokens have been seen. STRATA_INK_ELASTIC_HEAT=0 keeps the order of the pack. The kit's tracker was never fed and
its score mixed a prior of 0.35..1 with a rate of 0..0.06; the score now has one unit.

InkElasticSec4Pool gets unmap_tail / map_tail for callers that manage the pool's contents themselves. Tests: ink_elastic_sec4_test (tail moves, set_recent),
ink_expert_policy_test (kill / revive).
2026-12-02 21:47:40 +01:00
Niko1221 7fc405bcc4 Merge f-ling32-prod (b2360bb3d3) into int-0225 2026-12-02 21:40:08 +01:00
Niko1221 52954a6a09 Inkling CUDA: elastic expert pool, the global K/V grows on the card and takes 2 MiB chunks from the coldest experts instead of spilling to host RAM
Port of PR 1 of the owner's Inkling 2 Mini elastic VMM kit onto int-0225, reworked after review (see notes-ink-evmm.md).

When every expert fits at load (the non-COMPACT all-resident branch), d_sec4 is now one VmmRange packed in descending heat order (the 3x-looped
core layers first, the 1x prelude / coda layers last). The K/V no longer reserves its full size up front: the planner keeps the whole K/V on the
card (kv_host_ctx = 0) when the free memory plus what the pool may give up holds max_ctx, and the K/V grows through its own virtual memory. When
it needs more than the card has free (256 MiB floor kept), whole chunks from the tail of d_sec4 go to it directly (no cuMemRelease / cuMemCreate).

An expert that leaves the card is copied device-to-host into a pinned arena first, its table entry becomes tier 2, and the hybrid engine (not
started until then) serves it. The lane is the exact one (the card copies the expert in and computes it with its own kernels: same bits
wherever the expert lives), staged inside the CUDA graph for decode; STRATA_INK_EXACT=0 forces the CPU lane. What arming needs on the card
(prefill staging pair, staging slots) is set aside at load and handed back at the first eviction. When the conversation ends (reset_slot) with
experts off the card, the K/V returns to its start size and the freed chunks map behind the experts, which are copied back.

Switches: STRATA_INK_ELASTIC_EXPERTS=0 (one cudaMalloc as before), STRATA_INK_ELASTIC_MIN_EXP_MIB (floor of resident experts, default 1536).
Changes to the kit: init_vmm closed the file view it was given (removed with the view: the host copy is a D2H copy now, valid for any layout);
the hybrid engine is armed lazily with its VRAM reserved at load; resident experts keep host_meta.body null (the prefill streamer treats a
non-null body as cold); the K/V sizing branch is guarded for COMPACT / ls / ep2; the D2D swap uses the prefill staging buffer, not d_w_scratch.

Tests: engine CTest ink_elastic_sec4_test (host, simulated chunks; asserts are real checks, not assert()).
2026-12-02 20:57:41 +01:00
Niko1221 fe96b81b73 ling32: --mtp-auto loads the MTP sidecar only where it measurably pays; the engine measures the host-to-device link at start
Measured (2026-12-02, L32-TABLE / L32-MID / L32-SMALL, real Ling-3.2-Air, plain vs MTP, greedy): the drafter pays on an RTX 5090 (PCIe 5.0 x16: +4..11 % decode,
115.8 tok/s with it at ctx 131072 on our 5090 box) and where everything is resident or memory is unified; on tiered cards over PCIe 4.0 x16 or narrower
(3090: 1.00 tokens per verify, prefill 947 vs 1042 tok/s at 4K, 89 fewer pool slots; 4090: acceptance 0; 5080 16 GB -3.4 %; 5060 Ti -3 %) it never does, yet
the sidecar still costs prefill and pool slots.

--mtp-auto FILE (with --spec mtp --spec-adaptive; --mtp FILE stays the forced 'on'): after the memory plan, tier A / unified memory: loaded; tier C: not loaded;
tier B: one pinned 256 MiB host-to-device copy (3 repeats, median) and loaded only from 32 GB/s (kMtpAutoMinLinkGbps, between PCIe 4.0 x16 = 24.4 GB/s measured
and PCIe 5.0 x16 = 45+; 53.5 GB/s measured on the 5090 box); an unmeasured link: not loaded.  When it is not loaded the sidecar, --spec mtp and the speculative loop
are dropped and the plan is made again without the sidecar's bytes.  The rule is the pure function mtp_auto_pays (planner header, rows in its comment), table-tested in
ling32_tier_planner_test; ling32_mtp_auto_regress runs the wiring on the wide fixture (link by STRATA_L32_H2D_GBPS: 24.4 -> not loaded and plain ids, 46 -> loaded and
speculation on, --mtp forced -> loaded, tier A -> loaded; ids equal to the plain run in every leg).

Also: the measured link is printed ('tier store: host-to-device link moved N GB/s (pinned 256 MiB copies, median of 3)') whenever a tier store is planned, the serve INFO line
carries h2d_gbps=N (before images=), and --info FILE --kv says mtp_auto=1 so the launcher can tell old engines apart.
2026-12-02 20:49:13 +01:00
Niko1221 63e2d26617 Merge f-ling32-prod (ba1e850fd3) into int-0225
Only conflict: terminal/data/settings-register.json. Three-way merge of the names and the hand-kept fields from both sides (the STRATA_L32_SPEC_SPAN note changed on both: took f-ling32-prod's newer text), launch_settings from f-ling32-prod, then regenerated with tools/settings_register.py (check clean, no empty status) and docs/SETTINGS.md regenerated with --docs.
2026-12-02 20:39:18 +01:00
Niko1221 7f3db446e7 ling32 sycl tier: chunked hot/warm prefix and dynamic slots for the per-allocation limit, pinned host alloc alignment, pageable-copy staging, store driver and memory probe
- tier store (SYCL build only): hot prefix, warm prefix and dynamic slots are lists of allocations cut at slab ends (ChunkSet / ChunkPtr), split reads and copies at chunk borders; pinned refusal falls back to one ordinary-pages block
- sycl_compat: cudaHostAlloc via aligned_alloc_host (64 KiB), staged enqueue copy from small pageable sources, opt-in relaxed allocation limits switch
- ling32_sy_tier_check: drives the store without engine kernels, compares every table slab on the host and with a SYCL kernel
- l32sy_probe.cpp, l32sy_tierbox.sh: memory / copy probe and tier check box script
2026-12-02 19:50:22 +01:00
Niko1221 f1780b1e5a ling32 sycl: argmax, Windows build fixes (NOMINMAX), exact u/255 table, prefer Level Zero devices, offload prec div/sqrt flags 2026-12-02 19:32:00 +01:00
Niko1221 1ad43851dd ling32: lazy latent KV reservation in tier B / C: the cache grows with the conversation and the pool gives slots back
The planner counted the latent KV for the whole context up front (ctx * MLA layers * 576 * 4: 2.1 GiB at the
128K default), which cost dynamic expert slots on every card in tier B / C (L32-MID, 16 GB RTX 5080: 1671 slots /
38.1 tok/s at ctx 131072 against 2104 / 41.2 at ctx 8192; 4090: -4 %; 5090: 4875 vs 5307 slots, -2 % decode).

Now, with a tier store, the engine starts with min(ctx, 16384) rows per MLA layer (the planner counts only those;
--kv-init N sets it, STRATA_L32_LAZY_KV=0 or --kv-init 0 reserves everything up front as before).  When the
position + chunk + 512 rows of margin reaches the capacity (forward_mm, forward_span, spec_cycle), every cache is
re-allocated at twice the size (clamped to ctx), the rows are copied on the device, the old buffer is freed and the
captured graphs are dropped.  When cudaMalloc fails the tier store gives dynamic slots back (the small pool is
allocated in chunks of 64 slots; the tail chunks are freed, their slots get state 4 and are never picked,
alloc caps follow the live count; ExpertProvider::release_bytes).  Tier A (all resident, CUDA graphs capture the
cache pointers) is planned again with the whole context and keeps the full reservation.

The attention kernels keep receiving max_ctx as their plan bound, so the split plan and therefore the bits do not
depend on the capacity; the same positions hold the same values.  The 512-row margin keeps a tile of over-read
inside the buffer.

Tests: ling32_kv_grow_regress (wide fixture, 1200-token prompt, --kv-init 64, ctx 4000: growth 64 -> 1024 -> 2048;
dump and ids byte-identical to --kv-init 0 in tier B, tier B with a pool chunk freed at every growth step
(STRATA_L32_KV_FORCE_RELEASE=1), tier C and MTP speculation); z440 CTest 18/18, compute-sanitizer memcheck clean on
the growth + release legs (plain and speculative).  Also merged: L32-MID's logits-buffer sizing (cced9a40a1).
2026-12-02 19:07:55 +01:00
Niko1221 7363785241 sycl: a Windows build of the Qwen engine (icx, no oneMKL): own XMX dense prompt GEMM, POSIX and windows.h shims
engine/sycl now configures, compiles and links on Windows with icx (AOT bmg-g31). What changed:
- STRATA_SYCL_NO_ONEMKL (default ON on Windows): the dense prompt GEMM (BF16 and FP16 inputs, FP32 accumulation) is the engine's own
  joint_matrix kernel, src/prefill/xmx_dense_gemm.dp.cpp, instead of dpct::blas::gemm. STRATA_DENSE_XMX=1 takes it in an oneMKL build too
  (A/B). The QSA block-score GEMM falls back to the existing warp / tensor-core kernel without oneMKL. Linux builds are unchanged.
- quant.cmake: icx (IntelLLVM, MSVC frontend) gets the clang-cl AVX-512 flags.
- windows.h macros (OUT, small) undefined where the kernels use the names; memmem shim; CUDA leftovers out of pinned.dp.cpp; the GGUF expert
  reader uses platform/posix_io_compat.hpp (pread by ReadFile on Windows); prefill.cpp creates its cache folder with std::filesystem.
2026-12-02 18:56:27 +01:00