Pure renames, no behaviour change: LING32_SY_KDA_SEQ -> STRATA_L32_KDA_SEQ (0 old scan, 4 / 8 split scan, default 8), LING32_SY_MLA_EXP -> STRATA_L32_MLA_EXP_MODE, LING32_SY_MLA_ORIG -> STRATA_L32_MLA_FD_ORIG, LING32_SY_MLA_FD_NS / _PVU / _RB -> STRATA_L32_MLA_FD_NS / _PVU / _RB, LING32_SY_MLA_EXP_ABS (test) -> STRATA_L32_MLA_EXP_ABS. Register entries (rollback for the switches, research for the tuning knobs; STRATA_SY_PROF_TOP of the profiling hook too), docs/SETTINGS.md regenerated, tools/settings_register.py --check clean and test_settings_register OK on this commit (based on the scratch merge 8c8ed5cd0b of int f9f533c65f + MLA efff44d494 + KDA c7f2967a16).
The serial scan of a head over the chunks of 8 tokens ran as one work-group per head with one value column per lane and the 128-float state column in registers (spills on Xe). The state update is independent per value column, so the scan now runs as HD / 32 work-groups per head (32 columns each), G sub-groups per work-group, each owning HD / G key rows of the state in registers (lanes are the columns); the partial sums over d of kE s and qE s are exchanged through shared memory per chunk, U and the output row are computed redundantly per sub-group, the next chunk's tiles are prefetched into registers and stored into the other shared-memory buffer (two barriers per chunk). The gated RMS norm needs the whole row, so the scan writes the raw output into out and launch_chunk_norm normalises it in place (same expressions). Mode switch LING32_SY_KDA_SEQ: 0 the old scan, 4 / 8 the new one with 4 / 8 key-row groups (default 8); the decode / verify / snapshot path (launch_step, N <= 16) is untouched, state layout and final state are the same.
ling32_sy_kda_test: chunk scan modes against the sequential recurrence (hd 64 / 128, N 40 / 100, and 32 heads x 2048 tokens: max rel error <= 2.9e-5, gate 2e-4) and timings. A750: pre + scan for 32 heads, hd 128, 2048 tokens 141.6 ms (old) -> 77.3 ms (4 groups) -> 44.0 ms (8 groups). Forward tests f32 / q8 / wide with --kda-seq 4 pass in every mode (top-1 12 / 12, KL 4.3e-12 vs 4.2e-12 old).
Test-only: ling32_forward_test sets kda_seq_max_n and graph_max_n to K (the expanded MLA needs N above both). A750, plain-loop mode, wide fixture: prefill of layer 2 differs from the decode figure (the expanded path ran), top-1 12 / 12, KL 4.15e-12 against 4.24e-12 of the absorbed control. tools/fwd_exp_a750.sh runs the control and --mla-exp variants.
Ling32Engine::init no longer switches the expanded-form MLA prefill off on SYCL when the device has XMX (mla_exp_ok); the conversion of the projection weights keeps buffers valid for models with other head dimensions. One line in ling32_engine.cu (the SYCL block of Ling32Engine::init).
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.
f-ling32-int 7c04fb2161 (Metal 1024-thread kernels, mla_qabs_d, opt-in --skip-tau) and the register statuses of the 15 Ling SYCL env names. Only conflict: docs/SETTINGS.md (generated): regenerated with tools/settings_register.py --docs; the register merged automatically, regenerated, check clean, no empty status.
A decode / verify token's routed experts whose share of its routing weight is below T are dropped (the top expert is always kept, the kept
weights are scaled to the original sum, the dropped slot repeats the top expert with weight 0 so the tier store fetches nothing for it);
prefill and the MTP layer are untouched. Off (T = 0, the default) the engine path is unchanged. Quiet RTX 3090, tier B, plain decode:
T 0 / 0.03 / 0.05 / 0.08 = 53.0 / 53.5 / 58.0 / 70.8 tok/s, H2D per token 331 / 324 / 299 / 240 MB; teacher-forced against the unpruned
engine: top-1 100 % / 98-100 % / 97.5-98 %, mean KL 1e-4 / 1e-3 / 1.6e-2 (T 0.08 max KL 0.7). ling32_bench decode checks the prune kernel
against a CPU reference (bit-identical). STRATA_L32_LA_KS (bit mask of the lookahead lists a tier run computes) with STRATA_L32_PF_K: with
both lists computed the k=2 list as the prefetch driver is +3 % on the 3090 (ABAB x3). Register entries for both and for the HIP
ROUTE_EARLY / PROBE_ALLOC / GPU_CAP_GIB settings that had no status.
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.
New ling32_sy_k_mla_exp.cpp (convert weights to packed fp16 x 256, q hi/lo planes, per-slab projection, attention with hi/lo splits as in the CUDA kernel, final sigmoid gate) replaces the four mla_exp_* stubs; ling32_sy_mla_exp_test (port of ling32_mla_exp_test.cu). A750 in plain-loop mode (LING32_SY_MLA_EXP=1): all cases within 1.4e-6 of the absorbed original kernel. mla_exp_ok is false without XMX. Not enabled in the engine yet (the SYCL gate in Ling32Engine::init still turns --mla-prefill expanded off).
VisionGpu was a stub in the SYCL build (the CPU encoder served every picture). New sycl/ling32_sy_k_vision.cpp implements the interface of ling32_vision_gpu.hpp with SYCL kernels in the CUDA encoder's structure: tiled SGEMM (BF16 or float weights), layer norm, 2-D rope, online-softmax attention without an S x S matrix, GELU, position grid. No double in a kernel: the position-grid weights and the rope tables come from the host in double, like the CPU encoder's.
- Memory: weights 829 MiB resident (idle unload as in the CUDA encoder), activations ~34 KB per patch (the MLP in row chunks), all inside the 1600 MiB the planner already reserves for the encoder (ling32_main.cpp). A picture whose activations + weights exceed that budget is refused BEFORE any allocation (encode returns false with a message); the driver's free-memory query is not used (it does not move on the A750 under Level Zero on Linux).
- ling32_vision_run.hpp: VisionRun encodes a picture on the CPU when the GPU encoder returns false (low memory / failure), one log line; the next picture tries the GPU again (CUDA / HIP too).
- ling32_main.cpp: `--info FILE --kv` prints vision=gpu when this build has a GPU encoder and device 0 has 24 GB or more (vision_default_backend), else vision=cpu; the launcher drops its pixel cap on the word gpu.
- Test: ling32_vision_gpu_test (the CUDA test, compiled as C++ against the shim for SYCL) with --time IMAGE and --lowmem (the budget refusal); sycl/tools/l32sy_vis.sh builds and runs it on a Linux box.
A750 (p1006, spir64 JIT): output rel L2 vs float64 5e-6 .. 1.6e-5 on the five golden pictures, vs the CPU encoder 6e-6 .. 2e-5 (1920x1080: 4.2e-5); two runs bit-identical; idle unload / reload; 196 embeddings 0.50 s (CPU 1.45 s), 300 embeddings 0.78 s (2.4 s), 2040 embeddings 19.7 s (47 s). The XMX step (next) is what makes it fast.
ling32_moe_sy_test: P = 512 .. 16384 pairs over E = 512 experts with a hot expert (12 - 60 % of the pairs, up to 849 pairs on one expert), unused experts and the last expert used; checks the route tables
against a host histogram / permutation (counts, starts, every pair exactly once, the tile list) and the grouped gate/up + down against the per-pair kernels (bit for bit on the scalar kernel, 2e-5 of the rms
on XMX). A750: exact tables and no unwritten pair in all cases, scalar grouped bit for bit, XMX 2.0e-5.
L32-SMALL's gate on a quiet RTX 3090 (build 418f142af4, chunk 1024 regrow off = A, chunk 2048 regrow on = B, chunk 2048 regrow off = C):
prefill 4K 4.10 s / 3.62 (+13 %), 16K 16.4 s / 14.2 (+15 %); steady decode 53.3 / 55.1 (+3.4 %) / 52.3; slots 4088 / 4345 / 3813; ids of all 9
jobs identical; CTest 19 existing + ling32_regrow_regress pass. Register: STRATA_L32_REGROW and STRATA_L32_REGROW_RESERVE_MB (status
research); the only merge conflict was the generated register, regenerated. Needs a HIP compile before the default flips.
The adaptive warm tier (default with in-place reads) takes the coldest RAM slots as spares and relies on the SSD for them; in Mode B it makes those experts unreachable. The driver sets STRATA_L32_ADAPT=0 in Mode B (--adapt 1 forces it).
l32sy_spec_legs.py runs every leg of the spec-span test without stopping at the first difference.
c4fb1f7af7 added test_pool_is_for_one_slot_only with a literal line break inside the string of its PASS line, so the file did not compile
(error: missing terminating " character, ink_elastic_sec4_test.cpp:291) and the cmake-cpu step of tools/check failed on p1006.
The string ends in \n again. Test only; no product code changed.
- engine: every row-dependent buffer (activations, logits, KDA chunk scratch, MLA workspaces, grouped-MoE work, lookahead snapshots) lives in a ScratchSet; a small `dec` set (decode_rows = 64 rows) is always resident, a `big` set of the prompt chunk is allocated by the first prefill-sized forward (the existing allocation retry makes the tier store release chunks of pool slots when the card has no room) and freed by the first decode-sized forward, which also frees the span rows and tells the store to take the memory back
- store: ExpertProvider::grow_bytes / ExpertStore::grow_bytes re-allocate released chunks of small dynamic slots (empty, lowest chunk first, keeping 192 MiB free: STRATA_L32_REGROW_RESERVE_MB)
- planner / main: --regrow on|off (or STRATA_L32_REGROW=1; default off), --decode-rows N; with regrow the plan counts decode_rows rows of scratch instead of the chunk (tier A and runs without lazy KV keep the full chunk); a speculative request (MTP, not plain) keeps its sets and does not regrow
- test: ling32_regrow_regress (same dump and ids with regrow on and off: tier B, two prompts, injected allocation failure, tier C, MTP speculation; STRATA_L32_KV_FORCE_RELEASE=1 makes the big set take one chunk even where the card has room)
trunk_xmx_try (ling32_sy_k_moe_xmx.cpp): the grouped expert kernel with the pair list replaced by a token range, tiles of 32 (16 below 24 tokens) tokens x 128 weight rows, any S_K code, out_stride and
accumulate like gemv_sk. gemm_sk_tc and gemv_sk (when g_tc_min_n > 0) call it first; it runs on XMX devices (Battlemage-class, Alchemist with STRATA_L32_MOE_XMX=8) for N >= 32 tokens and at least
128 work-groups (STRATA_L32_TRUNK_XMX_TILES; below that the scalar GEMV is as fast), STRATA_L32_TRUNK_XMX=0 off. A750 Alchemist AOT, S8 shapes of the trunk at N = 512 .. 2048: 3.6 - 3.9 TFLOP/s vs 2.0 for the
scalar GEMV (1.8 - 2.1x); error <= 1.1e-5 of the rms against the float GEMV. S8 slabs use 8 chunks in flight in every XMX kernel (B70: S8 16 pairs 2.11 -> 1.87 ms).
ling32_moe_sy_test: trunk GEMM cases (all codes, tile tails, accumulate) and L32MOE_BENCH=trunk.
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.
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).
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).
With several slots a visit's K/V is one block [slot][position] of a fixed size per slot: it cannot grow one slot at a time inside one address range, so no chunk
could ever go to the K/V and the pool would only be a different way to allocate d_sec4. The loader now takes the old path (one cudaMalloc, no pool, no hybrid tier
pool in virtual memory) when the planned slot count is above 1 and logs one line: "[InkElastic] off: N parallel slots ...". The decision is
InkElasticSec4Pool::slots_allowed, covered by the host test.
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.
Only conflict: terminal/data/settings-register.json. 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.
The parallel routing kernel for the 32-expert lookahead lists measured +5% decode on an R9700 (HIP) but
-1.3% plain and -2% MTP K=1 on an RTX 5090 (3 interleaved rounds each, ids identical). g_alflb_look
defaults to 1 for HIP and 0 for CUDA; the router's top 8 keeps the parallel kernel everywhere. The
ling32_bench decode check forces it on so the identity test still covers the lookahead lengths.
RTX 5090 with the gate: plain 112.1 (reference 111.9), K=1 123.1 (reference 122.2).
A float-activation row dot with the arithmetic of sy::row_dot (same lane ownership, same fma chain: bit for bit the same results, checked by ling32_moe_sy_test against the CPU model) and 16-bit loads of
exactly the words a lane needs, the activations as float4. STRATA_L32_MOE_DEC = 0 generic row dot, 1 (default) / 2 / 4 weight rows per warp; more than one row or superblock in flight spills registers
of a SIMD32 work-item (A750: 2 rows 15% slower, 4 rows 50% slower, 4 superblocks 3.5x slower). A750 (Alchemist AOT), real shape, 8 pairs from 8 distinct S5 experts: gate/up 0.196 -> 0.148 ms
(104 -> 138 GB/s), down 0.115 -> 0.093 ms; 32 pairs gate/up 0.558 -> 0.436 ms. ling32_moe_sy_test: L32MOE_BENCH=decode times the decode path.
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.
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).
RTX 3060, ling32_bench decode: parallel vs reference 0 of 262144 (expert, weight) pairs differ (top 8 / 24 / 32 / 64, random and tie-heavy scores); the 32-expert lookahead route with 4 groups 34.63 -> 19.56 us per layer, with 8 groups both 41.6 us (the reference kernel is used). The one-warp reference writes weights only for lane < top_n (the first 32 ranks), so the test compares the lists in full and those weights.
alflb_route launched the parallel one-block kernel (rank instead of n argmax rounds) only for the
router's top 8; the lookahead predictors (32 ranked experts per layer, 40 us on the one-warp kernel,
1.6 ms of GPU time per decode token on the lookahead stream on a 3090, nsys) still took the one-warp
reference. The parallel kernel handles top_n <= 64 and topk_group <= n_group with the same arithmetic
and tie-breaking (higher score first, then the lower expert id); the gate now admits them.
ling32_bench decode: the parallel-vs-reference check runs top 8 / 24 / 32 / 64 with 4 and 8 groups,
random scores and two tie-heavy sets (512 tokens each), must print IDENTICAL, and prints the time of the
32-expert lookahead route on both kernels.
mla_attn is now a dispatcher: fp32 cache, N <= 16, kv_lora 512 / rope 64, H % 8 == 0 take the flash-decoding kernel (ling32_sy_k_mla_fd.cpp); everything else the original kernel (mla_attn_orig). LING32_SY_MLA_ORIG=1 forces the original for A/B. ling32_sy_mla_fd_test compares both at ctx 1 .. 8192 and spans of 3 and 16 tokens (max abs 4.5e-7).
The tile list of moe_tc_route is 32 pairs wide when the XMX kernel takes at least 24 pairs per expert (16 otherwise): the weight decode of a tile is shared by twice the pairs and the B tile is reused 4 x 2 times.
xmx_plan() decides (XMX device, pairs per expert >= STRATA_L32_MOE_XMX_MIN, default 6: on the B70 4 pairs per expert were no faster than the scalar kernel; STRATA_L32_MOE_TN forces 16 / 32);
route and kernels ask the same function. A750 (Alchemist AOT, STRATA_L32_MOE_XMX=8), 64 pairs per expert, 64 experts: S5 17.6 -> 13.4 ms, S8 22.9 -> 17.6 ms.
ling32_moe_sy_test: two 32-pair-tile cases (bit-identical to the CPU model for the per-pair kernels, 1e-5 of the rms for the grouped path).