Commit Graph
950 Commits
Author SHA1 Message Date
Zac Chen 9da37ce3e4 mtp: --mtp-q4 head/all fails at bind when no draft head subset is installed
make_q4_head() was only reachable inside the draft_vocab.bin branch, so the
flag silently drafted over the full head (and the 10-27 mtpq4 head-arm A/B
measured nothing). bind() now errors with the fix instead. Still open in
upstream v0.2.7 (same call shape at mtp.cpp:777).
2026-11-17 08:45:34 +08:00
Niko1221 5450e4344d Integrated gfx11 under Linux: the unregistered expert arena only on the Radeon 780M class
The owner decided (by 11:05 on 11-15) that the default "arena not registered with the GPU driver" (NOREG, 8d1fadf92 and the
pinned.cu guard 05718a08f) applies to the Radeon 780M class only: gfx1103, which includes the 760M / 740M of the same chip
family. Strix Halo (gfx1151) keeps its registered arena. Strix Point (gfx1150, an experimental opt-in like gfx1103) also
keeps registration, as before NOREG.

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

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

Test: tests/core/kfd_quiet_test.cpp checks 110003 (unregistered), 110500 and 110501 (registered), discrete cards and
mixed machines (registered), the switches and STRATA_ARENA_PIN_GIB on top of the new rule, and that LOAD / EXIT / XFER keep
the whole class. g++ -std=c++20 -O1 -Wall -Wextra -Werror on p1004: ok.
2026-11-15 11:09:51 +01:00
Niko1221 6069c9d0c4 Integrated gfx11 under Linux: two more first-request allocations made during the load
What the box showed (p2006, Radeon 780M gfx1103, 11-15): in every mode, registered or not, the first request still grew the GPU's
GTT by 10-15 MiB in 3-5 steps (for example +3 MiB at 87 ms and +10 MiB at 487 ms into the first 512-token request), while its
kernels ran.

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

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

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

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

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

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

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

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

A value the user set for STRATA_ARENA_PIN_GIB wins (none / 0 / N / auto), STRATA_UMA_REGISTER=1 still registers, a
STRATA_ARENA_LOCK the user set still decides the lock. Switch: STRATA_KFD_QUIET_NOREG=0 (or STRATA_KFD_QUIET=0) registers the arena
as before. No new user setting; STRATA_TRACE prints one trace line.
2026-11-15 03:11:03 +01:00
Niko1221 f73fa74107 Integrated gfx11 under Linux: pageable copies staged by the HIP runtime
The HIP runtime copies a pageable source of 1 MiB or more by pinning its pages in place
(a GPU userptr) and keeps them (generate.cpp, the STRATA_ARENA_MMAP note). On a Radeon
780M such a userptr is memory the kernel can move under a running dispatch: the hc
check's two 6.5 MB vectors at load, and without a registered arena the lent refill's
1.3 MiB blobs (expert_cache.cpp fill_slot_queued); uma-r13 reset in the load with a
"Failed to quiesce KFD" line although nothing of ours was registered.

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

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

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

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

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

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

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

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

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

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

