Commit Graph
62 Commits
Author SHA1 Message Date
Niko1221 c8c82e300a rdna3: fix STRATA_VERIFY_DEVICE_HITS alias in expert_source and keep opt-in on discrete gfx11 2026-11-22 01:05:25 +01:00
Niko1221 d31256b79d rdna3: Phase 3 CU-safe/WDDM-safe WMMA DFlash2, rdna_gr, rdna_mmvq, and GDN megakernel 2026-11-21 21:31:25 +01:00
Niko1221 bbb22af24a rdna3: Phase 2 native_h11p_kernel (PF_F16=2) and discrete moe_p1a FL=3 across gfx1100-1151 2026-11-21 21:31:25 +01:00
Niko1221 34b82b5409 rdna3: Phase 1 WDDM coherent alloc, gfx1100-1151 defaults, and AVX512BW+VNNI ZMM dots 2026-11-21 21:31:24 +01:00
Niko1221 8601e766b3 Merge f-hy4-int (Hy4-Flash Strata side and runner base) into the 0.2.18 branch 2026-11-20 00:15:23 +01:00
Niko1221 7c90399f4e Merge f-cg1-ram: a cgroup v1 limit credits the group's clean page cache in the RAM probe 2026-11-19 21:05:19 +01:00
Niko1221 de17f306f7 Merge f-hy4-run (933b9bfd3: Hy4-Flash .strata reader, S_K codecs, Engram reader, gfx1151 runner) into the 0.2.17 release candidate
The merge is clean: every file of f-hy4-run is new on top of the candidate except
engine/include/strata/artifact/model_family.hpp (+6) and engine/cmake/backends/quant.cmake (+3).
2026-11-19 20:51:34 +01:00
Niko1221 8a38bc52b6 Merge f-fetch16: STRATA_ADAPT_FETCH=2 default on 12.x CUDA cards with 16 GiB or less
The settings register conflicted on line numbers only. It was taken from the rc,
STRATA_ADAPT_FETCH's status and note were carried from f-fetch16, then
settings_register.py and --docs were run over the merged tree (1125 names);
--check passes.
2026-11-19 20:50:36 +01:00
Niko1221 c9f031dcd8 RAM probe: a cgroup v1 limit credits the group's clean page cache (a Docker container on a v1 host read "only 0.1 GiB of RAM is free")
detail::host_available_memory read a cgroup v1 limit as memory.limit_in_bytes - memory.usage_in_bytes. v1's usage_in_bytes charges the whole page cache, and the kernel
evicts that cache before it fails an allocation at the limit, so a container that had read its model through the file cache sat at its limit with its RAM to spare.
The v2 branch credits the group's clean file pages (and the conversation memory guard and the setup's Python probe credit them on v1 too); this branch did not.
Every figure built on it was short: the default CPU prompt share was "not armed by default: only 0.1 GiB of RAM is free" (the share needs 3.3 GiB), and the arena
verdicts, the resident-budget clamp and the file tier's room read the same number.

Measured on the rented RTX 5090 box (Vast 61335444: Docker, cgroup v1 hybrid, 171 GiB limit, 104 GB model, EPYC 9B14): limit - usage = 2.57 GiB with 99.9 GB of clean file
pages (total_inactive_file + total_active_file) in the group.

arena_cgroup_room_v1 (conversation_memory.cpp): room = limit - (usage - credit), credit = total_inactive_file + total_active_file - total_dirty - total_writeback, never more
than the usage, less min(credit / 2, limit / 64): the rule of the v2 container branch (arena_cgroup_room). shmem (in total_cache, on the anon lists) and mlocked pages are
not on the file lists, so they stay charged. A memory.stat without total_inactive_file or no memory.stat: no credit (limit - usage, as before). STRATA_MEM_CREDIT_INACTIVE=1
credits total_inactive_file alone. The v2 branches are unchanged.

Test: file_expert_source_test (test_host_memory) has the box's memory.stat / usage / limit (2026-11-19 19:01:37 UTC) in the hybrid fixture: the room was 2.57 GiB before and is
92.9 GiB now; memory_guard_test has the pure arena_cgroup_room_v1 cases (shmem, dirty, writeback, bound by the usage, no stat, inactive only).
2026-11-19 20:09:20 +01:00
Niko1221 f705bf0a81 Merge f-bw-h (link-aware CPU prompt share limit) into the 0.2.17 release candidate
f-bw-h (a620ffb61, 595d40922) and f-bw-f (38e6a0506) both arm the CPU prefill
share on a layer split. One conflict, engine/src/program/generate.cpp, the
share arming block of the serve start-up, resolved to one rule:

- BW-H first: on a layer split the stages' stream floors are summed; where the
  link rule raises the limit above 3,072 (Prefill::arm_cpu_share_split) it arms
  the share by itself and sets the limit and the expert width. This is what arms
  a split of three or more cards, and it gives a two-card split with a slow link
  its larger limit.
- BW-F second: arm_cpu_share(share_pool, share_pool && share_layout &&
  share_has_work): one card, or exactly two CUDA cards (STRATA_SPLIT_CPU_SHARE=0,
  kSplitShareDefault), armed by default with the default limit. A two-card split
  of fast links therefore keeps the share armed, as BW-F measured it.
- set_card_expert_share takes pool.workers() (BW-H) in the one-card condition.
- BW-F's start-up line is kept.

