Commit Graph
876 Commits
Author SHA1 Message Date
Niko1221 5d26d6f4ba spec: a learning stretch can time a lookup-type window in a round that has no proposal
On the M5 Max the MTP window is at most 3 rows, so windows of 4 and 5 rows exist only as lookup windows, and a prose learning stretch has a
lookup proposal in about 2 % of its rounds: with forcing limited to the first 6 seconds of a busy run (the rounds that count), sizes 4 and 5 got
11 and 31 rounds in the burst (table 12.808, 14.397, 16.526, 18.810, 21.094).

- DraftPolicy::explore_lookup(cap): in a round with no lookup proposal, a learning stretch may run a lookup-type window of the smallest unmeasured
  size (2..cap rows); every row after the first is filler (the MTP's own first guess repeated, which the verifier rejects). Same limits as the other
  forced windows: from round 100, only while the rounds count, 40 per size, 300 per stretch, deterministic windows only, learning only.
- Unit test draft_policy_test: 117 of 117.
2026-11-13 02:41:31 +01:00
Niko1221 f3ebb13687 spec: restore the CLI loop's observe_probs line
The previous commit also changed the CLI loop's observe_probs condition, but that loop has no forced-window variable, so the Metal build
failed there. The line is back as it was; only the serve loop changes.
2026-11-13 02:34:44 +01:00
Niko1221 bcbaf72dd4 spec: a learning stretch times window sizes in the rounds where they count, on every round
On the M5 Max the learning burst is one busy run, so only its first 6 seconds (about 375 rounds) are fresh rounds, and the sizes the table is made
of must be measured there. The forced rounds of the previous commit started after 300 rounds (after the fresh seconds) and needed a lookup proposal:
sizes 4 and 5 reached 68 and 95 rounds in the whole burst but under 20 fresh ones, so the table still filled them (12.651, 14.315, 16.398, 18.481, 20.564).

- A round with no lookup and no chain may run its MTP / drafter window at another size (DraftPolicy::explore_window): the smallest size under 30
  usable samples, not the size the round already has, up to the widest window; rows past the real drafts are whatever the drafts array holds
  (valid ids, rejected by the verifier). Deterministic windows only (not a probabilistic MTP window, not a gated proposal), learning only.
- Forced rounds start after 100 rounds and happen only while they count: in the first 6 seconds of a busy run, or when the stretch has shown no
  state effect (size with 20 fresh and 20 late samples agreeing within 2 %); a stretch with only late rounds so far does not force.
- A forced round goes to the learner and the size's cost and to no MTP / lookup / probability statistic (observe_forced; observe_probs skipped).
- Usable samples = fresh ones with a state effect, fresh + late otherwise (CostLearner::usable, state_known).
- Budget 300 forced rounds per stretch, 40 per size.
- Unit test draft_policy_test: 116 of 116.
2026-11-13 02:33:20 +01:00
Niko1221 c43347d094 spec: a learning stretch times window sizes past its proposals with filler rows
Sizes 5 and 6 of the Radeon 780M and 4 and 5 of the M5 Max were never reached by a lookup proposal in a prose learning stretch, so their
table entries were filled in (780M: 174.9 and 206.1 ms against 160 and 178 measured by live costs; the lookup of 5 rows was then priced
out and the frozen table lost 1.9-2.5 % on code and JSON to live costs).

- choose() takes pad_cap: during learning, when the caller allows it (a deterministic proposal, never a probabilistic window), the window of the
  smallest size with under 30 samples is run even when the proposal is shorter; the rows past the proposal repeat its last token, which the
  verifier rejects. Pick::pad says how many rows are filler.
- A window run this way goes to the learner and to the cost of its size (observe_forced) and to no lookup or MTP statistic.
- The forced-round budget is 200 per stretch (40 per size).
- Unit test draft_policy_test: 108 of 108 (5 new: padded window, filler count, forced round feeds no statistic, pad_cap of one draft).
2026-11-13 02:25:47 +01:00
Niko1221 1e50a146ed spec: a learning stretch measures the window sizes it can pick
The draft-cost table was filled in for every size with fewer than 20 rounds. On the Radeon 780M two sizes had 2 and 6-12 rounds, the filled
values (134.6 / 129.7 ms against 143 measured for 4 rows) lay below the measured trend, and a frozen table of guessed sizes can lose to live costs.

- After 300 rounds of a learning stretch, a lookup proposal long enough for a size that has under 30 samples takes that size's window
  (smallest size first), at most 40 times per size and 150 times in a stretch. Nothing is forced when learning is off or the costs are fixed.
  A learning stretch was never repeatable: window sizes follow the live costs.
- A size with 5 to 19 rounds counts by its median when that median is not below the fill and at most 1.5 times it; a handful of stalled rounds does not.
- A size above the measured ones continues the steeper of the last segment's slope and the slope over all measured sizes, and the table is written up
  to the largest allowed window size (so no size is left to the prior shape).
- CostLearner::table gains an `upto` argument; DraftPolicy gains reset_learning(), top_size() and forced_rounds().
- Unit test draft_policy_test: 103 of 103 (15 new: table fill rules, forced-round budget, per-size cap, none when fixed or not learning,
  a size no proposal reaches).
2026-11-13 02:05:23 +01:00
Niko1221 15a4be9c7a spec: the draft-cost table learns from the first seconds of a busy run
The learned window costs came from one continuous learning stretch. On a GPU that
slows down under sustained load (measured on an M5 Max: 1 row 14 %, 3 rows 21 %,
5 rows 27 % slower after 75 s of continuous load) the stretch priced 5 rows at
1.38 times 3 rows against 1.30 for a request that arrives after a pause, so
the fixed table priced two profitable 5-row lookup windows per request out.

The learner now keeps each round with the busy age it ran at (seconds since the
last pause of 0.5 s or more between requests, measured at the request's arrival).
Rounds of the first 6 s are fresh, the rest late. The table uses the fresh rounds
when a size with 20 samples of both differs by more than 2 % between them, and
every round otherwise (the Radeon 780M shows no difference, so it keeps all its
rounds). A stretch that never pauses ends after three times the round quota when a
fifth of the quota is fresh. Sizes with fewer than 20 samples above the measured
ones continue the straight line through the two largest measured sizes; the table
never falls from one size to the next. The file header is version 2, so tables
already learned are learned again; a table is still written whole or not at all,
only when the stretch is ready, and is fixed from then on.
2026-11-13 01:17:13 +01:00
Niko1221 59211f98b1 Merge f-fused-staged e521524f3 into f-p4-int (Windows Strix Halo reads prompt pieces below 1,024 tokens on the fused kernels' staged group entry; --short-read defaults to 24 there)
Five commits on f33e9fa7b (the earlier short-piece rule). On Windows with one gfx1151 card and a layer set in which every layer has no MMQ tile and the fused kernels take it (UD-Q4_K_XL), a
prompt piece below 1,024 tokens (the batched ones, from 26 tokens) now takes the staged walk's fused group entry: only the routed experts stream and they run on the fused kernels, with FP32 down
rows, instead of a dequantize and two FP16 GEMMs per routed expert. The step-one floor of 64 applies only with the entry off. The serve loop's --short-read default is 24 instead of 64 on that
class (a --short-read on the command line wins). Pieces of 1,100 tokens and more, other cards, other systems and sets with an MMQ tile are unchanged. STRATA_PF_STAGED_FO=0 is the way back
(the earlier behaviour byte for byte); with STRATA_PREFILL_STREAM_MIN=1024 as well it is the old FP16 path; STRATA_PF_STAGED_FO=1 asks for the entry on any card (research).

Measured on a Strix Halo (UD-Q4_K_XL, three rounds, one start per arm): prompt ms with the old FP16 path / the earlier rule / this default 303 / 303 / 268 at 32 tokens, 595 / 595 / 317 at 64,
1,797 / 418 / 343 at 128, 2,305 / 514 / 449 at 256, 3,675 / 1,022 / 977 at 1,000; 1,100 and 2,048 tokens the same in every arm. Forced-token KL of the default against the long path with FP32 rows 0
at 256 and 768 tokens, the way back equals the earlier rule (KL 0, 36 of 36 request ids identical). Decode unchanged (65.8 ms a window).

The branch changes data/settings-register.json, docs/STRIX_HALO.md, prefill.cpp and generate.cpp; the register is regenerated by its tool on the merged tree with the branch's hand-kept entries
(the new STRATA_PF_STAGED_FO and the note of STRATA_PREFILL_STREAM_MIN).
2026-11-13 00:09:19 +01:00
Niko1221 116cdf2a35 serve: --short-read defaults to 24 where the staged fused entry reads short pieces
With the staged group entry on (Windows gfx1151, a layer set with no MMQ tile that the fused kernels take, STRATA_PF_STAGED_FO not 0) a batched read of a short
piece is cheaper than the verify windows from about 28 tokens. Strix Halo, UD-Q4_K_XL, prompt ms, median of 3 (windows / batched): 24 tokens 231 / 261,
32 tokens 303 / 265-270, 48 tokens 453 / 293-299, 64 tokens 598 / 314-316. The class default of --short-read is therefore 24 (the largest size measured
where the windows win; 64 stays everywhere else). A --short-read on the command line wins; the setting is not part of the draft-cost table key
unless it is given.
2026-11-12 22:40:12 +01:00
Niko1221 c54a0cf460 Merge f-kq-default d1ec6f039 into f-p4-int (Flash-Next's K-quant experts are read by Strata's fused prompt kernels by default on the NVIDIA cards the i-quant default takes, with the 128-row tile where it was measured)
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.
2026-11-12 22:18:38 +01:00
Niko1221 47d46ccce9 Merge f-strix-c4 00807c9b3 into f-p4-int (with two or more requests at once on Windows integrated AMD, the pinned RAM copy of experts is capped so every slot fits)
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.
2026-11-12 20:29:16 +01:00
Niko1221 00807c9b30 [Engine] Strix Halo: the RAM cap with several requests at once has a way back and speaks only when it cuts
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.
2026-11-12 20:00:01 +01:00
Niko1221 3a25581693 [Engine] Strix Halo: cap the pinned RAM copy of experts when --batch slots pin their K/V
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.
2026-11-12 19:41:47 +01:00
Niko1221 4d958fbdbf nv_defaults, docs: the start-up line about K-quant experts says what happens on the card; the QUANTS.md row names the fused kernels
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.
2026-11-12 19:09:03 +01:00
Niko1221 8ce488608d Small-card prompt path: keep the switch helper out of the CUDA kernel headers
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.
2026-11-12 17:29:24 +01:00
Niko1221 6d7a183f0c Small-card prompt path: the native fused expert kernels run by default (CUDA)
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.
2026-11-12 15:34:50 +01:00
Niko1221 466626cbb7 Merge f-int-tidy 4e9dde87e into f-p4-int (conversation tests in the CPU check preset, packer probe without bytecode, a per-architecture spill-guard baseline, a log line for a driver GPU pause between requests on AMD under Linux)
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.
2026-11-12 11:38:55 +01:00
Niko1221 0ee2639926 integrated gfx11 on Linux: the engine gives the model files' cached pages back while and after it reads the expert arena
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).
2026-11-12 11:13:18 +01:00
Niko1221 8f6393a373 integrated AMD GPU under Linux: wait until the kernel has stopped moving the registered arena before READY
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).
2026-11-12 11:13:17 +01:00
Niko1221 0a17fb99e2 integrated gfx11 on Linux: the registered expert arena asks for no transparent huge pages
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).
2026-11-12 11:12:08 +01:00
Niko1221 f55afa1521 serve: log a driver GPU pause that happens between requests (AMD on Linux)
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).
2026-11-12 10:44:10 +01:00
Niko1221 62b6a47ea4 [Engine] Tesla P100: the rule for the FP16 prompt path with few-row experts as the default (not switched on yet)
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.
2026-11-12 08:57:08 +01:00
Niko1221 07f611c755 Merge f-agent-cap 33648fef1 into f-p4-int (STRATA_SERVE_STOP_SKIP, default on: a decode window that finishes after the server's STOP is dropped whole)
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.
2026-11-12 08:33:02 +01:00
Niko1221 33648fef1e serve: a decode window that finishes after the server's STOP is dropped whole
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).
2026-11-12 05:52:51 +01:00
Niko1221 a46c667cc0 Merge f-park-pool ef371eba8 into f-p4-int 2026-11-12 02:36:27 +01:00
Niko1221 ef371eba84 park pools: the segment pool is min(2 GiB, a quarter of the cache) (measured: 55K-token park 283 ms with 1 GiB, 117 ms with 2 GiB)
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.
2026-11-12 00:57:11 +01:00
Niko1221 01e21ef20e engine: the park pools are on by default (a diagnostic switch turns each off), sized from the conversation cache
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.
2026-11-11 23:40:35 +01:00
Niko1221 291b91025e Merge f-agent-turn b92075d92 into f-p4-int 2026-11-11 21:55:57 +01:00
Niko1221 8f4a2e0af8 engine: STRATA_PARK_SEGPOOL_MIB, a research switch for the segment pool (off unless set)
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.
2026-11-11 21:55:53 +01:00
Niko1221 9b7a1d84ff Merge f-ok-reader 4c8faae99 into f-own-int
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.
2026-11-11 21:30:14 +01:00
Niko1221 436ff36438 Merge f-repeat-default 6e4afbbc9 into f-own-int
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).
2026-11-11 21:30:00 +01:00
Niko1221 01d0646fdb Merge f-agent-turn 77c344bdd into f-own-int 2026-11-11 21:28:51 +01:00
Niko1221 b92075d924 serve: the thinking budget's hold on --batch engines (BGEN slots)
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.
2026-11-11 21:22:34 +01:00
Niko1221 f7ea7005c1 Merge f-spark-s2 a5104df5b into f-own-int 2026-11-11 20:13:43 +01:00
Niko1221 4c8faae99d engine: keep the picture reader's room in the reserve in the resident RAM mode
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).
2026-11-11 17:04:23 +01:00
Niko1221 9a56a36250 generate: name the CPU expert pool on arm64 in the start log line
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).
2026-11-11 16:45:09 +01:00
Niko1221 fefaa985c1 Merge main c1ff07f1a into f-own-int 2026-11-11 16:44:44 +01:00
Niko1221 77c344bdd0 serve: the picture guard inside the replaced-reply rule; its log line marked [DRAFT]
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.
2026-11-11 16:27:28 +01:00
Niko1221 be101072ba serve: the thinking budget's hold (GEN hold=N:ID), so the wrap-up pass continues from the live session
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.
2026-11-11 16:18:59 +01:00
Niko1221 a5104df5bf engine: the shared-memory page drop only in a Linux CUDA build, its line only when pages were given back
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.
2026-11-11 15:45:26 +01:00
Niko1221 5e41f69844 serve: no park of the reply a request replaces
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.
2026-11-11 15:40:18 +01:00
Niko1221 7d4f78242c serve: the #4677 stop bound on every backend, not only HIP
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.
2026-11-11 15:35:46 +01:00
Niko1221 d3d4d16120 engine: the page-drop line is a [DRAFT] for the owner's wording; STRATA_UMA_DROP_PAGES in the settings register
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.
2026-11-11 13:11:41 +01:00
Niko1221 3220dbc0e0 engine: a shared-memory GPU with every expert resident gives the model file's cached expert pages back
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).
2026-11-11 12:22:53 +01:00
Niko1221 6e4afbbc9d serve: repeatable output also fixes the decode PCIe share: PcieAuto's settled value is stored with the draft cost table
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.
2026-11-11 12:07:28 +01:00
Niko1221 cd97450504 Merge main 6c642df75 into f-own-int (round 16: network waits, robustness, Windows kill-on-close job start, GitHub and transfer fixes)
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.
2026-11-11 10:21:31 +01:00
Niko1221 042bc2b5a4 Merge f-evict-report (AMD Linux: driver-pause time in the stall report and per request) into f-main-1111b 2026-11-11 10:20:16 +01:00
Niko1221 03e687ace4 AMD Linux: show how long the driver paused the GPU (stall report and request line)
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.
2026-11-11 07:50:00 +01:00
Niko1221 2f52b86360 Merge f-gh1110 (automatic RAM copy wording of 11-11 morning) into f-main-1111 2026-11-11 07:38:29 +01:00
Niko1221 c28474dc4f automatic RAM copy: two lines in the owner's wording of 11-11 morning
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.
2026-11-11 07:38:29 +01:00
Niko1221 6a56a44a29 prefill, serve: the CPU prompt share is learned once and kept in the draft cost table file (opt-in)
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).
2026-11-11 04:18:34 +01:00