Commit Graph
874 Commits
Author SHA1 Message Date
Niko1221 7e9bf8c8f8 PLE: use the model file's hash constants again, and keep the row-range check
The engine reads the PLE hash constants out of the model file when it carries them (ple_consts_run), and refuses to start when a hash would reach past the PLE table's rows. A rebase of the trim change (PR 4522) lost both: the wiring step took the default constants (ple_artifact_consts) and the range check was gone. That change reaches a single card too, so a model whose file has its own constants would have been hashed with the wrong ones.
This puts back the two lines and the check as they were before the merge. No other change.
2026-11-12 22:29:34 +01:00
Niko1221 3f64aa6534 Merge PR 4549 (f9a09885c) into f-pr-split: a layer split keeps the draft head's room out of the last card's cache
One commit by cobra91 on dbb2d168c, merged as written: in the per-stage cache sizing the last stage subtracts the draft head and its logits (mtp.bind_bytes), as one GPU does (#199), so they no longer come out of that card's reserve.
1 file: src/program/generate.cpp, 7 lines added, 2 changed. Git merged it without a conflict.
2026-11-12 22:28:51 +01:00
Niko1221 d20c94caeb Merge PR 4534 (b1b8b8d3d) into f-pr-split: the split search prices a pipelined two-stage split by its slower stage
One commit by cobra91 on dbb2d168c, merged as written: with --pipeline-windows 2 and exactly two stages the search's predicted window time is the slower stage's (its layers, plus about 12 layer-times for the last stage's head and draft chain, plus that stage's misses on its own link) instead of the sum of the stages. Nothing changes without --pipeline-windows 2 (on CUDA it is not on by default).
1 file: src/program/generate.cpp, 16 lines added in the search's predict lambda. Git merged it without a conflict.
2026-11-12 22:28:51 +01:00
Niko1221 b4a0b5e227 Merge PR 4522 (935165402) into f-pr-split: every card trims its dense weights to its own layers on --layer-split auto too
Two commits by cobra91 on dbb2d168c, merged as written: per-card weight trimming on --layer-split auto (default on, --no-trim-stage-weights keeps the copies; the split search counts the freed VRAM towards each card's expert cache; CUDA0 reloads only its own layers' dense weights), and the reload resets the process-wide layer range before each stage.
3 files: include/strata/core/native_dense.hpp, src/core/native_dense.cpp, src/program/generate.cpp. Git merged generate.cpp without a conflict.
2026-11-12 22:28: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 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
cobra91 935165402c Trimmed reload: reset the process-wide layer range before each stage reloads
With an explicit --layer-split, main loads the later stages eagerly and each
set_layer_range(lb, le) call stays in effect process-wide; a trimmed reload of
CUDA0 with a different range then intersected with the stale one and found no
eligible matrices ('native dense: no supported GDN/QSA matrices'). Set the
range to the reloading stage's own before its load.
2026-11-11 07:46:31 +01:00
cobra91 7f57e4c24c Per-card weight trimming on --layer-split auto, from Hardin22's Strata-DualGPU (d9ff514), rebased onto main
Each card keeps only the dense weights of the layers it runs, and the VRAM
this frees goes to its expert cache. On top of main this needed:
- NativeDense::release()/bytes_in()/per-layer accounting alongside main's
  layer-range load and set_layer_range
- the fork's trim_frees() added to the split search's stage_left()
- CUDA0's trimmed reload + the PLE re-wiring (wire_ple) in main's flow;
  the later stages already trim via main's late_weights loop
- --trim/--no-trim-stage-weights flags, on by default as in the fork

Measured on RTX 5080 + RTX 4060 Ti / 32 GB, Swift 1.5 IQ2_XS, 64K, q4_0 KV:
expert cache 6812 -> 8021 slots on CUDA0 (+19%), decode 38.8 -> 52.0 tok/s
(cold) and 33.9 -> 52.0 (warm) vs main 0.1.53 with the same prompts.
2026-11-11 07:46:31 +01:00
cobra91 f9a09885c1 Layer split: keep the draft head's room out of the last card's cache (from Strata-DualGPU)
The drafter's draft head and its logits are allocated when it binds, after
the expert caches are sized. One GPU already keeps their room out of its
cache (#199); a split's last stage did not, so on a card without a display
they had to come out of a 300 MiB reserve - or not fit at all. The last
stage's cache now leaves room for them, as on one GPU.

Measured on RTX 5080 + RTX 4060 Ti / 32 GB, Swift 1.5 IQ2_XS, 64K, q4_0 KV,
--pipeline-windows 2, --layer-split auto, no --vram-reserve-later-mib: the
engine starts, runs and survives a full bench suite (three generations,
health 200) with the last card at 433 MiB free, decoding 76.9 tok/s on a
2.7K-token answer.
2026-11-11 07:43:49 +01:00
cobra91 b1b8b8d3d4 Split search: price a pipelined two-stage split by its slower stage (from Strata-DualGPU)
With --pipeline-windows 2 on two stages the stages overlap, so a window costs
about the slower stage, and a stage's CPU misses wait on that stage; the last
one also runs the head and the draft chain the next window waits for (~4 ms on
an RTX 5080, about 12 of its layers). The serial sum balances the two cards'
totals instead and starves the fast card's expert cache: on a 4060 Ti + 5080
pair it picks K=23 of 48 layers (33.4 ms predicted) where the pipelined price
picks K=18 (17.0 ms).

Adapted from Strata-DualGPU (Hardin22), keeping this tree's per-link miss
scaling (link_scale). Measured on RTX 5080 + RTX 4060 Ti / Ryzen 7 9800X3D /
32 GB, Swift 1.5 IQ2_XS, 64K, q4_0 KV, --pipeline-windows 2, --layer-split
auto: decode 48.1 tok/s sustained on a 1.9K-token answer (stock main prices
the same placement serially at 33.4 ms; with #4522's trim also applied the
pair reaches 66.5 tok/s).
2026-11-11 07:43:48 +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
Niko1221 c25a71c6c2 serve: a draft cost table is learned after 1,000 timed rounds, not 1,500
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.
2026-11-11 02:16:41 +01:00
Niko1221 4c999bcde8 serve: --draft-costs FILE learns this machine's draft cost table once and then fixes it (opt-in)
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.
2026-11-11 02:08:37 +01:00