docs/SETTINGS.md is generated (conflict only in its table): regenerated from the
register.
2026-11-19 19:48:39 +01:00
Niko1221 595d409226 CPU prompt share on a layer split: the link rule arms it from the stages' summed stream floors (cc 12.0 cards, STRATA_PREFILL_CPU_SHARE_AUTO=0 keeps it off)
The share is off on a layer split by default.  With explicit STRATA_PREFILL_CPU_SHARE=auto and the limit above the split's 8,192-token chunk, experts of up to 64 tokens, 2x RTX 5090 on one board (GPU0 PCIe 4.0 x2
3.6 GB/s first stage, GPU1 x8 14.1 GB/s, 32 pool workers, UD-Q4_K_XL, --layer-split auto, 3 rounds) the prompt takes 0.25-0.68 of the split's default time at 84 / 1,024 / 2,048 / 4,096 / 8,192 / 12,288 /
16,384 / 32,768 tokens (843 -> 327, 1,957 -> 829, 5,549 -> 1,395, 5,949 -> 2,345, 6,783 -> 4,599, 11,052 -> 5,999, 11,233 -> 7,578, 20,026 -> 13,125 ms), decode level; the share with the default limit 3,072 costs
3-4% from 4K up.

Prefill::arm_cpu_share_split(applies, floor_ms, pool_workers, all_cc120) (called before arm_cpu_share in the serve path when the engine runs a layer split): floor_ms is the sum over the stages of (pairs of the
stage's layers - its cache slots) x blob / its link; the share is armed by default only when share_rules::link_rule_floor raises the limit above 3,072 (here 3,556 ms -> 12,032 tokens, 64-token experts), so a
split of fast links keeps the share off as before.  With the rule (nothing set against STRATA_PREFILL_CPU_SHARE_AUTO=0): x0.38 / 0.41 / 0.25 / 0.38 / 0.63 / 0.52 / 0.64 / 0.62 of the default at the same
lengths, decode chat 129.2 -> 132.5, code 189.7 -> 203.9, agent 136.3 -> 138.2 tok/s.  Forced-token KL on the split against the FP16 prompt path (48 prompts, 12,288 positions, fixed share 0.5): exact 0.01119,
share with 8-token experts 0.980 [0.938, 1.024] of it, share with 64-token experts and limit 16,384 0.979 [0.907, 1.053].  Docs updated (DETAILS.md).
2026-11-19 19:23:55 +01:00
Niko1221 ca99e886f7 STRATA_ADAPT_FETCH=2 is the default on compute capability 12.x CUDA cards with 16 GiB of memory or less
RTX 5050 / 5060 / 5060 Ti / 5070 / 5070 Ti / 5080 and the laptop parts. A card with more memory,
and every other vendor and architecture, keeps it off. A value the user sets (0 included) always wins;
STRATA_ADAPT_FETCH=0 is the way back, STRATA_SM120_PERF=0 and STRATA_DEFAULTS=026 leave it out with the
rest of the sm_120 table.

The switch is read once per process and only a one-card run uses it (a layer split, helper cards, a peer
tier and --batch turn it off), so the engine's main card (STRATA_PRIMARY_DEVICE) decides; its memory is
cudaDeviceProp::totalGlobalMem, read without making a context.

BW-9, 2x RTX 5060 Ti 16 GB, UD-Q4_K_XL, tail skip off, product flags, 3 paired rounds: decode +4 to +43%
by kind (medians 1.087 to 1.325), expert cache hit rate 54.4 -> 62.0%, forced-token KL against the FP16
prompt path 0.948 [0.830, 1.063] of the default's, prompts level except json 169 at +3 to +5%.

The start-up line of the sm_120 defaults names it and says it is not bit-exact; the lines that say the
switch cannot run in a given start (a layer split, --batch, ...) say the default is not used there.
Unit test adapt_fetch_default_test (the card rule, the table, apply_nv_defaults with the user's value,
the off switches); settings register: status default.
2026-11-19 19:22:00 +01:00
Niko1221 ae4239aca6 Merge f-bw-f (two-card CPU prefill share by default) into the 0.2.17 release candidate 2026-11-19 18:55:56 +01:00
Niko1221 a620ffb619 CPU prompt share: the limit and the expert width follow the card's PCIe link (compute capability 12.0 default, STRATA_PREFILL_CPU_SHARE_AUTO=0 to get 3,072 / 8 back)
The default share took chunks up to 3,072 tokens and experts of at most 8 tokens, a setting measured on one 28 GB/s link.  A chunk from the limit up streams every expert the card does not hold in
one pass whose time F (bytes of the missing experts / the link) does not depend on the chunk length; the staged walk with the share grows with it, so the share pays up to a length T* that
grows with F.  RTX 5090 cards, UD-Q4_K_XL (8,056 of 24,576 experts on the card), 3 interleaved rounds, the share with 32-token experts against the default: T* 4.2K tokens at 53.6 GB/s (15 pool
workers), 8.8K at 28.3 GB/s (22), 14.0K at 14.1 GB/s (32), 19.7K (32-token experts) / 25K (64-token experts) at 3.6 GB/s; 8 pool workers 7.7K, 16 workers 8.5K (22: 8.8K).  At 53.6 GB/s the
default 3,072 beats streaming by 25-34% from 1,536 tokens and above ~4K staged equals streamed, so the rule never goes below 3,072.

share_rules.hpp link_rule(): limit = 3.4 x F (ms) tokens up to F = 3.67 s, +0.76 tokens per ms of F above it, between 3,072 and 20,480, scaled by (workers / 22)^0.15 for smaller pools; experts of
up to 32 tokens (64 from F = 3 s) where the limit is raised.  Prefill::set_card_expert_share takes the pool's workers; arm_cpu_share applies the rule to the default-armed share only (an explicit
STRATA_PREFILL_CPU_SHARE, STRATA_PREFILL_CPU_SHARE_MAX and STRATA_PREFILL_CPU_SHARE_NT keep their meaning) and prints one "CPU share rule:" line.  STRATA_PREFILL_CPU_SHARE_AUTO: unset = cc 12.0
discrete cards with the link probed, 1 = any CUDA card, any other value = off.  Settings register, docs, unit tests (share_rules_test) updated.
2026-11-19 17:28:01 +01:00
Niko1221 e9c9d504cc CPU rows prefetch: the non-x86 branch passes a constant locality to __builtin_prefetch (clang on arm64 refused the computed one; the Metal engine did not build)
BW-G's row_prefetch.hpp (STRATA_ROW_PF) chose the locality with a conditional; __builtin_prefetch needs a constant integer. One call per case, the same three localities. x86 is unchanged (it takes the _mm_prefetch branch).
2026-11-19 16:39:25 +01:00
Niko1221 4a409b919b Serve: the first request's free-VRAM note is said only when the free memory fell since the start-up line or is under 512 MiB (item 17)
0.1.62 and before warned "only N MiB of VRAM free at the start of this request" at the first request of every start below 1 GiB (512 MiB off
Windows), also on a card the expert cache fills on purpose. The rule is now strata/core/vram_request_notice.hpp: say it below the safe figure
when the free memory is at least 64 MiB lower than the start-up line reported (generate.cpp keeps that figure in g_startup_vram_free_mib; the
request compares the same figure the start-up line prints) or is under 512 MiB; with no start-up figure the old rule stays. The text is the
owner-approved wording of TEXT-BATCH-0217 item 4 (Windows says "Windows", other systems "the driver"). Once per 128 MiB lower, as before.
Test: vram_request_notice_test (header-only, CPU). docs/DETAILS.md describes the new rule.
2026-11-19 16:24:56 +01:00
Niko1221 38e6a05061 Layer split of two CUDA cards: the CPU prefill share is armed by default, as on one card (STRATA_SPLIT_CPU_SHARE=0 turns it off)
Until now the default CPU prefill share (idle pool takes some of the experts a prompt chunk would stream over PCIe, chunks up to 3,072 tokens) was armed on one card only.
A layer split streamed every expert of every short prompt over PCIe, stage after stage, so a prompt of 32 to 566 tokens took 1.4 to 1.8 times as long on two
RTX 5060 Ti 16 GB as on one (UD-Q4_K_XL, DFlash2, PCIe 4.0 x8, 48 cores). The stages already take the pool one at a time (prefill.cpp), and
STRATA_PREFILL_CPU_SHARE=auto works on a split; only the default was missing.