Scope: compiled only with STRATA_USE_HIP on __linux__ (CUDA, Metal, SYCL and Windows HIP
builds have no new code), and at run time only when kfd_quiet::class_flag() is set, from
the same rule as the existing settle (igpu_kfd_settle_default: every visible card an
integrated gfx1103 / gfx1150 / gfx1151). Every other card runs the old order.
STRATA_KFD_QUIET=0 or STRATA_KFD_QUIET_LOAD=0 is the old order on the same binary;
STRATA_TRACE prints one line when it is active. Test: tests/core/kfd_quiet_test.cpp.
2026-11-15 01:53:45 +01:00
Niko1221 3e401e97f6 serve: two more log lines lose their draft tag
"strata serve: this GPU shares the system memory and holds every expert, so the model file's cached copy of them is
given back." and "strata serve: conversation cache: the reply this request replaces is not parked (N tokens past the turn
checkpoint at M)" keep their wording; the comment that called the first one a draft is trimmed.
2026-11-14 23:58:33 +01:00
Niko1221 2514e0d168 generate: the arm64 CPU expert kernels line loses its draft tag
The line now reads "strata generate: CPU expert kernels: ggml-cpu (NEON)", or "the Strata quant
layer (NEON)" in a build with STRATA_OWN_CPU_QUANT. Both come from the same format string.
2026-11-14 23:37:22 +01:00
Niko1221 74e0ad55ba prefill: keep today's cut when the equal chunk would be short (under 6,144 tokens at a chunk of 8,192 or more)
In a build without MMQ on one GPU, a segment longer than its chunk is read in
equal chunks. On an RTX 4090 24 GB with IQ3_S at a chunk of 8,192, equal
chunks of 4,140 to 5,628 tokens made a prompt just above one chunk slower:
8,279 tokens as 2 x 4,140 took 3,517 ms against 2,579-2,686 ms for
8,192 + 87 (wait copy 1,178 against 470-480 ms, K/V stage 450 against 4 ms,
34,852 experts streamed against 20,963). Against today's cut the equal cut
measured 1.34 / 1.25 / 1.14 at 8,279 / 8,448 / 9,192 tokens, 1.01-1.03 at
11,192, 1.13 at 16,884, 0.98 at 20,000 and 0.99 at 32,000. Every gain
measured on the RTX 5070 12 GB has equal chunks of 6,978 tokens or more.

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

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

Tests: equal_cut_rule_test (two cases at a 10,240 chunk flip, new cases at
8,192 and 4,096 and for keep_equal), fit_out_rule_test unchanged.
2026-11-14 19:31:02 +01:00
Niko1221 a6859aa7db Merge f-texts-b20: start-up lines of a build without MMQ no longer name MMQ kernels
A build without llama.cpp's MMQ kernels said at start that a model with
K-quant experts reads its prompt "on llama.cpp's MMQ kernels". It now says it
reads it on Strata's own kernels, on NVIDIA cards and on gfx12 (RDNA4) cards.
The "prompt pieces" line of such a build named STRATA_PREFILL_STREAM_MIN=1024
as the way back to the old rule, which was not true; it now names
STRATA_PF_PLAIN_FLOOR=0 for the plain pack, the only pack that switch changes,
and says that STRATA_PREFILL_STREAM_MIN=N sets the number by hand.

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

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

A build with MMQ is unchanged.

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

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

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

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

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

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

The "prompt pieces" line of a build without MMQ said that
STRATA_PREFILL_STREAM_MIN=1024 keeps the old rule, which is not true. It now
names STRATA_PF_PLAIN_FLOOR=0 for the plain pack, the only pack that switch
changes, and for every pack says that STRATA_PREFILL_STREAM_MIN=N sets the
number by hand.
2026-11-14 10:18:54 +01:00
Niko1221 28e8d0e05c Merge the expert cache fix for a part-way shrink: with --vram-elastic, a refused shrink no longer leaves experts listed in unmapped slots
When the driver refused a segment part way through a VRAM shrink, the segments
given back before the refusal were gone but the residency table still listed
experts in them. After every shrink, refused or not, the entries past what
stays mapped are now evicted, the table is uploaded again and the prompt
path's loan moves down to the end of the live slots; then the error goes out
as before. A segment whose unmap succeeded but whose handle release failed now
counts as unmapped at once.

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

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

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

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

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

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

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

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

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

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

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

