322 Commits
Author SHA1 Message Date
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
Niko1221 cced9a40a1 ling32: the logits buffer holds 32 rows in --genjobs / --serve, not a whole chunk (0.58 GiB more pool on a 1024-token chunk)
The engine allocated chunk x vocab floats of logits (644 MB at chunk 1024) although a chat or serve run asks for the last token of a prompt chunk and at most block + 1 rows of a speculative verify batch. EngineOptions::logits_rows (default 0 = a whole chunk, so the library, the fixture tests and the teacher-forced modes are unchanged) sizes it; strata-ling32 sets 32 for --serve and --genjobs (--logits-rows N overrides, 0 = a whole chunk), and the tier planner's activation estimate follows (TierSizes::logits_rows), so the freed memory becomes expert slots. forward() / forward_span() refuse a request for more rows than the buffer holds, and spec_init refuses a buffer smaller than a verify batch.

RTX 5080 16 GB (tier B, ctx 131072, plain, 5 x 256 greedy): pool 1671 -> 1807 slots (fixed 7.72 -> 7.14 GiB), decode 37.9 / 38.1 -> 39.0 tok/s, greedy ids identical on all 5 prompts.
2026-12-02 18:48:01 +01:00
Niko1221 b325310b6b ling32 sycl: trunk (S_K GEMV, float GEMV, rmsnorm, embed, quantisers), KDA sequential and absorbed MLA kernels; SpecState host half, vision stub, engine switches off what SYCL lacks 2026-12-02 18:41:46 +01:00
Niko1221 951a4af886 Merge f-0225-ink (580852d82f) into int-0225
Conflicts: terminal/tools/strata_mcp.py (default context in the install plan: kept INK-KV's inkling_fit.default_context for Inkling and the ling32 branch from f-ling32-prod), docs/SETTINGS.md (regenerated from the register with tools/settings_register.py --docs; the register merged without a conflict and its check is clean).
2026-12-02 18:35:46 +01:00
Niko1221 580852d82f Inkling CUDA hybrid: the cold-expert lane probe runs three times and keeps the exact lane unless the CPU lane is clearly faster; STRATA_INK_LANE_PROBE_OLD=1 brings the old rule back
The launch probe times the CPU lane and the card's copy-in (exact) lane and keeps the faster one. The old rule kept the CPU lane unless the copy-in lane was 10 % faster (t_card < 0.9 * t_cpu), from one
probe per lane. On the owner's RTX 5070 12 GB (Windows, SQ-10, drafter off, the published 0.2.24 packages) a quiet PC measured CPU 9.0 to 9.5 ms and copy-in 8.6 to 8.8 ms (ratio 0.95): the old rule kept the CPU
lane and every start decoded 65-68 tok/s and 34.5 on a 4K document where the copy-in lane gives 73 and 56.4 (+11 to +64 %); with a busier PC the same card measured 12.0 against 8.6 and chose the copy-in lane,
so two starts can land on different sides of the threshold (that is the only reading of the 9 to 12 % cuda12 / cuda13 gap of NUMBERS-0224 that the data allows: the packages themselves are equal in every forced lane).

- strata/core/ink_cold_lane.hpp: ink_probe_median and ink_cold_lane_exact (the exact lane unless the CPU lane is clearly (10 %) faster: t_cpu < 0.9 * t_card; ties go to the exact lane); unit test
  ink_cold_lane_test (in CMake, no GPU).
- ink_runner.cuh pick_cold_lane: three probes per lane, alternating, the median of each (about 1 s more at start); "(median of 3)" in the line. STRATA_INK_LANE_PROBE_OLD=1: the old rule (one probe per lane).
  Register entry (rollback) and the SETTINGS.md row; docs/INKLING_KV.md (the earlier commit) says what it does.

Gates (decode tok/s prose / chat / code / doc4k, ABAB, 3 rounds, SQ-10 for the 5070, ctx 8192, drafter off):
- owner RTX 5070 (MSVC + CUDA 13.0, sandboxed jobq): new rule picked the copy-in lane in all 3 starts (CPU 9.0-9.2 against copy 8.7): 65.4 -> 73.x / 67.2 -> 73.5 / 68.5 -> 72.9 / 34.4 -> 56.0 against the old rule
  (old exe, same host): chat +9 %, code +6 %, doc4k +63 %; STRATA_INK_LANE_PROBE_OLD=1 on the new exe reproduces the old numbers (65.4 / 67.0 / 68.5 / 34.4).
- z440 RTX A4000, SQ-15 made hybrid with a VRAM ballast (1,977 experts on the card, 1,095 in RAM): CPU lane 31.9 ms against copy-in 42.7: the CPU lane under both rules, identical decode (34.2 / 36.2 / 34.9 / 31.4
  against 34.2 / 36.3 / 34.8 / 31.2): the rule changes nothing where the CPU lane is clearly faster. (Without the ballast SQ-15 fits the A4000 whole: no cold expert, no probe.)
- HIP and SYCL have no such probe (cuda/ink_runner.cuh only): no R9700 / A750 gate applies.
Tests: ink_cold_lane_test and ink_sm120_table_test pass, settings register check passes, MSVC + CUDA 13.0 sm_120 build OK.
2026-12-02 18:35:17 +01:00
Niko1221 32e1a628b6 ling32 sycl: LING32_SYCL build option, CUDA-runtime-on-SYCL compat header, kernel idiom header, aborting launcher stubs 2026-12-02 18:32:25 +01:00
Niko1221 038bf6db6a Merge f-ling32-prod (5df7db6133) into int-0225
Conflicts: tools/packaging/elf_check.py (add/add; f-ling32-prod carries the same file plus archive_problems, took theirs: ours was a strict subset). terminal/data/settings-register.json (many hunks): three-way merge of the names and of the hand-kept fields (status, owner, note, retire_after, retired_in) from both sides, launch_settings from f-ling32-prod, then regenerated with tools/settings_register.py (check clean) and docs/SETTINGS.md regenerated with --docs.
2026-12-02 18:24:11 +01:00
Niko1221 be3e2b07ba Merge f-0225-ink (ddc5a0e06a) into int-0225 2026-12-02 18:03:40 +01:00
Niko1221 3c3d5f1d0b RTX 50 16 GB card that cannot hold every expert (a display holds part of it): COMPACT_HYBRID instead of the old path (PLAN-0225 item 17)
The 16 GB COMPACT set (RTX 5060 Ti row, kSm120SmallFast) runs only when every expert fits next to the compact trunk: 15,534 MiB for SQ-20 v2 + DFlash 2 on a card that has 15,696 MiB free headless
(162 MiB to spare). A card that drives a display has less, the loader's precheck refused COMPACT ("COMPACT refused: not enough free VRAM") and the whole fast set went to the old path: no drafter
(DFlash 2 needs the Q8 unembed screen), 2 to 5 times slower. The 12 GB and 8 GB rows already carry COMPACT_HYBRID (the compact trunk, the experts that fit on the card, the rest in RAM through the
adaptive tier); the 16 GB rows did not (NV-ADA note: with 2..15 slots it let COMPACT start with 3 MiB free).

- ink_sm120_table.hpp: ink_sm120_hybrid_fallback_parts() (the parts of the 12 GB row's set: PACK, PREFILL, PLD, CORE_GRAPH, C64_SPEC out, COMPACT_XCODE + COMPACT_HYBRID in, the KV rule of the hybrid, parts
  named by the person kept), Sm120Decision::forced_off (what STRATA_INK_SM120_<PART>=0 switched off); ink_sm120_table_test covers both.
- ink_sm120_cfg.cuh: sm120_compact_to_hybrid(dev) rebuilds the device's decision with those parts and the 12 GB row's numbers; ink_rtx5060ti_fill() is the 5060 Ti view the loader reads.
- ink_runner.cuh (the loader's COMPACT precheck): when the experts are short, the run is ONE slot, the model is all SF4 / MX8, at least 3 GiB of experts still fit next to the compact trunk, and the person
  did not switch COMPACT_HYBRID off, COMPACT_HYBRID runs (one line says so) instead of the refusal. 2..15 slots keep the refusal (unchanged), headless cards keep the all-VRAM COMPACT (unchanged).

Measured (rented RTX 5060 Ti 16 GB, driver 595, CUDA 13.0, SQ-20 v2, DFlash 2, ctx 8192, 3 rounds, VRAM ballast taken before the first allocation = what a display holds; prose / chat / code / doc4k decode tok/s):
- headless (no ballast): unchanged, 100 / 149 / 259 / 112 (all 3072 experts on the card, COMPACT).
- 800 MiB held: old path 51.4 / 52.3 / 49.0 / 35.1, now 73.7 / 88.7 / 88.9 / 43.4 (+43 / +70 / +81 / +24 %; prompt reading 79-60-48-747 -> 134-114-91-1194 tok/s); 2,200 MiB held (1 round): 49 / 50 / 49 / 32 -> 69 / 90 / 90 / 43.
- 6,000 MiB held (9.7 GiB free): 40.9 / 42.4 / 41.1 / 28.5 -> 45.5 / 58.5 / 54.2 / 36.5; 9,500 MiB held (6.2 GiB free): 28.9 / 28.0 / 27.5 / 21.7 -> 28.8 / 36.5 / 34.7 / 29.2 (never slower).
- --parallel 4 (the refusal stays): starts and answers with 0 and 800 MiB held, e2e 45 and 42 tok/s.
- STRATA_INK_SM120_COMPACT_HYBRID=0 restores the refusal (old path), checked at 800 MiB.
Builds: Linux sm_120 (CUDA 13.0, source = main 03bb4f48ba + this change) on the 5060 Ti; MSVC + CUDA 13.0 sm_120 (jobq owner). Not measured: RTX 5080 / 5070 Ti (their rows are default off), quality of the hybrid path on this card (it is
the 12 GB row's set, FASTQ and KL as measured there), a real display (the ballast imitates the memory it holds, not its compute use).
2026-12-02 15:12:18 +01:00
Niko1221 af34ea0309 CPU expert pool: a worker that sleeps through the prefetch no longer runs it after the host moved on (PLAN-0224 item 35, issue #29 watchdog)
pool_tasks_test stalled on boston (i9-13900K) and sometimes on p1004: "the CPU expert pool stalled after a phase (N-1 of N workers parked)", abort after 60 s; 12 of 12 runs here.
The stall report now shows what was missing before (the pool's own diag(): every worker's state, the host's, the batch counters and mode; the Linux thread table; and, with glibc, a call stack of every pool thread, resolved with addr2line). It showed one worker, always spinning, always inside ExpertPool::prefetch_task.

Cause: prefetch_next() publishes a per-worker batch that nobody waits for ("the next batch of any kind stops it", wait_parked). A worker that slept through that publish still counts as parked, so the host's next wait_parked passed at once, cleared the abort flag and went on. The late worker then woke for the stale prefetch, entered its all-workers barrier (pf_arrive_ < W) with nobody left to arrive and no abort flag set, and spun for ever; the host waited for it to park, and the batch counters of the next phase were disturbed (done_ above the task count).

Fix: every worker records the epoch it last finished (wack_), and while a prefetch is in flight wait_parked also waits until all of them have finished the prefetch's epoch. The abort flag stays set meanwhile, so a late worker leaves the prefetch at its next check. Nothing changes for batches without a prefetch.

pool_tasks_test on boston: before 12 of 12 aborted (60 s); after 10 of 10 passed in 7.8 s.
2026-12-02 13:46:27 +01:00
Niko1221 cd84665c87 Merge origin/main 03bb4f48ba (0.2.24: GUI / Harness, Hy4 GGUF, Inkling) into the Ling integration branch
Conflicted files and how each was resolved:
- engine/include/strata/kernels/mla_latent_attn.hpp, engine/src/kernels/cuda/mla_latent_attn.cu, mla_latent_attn_tc.inc, engine/tests/kernels/mla_latent_attn_bench.cu: both lines carry the same kernel from two histories; the Ling side is a strict superset of main's (checked by diffing the two trees: only main's older versions of lines the Ling side extends), so the Ling side is kept
- terminal/serve/server.py: main's config-arch hint for Inkling (self._shape_inkling) plus the Ling engine fields; the picture check keeps main's gguf_images flag and the Ling in-process reader; set_family knows hy4, inkling2, ling32 and hy4-flash
- terminal/serve/frontend.py: main's dict(_OFF_KWARGS) for the thinking-off case, the Ling thinking-on case kept after it
- terminal/strata_cli/launch/runner.py: main's is_hy4 test (Hy4 GGUF excluded) with the Ling is_ling32 and the widened is_native_strata; model_shape() returns None for a Hy4 GGUF, then the Ling shape; drafting_plan_line() has both the Ling and the Hy4 GGUF lines
- terminal/strata_cli/launch/cmd.py: the Ling --mtp help text and main's --drafting choices (dfly added)
- terminal/tools/strata_tokenizer.py: the ling32 family first, then main's deepseek test with DEEPSEEK3_PRES
- tools/docker/Dockerfile.src: the Ling CMake flags and main's -DSTRATA_BUILD_HY4_FLASH=ON
- terminal/data/settings-register.json and docs/SETTINGS.md: the Ling side kept for the hand-kept fields, then regenerated with tools/settings_register.py (1656 settings) and its --docs
2026-12-02 13:17:26 +01:00
Niko1221 37b89d7de4 Merge f-ling32-small-plainpool (L32-SMALL: MTP sidecar experts as pool slots) into the integration staging line 2026-12-02 00:37:37 +01:00
Niko1221 35e0cd87c8 ling32 tier planner: the --tier-pool auto line covers a 32 GB card on every build (RTX 5090 measured)
RTX 5090 (32 GB, PCIe 4.0, tier B, 5 prompts x 256 greedy tokens, ids identical in all arms):
plain 42.5 / 36.2 tok/s with --tier-pool off, 54.4 / 73.2 with the pool; MTP (plain path +
sidecar in the pool) 38.9 / 48.5 off, 60.1 / 76.3 on; 4K prompt 46.3 -> 66.0 decode.
pool_auto_max defaults to 32.5 GiB (as the HIP build already had); the HIP-only override in
ling32_main.cpp is gone. Cards above 32 GiB (not measured) keep the static prefix.
Planner test: 32 GiB card is pool mode by default, --tier-pool off is static, a 48 GiB card is
static unless the line is raised.
2026-12-02 00:36:13 +01:00
Niko1221 3005bbf0ef ling32 MTP sidecar experts as pool slots (pinned RAM -> card on demand): WIP for measurement 2026-12-01 23:25:43 +01:00
Niko1221 b559cb8d16 ling32 tier planner: the pool-mode auto line is a request field; HIP builds raise it to cover a 32 GB card
--tier-pool auto switches the pool layout on for cards whose budget is at most TierRequestOpts::pool_auto_max. The default stays 30 GiB (CUDA: measured on 12-24 GB cards);
a HIP build sets it to 32.5 GiB in make_request so a 32 GB R9700 (budget 31.4 GiB, experts do not fit) gets the pool: L32-HIP measured tier B plain 29.4 -> 37.5 tok/s
and MTP 39.7 -> 58.0 tok/s with identical ids. Planner test: a 32 GiB card is not a pool plan by default, is one with pool_auto_max raised (planned <= budget),
and --tier-pool off still gives the static layout.
2026-12-01 23:11:22 +01:00
Niko1221 0ba14b2611 Merge f-ling32-hip dc10bc0a03 (adaptive warm RAM tier on by default where the RAM tier is read in place, single-token decode only, off with --mtp) into the integration staging line 2026-12-01 22:07:18 +01:00
Niko1221 dc10bc0a03 ling32 tier store: adaptive warm RAM tier on by default for the Windows iGPU plain decode
The adaptive warm tier (decayed use counts, promotion of SSD-resident experts from the ring into spare
RAM-tier slots, quarantined demotion) is now on by default where the RAM tier is read in place
(zero-copy, Windows iGPU).  Spare slots 8 per size class, quarantine 24, queue 16; knobs
STRATA_L32_AD_Q / AD_SPARE / AD_QUAR; STRATA_L32_ADAPT=0 / 1 still overrides.

It is only used for single-token decode: promotion and use counting are skipped for MTP verify
batches, and main sets StoreOptions::adaptive_default = false when --mtp is given (the first
default-on build cost -10 % with MTP: the copies and the spare slots taken from the warm prefix
buy nothing there).  Drop-reason counters (ring slot gone / no spare / not hotter / queue full)
are printed with the PF_COV statistics.

Strix Halo (gfx1151), 48 short prompts, greedy ids identical to the switched-off runs in every arm:
plain 23.6 tok/s vs 22.9-23.0 off (+2.6 %, SSD wait 45 s vs 55 s); MTP default 31.2 vs 31.4 off
(parity, ids identical).
2026-12-01 22:06:23 +01:00
Niko1221 d5026839ff #6770: the global K/V of one slot grows through CUDA virtual memory (no copy), the context is set to what the card holds once the drafter has loaded, opt-in --kv-prealloc
The elastic global K/V grew one visit at a time (new buffer, copy, free the old one), so the card needed one old visit buffer extra and a long request stopped 1.2 to 1.8 GB short of the
context that had been planned ("VRAM exhausted growing elastic global KV cache", 503), and the plan was set before the drafter (DSpark's fused weights, DFlash 2 codebooks and rings)
took its memory.

- ink_runner.cuh: with ONE slot on ONE card (no layer split, no elastic 1M mode, K/V not split to host at the start) every global visit's K, V and scale buffers are address ranges for the
  requested context (strata::core::VmmRange, src/core/vmm.cpp, now also linked into the CUDA backend) and physical memory is mapped behind them as the context grows; the pointers never
  move, so no peak of old + new. A failed mapping falls back to the host tail (kv_spill_tail, the earlier code, now a function) or to a refused request, as before.
  STRATA_INK_KV_VMM=0 takes the earlier growth back.
- ink_dspark.cuh: the classic drafter's global context grows the same way (ctx_vmm).
- ink_cuda_backend.cu: after the drafter has loaded (--kv-offload off), max_ctx is set to what the card holds (ink_kv_reach_ctx, 256 MiB kept free), up or down, never above
  --max-context ("max_ctx A -> B" line); --kv-prealloc / STRATA_INK_KV_PREALLOC=1 maps that whole context at start-up (and refuses to start, with a message, if the mapping fails); a request
  that fails to grow says how much video memory is free now and what to do.
- ink_serve.h + InkBackend::kv_reachable_tokens(): a prompt the card can no longer hold (another program took video memory after the plan, --kv-offload off) is refused at the start with
  a message instead of ending with 0 tokens; the engine stays up.
- strata/core/ink_kv_grow.hpp: ink_kv_reach_ctx() and its test (ink_kv_grow_test). Register: STRATA_INK_KV_PREALLOC (opt-in), STRATA_INK_KV_VMM (rollback); docs/INKLING_KV.md, SETTINGS.md.

Measured (RTX 4090, SQ-20 v2, --kv fp8 --kv-offload off, prompts of 90K / 100K / 110K / 128K tokens; VRAM ballast taken before the first allocation to get the Windows 4090's room;
phaseA-tests/rel0224/ink-kv/RESULTS.md, REPLY-6770.md): no ballast: tokens identical old / new / --kv-prealloc, decode equal; 700 MiB ballast, classic drafter: old ends the 110K request at
100,864 tokens with 0 tokens, new answers it; default drafter: old plans 104,192 and refuses 110K and 128K, new answers both; 1,300 MiB: old plans 74,240, new raises it to 109,568 and
answers a 100K prompt; every answer identical to the unballasted run; short prompts: same tokens, speed within 0.5%; ballast after the start: --kv-offload auto answers (host tail), off
refuses with a message. An RTX A6000 with a 128K prompt: identical tokens. Builds: CUDA sm_86 and sm_89 (Linux), sm_120 (MSVC), HIP gfx1151.
2026-12-01 21:46:58 +01:00
Niko1221 1fe5154714 Merge f-ling32-long 9bbf432586 (AMD WMMA MLA decode / verify kernel over the pre-split fp16 hi / lo latent cache, --latent f16x2, default on gfx11 / gfx12; CUDA builds reject f16x2) into the integration staging line 2026-12-01 21:06:28 +01:00
Niko1221 4ce01c3f08 --kv auto, final rule per backend (owner, 2026-12-01): NVIDIA FP8; AMD, Mac and Intel keep FP16; the one rule takes the backend's default and its reason
The measurements (phaseA-tests/rel0224/ink-kv/RESULTS.md) made FP8 a good default where the card likes it and a bad one where it does not:

- CUDA: FP8 on every card and slot count (KL 0.005, top-1 95-98%, FASTQ subset SQ-20 v2 201/213 FP16 against 202/213 FP8, 64 slots +24 to +27% and a 32K
  decode x2.5 on 12 and 16 GB cards because the cache is half the size and stays on the card; -1 to -3% on an RTX A6000 that has no native FP8).
- HIP (AMD): the 0.2.23 rule is back, unchanged: FP16, FP8 from 16 slots on a card of 36 GiB or less, STRATA_HIP_KV_FP8_SMALL and the Strix Halo FP8_KV_C64 set as before.
  On the Radeon AI PRO R9700 FP8 costs 7% decode at 4K and 17% at 32K (prefill -8% at 32K); the retirement of STRATA_HIP_KV_FP8_SMALL is undone.
- Metal (Mac): FP16 ("auto: Mac default"); --kv fp8 (#6983) and the opt-in M5 Max fast set are as they were.
- SYCL (Intel): FP16, FP8 from 16 slots and in the Intel Arc fast set, as before (Arc A750: FP8 decode -6%, KL 0.0044 at 4K and 0.0054 at 32K).

ink_kv_auto_rule() now takes the parallel slots, the card's memory and what the backend's default is (fp8_by_default / fp8_from_slots / card cap / its sentence), so
the rule and its reasons stay in one place; every backend prints "[kv] <backend>: K/V cache <type> (auto: <reason>)". ink_main no longer sets FP8 at 16 slots for every
backend (that made a Mac and an Intel card take FP8 by the back door); the CPU reference keeps its own FP8-from-16-slots rule in its backend. The plan
(inkling_fit.auto_fp8_kv) follows: FP8 for CUDA and an unnamed backend, the 0.2.23 rule for HIP, FP16 for Metal and SYCL. Tests: ink_kv_rule_test (host only),
test_inkling_kv_auto.py, and the planner tests that pinned FP16 numbers pin them with fp8_kv=False.
2026-12-01 20:52:09 +01:00
Niko1221 27dd369432 ling32: WMMA MLA decode / verify kernel for gfx11 and gfx12 over a pre-split fp16 hi / lo cache (--latent f16x2)
New cache format LatentFmt::F16X2 / MlaCacheType::kF16x2: every cache value as two fp16 numbers, hi = fp16(x), lo = fp16((x - hi) * 2048), row = [hi[576] | lo[576]]
(the bytes of an fp32 row, fp32-class accuracy like the CUDA tensor-core split path: three WMMA 16x16x16 f16 per product, cross terms in a second accumulator added with 1/2048).
mla_prep writes the planes; the kernel (mla_latent_attn_wmma.inc, AMD only) computes S^T = C Q^T with the key tile as the A operand, online softmax over the accumulator
elements, O += P C with the key tile read against its layout for the B operand; dense visibility, one block per (token, head tile, chunk), the same split-K / merge machinery.
CUDA builds reject f16x2.  mla_latent_attn_long: --fmt f16x2, relative error against the f32 cache of the same data, --ntok.

gfx1151 (Strix), one layer, decode, vs the scalar fp32 kernel on the same data: 128K 1.59 vs 2.89 ms, 256K 3.22 vs 5.81 ms (187-192 GB/s of cache, the memory floor of this
box); relative L2 error 1e-6 .. 2.2e-6 over 39 cases (contexts 1 .. 262144, one and several chunks, verify batches of 1 .. 16 tokens).
2026-12-01 20:36:48 +01:00
Niko1221 d1d0f59c7c Metal K/V start-up line follows #6983 (--kv fp8 on any Metal GPU); the doc and the rule header say so
After #6983 an explicit `--kv fp8` is honoured on every Metal GPU (the M5 Max fast set still picks FP8 by itself). `--kv auto` stays FP16 outside the M5 Max set: INK-PR measured
FP8 on an M5 Max at KL 0.0053 / top-1 96% against FP16 with the K/V halved, but decode -10 to -12% at 4K to 16K, so it is a choice there, not a default (the owner decides).
The [kv] line says which of the two happened, and says so when `--kv fp16` meets the M5 Max set's own FP8.
2026-12-01 20:13:00 +01:00
Niko1221 ff17a139fa Inkling 2 Mini: --kv auto is FP8 on every card and slot count; one rule for every backend, a start-up line, and a long-document KL mode
`--kv auto` (the default) now stores the K/V cache as FP8 wherever the backend can (CUDA, HIP; SYCL stays FP16 by default until its A750 / B70
numbers are in, Metal takes FP8 only in the M5 Max set) and FP16 where it cannot. K8V8 and K8V4 are only chosen when asked for (--kv k8v8, --kv k8v4).
An explicit --kv always wins. Before, every backend had its own rule (CUDA: FP16 unless 16+ slots, a card of 13 GB or less with the K/V offload off, sm_89+ with a
context over 16K, three RTX 50 rows; HIP: FP16 below 16 slots; SYCL: FP16).

- engine/include/strata/core/ink_kv_rule.hpp: the one rule (host only) and the one start-up line, "[kv] cuda: K/V cache fp8 (auto: default)"; the CUDA, HIP, SYCL
  and Metal backends call it. Test: engine/tests/core/ink_kv_rule_test.cpp.
- CUDA: plan_vram_reserve() takes the type from the rule; STRATA_INK_ELASTIC_1M + STRATA_INK_KV_K8V4 remains the tester's way to K8V4. HIP: the old small-card
  switch STRATA_HIP_KV_FP8_SMALL is retired (register entry marked retired in 0.2.24).
- ink_main --help: the --kv line says what auto is.
- --dump-ref / --kld-eval: a row-selected form for long documents (INK_KLD_TAIL=N INK_KLD_STRIDE=s keep the logits of every s-th of the last N positions; the file
  then starts with -n_tokens; INK_KLD_CHUNK / INK_KLD_CHUNK_TAIL set the prompt chunk of the head and of the scored part). The old file format and behaviour are unchanged;
  the --kld-eval line gains refPPL and dNLL at its end.
- terminal: the memory plan (inkling_fit.auto_fp8_kv) sizes FP8 for every backend except SYCL and Metal; compute_unified and recommend take fp8_kv like compute does.
  Tests that pinned the FP16 numbers now pin them with fp8_kv=False; test_inkling_kv_auto.py covers the new rule, the launcher's k8v8 / k8v4 clamp and that every backend
  calls the one rule. docs/INKLING_KV.md; docs/SETTINGS.md regenerated.

Measurements (phaseA-tests/rel0224/ink-kv/RESULTS.md): teacher-forced KL of FP8 against FP16 K/V 0.005-0.007 and top-1 95-98% on 4K / 32K / 128K documents
on RTX A6000 (SQ-20 v2), RTX A4000 (SQ-15), R9700 (SQ-15), Arc A750 (SQ-10, 4K), RTX 5070; the needle misses are the same with FP16.
2026-12-01 20:11:36 +01:00
Niko1221 707376f1bc Merge f-ling32-small f720d382d3 (pool sizing within the budget by construction, planner test) into the integration staging line 2026-12-01 19:59:34 +01:00
Niko1221 f720d382d3 ling32 tier planner: pool mode keeps the budget a hard cap, tests follow the pool default
- pool mode no longer adds a free-standing bonus to the pool: with an auto budget it uses a 256 MiB reserve instead of 600 MiB, a 1 % margin instead of 2.5 %
  and an activation estimate 512 MiB lower (all three measured on 4 cards: 1.7-2.1 GiB were left free), so vram_total_planned <= vram_budget holds by construction;
  an explicit --vram-budget-gib stays a hard cap.
- the MTP sidecar bytes (+200 MiB of buffers) are taken out of the pool's memory.
- ling32_tier_planner_test: the 24 GiB case asserts the pool default (no static prefix, many slots, planned <= budget), the old layout is checked with --tier-pool off,
  and a 1 GiB sidecar must shrink the pool.
2026-12-01 19:59:16 +01:00