share_rules.hpp: default_share_layout(later_stages, multi_gpu, env, cuda): one card as before; one later stage (two cards) on a CUDA build by default, the
switch both ways; three and four cards, the helper caches and HIP / SYCL builds stay off. generate.cpp (serve): the H11 memory check and arm_cpu_share use it,
one start-up line says so. share_rules_test: the layout table.

Prompt ms, two cards, default share off against on (3 rounds, tail skip off): 32 tokens 605 -> 268, 64: 825 -> 384, 84: 1,193 -> 489, 169: 1,680 -> 669,
566: 3,188 -> 1,574, 1,024: 2,869 -> 1,754, 2,048: 4,547 -> 2,512; 4,096 and longer are above the limit (+2%). Details and the KL gate: phaseA-tests/bw/RESULTS-BW-F.md.
2026-11-19 16:23:40 +01:00
Niko1221 902ea23283 CPU pool: STRATA_POOL_DEP is on by default (the per-expert dependency queue of a native layer call); STRATA_POOL_DEP=0 is the way back
BW-G measured it bit-exact (BASE-05 27 of 27, pool_determinism --reps 20, 124,656 checks) with the CPU pool's window -2.9% on an RTX 5090 + EPYC box.
ExpertPool's constructor reads the variable once: unset or anything but "0" is on. Not under the NUMA split and not for Q2_0 down rows, as before.
A second ctest, pool_determinism_dep_off, runs pool_determinism with STRATA_POOL_DEP=0 so the way back stays covered.
2026-11-19 16:23:12 +01:00
Niko1221 d6ef2d2be1 Slot read switches: the wide and ahead rules in batch_groups.hpp, with a test that they are off unless set and only beside what they build on (#5866, #5868) 2026-11-19 16:21:25 +01:00
Niko1221 240aeb9858 [Engine] prefill tier sort, Volta WMMA, NVLink P2P peer prefill and stage hand-offs, P2P decode scatter (#6023)
From PR #6023 (midhatn; its engine commit 3440d4609), author kept. The engine, the unit test and the register entry are taken;
the PR's docs (docs/NVIDIA_V100.md rows, the bench report under docs/bench-results/) are not (they describe the mechanisms as
measured on 2x V100-SXM2 NVLink only). What the commit does:
- STRATA_MMQ_TIER_SORT=1 (opt-in): the experts of a prompt chunk go in readiness-tier order (VRAM, pinned RAM, file stager) and
  row-count order within a tier (mmq_resident_sort.hpp, mmq_resident_sort_test), in the staged walk, the layer-major walk and the
  peer's walk; under it an async P2P copy (cudaMemcpyPeerAsync + an event) hands a chunk's hidden state from one layer-split stage to
  the next;
- pf_wmma() (STRATA_PF_WMMA=1, opt-in) is no longer compiled out of an MMQ-free build;
- Prefill::set_peer() works on an MMQ-free build: int8 (q8_1 over P2P) or WMMA expert kernels on the peer card, the peer's gathers
  grouped (gather_native_group), the 35 % peer stream over every layer the peer can take;
- the decode peer's output goes straight into the primary's hit_out buffer over P2P (hit_out_dev), and the layer split's hand-off
  buffers sit in VRAM when two cards can reach each other;
- the staged walk's stream-ahead window counts pending copies (max_pending), the layer-major walk groups its gathers
  (STRATA_PREFILL_GROUP_GATHER, on unless 0).

This commit is the PR as it came; the next commit of this series turns the pieces that change a default (VRAM hand-off buffers,
decode scatter, tail-skip rules, layer-major group gather) into opt-in switches and says why.
2026-11-19 16:21:18 +01:00
Niko1221 d59c367522 verify window: one routing launch pair per layer for a non-native router, opt-in STRATA_ROUTE_WIN=1; a profile stamp for the routing (#3476)
From PR #3476 (pugolini; its commits 51d8370a8 and 70813d5b8), author kept; hand port, and the default is changed. The native router is
512 x 10 only, so a 256-expert model (Qwen3.8-Flash-Next Coder) took the per-token moe_route loop in the verify window,
a projection and top-k launch pair per token and layer. moe_route_window (one multi-column BF16 projection and one top-k per
layer, bitwise the per-token calls by route_window_parity) was reachable on gfx906 builds only; the PR made it the default on
every HIP card. Here the branch is compiled on every backend and route_window_on() keeps gfx906's default (on) and makes
every other backend opt-in (STRATA_ROUTE_WIN=1), because we have not repeated the PR's measurement (R9700, Coder IQ1_M,
--spec 4: routing 3.34 to 1.39 ms a window, decode +9%, same output hashes). Also taken from the PR: profile stamp slot 33
("router (proj+topk)", under STRATA_VERIFY_PROFILE=1) splits the routing from the plan / doorbell time, and
route_window_parity now covers T = 1..6. Unset, the launches on CUDA, HIP and Metal are the ones before. The name is in the
settings register (status research); the parity program on the R9700 is in the gate table.
2026-11-19 16:19:26 +01:00
Niko1221 6175deb948 MTP: --mtp-q4 head/all says so when no draft-head subset is installed (#4333)
From PR #4333 (xyzzing; its commit 9da37ce3e), author kept, changed from a refusal to a warning.
--mtp-q4 head (and all) requantizes the draft head's token subset, but make_q4_head() is only reached inside the
draft_vocab.bin branch of MtpDrafter::bind(). With no rt/draft_vocab.bin (and no --mtp-draft-vocab) the flag did
nothing and drafting ran over the full head, with no hint (the reporter lost a measurement window to it). bind() now
prints a line that names the missing subset and the fix (tools/draft_vocab.py, or --mtp-q4 proj). The PR made bind()
fail; here it only warns, because the setup config of some machines passes --mtp-q4 all and a pack without a subset
used to start (warnings over refusals). It stays silent for the shared-drafter path and for rebinds, as in the PR.
The usage line, the option comment and the set_q4 header comment state the requirement. Nothing else changes.
2026-11-19 16:19:23 +01:00
Niko1221 abb120c5e7 CPU Q2_0 rows: a CPU with AVX but no AVX2 takes Strata's AVX1 rows, and the AVX1 bit-plane row does its float work on 256 bits (#4854)
From PR #4854 (Keoian; its commits 43e390e0e and 7a68664ac), author kept. On a CPU with AVX and no AVX2 (the older-CPU
source build, STRATA_ISA_FLOOR=avx) q2_native_kernels() admitted AVX2 only, so every native pack's Q2_0 expert ran on
ggml-cpu's own vec_dot and never reached the AVX1 rows of q2_avx1.cpp. It now also admits cpu_avx1_ok(); a CPU
without AVX keeps ggml-cpu. On a CPU with AVX2 nothing changes (the first term is true as before). The AVX1 bit-plane
row (STRATA_Q2_BITPLANE=1) computes a pair's float part in one 256-bit register, block 0 in the low lanes and block 1
in the high ones, each lane with the operations of the 128-bit form, so its bytes do not change; h2f_scale converts a
normal fp16 block scale in four integer operations (h2f's normal branch, bit for bit; zero, subnormals, inf and NaN
still take h2f). Author's numbers (i7-3770): a one-token Q2_0 expert 0.975 ms on ggml-cpu, 0.487 ms on the AVX1 rows,
0.297 ms with the bit-plane form; decode on 2x RX 5700 XT 14.97 to 22.38 tok/s. Not measured by us (no AVX-only CPU);
q2_bitplane_parity (AVX1 form against its 128-bit legacy form) with STRATA_Q2_BITPLANE=1 is in the gate table.
2026-11-19 16:19:22 +01:00
Niko1221 4e94b05592 SYCL start-up line: a CPU with AVX-512 VNNI but no VBMI no longer reads "no AVX-512" (#5481)
From PR #5481 (nekorobi-0; its commit 0946bbd77), author kept. On a CPU with AVX-512 VNNI and
no VBMI (Cascade Lake) the SYCL engine's start-up line said "this CPU has no AVX-512: the expert kernels run on AVX-2",
even with STRATA_VNNI_TIER=1 on. The line now says which case it is: no AVX512-VNNI at all; the VNNI tier off or not
available; or (with the tier on and no VBMI) "AVX-512 VNNI tier enabled (no VBMI)". The cpu_vnni_ok() header comment
names the DQ requirement and the switch, and docs/DETAILS.md gains the STRATA_VNNI_TIER row (off by default: those
rows round differently from the AVX-2 rows). Log text and docs only; no computation changes. The two new lines are in
the results file's text list.
2026-11-19 16:19:21 +01:00
Niko1221 4ced1736e9 STRATA_TAP_FILE works on a layer split (#5748)
From PR #5748 (botBehavior; its commit 5d3f3cda6), author kept. STRATA_TAP_FILE (the residual-stream research dump)
was dropped without a message when the model ran on a layer split: Verifier::init cleared the path unless one verifier
held every layer. On a split each stage now parses STRATA_TAP_LAYERS (same rules as one card: sorted, unique, the last
layer excluded), keeps the layers inside its own range as the drafter's taps do, and the first stage opens the file,
writes the header with the whole layer list and, after the chain has run, gathers every stage's rows to the host
(gather_taps_host) and writes the window, on both the overlapped and the sequential return path. The file has the same
"STAP" v1 layout as one card. Two messages say so when the dump cannot be done (no layer in range; the drafter owns the
split's taps). With STRATA_TAP_FILE unset nothing new runs (tap_split_ stays false) and the one-card path is unchanged.
Author's check (2x RTX 5070 Ti, 2 stages): replies byte-identical with the dump on and off, rows against one card
at cosine 0.998 or more per layer in the median, no empty slots. Not run by us (it needs two cards and a model); the
CUDA build is checked on l620.
2026-11-19 16:19:20 +01:00
Niko1221 43e44ac3b7 Windows file tier: opt-in STRATA_BLOB_VERIFY re-reads each direct-read expert blob through a buffered handle and compares (#6166)
From PR #6166 (IvanAndreychikov; its commits 417611ae0 and 955198e42), author kept. A diagnostic for the non-finite
logits reports (#879, #6145): after the direct reader (read_direct) delivers an expert blob, the same byte ranges
are read twice through an independent buffered handle (one synchronous handle per thread and shard) and compared. A
mismatch is reported only when both buffered reads agree with each other and differ from the direct bytes, with the
shard, offsets, a hexdump and a third view from a read-only file mapping that says which side is wrong. A summary
line is printed at exit. STRATA_BLOB_VERIFY=1 arms it; STRATA_BLOB_VERIFY_DELAY_SEC holds it off during the start-up
fill. It is Windows-only code (the other systems compile to nothing), and unset it costs one atomic load per
blob. Both names are in the settings register (status research). Not run by us on a pack (no machine that shows the
fault); the Windows compile is checked on the owner PC build (see the gate table).
2026-11-19 16:19:19 +01:00
Niko1221 6520778870 gfx906 build: the HIP compat layer maps the two stream-priority CUDA names (#6246, also #5233, #3986, #4766)
From PR #6246 (shjszwh; its commit 6407cc70b), author kept. The gfx906 source build (-DSTRATA_HIP_GFX906=ON)
stopped in dflash2.cpp and verify.cpp ("use of undeclared identifier cudaDeviceGetStreamPriorityRange" and
cudaStreamCreateWithPriority): strata_hip.h had no alias for either name. It now maps both to their hip
functions, next to the other cuda-to-hip device and stream names. The same gap was reported in #5233, #3986 and
#4766; those three fix it in dflash2.cpp alone (a macro test or a missing guard), which would leave the other callers
(mtp.cpp, verify.cpp) unmapped, so only the compat-layer fix is taken. No effect on a build that already compiled.
2026-11-19 16:19:18 +01:00
Niko1221 4965bec412 gguf_reader: the header bounds check cannot wrap on a huge string length (#4536)
From PR #4536 (schmittcn; its commit 78f48d507), author kept. Cursor::need tested pos_ + n > size_. A GGUF whose
tensor-name (or key) length is near 2^64 made the sum wrap to a small number, so the check passed and the read went
on; only std::string's length_error stopped it. The test is now n > size_ - pos_ (pos_ never passes size_, so the
subtraction cannot wrap). gguf_reader_test gains a case with a name length of UINT64_MAX - 15: it is refused as
"unexpected end of file in header" (before the fix it ended in a different error).
2026-11-19 16:19:16 +01:00
Niko1221 7e89e22cf7 Merge f-fix-win-eng (FIX-WIN engine, #3725) into f-eng-0163 2026-11-19 16:19:04 +01:00
Niko1221 0476b64aae Merge f-fix-gpu (FIX-GPU) into f-eng-0163 2026-11-19 16:19:01 +01:00
Niko1221 88b8578c3b Merge f-fix-eng (FIX-ENG) into f-eng-0163 2026-11-19 16:18:56 +01:00
Niko1221 87d20b7cc8 Merge f-tailskip-engine (engine: STRATA_ROUTE_TAIL_SKIP off when unset) into f-eng-0163 2026-11-19 16:18:53 +01:00
Niko1221 29ca1fca37 Merge f-bw-e (BW-E: CPU prompt share, VNNI rows) into f-eng-0163 2026-11-19 16:18:53 +01:00
Niko1221 48a40d32f8 Merge f-bw-b (BW-B: GB10 sm_121 defaults) into f-eng-0163 2026-11-19 16:18:41 +01:00
Niko1221 15b55d5581 Windows HIP: --adapt-async 1 and STRATA_ADAPT_OVERLAP=1 are refused unless STRATA_WIN_HIP_RISKY=1 (#5672, #5738)
On an RX 7900 XTX (Windows, HIP) --adapt-async 1 ended long generations with a verify timeout and a display-driver reset every 1 to 3 long answers;
without it the same engine and config ran clean at the same speed (#5672). STRATA_ADAPT_OVERLAP=1 on a gfx1030 card (Windows, HIP) ended the first
request with a GPU fault and a display-driver timeout; it was confirmed on CUDA only (#5738). Both are opt-in. On a Windows HIP engine the engine now
starts with each of them off and prints one line saying why. STRATA_WIN_HIP_RISKY=1 takes both as asked and prints one warning line. Linux HIP, CUDA,
SYCL and Metal are unchanged.

Decision and the lines: include/strata/core/win_hip_risky.hpp; test win_hip_risky_test (both platforms, with and without the override, the lines).
The setting is registered with status research. STRATA_NUMA_BALANCING (the earlier HIP NUMA commit) was missing from the register and is added with
status default: tools/test_settings_register.py failed on it. Windows cannot be run here: the Windows branch is two constants and was compiled on
the HIP build only as the Linux side.
2026-11-19 13:59:21 +01:00
Niko1221 edef565b90 CPU pool: STRATA_POOL_DEP=1 runs a native layer call as one batch with per-expert dependencies (opt-in, off by default)
The two row phases of run_split_multi_native (gate/up, then down) end in a barrier: every worker waits for the slowest task of the phase, and the host quantizes the intermediate between them. With STRATA_POOL_DEP=1 the layer call is one batch (mode 7): the experts' gate/up row ranges first (expert-major), then the experts' down row ranges. A down task waits only for its own expert's gate/up tasks (a counter), and the first thread that gets there quantizes that expert's intermediate once. Every gate/up task has a lower index than every down task and waits for nothing, so a waiting down task always waits for a running task. The rows are computed by the same kernels from the same bytes: the outputs are the two-phase batch's bits (bwg_pool_bench hashes equal for Q4_K/Q5_1 and Q4_K/Q8_0 experts, 1-3 tokens, tasks 0 / 41 / 132, 1 and 3 workers). Not used under the NUMA split or for Q2_0 down rows.
2026-11-19 12:37:34 +01:00
Niko1221 a9a00cd48e CPU expert rows: STRATA_ROW_PF=<bytes> requests the weights a few rows ahead (opt-in, off by default)
The Q4_K / Q5_1 / Q8_0 row loops of native_gu_rows / native_down_rows can request the next rows of the expert while the current row is computed (row_prefetch.hpp; t0 / t1 / nta hint, a prologue for the first rows). It reads and writes nothing: the results are the same bits. On a 22-worker pool over a cold 6 GB arena it moves the layer call by at most 2.5% (0.389 to 0.379 ms), so it stays off.

Adds bwg_pool_bench: the pool's own run_split_multi_native on UD-shaped synthetic experts (Q4_K gate/up, Q5_1 / Q8_0 down), cold or hot arena, optional MADV_HUGEPAGE, a hash of the outputs.
2026-11-19 12:33:39 +01:00
Niko1221 de7ba14078 Verify window capture: an error an earlier call left pending is said and cleared, not blamed on the capture's first launch (#5636)
On sm_70 / sm_75 the first verify-window capture ended the engine with "copy_i32_from_mapped launch: invalid argument" on a plain grid-stride copy,
deterministically on a 2080 Ti, and on a V100 only until STRATA_VERIFY_DEBUG=1 changed the calls in between. The launch wrappers read
cudaGetLastError(), which returns the first error since the last read from ANY call of the thread, so an earlier call that failed unchecked is
blamed on the next launch that is checked, and that check exits.

Verifier::capture (CUDA builds) now reads the slot before cudaStreamBeginCapture: a pending error is said once with its text and number ("a CUDA
error was already pending before the verify window's capture") and cleared when it is not sticky. A sticky error (illegal address, lost device)
stays and fails the calls after it as before. Nothing a launch inside the capture produces is cleared. HIP and Metal builds are untouched.

Test: pending_cuda_error_test (a failing cudaMemcpy leaves its error in the slot; take_pending_cuda_error returns it and the slot is empty after;
nothing pending changes nothing; needs a device, exit 77 without).
2026-11-19 11:36:29 +01:00
Niko1221 2720fddb11 Prompt indexer: the batch append's refusal names the failed predicate and its values (#5822)
native_qsa_indexer_append_batch threw one text, "bad geometry, positions, parameters or scaling", for seven different causes (no stream, a wrong
geometry, a negative position, positions past the session's cells, a cell count or base past 2^31, a bad epsilon, a bad RoPE scaling). Three engine
exits on 0.1.58 could not be told apart, and nothing in the log said whether a prefix reuse had handed the append a position past the session.

The check moved into strata/kernels/qsa_batch_check.hpp (pure, no GPU): the text now starts as before and ends with the first failed predicate and
its values (p0, n and the session's cells, the block, the epsilon, the RoPE problem). The conditions are the same as before, so no request that
passed fails and none that failed passes.

Test: qsa_batch_check_test (every predicate, the position case with p0 / n / cells in the text, the old text kept at the start).
2026-11-19 11:36:29 +01:00
Niko1221 0e091d4f9f MTP: the draft head subset buffer holds the wider of the head's row and the Q4_0 row (#5841)
--mtp-q4 head|all rewrites the gathered draft-head subset in place as Q4_0 rows (n_embd / 32 * 18 bytes). bind() sized the buffer for the
head's own row, and an IQ4_XS head has the narrower row (1,360 bytes against 1,440 at n_embd 2560), so the host-to-device write went 8.1 MiB
past the buffer on a 106,299-token subset: "mtp: writing the draft head", engine exit 1 at load (GB10 defaults select --mtp-q4 all).

The buffer and the vram_ account now use mtp_draft_head_row_cap (strata/core/mtp_head_rule.hpp): the wider of the two rows. Formats at least
as wide as Q4_0 (Q6_K, Q8_0) and --mtp-q4 off are unchanged.

Test: mtp_head_rule_test (IQ4_XS 1,360 -> 1,440, wider formats and q4 off unchanged, n_embd not a multiple of 32).
2026-11-19 11:36:29 +01:00
Niko1221 ad9aa75973 RAM probe: a cgroup without a memory.max, or a path outside the mount, no longer ends with "cannot determine available memory" (#5196)
host_available_memory (the probe behind --resident-experts, --resident-budget-gib and the arena's RAM check) returned false on two cgroup v2 shapes
that carry no problem for the memory itself, and the engine then read every expert from the files (--mmap-experts) with RAM free:
- a group in the process's chain that has no memory.max (the memory controller is not switched on for it, as for many desktop session scopes): it
  counts as no limit of its own now, and the groups above it are still read;
- a container whose /proc/self/cgroup names the host's path while /sys/fs/cgroup is its own group (no cgroup namespace): the path is not in the
  mount, so the mount's root is read as the process's own group (on a real v2 host the root has no limit, MemAvailable alone).
An unreadable or malformed limit still fails, and the failure now names what could not be read (HostMemory::why), appended in brackets to the three
"cannot determine available memory for ..." messages (the texts keep their start).

Test: file_expert_source_test (test_host_memory): a controllerless child, the parent's limit above it, a path outside the mount with and without a
limit on the mount's root, an unreadable memory.max. The cases that expected a failure for the first two shapes are replaced.
2026-11-19 11:24:56 +01:00
Niko1221 becf4a3d9a Layer split: STRATA_SPLIT_LINK_MIN moves the gap from which a slow link scales the auto split's miss cost (opt-in, default 4 as before)
The auto split scales a stage's miss term by the gap to the fastest stage's link only from a 4x gap on.  A PCIe 4.0 x2 slot beside a x8 one (3.6 and 14.1 GB/s probed on a rented
2x RTX 5090) is a gap of 3.92: unscaled, so auto picks K=24 and the x2 card streams ~3,000 experts per prompt chunk (4K prompt 5,950 ms against 4,270 on the x8 card alone).
STRATA_SPLIT_LINK_MIN=3 reads that gap as a link gap; unset, empty or a value below 1 keeps 4.  split_rules_test covers the rule and the variable's text.
2026-11-19 11:22:10 +01:00
Niko1221 8d92f0a388 HIP: the arch choices of the prompt path and the drafters are made per card, not by the first card that asks (#4431)
gr_upmix (prefill/kernels.cu) cached "this card has gfx11 matrix cores" in a function-level static, so on a layer split over an RX 7900 XTX (gfx1100)
and an RX 9070 XT (gfx1201) the card that reached it first decided for both: with the gfx1100 stage first, the gfx1201 stage launched the gfx11 kernel
and the first prompt died with "prefill gr_mix_r: no kernel image is available for execution on the device" (the error check after it names the next
kernel, not the bad launch). The same one-answer-for-all-cards form decided the fused hyper-connection read (STRATA_QFUSE_HC default, verify.cpp), the
DFlash2 Q4 kernel pick (dflash2.cu) and the MTP drafter's stream priority (mtp.cpp), all on "is this a gfx12 card". Each now asks once per device
ordinal through strata::core::PerDeviceFlag; the environment overrides still win for every card.

Test per_device_flag_test (host only, fake arch table: a gfx1100 first then a gfx1201, and the reverse); --legacy is the process-wide form, registered
WILL_FAIL. On a single card nothing changes: identity gate on the R9700 (gfx1201) in RESULTS-0217-FIXGPU.md. Not run on a mixed gfx11 + gfx12 pair: none here.
2026-11-19 11:10:57 +01:00
Niko1221 5152c03663 --batch-mtp: the slot's own draft counters reach the response (#5890)
With --batch-mtp the proposals are checked in the slot windows and were counted only in the engine's totals and its log, so every response of a batch-path
request read timings.draft_n = 0 and draft_n_accepted = 0 (and last_timings) while /metrics and the log showed real drafting; users read it as "MTP is off".

Each batch slot now counts the proposals its windows checked and kept (both the serial and the pipelined group path), and its BDONE line ends with
` drafts=<checked>:<kept>` (nothing is added for a slot that checked none; an older server ignores the key). The server's _apply_bdone adds them to the admission's
DONE counters, which feed the response and the per-request record.

Tests: terminal/serve/test_parallel.py BatchDraftCounters (fake engine with --drafts: the response record reads them; without the key it reads as before),
engine/src/program/bdone_drafts_test.cpp (the text).
2026-11-19 11:09:13 +01:00
Niko1221 027aac9bd7 The window warm-up is skipped while STRATA_ROUTE_PRIOR is on (#6171)
The warm-up before READY runs one dummy window per width on token id 1; its misses page that token's experts into the GPU expert cache. With the route prior
on, the first request is routed towards what is resident, so those experts bend its answer: on an RTX 3090 (IQ4_XS, 60K-token passkey prompt, 8 starts per arm) the
probability of <|im_end|> summed over the 8 answer digits had a median of 4.8 to 7.4 % in the first request after a start, 1.7 % with STRATA_WINDOW_WARM=0, 1.4 % with
the prior off (reporter's measurement).

window_warm_on(STRATA_WINDOW_WARM, prior): "0" off, "1" on, unset: on unless the prior is on. Nothing changes without STRATA_ROUTE_PRIOR (the default).
The cost is the graph build of a width that the policy first picks inside a request, tens of ms once.

Test: arch_defaults_test (window_warm_on rows). Not measured here: the reporter's 8-start passkey runs need a 3090 with the arena filled.
2026-11-19 11:09:13 +01:00
Niko1221 a086371eb2 vmm.hpp includes <cstddef> for size_t (gcc 12 build, noted on #5241)
include/strata/core/vmm.hpp uses std::size_t and size_t but only included <cstdint> and <vector>; gcc 12 (gcc-toolset-12 on
AlmaLinux 8) does not get it from those. One include line.
2026-11-19 11:09:13 +01:00
Niko1221 e420271229 strata-q36: a hybrid placement that does not fit with the staging pair is tried without it (#5533, #5285)
On a 10 GB card the Qwen3.6-35B-A3B hybrid placement needed 1696 MiB for its buffers against 989 MiB free after the
weights, the context and the sessions, and nothing the user could set changed that figure: the two staging buffers of
the streamed prompt path (twice the largest layer's experts, 1.3 GB for UD-Q6_K_XL) are alone larger than the free memory.
The message told the user to use fewer slots or a shorter context, which cannot lower it.

place_experts now asks hybrid_plan (include/strata/qwen35/hybrid_fit.hpp, the old arithmetic moved there unchanged).
When the plan with the staging pair does not fit, the plan without it is taken: the streamed prompt path stays off (the
state a layer set with no fast prompt route already has), every batch up to a chunk's rows runs its resident experts on
the GPU and the rest on the CPU pool, and one line says so. Prompts are slower there; the model starts instead of
stopping. STRATA_Q36_KEEP_STAGING=1 keeps the old plan. When even the plan without the pair does not fit, the old
message and exit stay.

Test: engine/tests/program/q36_hybrid_fit_test.cpp (the 10 GB card's figures: old plan does not fit, new plan fits with
2 slots; a big card keeps the staging; a tiny one is still refused; the MTP-only placement and --expert-slots).
2026-11-19 11:09:13 +01:00
Niko1221 87c9821bb1 HIP Linux: keep the kernel's NUMA balancing off the engine's memory (#4866, from PR #4867)
With kernel.numa_balancing=1 the NUMA scanner marks the PTEs of the expert arena (registered with hipHostRegister, a KFD userptr range) PROT_NONE
to sample which node touches it; each change invalidates the range and KFD evicts all of the process's GPU queues until it is validated again.
On a two-socket host that was 77-236 s of eviction per engine start and the "no progress for 60 s" stops (7 of 20 fresh 1K prompts), with free
RAM and no swap. The engine now sets MPOL_LOCAL (the same first-touch placement, but the scanner skips the memory) at the top of main(), before
any thread is made, when numa_balancing is on and no policy was set by the user (numactl keeps its own). STRATA_NUMA_BALANCING=keep leaves the
default policy. HIP builds on Linux only; the reporter's PR also changed the CUDA engine, which this commit does not.

Ported from PR #4867 by vivienfanghuagood (header, test, main() call; the hunks moved under engine/ and gated on HIP). The author line of the
original commit is not kept here: the commit is made as the repository owner, the PR author's work is named in this message. Test: numa_balancing_test (the decision, header-only).
2026-11-19 10:56:23 +01:00
Niko1221 64b02d0c3f STRATA_DENSE_MMQ: say at start-up that it does nothing in an engine without MMQ (#6269)
Since the MMQ kernels left the HIP and CUDA builds (0.2.16), STRATA_DENSE_MMQ=1 changes nothing: the dense projections of a prompt always run as
dequantize + FP16 GEMM. The setting was still in docs/AMD_HIP.md as a working switch, so a user tuning an RX 6000 card changed a dead knob.
The engine now prints one line at start when the setting is on; docs/AMD_HIP.md says it has no effect since 0.2.16.

The gap the reporter measured on gfx1030 (dense projections 4K prompt 1342 against 2310 tok/s with the old MMQ build) is a missing int8 dense
kernel for RDNA2, not a setting; that work is not in this commit.

Test: dense_mmq_notice_test (header-only, no GPU).
2026-11-19 10:56:01 +01:00
Niko1221 cca2d983a9 Layer-major prompt walk counts the model's experts, not the compiled shape's (#5104, #5354, #5966, #6018, #6134)
A pruned pack (GSQ-RCO Coder IQ1_M: 48 layers, 256 experts) on the default engine, whose kernels are compiled for 512 experts:
lm_run used the compiled count NE for its prefetch loop, its count tables and the stride of the resident-slot table. The prefetch
asked the stager for experts 256..511, which the pack does not have ("prefill: the expert source could not copy experts 256.. of
layer 0", abort, exit 0xC0000409 on Windows), and host_res (n_layers x the model's n_expert) was read with a 512 stride, so every
layer from 1 on looked at another layer's slots and layers from 24 on read past the table's end. The walk is reached from two
chunks on a small expert cache (the small-card rule) and on every layer-major read, so it hit every card with a small cache.

The walk now loops over lm_expert_count(g.n_expert, NE) and the prefetch list comes from lm_streamed_experts (prefill/lm_walk_rule.hpp).
512-expert packs run the same code with the same count.

Test: lm_walk_rule_test (header-only): a 256-expert pack lists 0..255 and not one more, the slot table has the model's stride,
a resident or pinned expert is not streamed, the compiled count as the bound lists 512.
2026-11-19 10:48:29 +01:00