The settings register was merged by hand (the new switch added, every other
entry as on this branch) and is regenerated in the next commit.
2026-11-14 06:50:29 +01:00
Niko1221 29147556b9 engine: background copies honour the process's CPU set
The background copy threads (checkpoints and parking) and the checkpoint
helpers start on the host's one CPU and widen their CPU mask before they
work. They widened to every CPU number, so the kernel gave them every
CPU of the cgroup: they left a CPU set the process was started with
(taskset, numactl) and the card's NUMA node the engine now places itself
on. They now widen to the process's CPU set as it is at start-up, after
the card-node placement. With STRATA_NUMA_CARD=0 they widen to every CPU
as before. These threads exist only with the conversation cache or
STRATA_CKPT_THREADS=1. Output does not depend on where they run;
home_cpus_test checks the widening.
2026-11-14 05:51:17 +01:00
Niko1221 716ebae14e engine: run on the graphics card's NUMA node on two-node machines
On a machine with two or more memory nodes the engine now restricts
itself, at start-up and before the CPU pool, the host thread and the
helper threads exist, to the CPUs of the node the graphics card is
attached to. A start with nothing pinned then ends with the same thread
masks, pool start-up line and worker count as the same engine started
under taskset on that node (checked on a rented two-socket host with an
RTX 4090; card_node_test checks the decision on made-up machines and the
restriction of a live process).

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

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

STRATA_NUMA_CARD=0 turns it off. One-node machines read the sysfs node
folder and nothing else; there the output is identical to
STRATA_NUMA_CARD=0 (first-token logits, expert-stream counts and
tokens). With STRATA_TRACE set the engine prints one line,
"strata trace: card node: ...", with the inputs and the decision. The
expert arena itself is not placed by this change.
2026-11-14 05:51:17 +01:00
Niko1221 51e5e7adcc prefill: read long prompts in equal chunks on one GPU in a build without MMQ
In a build without MMQ, a prompt segment longer than its chunk is now
read in ceil(tokens / chunk) chunks of equal size when one GPU reads it:
20,932 tokens at a 10,240-token chunk become 3 x 6,978 instead of
10,240 + 10,240 + 452, and 32,000 tokens become 4 x 8,000 instead of
3 x 10,240 + 1,280. The number of chunks stays the same and the short
last chunk under the stream floor goes away. Measured on an RTX 5070
12 GB with the Q2_0 plain pack, 14,000 to 32,000 tokens: 0.923 to 1.001
of the time of today's cut; first-token KL at 10,500 tokens no worse.

What STRATA_PREFILL_EQUAL does now in a build without MMQ:
- not set, one GPU: the equal cut
- not set, a layer split, a peer card, more than one slot or a head
  alias: today's cut, unchanged
- 0: today's cut everywhere
- 1, one GPU: the equal cut
- 1, a layer split: the existing opt-in rule, unchanged (equal chunks on
  the 256 grid, a short last chunk kept)

Today's cut is also kept when the equal chunk itself would fall under the
stream floor (a small chunk: two chunks under the floor instead of one
above it), and when the equal chunk would lend more cache slots than
today's chunk. The layer split's own chunk rule (--prefill-pipe) is not
touched.

A build with MMQ compiles the previous code unchanged.
2026-11-14 05:21:09 +01:00
Niko1221 388a1554f0 expert cache: evict the slots a part-way shrink lost
With --vram-elastic, a VRAM command shrinks the expert cache by giving its
last segments back to the driver. When the driver refused a segment part way,
the segments released before the refusal were already gone, but the command
returned its error before the residency table was updated. The engine kept
serving with experts still listed in slots that were no longer mapped, and the
prompt path's loan could still sit past the end of the live slots.

Now the residency entries past what stays mapped are evicted after every
shrink, refused or not, the table is uploaded again and the loan moves down
to the end of the slots left; then the error goes out as before.

Also: when the unmap of a segment succeeded and only the release of its
handle failed, the segment was still counted as mapped. It now counts as
unmapped at once; the handle stays and is released again by the next grow
or at close.

