The line "a model with K-quant experts (Unsloth UD-Q4/Q5/Q6_K_XL) reads its prompt on ..." was printed at option time, before the model is known, so it also appeared for an IQ3_S or IQ2_XS set that has no K-quant layer. The default is still set at that point (before any engine code reads its switches); the line is now printed once the expert layout is loaded, and only when some layer has a gate/up or a down tensor of one of the four types STRATA_MMQ_KQ and STRATA_PF_FUSED_KQ decide for (Q4_K, Q5_K, Q6_K, Q5_1; the types prefill::mmq::supported() hands to the K-quant switch). A set whose only such tensor is a Q5_1 down still prints it, because the switch decides that product. The wording is unchanged, and so is every default.
nv_kq_expert_type and nv_kq_line_wanted are the deciding functions, with unit tests in nv_defaults_test (IQ3_S / IQ2_S / IQ2_XS sets: no line; Q8_0 down only: no line; UD-Q4_K_XL: line; one Q5_K layer among i-quant ones: line; Q5_1-only down: line). apply_nv_kq_default gets a say argument (true by default) so the engine can set the default early and print later.
Five commits on 662e72ac2. Flash-Next's K-quant packs (UD-Q4_K_XL: Q4_K / Q5_K gate/up with a Q5_1 or Q8_0 down) took llama.cpp's MMQ kernels for the
prompt by default. Now, on compute capability 8.0 / 8.6 / 8.9 and 12.0 cards with 80 or more multiprocessors (RTX A6000, A40, RTX 3090, A100, RTX 40 and
RTX PRO 5000 class), and on the 40 to 79 multiprocessor cards (RTX A4000, RTX 5070 class) for the staged launches, the fused kernels read them;
STRATA_PF_FUSED_KQ=0 gives MMQ back (STRATA_PF_FUSED_SM40=0 for the 40 to 79 class only, STRATA_PF_FUSED=0 for every fused kernel). The tile: sm_86-class
cards with 80 to 99 multiprocessors take the 128-row tile for these pairs from 5.8 rows an expert, sm_120 cards with 100 to 149 multiprocessors the same for
the two Q8_0-down pairs; every other card keeps its tile pick. Under 40 multiprocessors, compute capability below 8, HIP and the other formats: as before.
The start-up line about K-quant experts says what runs on the card (src/core/nv_defaults.cpp, nv_kq_fused_here), and the QUANTS.md row names the fused kernels.
Measured on an RTX A6000 (UD-Q4_K_XL, 55% of the experts on the card): the 48 forced continuations score byte for byte the same as the old tile with the fused
kernels on (scored-file hash 362035373b02d395...), and with the way back set the same as MMQ (0f58ac95a92d51a6...); prompt speed against the way back
0.99 / 0.96 / 0.98 / 0.99 / 1.01 / 0.99 at 300 / 1,000 / 2,049 / 4,097 / 8,193 / 20,001 tokens; decode unchanged.
The branch changed data/settings-register.json (the status and the note of STRATA_PF_FUSED_KQ); so did the head (generated fields). The register conflicted
in one hunk: the STRATA_PF_FUSED_KQ entry's git stamps (head: 3a61182bbf, the branch: 4dbaf703fd) and its status (head: opt-in, the branch: rollback). The status
of the branch is kept (a hand-kept field); the file was then regenerated with tools/settings_register.py on the merged tree, so every generated field is the
tool's output for this tree (the new reads in nv_defaults.cpp and moe_fused_iq.cu, and the line numbers that moved). The hand-kept fields of both sides
are carried unchanged (checked field by field against each side's change). docs/SETTINGS.md is regenerated after the gate round, not here.
With --batch 2 or more on Windows, HIP, integrated AMD (the gfx1151 block that sets the own-path prompt chunk) and a RAM budget in the start
arguments, every session (the main one and each slot) pins its streamed K/V for the whole context, and the RAM copy of experts is pinned on top of
that; at 4 slots and 131,072 tokens the engine stopped inside the prompt path's allocation, and with a smaller budget the OS ran out of page-locked
memory. The RAM copy is now cut to what keeps it plus the sessions' pinned K/V at 22.75 GiB (include/strata/core/uma_cache.hpp, two plain inline
functions, unit tested in src/core/uma_cache_test.cpp), the level of the largest 4-slot start that worked (15 GiB of experts, 7.75 GiB of K/V).
The experts left out are read from the SSD when needed. Context, slot count and the 16,384-token chunk are untouched; --batch 1, starts without
--batch, every other OS and backend, and 2 and 3 slots on a 64 GB box (their RAM copy is under the cap) are unchanged.
The cap has no floor: for any number of requests the engine keeps as little in RAM as needed and starts. With so many slots that their pinned K/V
alone is over 22.75 GiB the RAM copy is empty (budget 1 byte; 0 would mean no limit) and every expert outside the GPU cache is read from the SSD;
the start goes on.
The engine says so once after the pin, only when the cap cut: "N requests at once: X GiB of experts are kept in RAM so that everything fits in
this PC's memory; the rest are read from the SSD when needed (STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set)", or at cap 0 the same without
the figure. After a start that really failed with 2 or more slots the engine says "N requests at once do not fit in this PC's memory: start with
--batch N-1", and the Terminal's step for that failure reads "This PC's memory cannot hold that many requests at once. Lower Concurrent requests
in the app (or `--parallel` in the Terminal) by one and start again." (strata_cli/launch/runner.py, tests/terminal/test_batch_memory_words.py).
STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set (settings register status rollback; one sentence in docs/BATCHING.md).
Measured on a Strix Halo with 64 GB (UD-Q4_K_XL, 131,072 context, 4 prompts of 68 to 2,067 tokens): 2 slots and 3 slots print no line and keep their
cache slots; 4 slots print the line with 15.0 GiB, start and serve every slot; the one-slot run gives the same 36 ids as before.
Both branches changed data/settings-register.json and src/program/generate.cpp. generate.cpp merged without a conflict. The register conflicted in
three hunks, all generated fields (the line numbers of the STRATA_PF_FUSED reads and defaults, and one read entry); it was resolved by running
tools/settings_register.py on the merged tree, so every generated field is the tool's output for this tree, and the hand-kept fields (status, owner,
note) of both branches are carried unchanged (checked against git's own merge of the file: no hand-kept field differs). docs/SETTINGS.md is
regenerated after the gate round, not here.
The cap on the pinned RAM copy of experts (--batch 2 or more, Windows HIP, integrated GPU) printed
its line at 2 and 3 slots too, where the whole copy (12.47 and 16.40 GiB) is under the cap and
nothing is cut: "18.1 GiB of experts are kept in RAM" was wrong there. Now the line comes after
the pin and only when the RAM copy reached the cap (4 slots at 131,072 tokens: 15.0 GiB).
STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set (any other value, or unset, leaves the cap on);
the line names it: "(STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set)". The register entry is
now status rollback with the measured points in its note, and docs/BATCHING.md has one sentence
where the memory per slot is described.
With --batch 4 at 131,072 tokens on a Strix Halo (UD-Q4_K_XL, the usual 38 GiB RAM
budget) the engine stopped inside the prompt path's allocation, and with an 18 GiB
budget the OS ran out of page-locked memory. Every session (the main one and each
slot) pins its streamed K/V for the whole context, 1.55 GiB at 131,072 tokens, and the
RAM copy of experts is pinned on top of that.
Now, with --batch 2 or more on this path, the RAM copy is cut to what leaves the RAM
copy plus the sessions' pinned K/V at 22.75 GiB, the level of the largest 4-slot start
that worked (15 GiB of experts, 7.75 GiB of K/V). The experts left out are read from
the SSD when needed. Context, slot count and the 16,384-token prompt chunk are
untouched; --batch 1 does not enter the code. The engine says so in one line, and
after a real init failure with 2 or more slots it names --batch N-1.
Measured on the box (4 slots, 131,072 tokens, 15 GiB): starts and serves, 49.2
tok/s inside the batch windows against 56.4 with the whole copy at a 65,536 context;
the 2,067-token prompt reads at 837 against 1,054 tok/s. 3 slots and below are not
changed: their RAM copy plus K/V is at or under the level.
The constant and its measured starts are in include/strata/core/uma_cache.hpp.
STRATA_UMA_PIN_CAP (test only, register status research) turns the cap off.
The line apply_nv_kq_default prints at every NVIDIA start of compute capability 8.0 and up said that a model with K-quant experts reads its
prompt on llama.cpp's MMQ kernels. With the previous commit that is no longer true on the cards the fused K-quant default takes. The call
now gets one more argument: whether Strata's own kernels read the K-quant experts on a visible card, from the new nv_kq_fused_here(major,
minor, SM count), which is fused_tile::kq_takes with the switches the engine reads (STRATA_PF_FUSED=0, STRATA_PF_FUSED_KQ, STRATA_PF_FUSED_SM40,
STRATA_PF_FUSED_SM86). Where it is true the line reads
strata: a model with K-quant experts (Unsloth UD-Q4/Q5/Q6_K_XL) reads its prompt on Strata's own kernels where they cover the layer (Q4_K and
Q5_K gate/up with a Q5_1 or Q8_0 down) and on llama.cpp's MMQ kernels for the rest (STRATA_PF_FUSED_KQ=0 gives all of them back to MMQ)
and where it is false the earlier line, byte for byte. generate.cpp asks every visible card and says it if any of them takes the kernels.
The line is printed as before: only when STRATA_MMQ_KQ was set by this default. src/core/nv_defaults_test.cpp checks both texts and the
card answer for the named cards, the way-back switches and the opt-in.
docs/QUANTS.md, row "Q4_K (gate/up)", column "CUDA prompt" (the Q5_K and Q5_1 rows say "as Q4_K"): names the fused kernels and the way back.
docs/SETTINGS.md is generated from the register and is not regenerated here.
Evidence for the 40 to 79 SM clause (RTX A4000, sm_86, 48 SMs, one layer of Flash-Next's shape, the staged 128-row tile the rule picks, MMQ ms /
fused ms at 300 / 1,000 / 2,048 / 4,096 / 8,192 / 20,000 tokens): Q4_K / Q5_1 1.67 1.44 1.49 1.35 1.05 0.97, Q4_K / Q8_0 1.79 1.61 1.67 1.46
1.08 0.98, Q5_K / Q8_0 1.72 1.59 1.60 1.45 1.05 0.99; the 64-row tile is slower at every size (0.60 to 1.37); the output bits hash is equal at
every tile. No end-to-end row exists on a card of 40 to 79 SMs with a K-quant set.
small_card_kernels_on() moves from core/sm120_series.hpp to
prefill/pf_fused_override.hpp (strata::prefill), next to the other reader of the
small-card override. sm120_series.hpp is byte-identical to its state before the
previous commit again, so none of the CUDA kernel translation units under src/kernels/cuda sees
a changed header. Behaviour is unchanged: same rule, same defaults, same way back
(STRATA_PF_SMALL_FUSED=0). generate.cpp and the unit test call the function in
its new place.
On one CUDA card whose expert cache is small (default prompt chunk under 8,192
tokens, native pack) the prompt path reads in MMQ's buffer layout so that the
layer-major walk runs. Inside that layout the native fused expert kernels
(the layer-major walk's groups and the streamed chunks) now run too, instead of
MMQ's kernels, by default.
On that path an unset STRATA_PF_FUSED reads as 1 in fused::native_supported
and fused::requested() (pf_fused_env_effective), so the kernels take every
format they cover on the card; K-quant, Q8_0 and the other formats keep their
own switches. The reading applies only while the small-card rule has fired in a
CUDA build (pf_fused_override() == kPfFusedKernelsOnly); a card where the rule
does not fire, a HIP build, and a user who named STRATA_PF_FUSED behave as
before.
STRATA_PF_SMALL_FUSED=0 is the way back (MMQ's kernels on that path, as
before); STRATA_PF_SMALL=0 still turns the whole rule off. The log line says
"so prompts are read the way that suits a card with little memory" in place of
"with the unfused experts". Unit test over the card sizes of the measured
grid; register entry STRATA_PF_SMALL_FUSED with status rollback.
f-int-tidy = bb1bdb4da + 46b3013f9 (conversation cache and park pool tests ON in the cpu-check preset, +8 tests), ab38d9298 (the packer's import
probe writes no bytecode, +3 tests), 02020478b (a dead "multi" check removed from serve/server.py), 6f1613cc1 (tools/cuda_spill_baseline.json: the
known spill violations per architecture, +24 tests), f55afa152 and 4e9dde87e (the owner-approved log line "the graphics driver paused the GPU for
N ms between requests ..." on AMD under Linux, gpu_pause_time.hpp and three call sites in generate.cpp). Merged with the integrated-graphics
arrival before it; generate.cpp merged without a conflict, nothing changed by hand.
On a Radeon 780M (gfx1103) under Linux the expert arena (31.6 GiB of the Q2_0 pack) is filled with buffered reads of experts.bin and registered
with the driver (a KFD userptr). The GPU's own buffers take about 12 GiB of the same RAM, and the file cache of the model files the start read
fills most of the rest: MemFree 1.6-2.4 GiB and Cached 6.9-7.6 GiB at READY. With that little free memory, broken into small blocks, the
kernel's proactive compaction (kcompactd, fragmentation score above its high mark) scans and migrates the node's pages in passes: one right
after the fill and, when a pass made no progress, the next one 32 s later (500 ms << COMPACT_MAX_DEFER_SHIFT). A pass that moves pages of the
registered arena makes KFD evict the process's queues, and the gc 11 MES firmware never answers the eviction while a dispatch sits in a barrier:
the late stalls of an 8K prompt (30-50 s after READY) that the wait before READY does not reach.
Passive starts (no request) under a g++ load, settle build, 100 s of idle after READY, the daemon's scan counters read once a second: late
compaction passes in 3 of 8 starts (one of them evicted the idle engine's queues, evicted_ms +434 ms); the three have compact_daemon_migrate_scanned
moving with compact_stall, compact_daemon_wake and the kswapd counters flat (proactive compaction). In the failing starts of the 8K prompt
arm (b) the first late pass came 31-34 s after the end of the fill, in all four.
The engine now asks the kernel to drop the cached pages of the model files: posix_fadvise(DONTNEED) on each 8 MiB chunk of experts.bin right
after it has been copied into the arena (drop behind), and once per file after the load: the arena's expert files, the pack's dense.bin and
embd.bin, the GGUF shards of --native except the PLE table's (its rows are read directly). It is advice for clean pages: a file that is still
mapped keeps its mapped pages, a failed call is ignored, nothing is written or deleted. Nothing reads these files after the load but the
session fingerprint (the first and last 2 MiB of each model file) and an engine restart, which reads them from the drive again. Automatic on the
class of the huge-page and wait-before-READY rules (igpu_cache_drop_default: integrated gfx1103 / gfx1150 / gfx1151 under Linux); Windows,
discrete cards and every other device are unchanged. STRATA_NO_ARENA_CACHE_DROP=1 turns it off (research / A-B only, registered as research). One
[DRAFT] log line after the load says how much was given back and how long the final call took.
The harness version of the final call (posix_fadvise DONTNEED on experts.bin, dense.bin, embd.bin and the native shard right after the line
"expert arena read"), same passive starts: late passes 0 of 8, MemFree at READY 8.4-9.3 GiB (1.6-2.4 GiB without), free 2-4 MiB blocks at
READY 0.8-3.3 GiB (0.01-0.25 GiB without), READY 23.8-24.6 s (23.7-26.4 s without), the call 0.51-0.55 s. Loaded starts of the finished change
(g++ load beside the start, first request at READY + 0 s, 2K and 8K prompts, early in a boot, one Radeon 780M box): 9 of 9 passed with the
give-back, 10 of 14 with STRATA_NO_ARENA_CACHE_DROP=1.
Tests: tests/core/page_cache_drop_test.cpp (the flag and the switch, a range and a whole temporary file, every error path ignored, the final
call over a mixed list, the meminfo reader, the draft line) and the device rule in src/core/arch_defaults_test.cpp; settings register: one
hand-added entry (STRATA_NO_ARENA_CACHE_DROP, research).
On a Radeon 780M (gfx1103) under Linux the engine registers its 31.6 GiB expert arena with the driver (a KFD userptr). The load
that fills it keeps the kernel moving pages (compaction, reclaim) for about two seconds after the engine is up. Every move inside a
registered range makes KFD evict the process's GPU queues, and the gc 11 MES firmware never answers the eviction while a dispatch
sits in a barrier: the driver resets the GPU and the first prompt ends in "unspecified launch failure" (60 s hang). The kernel log
of every failed start shows the same sequence (MES failed to respond to REMOVE_QUEUE, Failed to evict queue, Failed to quiesce KFD
in most, GPU reset begin).
Before it prints READY the engine now waits until its own KFD eviction counter (/sys/class/kfd/kfd/proc/<pid>/stats_*/evicted_ms,
the milliseconds the process's queues spent evicted) has not moved for 2 s, at most 10 s. Where the counter cannot be read (no such
file, another kernel, a container with its own pid namespace) it waits nothing and prints nothing. No user setting and no line a
person sees. The device class is the one of the huge-page rule: an integrated gfx1103 / gfx1150 / gfx1151 under Linux
(igpu_kfd_settle_default); Windows, discrete cards and every other device are unchanged. STRATA_NO_KFD_SETTLE=1 turns it off (a
research switch for A/B runs, registered as research).
Measured on one Radeon 780M box (Q2_0 pack, Linux kernel 7.0, one engine at a time, setup's environment, 2K and 8K prompts):
- g++ load beside the start, first request right after READY: 3 of 10 starts passed (5 failed in the first seconds after READY).
- the same load, the harness sending the first request 30 s after READY: 5 of 5; waiting until the counter had been quiet for 2 s
(waits 2.0-3.4 s, mean 2.4 s): 8 of 10; the failures of the first seconds went from 5 of 10 to 0 of 15. The counters show the
movement ending within about 2 s of READY and nothing after.
- the engine's own wait, quiet, build with and without STRATA_NO_KFD_SETTLE=1: READY 23.0-23.5 s against 21.1-21.3 s (+2.1 s), speed
unchanged within the spread; quiet starts with the wait: 9 of 9 passed.
Late stalls inside a long prompt (layer 17-25 of an 8K pass, 30-50 s after READY) are a different class and are not addressed here.
Tests: tests/core/kfd_settle_test.cpp (the counter file missing, unreadable, garbage, a counter that moves, a counter that is quiet, the
cap; the folder reader on a temporary folder; the engine's call with the flag down) and the device rule in
src/core/arch_defaults_test.cpp; tools/check cmake-cpu on a Linux CPU runner: 75 passed, 0 failed (kfd_settle_test, arch_defaults_test and
stream_watch_test among them); tools/test_settings_register.py 8 OK, settings_register.py --check clean (one hand-added entry).
On a Radeon 780M (gfx1103) under Linux the engine registered its 31.6 GiB expert arena and asked for transparent
huge pages on it whenever enough free 2 MiB blocks existed. Huge-page compaction and collapse inside a registered
range invalidate it; KFD then evicts the process's queues, and the gc 11 MES firmware resets the GPU when a dispatch
sits in a barrier. The prompt then ends in "unspecified launch failure". One Radeon 780M box (Q2_0 pack, Linux kernel 7.0), one engine at a
time: huge pages requested in 9 starts, 8 failed in the first prompt; not requested in 3 starts, 3 ran.
Setup already wrote STRATA_NO_ARENA_THP=1 for its 780M opt-in. This makes it the engine's own rule, detected from
the device (integrated, and gfx1103, gfx1150 or gfx1151), on Linux only. No new setting: STRATA_NO_ARENA_THP unset
lets the engine decide (this rule, and every other device as before); any value but 0 skips the request as before;
0 now asks for the huge pages, also on these GPUs (it used to skip them like any other value). The SYCL arena reads
the variable the same way. Windows and discrete cards are unchanged. The arena line's new ending is a [DRAFT] for
the owner's wording. Unit test: arch_defaults_test (the device rule and the variable's three states).
The paused-GPU counter of the AMD driver was read only when a request began and when
it ended, so a pause between two requests, or while the engine sat idle after READY,
showed in no line. The engine now also reads the counter at READY and when each request
ends (whichever way it ends), and when the next request begins it prints one line if
the counter moved by 100 ms or more in between:
strata serve: the graphics driver paused the GPU for N ms between requests while Linux moved memory the GPU uses
The bar is the one the per-request line uses. A failed read leaves no mark, so two
unrelated counters never make a gap, and a counter that went back prints nothing. The
begin-of-request read is the one that was already there; the other builds (no HIP, not
Linux) read nothing. Diagnostic only: no new setting, no change to any existing line.
gpu_pause_time_test gains the line's cases and a sequence test of the bookkeeping
(GpuPauseIdle).
On a Tesla P100 (compute capability 6.0, the STRATA_EXPERIMENTAL_SM60 build) the
prompt experts will take the FP16 path instead of MMQ, with the few-row experts
of the previous commit on the quantized grouped kernels. The rule is in
include/strata/prefill/gp100_prompt_default.hpp (gp100_prompt_default_test): only
with STRATA_PREFILL_MMQ unset (an explicit value keeps its old meaning), every
visible CUDA card compute capability 6.0, and none of STRATA_MMQ_WS=1,
STRATA_EXPERT_NIBBLE=1 and --peer-device (the prompt peer computes on MMQ only;
generate.cpp records the flag). prefill.cpp gp100_fp16_default() evaluates it
once; mmq_plan() takes it and the manifest names the reason; the few-row switch
STRATA_PF_FEWROWS takes it as its default.
kGp100Default in the header is false in this commit, so nothing changes yet: the
next commit sets it true. Settings register: STRATA_PREFILL_MMQ's read sites.
One commit on 5aa7f1d88 (in this branch). Owner: OK to take it (11-12). Lane gates as relayed: cmake-cpu 78 / 0 / 4, device code 3,852 functions
identical on sm_86, decode speed ratio median 0.998, stop turns left with unreturned tokens 49 of 56 -> 37 of 56, cap rows 0 of 19, pipelined
stop turns identical 18 of 18 on / off. No conflict, nothing changed by hand.
When the server ends a pass (a stop string, a client that left, a repeat or loop stop) it sends STOP and throws away every token that comes after it. The engine
sees STOP only at the end of a window, so the window that was running had already committed its rows: the session ended one or two windows past the tokens the
client was sent, and the next request of the conversation could not continue from it (the state is recurrent and cannot be cut back) and fell back to the newest
checkpoint, reading the cut reply again.
A window that finishes with STOP already set is now neither committed nor printed, in the serial loop and in the pipelined loop (a front stage that the speculative
window ran on goes back to the snapshot taken before the dropped window, with no replay). Not dropped: a merged window, the request's first window, and a window
whose state the one-token path advanced itself (Verifier::commit_deferred()). A request that ends by its cap or by EOS never sets the flag and takes the path it
took before; the cost in the loop is one flag read per window. The tokens a client receives do not change: the rows dropped were never sent.
STRATA_SERVE_STOP_SKIP=0 turns it off (research switch, on by default; register entry added). The decision is a pure function in serve_stop_bound.hpp with a unit
test (decision table and a ledger of the loop).
Part of lane AGENT-CAP (candidate C).
l620, 11-12, three runs per arm: with the arena at min(1 GiB, B / 8) the park of a
new 55K-token conversation beside three older parked ones stays at 283-291 ms
(K/V resize 205-213 ms: the arena is full of the older images, 47 misses of 372
allocations); with 2 GiB (a 16 GiB cache) it is 117-118 ms (K/V resize 41-44 ms).
Parks up to 20K are the same with either (35-59 ms).
Sizes now (park_pool_policy.hpp): segment pool min(2 GiB, B / 4) in 64 MiB steps,
none under 128 MiB; ready checkpoints as many as fit in B / 12, at most 4. At the
automatic cache sizes: ~8 GiB free RAM -> 2 GiB cache -> 512 MiB + 1 ready;
~12 GiB -> 3.75 GiB -> 960 MiB + 2; ~20 GiB -> 7 GiB -> 1792 MiB + 4; 40 GiB or
more -> 8 GiB -> 2048 MiB + 4. At most a third of the cache is held idle (30% at
8 GiB, 2.4 GiB); it is given back first (before any parked conversation is
evicted, before the RAM floor), and filled only while the cache budget and the RAM
floor plus 1 GiB leave room. Unit tests: the sizes at 8 to 200 GiB free and small
explicit caches.
Owner's go 11-11: the segment pool and the checkpoint pool with ready
checkpoints are on unless switched off. No user setting: STRATA_PARK_SEGPOOL_MIB=0
and STRATA_CKPT_POOL=0 are diagnostic switches, a value you set is kept.
Sizes (park_pool_policy.hpp, from the conversation cache's budget B): segment
pool min(1 GiB, B / 8) in 64 MiB steps, none under 128 MiB; ready checkpoints
as many as fit in B / 12, at most 4. At the automatic cache sizes: ~8 GiB free
RAM -> 2 GiB cache -> 256 MiB arena + 1 ready; ~20 GiB free -> 7 GiB cache ->
896 MiB + 4; 40 GiB or more free -> 8 GiB cache -> 1 GiB + 4. At most 21% of the
cache is held idle. Cache off: no pool.
Idle memory is accounted in the cache's budget (arena resident bytes no image
uses, plus the kept checkpoints) and given back before any parked conversation
is evicted (ConversationCache::make_room), before the park's physical-RAM
checks refuse or skip (shrink, then release_free_heap, then evict), before a
session save or load, and the top-ups run only while the budget and the RAM
floor plus 1 GiB leave room.
What the default means per OS and build (not the same everywhere, on purpose):
* Linux CUDA / HIP: both pools on.
* Windows CUDA / HIP: the checkpoint pool on; the segment pool is NOT created
(its OS layer, VirtualAlloc + pre-touch, is not written; reserve() returns
nothing and the arena is inert) until that exists.
* macOS (Metal build): neither is on by default (not gated there).
* A layer-split serve (several stages): the checkpoint pool is not on by
default (as READY never applied to it); the segment pool is.
Tests: park_pool_policy_test (sizes at 8, 12, 20, 40, 200 GiB free and small
explicit caches), the existing pool and cache tests.
With STRATA_PARK_SEGPOOL_MIB=N and a conversation cache, the serve loop reserves
min(N MiB, an eighth of the cache) once, installs it as the process-wide segment
pool, hooks it into the cache's budget (idle bytes counted, given back first)
and starts the background filler, which makes the arena resident while the cache
budget and the RAM floor plus 1 GiB leave room. The park's physical-RAM check
shrinks the pool before it releases the heap or evicts a parked conversation, and
every park kicks the filler to top the pool up again. Unset: no pool is created,
no thread is started, the code path is the one before. Trace lines only under
STRATA_PARK_TRACE. Registered as "research" in data/settings-register.json.
One conflict, CMakeLists.txt: both sides add a ctest block at the same spot of the
STRATA_BUILD_TESTS list (main's gpu_pause_time_test, f-ok-reader's reader_room_test).
Resolved by keeping both blocks, the existing one first.
One conflict, data/settings-register.json: two "line" values of generated read sites
(STRATA_MTP_BATCH_F16 in src/prefill/prefill.cpp, STRATA_SERVE_STOP_BOUND in
src/program/generate.cpp, whose backend field on the other side was still the old "hip",
before the stop bound went to every backend). Both resolved to the f-own-int side; the file is
not regenerated (the register's line numbers are informational; tools/settings_register.py
--check passes on the merged tree).
P2 ended the budget's first pass exactly at the budget for a solo request; a --batch engine kept the old behaviour (the server sent no hold to it), so there the second pass still read the whole reasoning again in 8-9 of 21-24 budget turns (p1004, --batch 2: base 9 of 24, head 8 of 21, PERF-AUDIT's R9700 and l620 runs the same shape).
Engine (src/program/generate.cpp, include/strata/core/serve_stop_bound.hpp): a slot carries the hold (SlotHold: on / n / id). BGEN hold=N:ID is parsed by the GEN path the admission runs; at the handover the slot takes the hold unless the admission's one token was </think>, and an admission whose hold is that one token ends there (DONE hold, no slot). In the slot windows the rows a window may commit stop at the hold (slot_cap(), in the MTP window, the pipelined MTP window's proposal count and the DFlash2 draft count), a slot ends with BDONE hold after exactly N emitted tokens unless ID was emitted first, and its sessions then hold exactly the tokens it fed, as in the solo case. The cap is the conservative one for a window that might emit ID: it stops at the hold and the next window goes on. READY says "stop hold holdb"; "holdb" is a protocol token only (no user-visible line, no setting).
Server (serve/server.py): the budget sends the hold to a --batch engine only when its READY says holdb (can_hold_batch); generate_batched adds the key per leg with the tokens the pass has already sent taken off (a solo leg promoted to a slot continues with hold=N-k, none once </think> was sent), and a leg that ends with finish "hold" ends the pass.
Tests: tests/core/serve_stop_bound_test.cpp (slot windows of changing width against a per-token reference over a whole reply: 75,360 cases; same tokens, same finish, no row committed past what was emitted, the hold ending at exactly N unless ID came first); serve/test_thinking_hold_batch.py (a fake --batch engine with the hold: solo path, a request admitted into a slot, a solo leg promoted to a slot with the count falling, first-N tokens of the unheld reply for N = 1 ... 53, hold ended by its token); serve/test_thinking_hold.py (stub engine with holdb).
The slot-model case failed on its first run (first=0 hold=1 max_new=3 id_at=0: got 7777 101 103, reference 7777 101 102). The test model was wrong, not the engine: it read a window's rows with `produced`, which it increments while the window is emitted, so it skipped a row; the engine emits from fixed arrays (outb[first + j]). Fixed in the test with a base index; the engine code was not changed by that run.
Mixed versions, both covered: new server + old engine (an engine without hold, and one with hold but no holdb, get no key when they run --batch; the budget cuts and STOPs as before) in test_thinking_hold.py, and old server + new engine (the extra READY tokens change nothing it reads, a request without a key runs as before through the solo path and through a slot) in test_thinking_hold_batch.py. Real-engine cross runs of P2 (head engine + base server, base engine + head server) were done on p1004 before this commit.
Lane AGENT-TURN, P2b.
In the resident RAM mode (--resident-experts, --resident-budget-gib, which
setup writes for Unsloth's UD-Q4_K_XL below about 71 GB of RAM and for the
low-RAM mode, or the start's own fallback when RAM is short for the arena)
the expert cache refuses the server's VRAM command ("VRAM: not with the
resident low-RAM mode"). With the on-demand reader and only setup's 700 MiB
reserve, the reader then found about 425 MiB free and every picture went to
the processor reader: 7.67 / 6.15 / 1.49 / 1.43 s against 2.06 / 0.93 /
0.41 / 0.37 s with the room held back (l620, IQ3_S, card held to 32 GB,
--resident-budget-gib 40).
The engine knows that mode before it sizes the cache, so there it keeps the
reader's 2,048 MiB in the reserve (strata/core/reader_room.hpp, applied
once after the arena / file pass loop, before the cache is sized; the mode
is not entered later). Only an engine with --vision, --vram-elastic,
--serve and the resident RAM mode changes; a larger reserve is never
lowered. One engine log line says it; no setting, nothing for the user.
Gate on l620 (same setup, 3 starts each, alternating):
- new default with the rule: the reader on the card in 3 of 3 starts
(1,509 MiB), 12,068 slots, pictures 2.06-2.45 / 0.91-1.08 / 0.39-0.59 /
0.37-0.55 s, text 1,714-1,722 / 3,867-3,882 tok/s at 2K / 8K;
- old default: the reader on the card in 3 of 3, 12,068 slots, pictures
2.07-2.37 / 0.91-1.09 / 0.39-0.59 / 0.37-0.55 s, text 1,719-1,740 /
3,873-3,889 tok/s.
Without the resident mode nothing changes: the same 12,719 slots, the same
answers to the same prompts and pictures, the shrink path as before, the
rule's line absent (one start each, engine before and after).
Test: reader_room_test (ctest; the rule's eight input combinations and the
larger-reserve case).
On arm64 every x86 CPU test is false, so the line read "ggml-cpu (older-CPU
build)" even when the pool is the Strata quant layer. Print, on arm64 only,
"[DRAFT] CPU expert kernels: the Strata quant layer (NEON)" when
STRATA_OWN_CPU_QUANT is defined and "[DRAFT] CPU expert kernels: ggml-cpu
(NEON)" otherwise. The x86 expression is unchanged. The wording stays [DRAFT]
until the owner words it (par/OWNER-WORDING-1111.md, ARM POOL).
live_tail_is_replaced_reply() takes the live branch's picture positions and answers "park as before" when one is at or past the resume point (unit case picture_at_or_past_checkpoint_parks in reply_branch_test, 16 cases); generate.cpp passes live_imgs' starts instead of checking them beside the call. Same behaviour: a chat request's reply holds no picture, so the guard does not fire from the chat API.
The engine log line of P3 now starts with "[DRAFT] " until the owner words it (par\OWNER-WORDING-1111.md).
Lane AGENT-TURN, P3 follow-up.
At the thinking budget the server cut the stream, STOPped the engine and sent a second engine request: the same prompt + the tokens it kept + the wrap-up. The engine sees STOP only at a window's end and commits each window before sending it, so it often held one or more tokens past the cut; its live session was then not a prefix of the second request, which fell back to the checkpoint before the assistant turn, parked the live branch and read the whole reasoning again (lane PERF-AUDIT, R9700 0.1.59: 4 of 9 budget turns, 535 tokens, 849-1000 ms against 85-96 ms).
Engine: GEN key hold=N:ID ends the request after N emitted tokens unless token ID (</think>) came first; the commit is capped there (serve_hold_remaining() + serve_stop_bound(), tested against the emission loop in serve_stop_bound_test), DONE finish "hold", READY says "stop hold". Without the key nothing changes; an older engine skips the key.
Server: sends hold=<budget - thought>:<</think> id> (HOLD_KEY, its own key, never a client's) only to an engine that says hold in READY, has no --batch slots and is not a multi engine, and only when </think> is one token. At DONE hold it wraps up if the point is clean; if not (a character split across tokens, a tag held back) one more pass from the live session with a hold of the tokens left (at least one). The second pass then reads the last token and the wrap-up only. Tested with a windowed stub engine in serve/test_thinking_hold.py: the answer is the same with and without the hold for every budget; an engine that does not say hold gets no key; one that says it but ignores it gives the same answer.
--batch engines (BGEN slots) are a separate path: not covered here, no hold is sent to them.
Lane AGENT-TURN, P2.
The block that gives the GGUF's cached expert pages back (generate.cpp, after the prompt path is set up) was under no
backend guard. cudaDevAttrIntegrated is true on AMD APUs under HIP (hipDeviceAttributeIntegrated) and on every Mac under
the Metal layer, the gfx906 layer has no such attribute, and Windows has no page drop, so on those builds the block either
ran ungated on a class it was not measured on, printed its line with nothing freed, or did not compile. The whole block
(call and log line) is now inside #if __linux__ && !STRATA_USE_HIP && !STRATA_HIP_GFX906 && !STRATA_GPU_METAL, and the
[DRAFT] line prints only when pages were actually given back. tools/test_uma_drop_guard.py checks that the call, the
setting's reads and the line all sit inside that guard. The register's two read lines follow the move.
A request that resumes from a checkpoint parks the live branch first. When that checkpoint is the live branch's own turn checkpoint (the history before its last assistant turn), the live branch holds nothing else past it, and the prompt opens the same assistant turn there again, the client has re-sent the history with that reply dropped (an OpenAI-style client sends every earlier reply back without its reasoning), edited, or regenerated. That branch is no longer parked: no request of the client sends the reply back as it was, and the park copied the whole conversation to host memory on the request's path (131-209 ms per turn at 2K-20K on an R9700, lane PERF-AUDIT's chat run) for a copy the next park dropped as superseded.
The rule is live_tail_is_replaced_reply() (include/strata/program/reply_branch.hpp, test src/program/reply_branch_test.cpp): live[resume] and ids[resume] open a turn with the same role token, live has no other turn after it, and both agree before resume. generate.cpp asks it only when nothing else comes in (no parked conversation restored, no borrow, no batch slot, no lent slot, same cvec, no pin sibling) and the live branch has no picture at or past resume. Reuse is unchanged: the request reads from the same checkpoint as before. A real switch to another conversation parks as before. New engine log line [DRAFT]: "conversation cache: the reply this request replaces is not parked (N tokens past the turn checkpoint at M)".
Lane AGENT-TURN, P3.
serve_stop_bound() caps the accepted rows a decode window commits at the rows the request can still emit (max_new) and at the first EOS, so the conversation the session keeps is exactly what the client got and the next continuation reuses it instead of falling back to the older checkpoint. It was compiled for HIP only, where it was measured (4 x R9700: 4 of 16 continuations fell back without it, 0 of 16 with it). It changes no emitted token; on CUDA it now applies too. STRATA_SERVE_STOP_BOUND=0 still turns it off (serve_stop_bound_on(), tested in serve_stop_bound_test). Host code only (generate.cpp is compiled as C++). The register entry's backend is now cuda-hip.
Part of lane AGENT-TURN (P1); the thinking-budget hold (P2) needs the bound on every backend.
The log line of the shared-memory page drop is plain words now and marked [DRAFT] until the owner words it
(par/OWNER-WORDING-1111.md, SPARK). The numbers (bytes given back, time, free memory before and after) print only with
STRATA_UMA_DROP_PAGES=2. The switch is in data/settings-register.json as a research setting (the A/B arm of the gate),
not documented for users.
On a GPU that shares the system RAM (cudaDevAttrIntegrated, the DGX Spark's GB10) CUDA counts only the RAM the kernel has
free: cudaMemGetInfo equals MemFree, not MemAvailable (measured: 62.59 GiB free = MemFree, MemAvailable 118.77 GiB). The
start reads every expert of the GGUF into the cache through the mapping, and those 47 GB of pages stay in the page cache
as a second copy of the cache's bytes. At READY the box had 1.3-1.6 GiB of MemFree, and the picture reader's own CUDA start
failed ("CUDA error: out of memory ... cudaSetDevice") in most starts, so a 2048x1536 picture took 91-105 s on the CPU
reader instead of about 3 s on the card.
When every expert is in the GPU cache on such a device (one GPU, the GGUF read in place), the engine now gives those
pages back after the prompt path is set up: madvise(MADV_DONTNEED) and posix_fadvise(DONTNEED) per expert blob, whole
pages inside the blob only. The experts of the slots the prompt path borrows keep their pages, because the refill after a
borrowed prompt reads them again. The cache holds the same bytes either way, so no output bit changes.
STRATA_UMA_DROP_PAGES=0 keeps the pages (for A/B runs).
PcieAuto refines the decode PCIe share (which of a layer's missed experts the GPU computes after a PCIe copy, the
rest on the CPU, which rounds differently) at fixed window counts, but the value it picks comes from the measured
CPU pool time. On an RTX A6000 (IQ3_S, DFlash2 Auto, frozen table, prompt share 0.5) two of 18 starts settled one
reading later (0.10 -> 0.15 at window 144 instead of 48) and gave other tokens from the second request on; with the
share fixed at 0.15 12 of 12 traced starts were identical, and identical to the 16 other starts.
- The table file gets an optional "pcie" line (0..1). The start that writes the table stores the share PcieAuto has
then (its third reading, or what it reached by that request's end) and fixes it from the next request; a start
that loads a file with the line runs with that share and PcieAuto off.
- A file written before this has no pcie line: it loads as before, PcieAuto refines as today, and once it has settled
(three readings, or it gave up) the share is written into the same file and fixed; the next start loads it.
- One GPU only (a layer split keeps PcieAuto's per-stage refinement). Same key, same ignore-and-relearn rules; without
--draft-costs nothing changes.
- draft_policy_test: the pcie round trip, an old file without it, out-of-range and malformed values refused.
Conflict: tools/test_setup_llama_archive.py, deleted on f-own-int (e43ff9885, no llama.cpp archive
download in the own stack) and changed on main (fd40eb0fd, its urlopen mock moved to netpolicy):
kept deleted.
The amdgpu driver suspends all GPU queues of a process while the kernel moves
or reclaims host pages the GPU maps, and counts the time per GPU in
/sys/class/kfd/kfd/proc/<pid>/stats_<gpu id>/evicted_ms. On p620 a slow
prompt read lost about exactly that time (RESULTS-GH-URGENT, option 1) and no
log showed it.
- include/strata/core/gpu_pause_time.hpp: header-only reader (sum over the
process's GPUs; a missing, unreadable or non-numeric counter = not
available, -1) and the two lines.
- generate.cpp: read once when a request begins and once at its end (a line
only when the request saw >= 100 ms), and in each pass of the stall report
beside the memory line (the change over the report's 2 s). HIP on Linux
only; every other build returns "not available" and prints nothing.
- tests/core/gpu_pause_time_test.cpp: fake KFD tree (present, several GPUs,
missing, unreadable, garbage) and the line formats.
Both lines are the owner-approved wording of 11-11. The test also reads a
missing KFD tree 10,000 times: not available, no line, mean cost printed.
The prompt-path line of the automatic RAM copy reads "A larger automatic
RAM copy (...)" (was "A larger the automatic RAM copy"), and the uncovered
lend-slots line asks to "Free more RAM for the automatic RAM copy (...)"
(was "Raise the automatic RAM copy"). With --resident-budget-gib given,
both lines stay byte for byte.
The default CPU prompt share (prompt chunks under the share's limit, CUDA one card and gfx12) picks
which streamed experts the CPU computes from measured CPU and GPU times (an EMA) and decides per
layer, from measured layer times, whether to share at all. On an RTX A6000 that streams experts
(DFlash2 Auto configuration, frozen draft table, STRATA_ADAPT_NOWAIT=0) two starts gave identical
tokens in 7 of 24 requests with the share balancing and in 24 of 24 with it fixed at 0.25 or 0.5
or off; the fixed 0.5 read the one short chunk the share helps (981 tokens) in 1,001-1,009 ms against
995-997 ms balancing and 1,070-1,074 ms off.
- Prefill::fix_cpu_share(v): the default-armed share at a fixed value, used like a fixed
STRATA_PREFILL_CPU_SHARE (the EMA and the per-layer gate are skipped); the variable, when set,
still wins. Prefill::cpu_share_balancing() says whether it is still balancing; PrefillStats
gains the last balanced value and the number of readings.
- The table file gets an optional "share" line (0..1). With --draft-costs the engine stores the
balanced share, to a 0.05 step (0.5 when no short prompt measured it yet), when it writes the
table, and fixes it from the next request; a loaded file with a share fixes it from the start.
Same key, same ignore-and-relearn rule; without --draft-costs nothing changes.
- draft_policy_test: the share round trip and an out-of-range share refused. Settings register
regenerated (moved lines only).
With the DFlash2 drafter (Auto's on most cards) a run of 24 requests of 256 tokens has about 1,215
timed rounds (RTX PRO 5000, IQ3_S), so 1,500 would not finish within such a run; the trimmed-mean
tables of three such runs agreed within 0.3-0.6 % per window size.
With --draft-costs the serve loop looks for a table learned on this machine under the same key:
the engine version and backend, every visible card (name, compute capability, memory), the driver
and runtime versions, the adaptive tier's timing switches, the cost-aware window, and the engine's
own command line (a file argument by its name and size), plus --draft-costs-key from the server.
- Found: the window costs are fixed to it from the first request (DraftPolicy::set_fixed_costs per
context bucket); the same request then gives the same windows and tokens on every start.
- Missing, broken, cut short or learned under another key: the run uses today's adaptive policy
and learns (CostLearner). At a request's end, after 1,500 timed rounds, a stretch that does not
look disturbed is written (whole, temp file + rename) and fixed from the next request on; a
disturbed one is dropped and learned again. Never an error and never a refusal to start.
Without the flag nothing changes. One log line says which case applies.
serve STOP on a closed pipe, the launch worker after quit, the stall report
asks the prompt's GPU work, ISA-floor parity legs, the sleep stand-in, a
Windows child in the kill-on-close job before it runs, and the approved
wording of their lines.
Conflict: CMakeLists.txt, where f-gh1110 and this branch both add test
targets after batch_telemetry_test (conversation_heap_test and
stream_watch_test). Both blocks are kept.
The line for a free-memory query that failed (#5708) and the clamp line of
the automatic RAM copy now read as the owner approved them on 11-11; the
placeholder markers are gone. The four other messages that named
--resident-budget-gib on the automatic path name "the automatic RAM copy"
there; with the flag given they stay byte for byte. resident_ram_copy_test
checks the automatic clamp line in full.
The engine read STRATA_RESIDENT_PIN only while parsing --resident-experts
and --resident-budget-gib. When the expert arena does not fit and the
engine takes the RAM copy by itself, the fallback set the pin
unconditionally, so STRATA_RESIDENT_PIN=0 left that copy page-locked
(the #5718 cap test's arm Z: "page-locked and mapped" with the variable
set). On the same path the clamp line said "--resident-budget-gib 47.07
exceeds available RAM" although no such flag was given.
New header include/strata/core/resident_ram_copy.hpp:
resident_pin_from_env (one reading of the variable: "0" pageable, unset
or anything else page-locked, as the two string compares before),
auto_ram_copy_mode (the fallback's mode, now reading it) and
resident_clamp_line (the clamp line by where the budget came from).
generate.cpp's two flag branches and the fallback use them; generate
tells the file source the budget is the automatic one
(FileExpertSource::budget_is_automatic) before pin_cache_complement.
Unset variable: the same mode and the same bytes as before on every
path except the automatic copy's clamp line. That line now carries a
placeholder wording marked [DRAFT] (resident_ram_copy.hpp, the
Automatic case); the flag's line and the what-fits line are unchanged
byte for byte (checked by the test).
Test: tests/core/resident_ram_copy_test.cpp (cpu-check). On the old
behaviour (the fallback's pin always on, the flag's line for any
budget) it fails 5 checks; now it passes.
A prompt read waits in cudaStreamSynchronize on its compute stream
(prefill.cpp, "waiting for the GPU (attention, router)"). When that wait
never returned, the watchdog's stall report and the release after it asked
only the verify window's streams, so a GPU that never finished the work
could not be told from a host that was not woken after it had finished
(#5718 follow-up).
New include/strata/core/stream_watch.hpp: a small list of the streams a
host may be waiting on. Prefill::run_impl names its compute stream there
while it reads; stall_report (both passes, before the release) prints one
line per named stream from cudaStreamQuery: finished, still running, or the
query's error. Works through the HIP shim and metal_compat (cudaStreamQuery,
cudaErrorNotReady). The line's wording is a PLACEHOLDER marked [DRAFT],
pending review.
Test: tests/core/stream_watch_test.cpp (cpu-check; faked queries, no GPU).
Prefill::bytes_needed answers for the current device (prefill.cpp fused_ring
decides the fused layout per card), and part_slots / ring_room priced every
participant of a layer split with whatever device was current, CUDA0's. On an
RTX 5080 + RTX 4090 split the 4090's loan was 2882 MiB for buffers that take
3014 MiB there, and its prompt path stepped down to small chunks.
New helper split_ring.hpp split_part_figure(on_device, dev, fn) evaluates
fn() with the participant's device current (OnDevice, put back after);
generate.cpp part_slots and ring_room's bytes_needed_no_ring go through it.
CUDA0's own part (dev -1) is priced as before. On like cards every device
gives the same figure, so the numbers are unchanged.
Test: tests/program/split_part_price_test.cpp (cpu-check, faked devices).
With the old pricing: CUDA1 lent 2880 MiB for 3014 MiB of buffers, reads
6144-token chunks (fail); now lent 3016 MiB, reads 8192; 2 and 4 like cards
give identical slot counts over the 256..32768 chunk grid. No mixed-card
machine was available: no real mixed-card run backs this.