Commit Graph
1164 Commits
Author SHA1 Message Date
Niko1221 265ac73524 Merge f-0216-tune-vt (03b402dad): the start-up line names the native output head's real GGUF type (#6030); the Volta int8 prompt products on the FP16 tensor cores for long prompts, bit-identical (#6053) 2026-11-16 16:06:46 +01:00
Niko1221 03b402dadb Int8 prompt kernels on Volta: the same products on the FP16 tensor cores for long prompts, bit-identical (#6053)
On a Tesla V100 every routed expert of a prompt runs on the int8 dp4a kernels (Volta has no int8 matrix
cores).  From about 8K tokens up they lost to MMQ per layer (0.82-0.83 of its speed at 26,000 tokens with
the two-block tile), and with every expert resident (#6053's 6x V100) that loss is most of the prompt gap.

Change: src/kernels/cuda/i8h_volta.cuh, i8h_kernel (tile code 5, compiled for sm_70 only; a trap
elsewhere): 64 weight rows x 64 entries a block, K in stages of 128, the decoded int8 codes of the
weights and activations stored as FP16 (integers -128..127: exact), mma.m8n8k4 with FP32 accumulators,
a fresh accumulator per 32-value sub-block (per 16 values for the two-scale formats).  Every partial sum
is an integer below 2^24, so it is exact in any order; the epilogue then does the dp4a kernels'
arithmetic on the same integers in the same order (t = s1 m1 + s0 m0, acc = fmaf(t, base * d_x, acc),
sub-block after sub-block).  The output is bit-identical to the dp4a tiles'.  The fragment layout was
checked on the V100 (phaseA-tests/tune0216/probe_m884.cu: every (quad pair, row, column) once).
Formats: every one without a per-32 minimum (the IQ3_S / IQ3_XXS / IQ2_XXS sets, Coder, IQ4_NL / Q2_0 /
Q8_0 downs, Q6_K); Q4_K / Q5_K / Q5_1 keep the dp4a tiles.  44 KB shared memory: two blocks per SM.

The pick is automatic: i8_expert_rule.hpp i8_tile_volta takes tile 5 from kI8hMinAvg = 160 entries an
expert on average (about 8K-token chunks) on a compute capability 7.0 card, the two-block tile below;
STRATA_I8_SM70=0 turns the Volta rule off, STRATA_I8_TM forces a tile (research).  No other card class
launches it.

Tesla V100-SXM2 32 GB, one layer of Flash-Next's shape (bench, uniform routing), MMQ time / time, tile 3
-> this kernel: 4,096 tokens 1.06 -> 0.88 (the rule keeps tile 3 there), 8,192 0.947 -> 0.954 (IQ3_S),
0.906 -> 0.945 (IQ2_S / Q2_0), 12,288 0.906 -> 0.946, 16,384 0.858 -> 0.888, 26,000 0.820 -> 0.859
(IQ3_S), 0.823 -> 0.889 (IQ2_S / Q2_0); output hashes equal in every cell.

End to end, 5 interleaved rounds, one V100, prompt ms (the previous commits = t3, this = t6, released
0.1.58):
  every expert resident (Coder IQ1_M, 12,288 slots):   t3 / t6 / 0.1.58
    256       393 /    392 /    532
    2,048   1,519 /  1,540 /  1,687
    8,192   4,876 /  4,789 /  4,739
    26,000 15,251 / 14,794 / 14,992
  IQ3_S, experts streamed (13,513 of 24,576 slots):
    256       710 /    715 /    740
    2,048   2,266 /  2,262 /  2,293
    8,192   5,133 /  5,087 /  5,239
    26,000 15,409 / 15,068 / 17,464
  (the repeat of t3 within 0.6 %)

Identity against 0.1.60 (gate21, first-token logit dumps and generated tokens, the reference's repeat as
control): IQ3_S streamed 10 of 10 dumps and 10 of 10 token sequences equal; Coder all resident 10 of 10 /
10 of 10.  Unit test: i8_expert_rule_test (the tile-5 threshold and format gate).
2026-11-16 15:18:15 +01:00
Niko1221 978b7a8d37 Merge f-0216-ggml2 (88b5ca6d0): own-stack steps 4, 5, 9 and 10: the Intel Arc CPU pool on Strata's quant layer, Strata's own quant format header, the web host's autostart.mjs gone, llama.cpp's MMQ build path and the vendored ggml-cuda removed 2026-11-16 15:15:10 +01:00
Niko1221 3e26b4e157 [Engine] remove llama.cpp's MMQ build path and the vendored ggml-cuda (own-stack step 10)
No release build compiled MMQ any more (x86 since 0.2.14, the DGX Spark since f-spark-nommq), so the path goes:
- CMake: the options STRATA_MMQ, STRATA_PREFILL_MMQ, STRATA_MMQ_TAB, STRATA_MMQ_TQ_OVERLAY, STRATA_ORCA_Q4KS_MMQ and STRATA_MMQ_KQUANTS, the
  macros strata_cuda_mmq / strata_hip_mmq / strata_pf_own_mirror / strata_ggml_mmq_types and the MMQ tests. Every CUDA and HIP build takes
  strata_cuda_pf_own / strata_hip_pf_own (Strata's own prompt kernels, mmq_absent.cpp for the MMQ half of moe_mmq.hpp), as the release builds did.
- Sources: moe_mmq.cu, moe_mmq_tab.*, mmq_tab_instance.cu.in, mmq_kq_lib.cu / mmq_kq_loader.cpp (libstrata_kq), mmq_nvfp4_w4a4/w4a8.cu,
  moe_iq4_w4a8.cu (called only from moe_mmq.cu), moe_ws*.cu, ggml_cuda_host.cu, mmq_expert_bench.cpp, mmq_nvfp4_parity.cpp, two headers,
  nine MMQ tests, the split engine's qdot_test.cu (its ggml-cuda oracle; qdot_golden stays), cmake/strata_ggml_tq_overlay.cmake and its test.
- third_party/strata-ggml/ggml/src/ggml-cuda and ggml-cuda-tq (64 manifest rows; check_vendored: 62 files, ok).
- The flags out of packaging/build_cuda_linux.sh, build_cuda_windows.py, build_hip_linux.sh, build_hip_gfx1103.sh, build_split_hip.sh,
  tools/hip/build_windows.bat, spark/build_engine.sh, setup.py, CMakePresets.json (cuda-compile builds strata only) and the Dockerfile.
  The strata_kq probes of the package scripts and setup's clean-up of an old libstrata_kq stay (no-ops now).
- Settings read only in the deleted files are retired in data/settings-register.json (STRATA_IQ4_W4A8, STRATA_MMQ_DIRECT, STRATA_MMQ_WS,
  STRATA_QUANT_GATHER, STRATA_W4A8_CFG, STRATA_WS_FAST; retired_in 0.2.16); docs/SETTINGS.md regenerated. Docs: lines naming the removed
  build options or settings deleted or shortened (AMD_HIP, BATCHING, DETAILS, DGX_SPARK_LINUX, GYRO, OLDER_GPUS, RADEON_780M, STRIX_HALO,
  UNSLOTH_Q4, packaging/ENGINE-COMPONENT.md). Tests that read the options follow (test_linux_aarch64, test_setup_stale_stamp,
  test_build_cuda_windows, test_gfx906_build_files).
MMQ comparison builds come from the v0.2.15 tag from now on.

Gates (A = f-0216-int f6de3a6c6 with its package flags, B = this tree, same folder):
- CUDA 13 (z440, sm_86 + sm_120 + PTX; and strata-split-2): host code identical; strata 155 of 156 device files identical, the one differing
  file only in native_mmvq_il_pf_kernel, which differs between two builds of A too (A/A2); the split's differing files (the same family and two
  PTX files) differ in A/A2 as well. CUDA 12.9 with SM60 (sm_60 + sm_86): host identical; the 4 differing device files are the same in A/A2,
  functions native_mmvq_il_pf_kernel and fused_gr.cu gr_down_v3_kernel (nvcc build-to-build: three compiles of fused_gr.cu.o give three PTX).
- HIP (p620, gfx1200;gfx1201, the rx9070 flags): f-0216-int with and without -DSTRATA_PREFILL_MMQ=ON -DSTRATA_MMQ=OFF gives the same
  build.ninja and byte-identical strata and strata-split-2, so the flag compiled nothing; this tree's strata is byte-identical to A; the split
  has identical disassembly (2,808 functions) and host code, raw bytes differing only in __hip_cuid / gpubin hashes (step 5's include path).
- tools/check_no_mmq.py on the CUDA strata and split (bytes, nm, cuobjdump: 5,524 / 3,225 / 5,632 device functions) and the HIP strata and
  split (bytes, nm): clean.
- SYCL (p1004, icpx 2026.1.1): builds, 117 steps, no ggml. Metal (m1002, packaging/mac/build_engine.sh --stages engine): builds, 2 ggml names
  (ours). The aarch64 (Spark) compile is not run here: it runs with the Spark engine release check when the Spark is restarted.
- pytest tools/test_*.py + test_linux_aarch64 / test_loader_diag / test_tuning_availability_0213 (boston): 1,694 passed, 15 skipped, 2
  failed in test_gfx906_build_files (asserted the deleted macro's gfx906 lines; rewritten, 3/3). settings_register --check and
  test_settings_register, check_vendored, check_links: ok.
2026-11-16 15:04:34 +01:00
Niko1221 f41d35929e Int8 prompt kernels on Volta: the tile that keeps two blocks per SM, and the big grids read from global memory (#6053)
A Tesla V100 has 96 KB of shared memory per SM.  The int8 tile kernels' tile 8 (54-62 KB) and tile 4
(51-59 KB) run one block of 8 warps per SM there; tiles 2 and 3 of the IQ3 formats (43 / 48 KB) run two.
IQ2_S's 8 KB codebook grid in shared memory kept even its tile 2 / 3 at one block.

Change (compute capability 7.0 only; STRATA_I8_SM70=0 is the research switch back):
- i8_expert_rule.hpp i8_tile_two_blocks: the pick (tile 8 counts as 4) is lowered to the largest tile 2-4
  whose shared memory leaves two blocks per SM (cudaDevAttrMaxSharedMemoryPerMultiprocessor and the
  per-block reservation, read once per device); a tile set by STRATA_I8_TM is kept.
- I8Smem / i8_kernel GG: the formats with a grid over 2 KB (IQ2_S, IQ2_XS, IQ1_M) read the grid words
  from global memory (L1) instead of staging them: the same words, so IQ2_S's tile 3 fits two blocks.
The tile only groups entries and the grid words are the same: bit-identical output (the layer bench's
output hash is equal at every tile; the engine identity below).  Other cards: the same code path as
before (the new instances are compiled but launched only on 7.0).

Tesla V100-SXM2 32 GB, one layer of Flash-Next's shape, uniform routing, MMQ time / int8 time (above 1:
ours faster), the old pick -> this rule at 8,192 / 26,000 tokens: IQ3_S / IQ4_NL 0.745 -> 0.949 /
0.795 -> 0.820; IQ3_XXS / IQ4_NL 0.721 -> 0.955 / 0.795 -> 0.831; IQ2_S / IQ4_NL (with the global grid)
0.70 -> 0.90 at 8,192.  Below 2,048 tokens the pick was 2 or 3 already: unchanged.
End to end with the previous commit (same build): see its message; the record fix alone (t2-style
rule-only build) measured 0.959 / 0.943 of 0.1.60's prompt time at 2,048 / 8,192.

Identity: the previous commit's gates ran on this tree (IQ3_S streamed and Coder resident 10 of 10
dumps and tokens; P100 BASE-05 9 of 9).  Unit test: i8_expert_rule_test (two blocks per SM, the
reservation edge at exactly 96 KB, the IQ2_S grid form; l620, g++).
2026-11-16 14:13:06 +01:00
Niko1221 5480e2bad4 Int8 prompt kernels: write each group's launch record with a small kernel instead of a host copy (#6053)
The int8 expert kernels (native_expert_i8) launch once per group of up to 16 experts, and each launch
read a 224-byte record (blob pointers, row bounds, group count) that prefill.cpp copied up from the host
with cudaMemcpyAsync on the compute stream.  With experts streamed that copy sits in the copy engine
behind the experts' own copies (about 480 MB a layer at 2,048 tokens on a 32 GB V100), so every group's
products waited for the experts in flight and copies and products ran one after the other.  MMQ uploads
nothing per group, which is why the build without MMQ lost most at mid-length prompts.

Change: native_expert_i8_put_record writes the record into the same device buffer with a one-block kernel
that takes the bytes as its argument (at most 512 bytes; i8_group.hpp checks the record fits).  The
bytes the kernels read are the same.  Reached only where the int8 kernels run: Volta for every layer,
the P100 below the stream floor, Turing for the K-quant sets; the fused paths have no such copy.

Tesla V100-SXM2 32 GB (sm_70), IQ3_S, one card, experts streamed (13,513 of 24,576 slots), CPU prompt
share 0, --pcie-frac 0, 5 interleaved rounds (with the Volta tile rule of the next commit in the same
build); prompt ms 0.1.60 / this / released 0.1.58:
  256      832 /   710 /   743
  2,048  3,707 / 2,273 / 2,291
  8,192  7,427 / 5,116 / 5,226
  26,000 17,716 / 15,302 / 17,467   (repeat of 0.1.60 within 0.4 %)
STRATA_PREFILL_TIMING, 2,047 tokens: the int8 expert step 2,753 ms before, 923 ms after (MMQ's gate/up,
down and dequantize 1,209 ms); 8,191: 4,640 -> 2,198 (MMQ 2,239).

Identity (gate21, first-token logit dumps, generated tokens; reference 0.1.60 and its repeat):
IQ3_S streamed 10 of 10 dumps and 10 of 10 token sequences equal (control 10 of 10); Coder IQ1_M all
resident 10 of 10 / 10 of 10 (control 10 of 10).  Tesla P100 (sm_60), BASE-05: 9 of 9 text prompts
identical to the released 0.1.60 baseline (ids and first-window logits md5), as 0.1.60 built the same way.
2026-11-16 14:12:51 +01:00
Niko1221 633db39c7b strata-q36 standalone entry: the Turing fused set-up as strata --model has it (one switch list for both entries)
The Qwen3.6 engine's run() is reached two ways: strata --model (generate.cpp's family switch, in the
strata process, after prefill.cpp's start-up list of a build without MMQ) and the standalone strata-q36
binary, which does not link that list.  The list sets STRATA_PF_FUSED_SM75, which Turing's fused set-up
(moe_fused_iq.cu dev_info) needs; the standalone entry never had it, so on a Turing card it ran every
Qwen3.6 layer on the plain int8 kernels while strata --model could take the fused ones.

Measured (RTX 2080 Ti 22 GB, sm_75, 250 W, Qwen3.6 UD-Q4_K_XL, launched as strata-q36): the start-up line
of a build with the Turing K-quant fused kernels still read "0 of 41 layers on the fused int8 kernels,
41 on our int8 kernels", and its prompt speed equalled 0.1.60's (0.896 / 0.881 / 0.863 of released 0.1.58
at 2,048 / 8,192 / 26,000 tokens, 5 rounds).

Change: own_only_switches.hpp q36_entry_switches(mmq_built) is the list run() sets when unset: the K-quant,
Q6_K and Q8_0 gate/up switches as before, and in a build without MMQ STRATA_PF_FUSED_SM75 as well.  A value
the user set is kept; a build with MMQ is unchanged.

Test: own_only_switches_test builds the environment of both entries (strata --model: the start-up list,
then run()'s; strata-q36: run()'s only) and checks that every switch the Turing fused decision reads has
the same value on both, with and without MMQ (l620, g++ 13: OK).
2026-11-16 13:57:09 +01:00
Niko1221 ffb11f0707 [Engine] quant format header: Strata's own, generated from its type tables (own-stack step 5)
include/strata/quant/strata-quant-common.h replaces llama.cpp's ggml-common.h text (third_party/strata-ggml/strata-quant-common.h, deleted).
tools/gen_quant_header.py writes it from tools/strata_quants.py BLOCK (every struct must add up to the bytes and values per block there, or
nothing is written) and tools/strata_quant_tables.py (the codebooks; ksigns64 and iq1s_grid_gpu are computed from them).

tools/test_quant_header.py: the header is current; every table equals strata_quant_tables.py and the GGUF reference (llama.cpp's
ggml-common.h in the vendored test oracle) byte for byte; every declaration is the reference's token for token (comments and static_assert
lines aside; the Metal iq1s_grid line is the one intended difference, Strata's since phase 1B); the static_asserts carry strata_quants'
sizes; with a C++ compiler the header compiles and its sizes and tables hold at run time.

The names (block_*, QK*, QI*/QR*, GGML_COMMON_DECL_* / GGML_COMMON_IMPL_*, GGML_TABLE_BEGIN) are unchanged, so every kernel compiles the
same tokens. third_party/ggml/ggml-common.h forwards to the new file; src/quant/internal.hpp and the split engine's qdot.cuh include it by
its new path; the Metal runtime's default path and the Mac package script take it from include/strata/quant. strata_quant_tables.py is
now described as Strata's copy (gen_strata_quant_tables.py --check proves it still equals the reference). The trellis header
(third_party/ggml/ggml-common-tq.h) is unchanged: Strata has no own copy of its codebook to generate it from.
2026-11-16 10:57:00 +01:00
Niko1221 e1a17f116b Merge f-gfx11-reset 5450e4344: the unregistered expert arena only on the Radeon 780M class
The owner's decision (by 11:05 on 11-15): NOREG's default applies to gfx1103 only (the 780M, 760M and 740M). gfx1150 and
gfx1151 keep the registered arena. LOAD, EXIT and XFER stay on for the whole integrated gfx11 class.
2026-11-15 11:10:03 +01:00
Niko1221 5450e4344d Integrated gfx11 under Linux: the unregistered expert arena only on the Radeon 780M class
The owner decided (by 11:05 on 11-15) that the default "arena not registered with the GPU driver" (NOREG, 8d1fadf92 and the
pinned.cu guard 05718a08f) applies to the Radeon 780M class only: gfx1103, which includes the 760M / 740M of the same chip
family. Strix Halo (gfx1151) keeps its registered arena. Strix Point (gfx1150, an experimental opt-in like gfx1103) also
keeps registration, as before NOREG.

Scope: only NOREG's class changes. LOAD (load order and settle), EXIT (the drain on a stop by signal) and XFER
(GPU_PINNED_MIN_XFER_SIZE) stay as they are for the whole integrated gfx11 class (gfx1103 / gfx1150 / gfx1151). Tokens are
the same in both modes.

How it is enforced: kfd_quiet.hpp gets NOREG's own rule, nodes_in_noreg_class: at least one GPU node in the KFD topology and
every GPU node gfx_target_version 110003. generate.cpp passes that rule to noreg_default instead of `true`, inside the
existing STRATA_USE_HIP && __linux__ block and still under the class check. Any other value (110500, 110501, a discrete
card, a 780M beside another card, no topology) keeps the registered arena. A user's STRATA_ARENA_PIN_GIB or
STRATA_UMA_REGISTER=1 still wins, and STRATA_KFD_QUIET_NOREG=0 (or STRATA_KFD_QUIET=0) still registers. pinned.cu changes
only two comments inside its Linux HIP guards.

Test: tests/core/kfd_quiet_test.cpp checks 110003 (unregistered), 110500 and 110501 (registered), discrete cards and
mixed machines (registered), the switches and STRATA_ARENA_PIN_GIB on top of the new rule, and that LOAD / EXIT / XFER keep
the whole class. g++ -std=c++20 -O1 -Wall -Wextra -Werror on p1004: ok.
2026-11-15 11:09:51 +01:00
Niko1221 cbb0a62d68 Merge f-gfx11-reset (6069c9d0c): the Radeon 780M fixes for integrated gfx11 under Linux
- f9932c6ae no GPU work right after the big load allocations
- 59375eb06 a stop by signal drains the GPU before the process ends
- f73fa7410 pageable copies staged by the HIP runtime
- f5f28ae74 kfd_quiet_test: build under -Wall -Wextra -Werror
- 8d1fadf92 the expert arena is not registered with the driver by default
- c3f6978b1 the prompt path can keep its own buffers instead of lending cache slots (off by default)
- 6069c9d0c two more first-request allocations made during the load
2026-11-15 04:14:40 +01:00
Niko1221 6069c9d0c4 Integrated gfx11 under Linux: two more first-request allocations made during the load
What the box showed (p2006, Radeon 780M gfx1103, 11-15): in every mode, registered or not, the first request still grew the GPU's
GTT by 10-15 MiB in 3-5 steps (for example +3 MiB at 87 ms and +10 MiB at 487 ms into the first 512-token request), while its
kernels ran.

Two of the candidates are now made before READY, inside the existing LOAD move (fix 1):
- one staged copy each way (2 MiB, pageable host memory, the null stream: the stream of the lent refill and the blocking cache
  fills) just before the last KFD settle, so the HIP runtime makes its staging buffer and copy path during the load and the settle
  waits for what that provokes. The 2 MiB device buffer is kept for the run;
- the CPU prompt share's pinned buffers (activations, rows, row scales) in Prefill::init at the sizes the first sharing layer asks
  for, for the largest chunk that shares. Only where the share is armed: it is off by default on this class (HIP keeps it off
  except on a single gfx12 card), so the default path allocates nothing here.
The DFlash2 tap staging needs no change: the serve path reserves it at load (sp.reserve_taps) before the settle.

Scope: HIP builds under Linux, the kfd_quiet class (every visible card an integrated gfx1103 / gfx1150 / gfx1151), through
kfd_quiet::load_moves() like the other load moves; nothing changes elsewhere. Token-neutral: no kernel and no computed value
changes; the copy writes only its own buffer.

Switch: STRATA_KFD_QUIET_LOAD=0 (or STRATA_KFD_QUIET=0) turns these off with the rest of the load moves. No new user setting and no
new user-visible line (one STRATA_TRACE line).
2026-11-15 03:14:32 +01:00
Niko1221 c3f6978b10 Integrated gfx11 under Linux: the prompt path can keep its own buffers instead of lending cache slots (off by default)
What the box showed (p2006, Radeon 780M gfx1103, 11-15): with the arena unregistered, every short prompt took 1.1-1.4 s more
(512 tokens 3,517 against 2,620 ms; 84-256 tokens about 2,850-3,050 against 1,500-1,920 ms). That time is the copy-back of the
1,967 cache slots (2.53 GiB) the prompt path borrows, from pageable memory, after every prompt. Without a loan there is no copy-back.

This extends the Strix Halo rule of 0.2.8 (Windows gfx1151: no loan) to this class, with two differences. The decision is made after
the expert cache is sized as with a loan, so the cache gets the same slots it gets today (--expert-cache N, or the auto size). And
the chunk stays the one the loan would have used: no drop to the 2,048 that --no-prefill-borrow alone gives an auto chunk. The
prompt path's own buffers must fit in what the driver reports free beside the cache and the reserve, with 3 GiB to spare (the
arithmetic of AUTO NO-BORROW); otherwise the loan stays. The chunk check at the prompt path's start then runs as for any path with
its own buffers. One GPU only, chunks up to 16,384.

Scope: HIP builds under Linux, the kfd_quiet class (every visible card an integrated gfx1103 / gfx1150 / gfx1151), one block after
the cache sizing in generate.cpp under STRATA_USE_HIP && __linux__; it reads class_flag(), so nothing changes elsewhere.

Default OFF: kNoLendDefaultOn in kfd_quiet.hpp is the one constant to flip once the box test decides. STRATA_KFD_QUIET_LEND=1 turns
it on for a test on the same binary; STRATA_KFD_QUIET_LEND=0, STRATA_KFD_QUIET=0 or STRATA_PREFILL_BORROW=1 keep the loan. No new
user setting and no new user-visible line (one STRATA_TRACE line). Unit tests: the switch rule and the pick, with the chunk kept.
2026-11-15 03:12:43 +01:00
Niko1221 8d1fadf925 Integrated gfx11 under Linux: the expert arena is not registered with the driver by default
What the box showed (p2006, Radeon 780M gfx1103, 11-15): with the load, exit and transfer fixes in, the registered arena still reset
the GPU on its first start (first 512-token request, queue 1, "Failed to quiesce KFD"). The same binary with the arena unregistered
(STRATA_ARENA_PIN_GIB=none) ran 12 of 12 starts and 144 of 144 requests clean, with no eviction and no page move after READY, and
gave the same tokens as the registered build on every request.

So on this class the arena takes the existing unregistered path (UMA mode) by default. In that default no mlock is tried: it cannot
succeed under the default memlock limit and only printed "mlock failed (raise ulimit -l)". The start-up line keeps today's text
without that part.

Scope: HIP builds under Linux, every visible card an integrated gfx1103 / gfx1150 / gfx1151 (the class rule of
igpu_kfd_settle_default, the same as the other kfd_quiet fixes). Enforced at the class site in generate.cpp, inside the existing
STRATA_USE_HIP && __linux__ block. Other cards and builds: arena_no_register() and the lock rule compute the same as before (the
rules moved to kfd_quiet.hpp as pure functions, with unit tests).

A value the user set for STRATA_ARENA_PIN_GIB wins (none / 0 / N / auto), STRATA_UMA_REGISTER=1 still registers, a
STRATA_ARENA_LOCK the user set still decides the lock. Switch: STRATA_KFD_QUIET_NOREG=0 (or STRATA_KFD_QUIET=0) registers the arena
as before. No new user setting; STRATA_TRACE prints one trace line.
2026-11-15 03:11:03 +01:00
Niko1221 64e95049ab prefill: the fused trellis prompt kernels are the default on Windows gfx1151
kG1151DefaultOn = true in include/strata/prefill/fused_tq_hip.hpp: with STRATA_PF_TQ_G1151 unset,
Windows gfx1151 takes Gyro-S's trellis pair on the fused prompt kernels in the build without MMQ
(STRATA_PF_FUSED_TQ=1 is set only there, own_only_switches.hpp). STRATA_PF_TQ_G1151=0 or
STRATA_GFX1151_DEFAULTS=0 is the way back. Linux gfx1151, gfx12, the other HIP devices, CUDA and
the build with MMQ are unchanged (device_on).

Strix Halo, Gyro-S at setup's low-RAM line, against 0.2.13 (same job, prompt ms):
128 / 256 / 512 / 1,000 tokens 348 / 485 / 680 / 1,098 against 476 / 736 / 1,136 / 1,676;
4,096 / 8,192 / 32,000 tokens 3,233 / 6,598 / 24,247 against 4,323 / 7,404 / 28,027.
Prompts of 26-64 tokens read through the verify windows, as with the switch off.

tests/prefill/fused_tq_hip_test.cpp: the shipped default is true, and device_on with it is on for
Windows gfx1151 and off on Linux, with STRATA_GFX1151_DEFAULTS=0, with the switch at 0 and
without STRATA_PF_FUSED_TQ.
2026-11-15 02:16:33 +01:00
Niko1221 f73fa74107 Integrated gfx11 under Linux: pageable copies staged by the HIP runtime
The HIP runtime copies a pageable source of 1 MiB or more by pinning its pages in place
(a GPU userptr) and keeps them (generate.cpp, the STRATA_ARENA_MMAP note). On a Radeon
780M such a userptr is memory the kernel can move under a running dispatch: the hc
check's two 6.5 MB vectors at load, and without a registered arena the lent refill's
1.3 MiB blobs (expert_cache.cpp fill_slot_queued); uma-r13 reset in the load with a
"Failed to quiesce KFD" line although nothing of ours was registered.

The engine now sets GPU_PINNED_MIN_XFER_SIZE=1000000 before HIP starts on this class,
the value STRATA_ARENA_MMAP=1 already sets (measured then: decode 49.06 vs 49.16 ms a
window). The class is read from the KFD topology files, since the device properties need
HIP up: every GPU node (simd_count > 0) of /sys/class/kfd/kfd/topology/nodes/*/properties
has gfx_target_version 110003, 110500 or 110501 (gfx1103 / gfx1150 / gfx1151, integrated
only); a machine with another GPU beside them, or no KFD topology, is not the class.

What the runtime does with the variable was not checked against its source: C:\TheRock
on the owner PC is the Windows binary SDK of TheRock 10.0.0 (bin, include, lib, share;
therock-10.0.0.tar.gz holds the same files), not the ROCclr / ROCr sources. Its
bin\amdhip64_7.dll carries the names GPU_PINNED_MIN_XFER_SIZE and GPU_PINNED_XFER_SIZE and
the line "HSA Copy Using Pinned resource size %d", without the flags' descriptions; it is
the Windows (PAL) runtime. The behaviour relied on is the one measured on Linux for
STRATA_ARENA_MMAP.

Cost by reading: one CPU copy into the runtime's staging buffer per pageable copy of
1 MiB or more (milliseconds at load); none in the default mode's requests, whose copies
come from registered or cudaHostAlloc memory.

Scope: compiled only with STRATA_USE_HIP on __linux__; set only in the class above, and
never over a value the caller set (setenv without overwrite, and not at all when the
variable exists). STRATA_KFD_QUIET=0 or STRATA_KFD_QUIET_XFER=0 sets nothing; STRATA_TRACE
prints one line when it is set. Test: the topology rule and the value rule in
tests/core/kfd_quiet_test.cpp (text cases and a temporary folder tree).
2026-11-15 01:57:16 +01:00
Niko1221 59375eb069 Integrated gfx11 under Linux: a stop by signal drains the GPU before the process ends
Reset 45 on p2006: SIGTERM 1 s into the first request ended the engine with kernels in
flight and the expert arena still registered; the kernel's exit then evicted the busy
queues ("Failed to evict queue 1", "Failed to quiesce KFD") and MES reset the GPU.

Now SIGTERM, SIGINT and SIGHUP take this order: the handler only writes the signal's
number into a pipe; a thread of its own (strata-stop) sets the serve loop's STOP flag,
releases the verify windows' GPU waits (the #267 release, silent, through a new bounded
hook release_gpu_waits_within), waits for the whole device for what is left of 3 s
(cudaDeviceSynchronize on a helper thread, the wait bounded), drops the arena's
registration only when the device finished (unregister_arena_ranges, pinned.cu, which
unregisters the ranges register_range recorded), and ends the process by the same
signal, so the wait status the caller sees is unchanged. A second signal during the
stop ends the process at once.

The bound: the server stops its engine with STOP + QUIT and waits 20 s, then SIGTERM and
5 s, then SIGKILL (serve/server.py:114, :3011-3034); Control sends SIGTERM to the server
and kills its process group after shutdown_timeout + 8 s (strata_control/runtime.py:
1113-1134); the macOS lifeline waits 10 s after its SIGTERM (serve/lifeline.py:132-145);
Linux children get SIGKILL by PDEATHSIG when the server dies. 3 s stays inside the 5 s.
QUIT was left as it is: it already leaves the serve scope through the destructors (the
verifier syncs its streams, the prefill frees) and ~ArenaExpertSource (the local at
generate.cpp:7898) unregisters the arena before main returns.

Cost by reading: a stop by signal during a request takes up to 3 s longer; nothing while
the engine runs.

Scope: compiled only with STRATA_USE_HIP on __linux__; installed at run time only when
kfd_quiet::class_flag() is set (integrated gfx1103 / gfx1150 / gfx1151, every visible
card), and only for a signal whose action is still the default (nohup's ignored SIGHUP
stays ignored). No signal mask is changed anywhere. Elsewhere the new code is a pointer
stored in Verifier::init and a list of registered range starts kept on Linux; neither is
read without the handler. STRATA_KFD_QUIET=0 or STRATA_KFD_QUIET_EXIT=0 keeps the old
death by signal; STRATA_TRACE prints one line when the handler is in and one at the stop.
Test: the stop's order with a fake GPU layer in tests/core/kfd_quiet_test.cpp.
2026-11-15 01:56:18 +01:00
Niko1221 f9932c6aee Integrated gfx11 under Linux: no GPU work right after the big load allocations
On a Radeon 780M (p2006) both load resets fell in the hyper-connection check, which ran
right after the 7.7 GiB expert cache was allocated, while the kernel was still moving
pages (KFD queue eviction, MES gave no answer, MODE2 reset). Three moves, token-neutral:

- the check (fused_gr_check) runs right after the card is named and before the warm
  thread and the expert arena; Verifier::init then finds it done. Its result depends on
  the card and STRATA_HC_SPLIT only (random weights compared bit for bit; nothing it
  reads is set between the two places), so it chooses the same variant as before;
- one more KFD settle (kfd_settle.hpp: eviction counter quiet for 2 s, at most 10 s)
  between the expert cache allocation and the profile fill;
- the first prompt's lazy device buffers are made in Prefill::init: the int8 experts'
  q8_1 activations for a whole chunk (chunk x 80 x 36 B, 24 MB at 8192), the group
  record, and the K/V copy stream when STRATA_KV_PREFETCH=1. Same buffers and sizes the
  prompt path makes; a failure there is ignored and the prompt path tries as before.

Cost by reading: one settle per start (at least 2 s, at most 10 s), about 24 MB of GPU
memory at an 8192 chunk; nothing per request.

Scope: compiled only with STRATA_USE_HIP on __linux__ (CUDA, Metal, SYCL and Windows HIP
builds have no new code), and at run time only when kfd_quiet::class_flag() is set, from
the same rule as the existing settle (igpu_kfd_settle_default: every visible card an
integrated gfx1103 / gfx1150 / gfx1151). Every other card runs the old order.
STRATA_KFD_QUIET=0 or STRATA_KFD_QUIET_LOAD=0 is the old order on the same binary;
STRATA_TRACE prints one line when it is active. Test: tests/core/kfd_quiet_test.cpp.
2026-11-15 01:53:45 +01:00
Niko1221 477831fb6f prefill: Windows gfx1151 with the fused trellis set: floor 64, --short-read keeps 64
With STRATA_PF_TQ_G1151=1 every Gyro-S layer is fused-only on Windows gfx1151, and two class
rules made for UD-Q4_K_XL took over: --short-read went to 24 (pieces of 25-63 tokens left the
verify windows for a batched read) and the long-prompt floor stayed 1,024 (the staged fused
entry is on). The staged entry does not take Hadamard-folded layers, so both sent those prompts
to the FP16 path: 26-49 tokens 705-993 ms against 293-486 ms with the switch off, 256 tokens
1,914 ms against 726 ms in 0.2.13.

- prefill.cpp trellis_g1151_all_fused(): a native pack whose every gate/up is a trellis type
  (TQ2_T..TQP7), stream_floor_class_measured() (one card, gfx1151) and layers_all_fused_only().
- stream_floor_rule.hpp: new argument trellis_g1151_fused -> kFusedOnlyFloor (64), as gfx12.
- staged_fo_rule.hpp short_read_default: new argument folded_trellis (that set with a
  Hadamard-folded layer, layers_any_folded()) -> keeps the base 64.
- Tests: stream_floor_rule_test and staged_fo_rule_test cover the new rows and the old ones
  with the new argument false.

How each scope is kept out:
- The switch: on gfx1151 layers_all_fused_only() is true for a trellis set only when
  fused_tq_hip.hpp device_on lets the fused kernels take the pair (STRATA_PF_TQ_G1151=1 while
  the default is off), so with the switch off both new flags are false.
- Linux gfx1151: trellis_g1151_all_fused() is compiled only under _WIN32 (and
  stream_floor_class_measured() is _WIN32 only); elsewhere it returns false.
- gfx12: trellis_gfx12_all_fused() and its argument are unchanged; the new function needs
  gfx_arch_is_gfx1151.
- gfx1100-1103, gfx1150: gfx_arch_is_gfx1151 is false, and device_on is off for them.
- CUDA: the function is compiled only under STRATA_USE_HIP; trellis_cuda_all_fused() and
  kTrellisCudaFloor are unchanged.
- The build with MMQ: the function is compiled only under STRATA_PF_OWN_ONLY; elsewhere false.
- Both new arguments default to false, so every other call keeps its old answer.
2026-11-15 01:36:42 +01:00
Niko1221 6bb186c278 prefill: gfx1151 can take the fused trellis prompt kernels (STRATA_PF_TQ_G1151=1, off by default)
The trellis pairs (Gyro-S TQK6 / TQK7, Gyro-M TQ2_T / TQ2_T) ran on native_w11_kernel only
behind a gfx12 device check. The kernel's gfx11 code is the one the other formats already run
on gfx1151, and the trellis decode, the FP32-H epilogue of a Hadamard-folded down and
rot_quant_h_kernel have no per-architecture code.

The three device checks (gu_covered, d_covered_on, native_supported) now go through one rule,
include/strata/prefill/fused_tq_hip.hpp: gfx12 as before (STRATA_PF_FUSED_TQ=1); gfx1151 only
with STRATA_PF_FUSED_TQ=1 and STRATA_PF_TQ_G1151=1 (Gyro-M only with the switch at 1); every
other HIP device off. The Windows gfx1151 default is off in this commit. CUDA and the build
with MMQ are unchanged. tests/prefill/fused_tq_hip_test.cpp checks every input.
2026-11-15 00:35:50 +01:00
Niko1221 49b61d0d44 prefill: the two-chunk equal minimum is 5,400 tokens (a prompt of 10,800 tokens or more takes the equal cut)
kEqualMinChunk2 5,500 -> 5,400. The engine cuts the prompt length minus 1, so a 10,800-token prompt is a segment of
10,799 and reads as 2 x 5,400. Measured at 10,800: RTX 4090 24 GB, IQ3_S, chunk 8,192: equal cut / today's cut 0.985
(5,500: 1.007, 5,600: 1.021); RTX 5070 12 GB, Q2_0 plain pack, chunk 10,496: today's 10,496 + 303 took 1.150 of the
equal cut's time. The test's limit cases move: 10,798 keeps today's cut, 10,799 and 10,800 take 2 x 5,400 at chunk 8,192
and at chunk 10,496; 10,500 keeps today's cut.
2026-11-14 23:57:19 +01:00
Niko1221 bc4026239d prefill: the two-chunk equal minimum is 5,500 tokens (segments of 11,000 tokens or more take the equal cut)
With two chunks the segment is twice the equal chunk, so the minimum is a prompt length.
RTX 5070 Q2_0 chunk 10,496, equal cut against today's cut, prompt ms (BLOCK C6):
5,250: 1.043 (a 10,496 + 3 cut), 5,500: 0.862, 5,650: 0.856. RTX 4090 IQ3_S chunk 8,192:
5,596: 1.011, 5,725: 0.938.

kEqualMinChunk2 5,700 -> 5,500; three or more chunks keep 6,144. Tests: the limit at chunk
8,192 (10,998 today's cut, 10,999 / 11,000 2 x 5,500), 11,192 now equal, 10,800 / 11,000 /
11,300 at chunk 10,496.
2026-11-14 23:08:37 +01:00
Niko1221 3cf99f840a prefill: two equal chunks take the equal cut from 5,700 tokens each (three or more stay at 6,144)
With a configured chunk of 8,192 or more the equal cut was taken only when its equal chunk
was at least 6,144 tokens. Measured since, equal cut against today's cut, prompt ms:
RTX 4090 IQ3_S chunk 8,192, two chunks: 5,596: 1.01, 5,725: 0.938, 5,950: 0.938, 6,125: 0.977;
three chunks: 5,628: 1.13, 5,717: 1.111, 5,933: 1.084, 6,133: 1.058, 6,667: 0.98.
RTX 5070 Q2_0 chunk 10,496, two chunks: 5,250: 1.04, 5,750: 0.83, 6,100: 0.86.

kEqualMinChunk2 = 5,700 applies when the equal cut has exactly two chunks; kEqualMinChunk
(6,144) stays for three or more. A configured chunk under 8,192 and the keep-equal fallback
are unchanged. Tests: the cases above at chunk 8,192 and 10,496 and the limits on both sides.
2026-11-14 22:40:42 +01:00
Niko1221 26c03ce743 Merge f-equal-min: keep today's prompt cut when the equal chunk would be short (under 6,144 tokens at a chunk of 8,192 or more) 2026-11-14 20:49:31 +01:00
Niko1221 74e0ad55ba prefill: keep today's cut when the equal chunk would be short (under 6,144 tokens at a chunk of 8,192 or more)
In a build without MMQ on one GPU, a segment longer than its chunk is read in
equal chunks. On an RTX 4090 24 GB with IQ3_S at a chunk of 8,192, equal
chunks of 4,140 to 5,628 tokens made a prompt just above one chunk slower:
8,279 tokens as 2 x 4,140 took 3,517 ms against 2,579-2,686 ms for
8,192 + 87 (wait copy 1,178 against 470-480 ms, K/V stage 450 against 4 ms,
34,852 experts streamed against 20,963). Against today's cut the equal cut
measured 1.34 / 1.25 / 1.14 at 8,279 / 8,448 / 9,192 tokens, 1.01-1.03 at
11,192, 1.13 at 16,884, 0.98 at 20,000 and 0.99 at 32,000. Every gain
measured on the RTX 5070 12 GB has equal chunks of 6,978 tokens or more.

With a configured chunk of 8,192 or more, an equal chunk under 6,144 tokens
now keeps today's cut (full chunks and a remainder). A smaller configured
chunk keeps the rule unchanged. If today's cut, handed back this way, cannot
be lent while the equal cut can, the equal cut is kept and one line says so
("prompt chunk X -> Y tokens for this request: the old cut's buffers do not
fit ..."), instead of halving the chunk.

equal_cut_rule.hpp holds both decisions (short_equal, declined_equal,
keep_equal); the serve lend and generate's prompt in generate.cpp call them.
A build with MMQ is unchanged: it never takes the equal cut.

Tests: equal_cut_rule_test (two cases at a 10,240 chunk flip, new cases at
8,192 and 4,096 and for keep_equal), fit_out_rule_test unchanged.
2026-11-14 19:31:02 +01:00
Niko1221 4786a2e7d8 Merge f-strix-p1a: P1A prompt experts for Windows gfx1151, on by default there 2026-11-14 16:58:36 +01:00
Niko1221 727890fde6 Merge f-q36-fit: strata-q36 context fit check counts the staging pair in a build without MMQ 2026-11-14 16:58:36 +01:00
Niko1221 1ed9c5c382 strata-q36: context fit check counts the staging pair in the build without MMQ
The one-session fit check (#5715) counted the hybrid mode's staging pair
only when a layer took MMQ or our int8 kernels. In the build without MMQ
the fused kernels take the layers, so use_mmq was false, n_i8 was 0 and
the floor was 0, while place_experts still allocates the pair on the
streamed prompt path. On an RTX 3060 Ti 8 GB at 32K that build went on
and ended with the hybrid buffers' line (1159 MiB needed, 114 MiB free)
instead of the line with a context size that fits.

one_session_staging_counted: the build with MMQ keeps its rule; the build
without MMQ also counts the pair when use_pf is on. The unit test gains
the rule's cases and the 3060 Ti 32K case.
2026-11-14 15:00:04 +01:00
Niko1221 3d302a600d prefill: P1A prompt experts on by default on Windows gfx1151
src/core/arch_defaults.cpp: STRATA_PF_P1A=1 joins the Windows gfx1151 table.
Measured on that chip with UD-Q4_K_XL, 5 interleaved pairs: prompt x1.046
(4K), x1.043 (8K), x1.043 (32K), decode unchanged. KL to the FP16 truth,
24 prompts a size: on 0.0112 / 0.0116 against off 0.0179 / 0.0118 at
4K / 8K. A value the user sets wins, so STRATA_PF_P1A=0 turns it off.
Every other card and system keeps its table.

H grows to FP16 rows only when a layer of the loaded pack takes the P1A
kernels (p1a_takes_pair), so a pack with none allocates what it did before.
The start-up line keeps its wording and is not printed when no layer takes
the P1A kernels.

The settings register lists STRATA_PF_P1A and STRATA_PF_P1A_L2; the
settings page is regenerated.
2026-11-14 14:56:44 +01:00
Niko1221 7aa7c8238f prefill: gfx1151 prompt experts with F16 activations and F16 H behind STRATA_PF_P1A=1
src/prefill/moe_p1a.cu: gufo's RoutedPairF16Kernel / RoutedDownF16Kernel
(07e1191f, MIT) on fused::group's tables and the native blobs: gate/up
(Q4_K, Q5_K) + SwiGLU from the layer input's FP16 rows into FP16 H, down
(Q5_1, Q8_0) of that H into FP16 down rows for moe_combine16. Work items
are 128 rows of one expert (two 64-row tiles). The kernels are the one-layer
harness's line for line except the work-item decode and the arguments.

experts_native takes them only on gfx1151 with STRATA_PF_P1A=1, when the
prompt path handed over the FP16 input (p1a_input), the down rows go out as
FP16 and H has room for FP16 rows (moe_bufs grows H only with the switch on).
Q4_K gate/up + Q5_1 down by default under the switch; STRATA_PF_P1A_L2=1 adds
the Q5_K gate/up and Q8_0 down layers. A layer whose pair is not taken keeps
today's kernels for both projections (the int8 H of today's downs does not
take FP16 H). One start-up line says which layers took which kernels.

With the switch off (the default) nothing changes on any card: p1a_input
keeps a null input, so experts_native never reaches the new branch, and
moe_bufs adds nothing to H.
2026-11-14 13:22:03 +01:00
Niko1221 13363bdb74 prefill: --peer-device keeps the fused prompt kernels in a build without MMQ
With --peer-device the prompt walk ran every layer off the fused kernels (no_peer from
core::peer_portable), so that a peer prompt share, which runs on MMQ only, found the MMQ
ring and buffers fused_ring() sized for it. A build without MMQ declines that share every
time (Prefill::set_peer), so the flag only cost prompt speed there: on z440 (2x RTX A4000,
Q2_0) prompt ms with the flag were 1.33x / 1.37x the build with MMQ at 8,192 / 20,000
tokens.

own_only_line.hpp peer_keeps_mmq(flag, own_only) is now the one rule: true only with the
flag in a build with MMQ. The walk's no_peer and the start-up line's peer_off use it, so a
build without MMQ keeps the kernels it picks without the flag, in MMQ's buffer layout
(fused_ring() still answers false for a peer session: the ring, the buffers, the Portable
host buffers and the peer's expert placement are unchanged). The fused kernels in that
layout are the small-card path's kPfFusedKernelsOnly combination; they read experts from
the ring and the primary's cache only. The start-up line of such a build no longer carries
"(--peer-device: the fused kernels are off)".

Without --peer-device nothing changes (peer_portable() is false, set only from the flag in
generate.cpp); a build with MMQ is unchanged (own_only false).

Edge: STRATA_PF_GROUP_SCRATCH together with --peer-device in a build without MMQ now
reaches the existing "needs MMQ on every layer" error in the walk, as that variable
already does there without the flag.

Tests: own_only_line_test checks the four cases of the rule and the start-up line of a
build without MMQ with the flag on (no clause).
2026-11-14 13:14:49 +01:00
Niko1221 3b0ca805f8 Merge f-sm75-iq-b19: in a build without MMQ, Turing cards (RTX 20 series) read i-quant prompts on Strata's fused expert kernels
On sm_75 the fused expert kernels already compiled for every format, but only
the Q2_0 pair was set up there. In a build without MMQ, where the Turing set
(STRATA_PF_FUSED_SM75) is on by default, they now also take the IQ3_S gate/up
with an IQ4_NL or Q2_0 down, and the other i-quant gate/up formats (IQ2_S,
IQ3_XXS, IQ4_XS, IQ2_XXS, IQ2_XS). A tile rule picks the 128-row instance
above 56 rows an expert for the i-quant gate/up, and an instance whose shared
memory does not fit the card's 64 KB is not set up.

pf_wmma_parity skips, with its reason, the formats whose tile needs more shared
memory than the card allows. The spill baseline lists the known sm_75
instances.

Cards other than Turing and a build with MMQ are unchanged.

No user text changes.
2026-11-14 12:38:54 +01:00
Niko1221 5a952d4d5b Merge f-numa-card2's comment fix: the home CPU set comment in home_cpus.hpp says what the code does
Comment only. No code change.
2026-11-14 12:01:15 +01:00
Niko1221 7a9f8d2ad0 platform: correct the home CPU set comment
The header comment said the home CPU set is not set on one-node hosts or
when the card-node rule declines. generate.cpp sets it in every Linux
start except STRATA_NUMA_CARD=0, so background threads keep the CPU set
the engine was started with. The comment now says that. Comment only; no
behaviour change.
2026-11-14 12:00:41 +01:00
Niko1221 a6859aa7db Merge f-texts-b20: start-up lines of a build without MMQ no longer name MMQ kernels
A build without llama.cpp's MMQ kernels said at start that a model with
K-quant experts reads its prompt "on llama.cpp's MMQ kernels". It now says it
reads it on Strata's own kernels, on NVIDIA cards and on gfx12 (RDNA4) cards.
The "prompt pieces" line of such a build named STRATA_PREFILL_STREAM_MIN=1024
as the way back to the old rule, which was not true; it now names
STRATA_PF_PLAIN_FLOOR=0 for the plain pack, the only pack that switch changes,
and says that STRATA_PREFILL_STREAM_MIN=N sets the number by hand.

A build with MMQ prints the same lines as before.
2026-11-14 11:51:00 +01:00
Niko1221 f02b8a9e02 Merge f-chunk-fit-out: with the equal cut, the automatic prompt chunk is sized for layouts without a short tail
In a build without MMQ, the serve scan for the automatic prompt chunk counted
every layout with the rows of a short last chunk under the stream floor. With
the equal cut on one GPU no layout above the old chunk has such a tail any
more, so the scan now counts what those layouts actually carve. On an RTX 5070
12 GB with the Q2_0 plain pack the automatic chunk goes from 9,216 to 10,240
tokens; with the equal cut that build reads 0.986 to 0.996 of the time of the
build with MMQ at 18,932 to 28,000 tokens.

The RAM copy's lend region (with --resident-experts, --resident-budget-gib or
the automatic RAM fallback) is now sized for that larger chunk too, so the
borrowed cache slots are not read from the model file on every chunk.

A build with MMQ is unchanged.

No user text changes.
2026-11-14 11:46:16 +01:00
Niko1221 c0c2d72c8d Merge f-chunk-equal: in a build without MMQ, long prompts on one GPU are read in chunks of equal size
A prompt segment longer than its chunk was read in full chunks and a short
remainder. In a build without MMQ on one GPU it is now read in
ceil(tokens / chunk) chunks of equal size: 20,932 tokens at a 10,240-token
chunk become 3 x 6,978 instead of 10,240 + 10,240 + 452. The number of chunks
stays the same, no chunk is larger than the configured one, and the short last
chunk under the stream floor goes away. On an RTX 5070 12 GB with the Q2_0
plain pack, 14,000 to 32,000 tokens read in 0.923 to 1.001 of the time of the
old cut; first-token KL at 10,500 tokens no worse.

A segment that fits one chunk keeps its chunk, and a guard keeps the old cut
when the equal chunk would lend more cache slots. The opt-in rule for other
builds (STRATA_PREFILL_EQUAL=1) is kept value for value. A build with MMQ is
unchanged.

No user text changes.
2026-11-14 11:46:04 +01:00
Niko1221 2e279f7583 Merge f-numa-card2: on two-socket Linux machines the engine runs on the graphics card's NUMA node
On a Linux machine with two or more memory nodes, the engine now restricts
itself at start-up to the CPUs of the node the graphics card is attached to,
before the CPU pool and the helper threads start. Decode with CPU experts on
a two-socket RTX 5090 host: a 32-worker pool on one node read 1.11-1.18 of the
two-node default over three rounds (UD 4-bit set).

The process is left as it is when any of these is not met: Linux, the
process's CPUs span more than one node, every card used reports the same known
node, that node can hold the pinned K/V copy and staging buffers, the threads
were not placed by hand (--pool-cores, STRATA_NUMA_SPLIT, --aux-cpus), the CPU
is not hybrid, and the pool keeps its worker count on that node alone. A
taskset, numactl or cpuset restriction is kept. The background copy threads
(checkpoints and parking) now also stay inside the process's CPU set.

STRATA_NUMA_CARD=0 turns it off. On one-node machines the output is identical
to STRATA_NUMA_CARD=0. With STRATA_TRACE the engine prints one
"strata trace: card node: ..." line with the inputs and the decision.

No user text changes outside STRATA_TRACE.
2026-11-14 11:44:58 +01:00
Niko1221 29173b3dba engine: start-up lines of a build without MMQ no longer name MMQ kernels
A build without llama.cpp's MMQ kernels said at start that a model with
K-quant experts reads its prompt "on llama.cpp's MMQ kernels". It now says
it reads it on Strata's own kernels, on NVIDIA cards and on gfx12 (RDNA4)
cards. A build with MMQ prints the same lines as before.

The "prompt pieces" line of a build without MMQ said that
STRATA_PREFILL_STREAM_MIN=1024 keeps the old rule, which is not true. It now
names STRATA_PF_PLAIN_FLOOR=0 for the plain pack, the only pack that switch
changes, and for every pack says that STRATA_PREFILL_STREAM_MIN=N sets the
number by hand.
2026-11-14 10:18:54 +01:00
Niko1221 6aae30348e Merge f-kv-default: with KV streaming on NVIDIA cards, the prompt's new K/V cells reach the host copy by one DMA copy per array
With KV streaming (--kv-resident, which setup writes from 64K context) the
prompt path's append kernel stored every new K/V cell into the host copy
itself, one small store per value over the link: on an RTX 5090 about
17-59 us per prompt token, a fifth to a third of the prompt time at 8K-128K.
CUDA builds now write the cells into the staging pool in VRAM, as before, and
copy the chunk's blocks to the host copy with one cudaMemcpyAsync per array on
the same stream. STRATA_KV_HOST_DMA=0 gives the kernel's own stores back.
HIP keeps its opt-in (STRATA_KV_HOST_DMA=1) as before, and a layer without a
staging pool keeps the kernel's stores. No new buffer.

Nothing changes without KV streaming.

No user text changes.
2026-11-14 10:10:23 +01:00
Niko1221 28e8d0e05c Merge the expert cache fix for a part-way shrink: with --vram-elastic, a refused shrink no longer leaves experts listed in unmapped slots
When the driver refused a segment part way through a VRAM shrink, the segments
given back before the refusal were gone but the residency table still listed
experts in them. After every shrink, refused or not, the entries past what
stays mapped are now evicted, the table is uploaded again and the prompt
path's loan moves down to the end of the live slots; then the error goes out
as before. A segment whose unmap succeeded but whose handle release failed now
counts as unmapped at once.

Nothing changes without --vram-elastic, or when every shrink succeeds.

No user text changes.
2026-11-14 10:09:27 +01:00
Niko1221 420e03b12a Merge f-small-walk: in a build without MMQ, long prompts on 8 GB cards use the layer-major walk with the fused kernels
A build without MMQ set STRATA_PF_FUSED itself before main, and the small-card
prompt rule took that as the user's choice and stood aside, so on an 8 GB card
long prompts were read chunk by chunk. The build now records which switches it
set and the rule only stands aside for a value the user named. The layer-major
walk also takes the fused kernels for the layers they cover in such a build,
instead of falling back to the dequantize and FP16 path.

A build with MMQ is unchanged. STRATA_PF_FUSED set by hand and
STRATA_PF_SMALL=0 keep working as before.

No user text changes.
2026-11-14 10:08:37 +01:00
Niko1221 b9c9484dda prefill: size the RAM copy's lend region for the tail-0 auto chunk
With --resident-experts, --resident-budget-gib or the automatic RAM
fallback (the arena does not fit the RAM, generate.cpp:8064-8091), the
RAM copy keeps the experts of the cache slots the prompt path borrows,
so a prompt does not read them from the model file on every chunk
(#669). The copy's lend region is sized before the serve scan runs
(generate.cpp, the resident block), by plan_lend, which counted today's
tail. After the tail-0 scan of the previous commit, the serve scan could
take a larger chunk (12 GB: 10,240 against 9,216) whose loan is larger
than the region. The slots past the region would then come from the
model file on every chunk, and the low-RAM warning did not report them.

Now, in a build without MMQ:
- One lambda (fit_case, generate.cpp:10810) fills fit_out::ScanCase
  for both the serve scan (generate.cpp:11510) and the region sizing.
- plan_lend takes a tail (generate.cpp:10311; default -1, so every
  other caller, the CLI path included, counts as before). It prices
  the tail the way the serve scan's ring_room and part_slots do.
- Under --serve, when scan_tail() is 0, the region holds the start-up
  loan (today's tail, the largest loan any request takes at that chunk)
  of the tail-0 chunk, when that loan keeps the 128-slot floor
  (fit_out::region_slots, generate.cpp:10836). Otherwise today's region
  is kept. plan_lend then runs once more at today's tail, which leaves
  the ring state as before.
- Hard guard (generate.cpp:11520): the serve scan takes the tail-0
  chunk only when the RAM copy KEPT every slot of its start-up loan
  (src.resident_lent_slots(); fit_out::region_holds). Otherwise it
  keeps today's chunk. The arena holds every expert in RAM and has no
  region, so nothing is checked there.
- The low-RAM warning (generate.cpp:11005) has the same text and the
  same condition. It now names the chunk and slot count of the loan
  that will be taken: the region's chunk, or today's when the RAM kept
  less than the larger region. Before, it named o.prefill_chunk, which
  under auto is the ceiling and not the chunk taken.

RAM: the larger region holds 207 more slots on an RTX 5070 12 GB (3,624
against 3,417 at 1.3175 MiB a slot, about 273 MiB) and about 155 more
on a 16 GB card (6,414 against 6,259, about 204 MiB; from the slope
measured on the 5070). The RAM decision counts these slots inside the
same budget and never refuses a start for them.
src/core/expert_source.cpp:3713-3731 checks only the complement (the
experts no slot holds) against the available RAM less the headroom.
3736-3739 with choose_resident_keep_from (293-303) keep the region's
slots from the last slot down while they fit what is left, and the
budget mode does the same (3675-3691). A start that fitted before
therefore still fits. A copy short of RAM keeps fewer region slots, and
the guard then keeps today's chunk. Today's loan is the region's last
slots, kept first, so it is held at least as far as before.

A build with MMQ compiles the same behaviour (the warning's numbers
are unchanged there). tests/prefill/fit_out_rule_test.cpp checks 12 GB
and 16 GB with the equal cut on and off: the region's extra slots, the
serve start-up loan never above the region, every lent slot kept
wherever today's were, a request's loan at most the start-up loan, and
today's chunk when the copy keeps less than the larger region.
2026-11-14 08:36:08 +01:00
Niko1221 a17d2f9100 prefill: size the auto prompt chunk for tail-free layouts when the equal cut is on
In a build without MMQ, the serve auto chunk scan counted every layout
with the rows of a short last chunk under the stream floor (3,071
tokens: GU, H, Hq and the FP16 Xs / Hh). With the equal cut on one GPU
no layout above 0.1.39's chunk has such a tail any more, so the scan
now counts what those layouts carve: tail 0. On an RTX 5070 12 GB with
the Q2_0 plain pack the auto chunk goes from 9,216 to an expected
10,240 tokens (the build with MMQ takes 9,984 there; at equal chunks
the two builds read level, 1.001-1.002 of the time). Measured with a
9,984 chunk and the equal cut: 0.996 / 0.986 / 0.991 of the build with
MMQ at 18,932 / 20,000 / 28,000 tokens, where the 9,216 chunk read
1.020 / 0.986 / 1.039.

When the scan counts tail 0 (include/strata/prefill/fit_out_rule.hpp,
scan_tail): --prefill auto, one GPU (no layer split, no peer card, one
slot, no head alias), the request-sized tail loan on, the equal cut on
(STRATA_PREFILL_EQUAL not 0), the small-card prompt path not taken, and
today's chunk a fused layout. Everywhere else, STRATA_PREFILL_EQUAL=0
included, the scan counts the 3,071-token tail as before.

Why no layout at run time holds a short tail next to the full ring
while the scan counted tail 0:
- equal chunks: equal_cut_rule.hpp:70-76 returns the equal chunk only
  when its last chunk is at or above the floor; every chunk of the cut
  is at least half the scan's chunk, so the request's tail is 0
  (loan_rules.hpp segment_tail).
- a one-chunk prompt above 0.1.39's chunk is above the floor: tail 0.
  A one-chunk prompt under the floor is not a fused layout and has its
  own small layout; one of 2,817-3,071 tokens is laid out at 3,072 with
  its tail, at or below 0.1.39's chunk.
- every layout at or below 0.1.39's chunk is bounded by old_pick, which
  is always priced with today's tail (generate.cpp:11303).
- today's cut as the loan guard's fallback (equal_cut::loan_ok) would
  carve chunk + tail at the scan's chunk: after a tail-0 scan it is
  taken only at or below 0.1.39's chunk (generate.cpp:18019,
  fit_out_rule.hpp today_cut_ok).
- the grow-only tail (loan_rules.hpp:64, used at generate.cpp:18071)
  grows to the floor's tail only for a request at the layout's own
  chunk that needs a tail, which the cases above exclude.
- a prompt cache hit, a follow-up turn and picture tokens all lend
  through the same lend() per segment (generate.cpp:18972); on one GPU
  the exact-chunk resume is 0 (Prefill::plan_chunk returns 0 under two
  stages, prefill.cpp:3300-3303), so each segment is cut as above.
- the start-up layout (the chunk with today's tail) is checked against
  the 128-slot floor before the larger chunk is taken, and is laid out
  again at the first request.
Today's chunk also stays when the host-aware plan (#2824) planned a
smaller chunk, or plans one for the larger chunk. The VRAM command's
relend (--vram-elastic) prices the cap with the same tail and the
128-slot floor with today's (generate.cpp:14984).

A build with MMQ compiles the previous code unchanged (every change is
under STRATA_PREFILL_FUSED && !STRATA_PREFILL_MMQ). No new setting and
no new log line. tests/prefill/fit_out_rule_test.cpp checks which tail
is counted in each case, the 12 GB and 16 GB chunks from the loans
measured on the RTX 5070, and that a card in the 3,409-3,566-slot band
keeps the small-card path it takes today.
2026-11-14 08:20:02 +01:00
Niko1221 6b63729a97 Merge f-container-mem-core: memory checks that read a container's limit correctly
Inside a container with a memory limit below the machine's RAM:
- the memory guard counts reclaimable file cache (active and inactive, less
  dirty pages and the engine's own mapped file pages) as available, so it no
  longer stops or shrinks a run that fits;
- the expert arena's RAM check no longer counts shared memory as free;
- setup reads the container's memory limit and compares RAM and the expert
  arena in one unit when it picks the low-RAM line; the Terminal tools read
  the same limit as the RAM size.

Outside a container, with a limit at or above the machine's RAM, or with
--memory-limit-mib, nothing changes. STRATA_MEM_CREDIT_INACTIVE=1 brings back
the old inactive-only credit.

The settings register was merged by hand (the new switch added, every other
entry as on this branch) and is regenerated in the next commit.
2026-11-14 06:50:29 +01:00
Niko1221 513fd0cff5 Merge f-kvgrow-guard: --kv-grow no longer faults on a long prompt when the expert cache is at its floor
With --kv-grow and an expert cache that cannot give slots (for example
--expert-cache 100), the K/V pools stayed at their first 16,384 cells and a
longer prompt wrote past them. The K/V now grows from free VRAM in that case,
or the run ends with the existing "no VRAM is left" exit. Nothing changes when
the cache can give slots, and nothing changes without --kv-grow.

Side effect: in the state where the cache cannot give slots, the elastic K/V
now counts as on, so the paths that check it behave as for an accepted
--kv-grow: the concurrent batch run and merge_from are off, and the
end-of-run elastic K/V stats line prints.

No user text changes.
2026-11-14 06:48:40 +01:00
Niko1221 4ebfcda436 Merge the Turing fused i-quant experts onto the NVFP4 base
Brings the sm_75 fused prompt kernels for the i-quant gate/up pairs
(IQ3_S, IQ2_S, IQ3_XXS, IQ4_XS, IQ2_XXS, IQ2_XS gate/up with IQ4_NL or
Q2_0 down; STRATA_PF_FUSED_SM75_IQ=0 turns them off) onto the base that
added the NVFP4 fused kernels.

Two conflicts:

- src/prefill/moe_fused_iq.cu: both sides ended the same list of type
  constants. Kept the base's list, which now ends with T_NVFP4, and put
  the Turing block (t75_slot, t75_bit, kT75Formats) after it. The lines
  the merge adds to this file against the base are exactly the lines the
  Turing commits added against their own base.
- data/settings-register.json: every conflict was a generated "line"
  field. Took one side, then regenerated the register; --check passes
  and the register test passes.

What an NVFP4 expert does on a Turing card, before and after the merge
(line numbers are the merged file's):

- dev_info() (2426-2443): on sm_75 it returns from the Turing block
  before the NVFP4 kernels are set up (2502-2508), so d.nvfp4 stays
  false there. This was already the case in the base; the merge only
  adds the i-quant set-up calls inside that block, and NVFP4 has no
  Turing slot (t75_slot gives -1, so t75_bit is 0).
- native_supported() (2918-2921): the NVFP4 clause returns before the
  new Turing pair check (3009) is reached, and it asks for d.nvfp4 and
  !d.t75, so it answers false on Turing, as in the base.
- gu_covered() (2570) answers false for NVFP4 on Turing, as in the base,
  so experts_native() would refuse the pair at its first check (3049)
  in either tree; the added t75_missing term does not change that.

So on sm_75 an NVFP4 layer never takes the fused kernels, before or
after the merge, and it goes down the same prompt path as in the base:
prefill.cpp, which picks that path, is the base's file unchanged. No
Turing-only branch sits in front of the NVFP4 path.
2026-11-14 06:24:20 +01:00
Niko1221 29147556b9 engine: background copies honour the process's CPU set
The background copy threads (checkpoints and parking) and the checkpoint
helpers start on the host's one CPU and widen their CPU mask before they
work. They widened to every CPU number, so the kernel gave them every
CPU of the cgroup: they left a CPU set the process was started with
(taskset, numactl) and the card's NUMA node the engine now places itself
on. They now widen to the process's CPU set as it is at start-up, after
the card-node placement. With STRATA_NUMA_CARD=0 they widen to every CPU
as before. These threads exist only with the conversation cache or
STRATA_CKPT_THREADS=1. Output does not depend on where they run;
home_cpus_test checks the widening.
2026-11-14 05:51:17 +01:00
Niko1221 716ebae14e engine: run on the graphics card's NUMA node on two-node machines
On a machine with two or more memory nodes the engine now restricts
itself, at start-up and before the CPU pool, the host thread and the
helper threads exist, to the CPUs of the node the graphics card is
attached to. A start with nothing pinned then ends with the same thread
masks, pool start-up line and worker count as the same engine started
under taskset on that node (checked on a rented two-socket host with an
RTX 4090; card_node_test checks the decision on made-up machines and the
restriction of a live process).

Measured value: decode with CPU experts on a two-socket host: a
32-worker pool on one node read 1.11-1.18 of the two-node default over
three rounds (UD 4-bit set, RTX 5090 host).

The process is left as it is unless all of these hold: Linux, two or
more nodes with CPUs, the process's CPUs span more than one node (a
taskset, numactl or cpuset restriction is kept), every card the run uses
reports the same known node (sysfs numa_node), the process may allocate
on that node and the node has free memory for the pinned K/V copy and
staging buffers, the threads were not placed by hand (--pool-cores,
STRATA_NUMA_SPLIT, an --aux-cpus list), the CPU is not hybrid, and the
pool keeps its worker count on that node alone (with --pool-workers N:
the node has N + 1 physical cores). A container CPU quota bounds both
counts alike, so the quota's worker count is kept.

STRATA_NUMA_CARD=0 turns it off. One-node machines read the sysfs node
folder and nothing else; there the output is identical to
STRATA_NUMA_CARD=0 (first-token logits, expert-stream counts and
tokens). With STRATA_TRACE set the engine prints one line,
"strata trace: card node: ...", with the inputs and the decision. The
expert arena itself is not placed by this change.
2026-11-14 05:51:17 +01:00
Niko1221 bde58068a0 Revert "expert arena RAM check: optionally leave the engine's own mappings out"
This reverts commit 667533760d.

Measured in a 57.7 GiB container (RTX 4090, IQ3_S, two starts each way):
with STRATA_ARENA_OWN_MAPPED=1 the arena check read about 27 GiB where
the memory guard read 56.8, waited 80 s, warned of a shortfall, and then
loaded the same arena as without it. Refaults and the PLE table's
resident pages were in the same range both ways and prompt time was
level. The switch was off by default, so the default path is unchanged;
the settings register is regenerated without it.
2026-11-14 05:05:02 +01:00