The eviction is a pure function (strata/core/residency_trim.hpp) with its own
CPU test. expert_cache_segmented_test refuses an unmap and a release part way
through a shrink, through a test-only hook that the engine never sets
(strata/core/expert_cache_refuse.hpp), and checks the slots kept, the entries
evicted and a full grow afterwards. A shrink the driver accepts behaves as
before.
2026-11-14 04:49:38 +01:00
Niko1221 652f5fbd35 generate: the elastic K/V grows from new VRAM when the expert cache cannot give it slots
With --kv-grow accepted at session init, the K/V pools hold physical memory only
for their first 16,384 cells. The start of the elastic K/V then switched growth
off completely when the expert cache could not give slots (no VMM range, no
residency table or expert source, or a cache top at or under its floor of 128
slots, as with --expert-cache 100). The pools stayed at their first cells, and a
longer prompt wrote past them: an illegal memory access.

Now the K/V grows whenever its pools are elastic. The cache gives it slots only
when it can; otherwise every grow takes new VRAM, as it already does when the
cache is at its floor, and the K/V is not trimmed back (there is no cache slot
to return). Nothing changes when the cache can give slots.

kv_grow_rules.hpp holds the decision and the grow target. Tests:
kv_grow_rules_test (CPU) and kv_grow_refused_test (GPU: elastic pools grown from
new VRAM to a 20,000-token prompt's cells and to the whole context, every mapped
cell writable).
2026-11-14 03:38:17 +01:00
Niko1221 f36f8168f9 memory guard: do not credit the engine's own mapped file pages
Under a container's limit the guard now credits every clean page on the
file lists, which includes the pages the engine itself maps and reads:
the PLE table in ram or mmap mode (when the lock is refused, as in most
containers), mapped model files and the libraries. Planning that RAM for
something else pushes those pages out: in a 24 GiB scope an allocation up
to the lists figure left 22% of a mapped 11 GiB table resident; up to the
figure without the process's own mappings it stayed fully resident.

The credit under a container's limit is now the file lists less this
process's RssFile (/proc/self/status), with the file bytes the engine has
locked added back (a locked PLE table is in RssFile but on the
unevictable list, not on the file lists; generate registers it after the
table is opened and clears it when the lock is given back). When RssFile
cannot be read the inactive-only credit is used. Cold and warm starts of
the same configuration get the same figure: before the table is mapped
its cached pages are credited, after it is mapped its resident pages are
left out in both.

Limit: the Intel engine's generate does not register a locked table, so
there a container with a locked table gets a lower figure than the true
one (on the safe side). Outside a container nothing changes.
2026-11-14 02:14:47 +01:00
Niko1221 4e4888ddc2 Small-card rule: tell a build without MMQ by a flag its start-up initialiser sets
The previous change asked mmq::built() in generate.cpp, whose header is only included in builds that define STRATA_PREFILL_MMQ, so a build without MMQ did not compile. The initialiser in prefill.cpp now sets a process-wide flag (own_only_switches.hpp, inline, no link dependency) and the rule reads that. Other builds keep the flag false and behave as before.
2026-11-13 23:00:57 +01:00
Niko1221 e95ba413c1 The small-card prompt rule ignores a STRATA_PF_FUSED that a build without MMQ set itself
A build without MMQ puts STRATA_PF_FUSED=1 into the environment before main, and the small-card rule read that as a value the user had chosen and stood aside. On an 8 GB card that build then read long prompts chunk by chunk (1.5 to 1.7 times slower than the build with MMQ at 8,192 to 32,000 tokens) instead of with the layer-major walk.

The build now records which switches it set (a name that was already in the environment is not recorded and stays the user's), and the rule asks "named by the user" instead of "not empty". STRATA_PF_FUSED set by hand still makes the rule stand aside. STRATA_PF_SMALL=0 is still the way back. In a build without MMQ STRATA_PF_SMALL_FUSED=0 has nothing to go back to, so the fused kernels stay on there.

Unit tests: the recorder with a fake environment (own_only_switches_test) and the rule rows for a build-set value, a user value, cards whose default chunk is 8,192 or more, HIP and STRATA_DEFAULTS=026 (arch_defaults_test).
2026-11-13 22:48:02 +01:00
Niko1221 0cb1550665 tests: cover the Q8_0 hyper-connection default and the file check behind it
The rule that reads a UD file's own Q8_0 hyper-connection rows by default on CUDA lived inline in generate.cpp and had no test.
It moves into NativeDense::apply_hc_q8_default (same condition, same environment write) and generate.cpp calls it.

native_dense_hc_default_test builds synthetic GGUFs and checks gguf_carries_q8_hc (Q8_0 rows true, BF16 rows false, inject rows,
one-dimensional tensors, several shards, a missing file) and the rule: unset plus Q8_0 rows sets 1, a value the user set (0 or 1)
is kept, BF16 rows leave it unset.
2026-11-13 16:49:51 +01:00
Niko1221 aad676f43f Merge f-dc-learn-fix fc66df986 into the batch 16 candidate (draft-cost table learning fix) 2026-11-13 16:33:04 +01:00
Niko1221 d3206b1450 Merge f-gyro-floor 2c388837f into the batch 16 candidate (Gyro floor; contains f-i8-gfx11) 2026-11-13 16:33:01 +01:00
Niko1221 2c388837f0 generate: no Hadamard-fold warning on gfx1201
The start-up warning "Hadamard-folded experts are validated end to end on gfx1151 among AMD GPUs, not yet on <arch>" no longer prints on a gfx1201 card (R9700): a Gyro-S run there passed the speed gate and the forced-token KL against the FP16 path. Other AMD cards keep the sentence, which now names both validated architectures. The comment above it names gfx1201.
2026-11-13 16:16:37 +01:00
Niko1221 fc66df9866 spec: the table the learning stretch writes is used by the next start at once
A table made by the one-start stretch (STRATA_DRAFT_COSTS_LEARN=1) had no real-size marks, so the next start held it back for 100 requests (live costs decided meanwhile) and rewrote the file at every request, which also drops a read-only mode. The stretch measured every size of its table, so mark_learned_real() marks all of them real (cost rounded to the 3 decimals the file keeps, so the learning start and the next start run the same numbers) before the file is written. The next start then logs "this machine's table is used", applies the stored CPU prompt share and PCIe share at once, and never rewrites the file. The call sits inside the learning stretch's "ready" block only; the passive path (no STRATA_DRAFT_COSTS_LEARN) does not reach it.

Unit tests: the marks and costs survive the file, a marked table is neither held nor calibrated and asks for no rewrite, an unmarked table is still held.
2026-11-13 15:16:13 +01:00
Niko1221 23c02a7f71 spec: the learning stretch of STRATA_DRAFT_COSTS_LEARN=1 starts a new busy run at every request
A harness that sends its requests back to back is one busy run for the learner, so only the first 6 seconds of the whole run count as fresh rounds. With a load-time effect in the data the stretch then needs 200 fresh rounds, which a burst on a slower card never collects (batch 15: no table after 20, 48 and 144 requests on Boston and z440). While the learning stretch runs, every request now begins a new busy run (CostLearner::starts_busy_run, used where the request's arrival is read). Outside the stretch the rule is the same 0.5 s pause as before, so the passive path (no STRATA_DRAFT_COSTS_LEARN, what a Mac user gets) is unchanged.

Unit test: 40 requests back to back finish the stretch with a busy run per request and never finish it with one long run.
2026-11-13 15:16:02 +01:00
Niko1221 f9bc2d239f Merge f-draft-costs 1b11a76e8 into f-p4-int (the draft-cost table is on by default on Metal only)
CUDA and HIP keep live costs, so a start with no table runs as before; "draft_costs": true in a config turns the table on anywhere. The branch also brings the passive learner of the table and the lookup-window statistic. The only conflict is data/settings-register.json (both sides add entries); both are kept and docs/SETTINGS.md is regenerated from the register.
2026-11-13 12:36:13 +01:00
Niko1221 30c2b84f27 Merge f-switch-point3 216af487d into f-p4-int (the per-card prompt switch rule is on by default for NVIDIA sm_86 cards)
The branch contains f-tail-loan (dd404b382, the prompt loan sized for the tail) and f-switch-point2; the default itself is one commit. The conflicts are mechanical: a test block in CMakeLists.txt (both sides keep their tests) and the generated docs/SETTINGS.md, regenerated from data/settings-register.json.
2026-11-13 12:35:52 +01:00
Niko1221 216af487d7 Turn the per-card prompt switch rule on by default for NVIDIA sm_86 cards
The prompt path now picks, per card, the chunk size from which every expert
the card does not hold is streamed (the floor), and sets the CPU share's
limit to 1.6 times it. It is on with nothing set for one class of card: CUDA,
NVIDIA discrete on PCIe, a single GPU, the start-up link probe ran, compute
capability 8.6. Every other card keeps the fixed 1,024 floor and the fixed
share limit.

STRATA_SWITCH_POINT=0 turns it off; STRATA_SWITCH_POINT=1 asks for it on any
other CUDA card. An explicit STRATA_PREFILL_STREAM_MIN or
STRATA_PREFILL_CPU_SHARE_MAX still wins over the rule.

On an RTX A6000 (UD-Q4_K_XL) the floor is 3,584 and the limit 5,632 against
1,024 and 3,072. With the tail-sized loan in the same build the rule equals
the old default above its limit.

The start-up line no longer calls the rule an opt-in and is printed only when
the floor moved. The rule's unit test covers the class (and every compute
capability, multi-GPU, no probe, integrated and HIP outside it) and the
variable. The settings register entry becomes a rollback switch.
2026-11-13 10:35:14 +01:00
Niko1221 dbe76e32de Merge the per-card prompt switch rule into the tail-sized loan branch
The settings register is regenerated with settings_register.py so that the
entries of both branches are in it.
2026-11-13 10:30:44 +01:00
Niko1221 271eb25a61 Merge f-pool-idle 379e966a5 into f-p4-int (the park pools are refilled only while the engine is idle)
Two commits. The pools that make a conversation park cheap (the checkpoint pool and the segment pool) were topped up while a request was running. Now a permit rule (park_pool_permit) lets them fill only while nothing is in flight; the serve loop kicks the refill at the top, between requests; a park or a periodic checkpoint that finds a pool short takes fresh memory and never waits; the park synchronises the device before it gives pool memory back; one log line per request says how many checkpoints came ready from the pool and how many were allocated fresh. Switches and pool sizes are unchanged. Way back: STRATA_CKPT_POOL=0 (no refill thread) or STRATA_PARK_SEGPOOL_MIB=0.

On a Radeon 780M the engine hung in 6 of 16 starts of a conversation plan with evictions (the GPU stopped answering and the driver reset it); with this change 8 of 8 starts of the same plan are clean. A park costs about 50 ms in a back-to-back test, against 13 to 17 ms before and 92 to 95 ms with the pools off.
2026-11-13 09:37:50 +01:00
Niko1221 9448501635 spec: a real draft-cost price is the median of its 16 rounds, the monotone guard lowers an outlier; the window warm-up runs before READY
srv118 JSON lost 2.4 % (10 of 12 pairs) with the passive table. A/B with hand-edited copies of the table as taken over (par/dc/w5c): the cause was the real price of 2 rows, 20.08 ms instead of about 8.3. The old "more rows never cost less" pass only raised: that one price became the price of every size from 2 to 7 rows and the policy took 12-row windows. Setting 2 rows to 8.5 ms brought the window counts and the speed back (JSON +2.4 % against off), setting sizes 7-12 to the earlier values did not.

- A size's real price is now the median of its 16 collected rounds (CalAcc keeps the rounds, "cal b t n sum v1..vn" in the file; a line without them keeps the mean). A cold first-use round, a stall or another process no longer moves it.
- The guard in apply_table lowers from the trusted side: a guessed size, or a real size below another real size, is lowered to the price of the next larger size first; a real size above an unreached next size is kept and that guess is lifted to it. The Q2_0 4-row / 5-row and the IQ3_S 4-row / 5-row inversions of the taken-over files and the srv118 2-row outlier are fixtures of the unit test (179 of 179).
- The window warm-up (one dummy verify window per allowed width, then session_zero) now runs before the READY line, from the options (lookup_size_mask), single-stage serve without --batch.
2026-11-13 09:23:03 +01:00
Niko1221 84e11a7732 spec: warm every verify window width once before the first request; log text of a taken-over table
A window width builds its graph / pipeline on its first run. A width the policy first picks inside a long request paid that cost there: on the M5 Max with IQ3_S the first five-row lookup round cost 37 ms instead of 25 ms in 5 of 8 launches of the table arm, because the release and the live costs happen to run one five-row round in the first (untimed) request.

serve now runs one dummy window per allowed width 1..S before the first request is read, then session_zero() as a request that reuses nothing does; no checkpoint, conversation entry, RNG draw, policy sample or statistic is touched. Single-stage, non-batch, non-pipelined serve only. STRATA_WINDOW_WARM=0 turns it off (research switch, in the settings register). The engine prints the ms of every width and the total.

The load line of a table that is in use but still collects sizes no longer says "not used yet" (policy.table_held() picks the text).
2026-11-13 08:56:40 +01:00
Niko1221 dd404b382e Add a debug switch that reuses a lent loan by chunk alone
STRATA_DBG_TAIL_NOREUSE=1 turns off the tail half of the loan reuse test, so a
later short segment runs in a layout whose tail is too small. It exists to
show that the chunk check in the prompt path ends such a request with its
error rather than an overrun.
2026-11-13 07:14:03 +01:00
Niko1221 71f3c6db67 Size the lent prompt buffers' MMQ tail from the request's own last chunk
The loan of expert-cache slots laid out the fused MoE buffers for a tail of
stream floor - 1 tokens of MMQ rows, taken out of the expert cache, so every
chunk above the floor streamed more experts (+1.2 to +1.5% prompt time on an
RTX A6000 at a floor of 3,584; a smaller share under today's CPU-share
limit). The lend now sizes the tail from the segment: Prefill::relayout and
bytes_needed take a tail, the lend asks loan_rules for it (grow-only while the
layout's chunk stays), the reuse of a loan by a later segment also needs its
tail to fit, and a chunk below the floor that does not fit the tail ends with
a clear error instead of an overrun.

One GPU, no peer, no --batch above one slot, no head alias; a layer split
keeps the floor's tail. STRATA_PREFILL_TAIL_LOAN=0 restores today's sizing.
2026-11-13 07:07:03 +01:00
Niko1221 8b225dcb2e spec: a machine with no draft-cost table builds one from its normal requests, no learning stretch
A start with no table file (a new engine, driver, model or setting discards it) ran a learning
stretch: forced filler windows to time every window size, for about 1,000 rounds. On a short
JSON request that cost 43 % on an RTX PRO 6000 (chat 6 %), and it would hit every user after
every release. Now such a start is passive from the first request: live costs decide exactly
as without a table, nothing is forced, and the rounds the policy runs anyway are counted per
size (only the first seconds of a busy run, the rule the table was tuned on; no detection of a
load-time effect is needed). A size is real at 16 own rounds; the file keeps the sums across
restarts ("fresh" file, no table lines yet). When every size is real, or after 100 requests, the
table takes over: real costs, and for a size never reached the live cost at that moment (the
policy's own prior when none was measured); such a size keeps collecting. The CPU prompt share
is stored only when a short prompt has measured it.

The old one-start stretch stays behind STRATA_DRAFT_COSTS_LEARN=1 for test harnesses (register
entry: research, harness switch); the server and the launcher never set it.
2026-11-13 06:13:43 +01:00
Niko1221 638533e3fc Merge f-pr-split-n4534 cca88a011 into f-p4-int (each card keeps only its own layers' dense weights on a layer split; the last card's draft-head room)
#4522 (the trim of each card's dense weights to its own layers, now the default for explicit and auto layer splits) and #4549 (the last card's draft-head room), with fixes on top as separate commits: the PLE hash constants and their row-range check restored, STRATA_STAGE_TRIM=0 as the way back, the trim's freed bytes credited to the first card only, exact pricing of a later card's hyper-connection rows and PLE key, a quieter pricing check, one test-fixture fix. #4534 is not in.

One card: nothing changes (48 forced continuations byte-identical to the base). Two RTX A6000 that already hold every expert: decode 122.27 against 122.71 tok/s, prompts 5.6 to 10.0% faster at 2K, 8K and 20K tokens (the base streams experts for the prompt, this build none). Two cards held to 15.5 GB free each: decode 75.88 against 64.16 tok/s (+18.3%), 867 more expert slots on the first card. Way back: STRATA_STAGE_TRIM=0.
2026-11-13 05:26:46 +01:00
Niko1221 8c1fa57f6f Merge f-loan-walk 5bc07c47a into f-p4-int (the prompt loan is sized by the walk a piece takes)
Two commits on c5e4e5109. The prompt path borrows cache slots from the experts for its buffers; the size of that loan is now taken from the walk the piece really takes, not from the rounded chunk. Only a piece whose rounded chunk reaches the floor while its real size is under it changes; every prompt of 1,024 tokens or more with a first chunk at or above the floor is unchanged. Way back: STRATA_PREFILL_LOAN_WALK=0 (settings register entry and one generated row in docs/SETTINGS.md). The second commit is test-only.

Measured on an RTX A6000 (UD-Q4_K_XL, 13,580 of 24,576 slots resident, MTP, fixed draft-cost table): prompt time -14 to -15% at 770 to 1,024 tokens with the CPU share off, -10 to -12% at 2,818 to 3,072 tokens with it on; no change below or above those pieces. R9700: -2 to -4%. With the way-back switch the base numbers come back.
2026-11-13 05:26:29 +01:00
Niko1221 b325833309 serve: a held draft-cost table leaves the CPU prompt share and the PCIe share live too
A table that is held back (live costs decide) also stored a CPU prompt share and a PCIe share,
and the engine fixed both at load, so a first start after a fresh table still differed from a
start without a table. The stored shares are now fixed when the table takes over (the end of the
request in which the last size is calibrated, or the 100th held request), not before. A table
that is used at once (every size calibrated, or 100 requests run) fixes them at load as before.
The log line at take-over says which case it was.
2026-11-13 04:58:36 +01:00
Niko1221 379e966a59 Serve: refill the park pools between requests, not during one
The segment pool's filler and the checkpoint pool's refill (also kicked from
the periodic prompt checkpoints) no longer run while a request is in flight:
their page faults and madvise calls overlapped the prompt read that follows a
park. The serve loop tops both up at its top, when nothing is in flight; a
park or a checkpoint that finds a pool short takes fresh memory and never
waits. The park also synchronises the device before it gives pool memory back.
The request log gets one line with how many checkpoints came ready from the
pool and how many were allocated fresh.
2026-11-13 04:52:36 +01:00
Niko1221 669b34a324 spec: a held table is used after 100 requests even when a size is never reached
Holding the table back until every size is calibrated would hold it back for good on a machine
whose real requests never reach the long lookup sizes (the RTX PRO 6000 table has 12 sizes, the
rounds of the sizes 7 to 12 are rare). The number of requests that ran while the table was held
back is kept in the table file ("reqs"); after 100 of them the table is used, and a size that
real requests have not reached is priced at its learned cost times the mean ratio real / learned
of the real sizes of 2 or more rows (the step of the earlier calibration, restored for this
case only), a size of 1 row at its learned cost. Calibration of those sizes goes on in use.
A start from a file with 100 or more requests uses the table at once.
2026-11-13 04:48:58 +01:00