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).
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.
The log line of the shared-memory page drop is plain words now and marked [DRAFT] until the owner words it
(par/OWNER-WORDING-1111.md, SPARK). The numbers (bytes given back, time, free memory before and after) print only with
STRATA_UMA_DROP_PAGES=2. The switch is in data/settings-register.json as a research setting (the A/B arm of the gate),
not documented for users.
On a GPU that shares the system RAM (cudaDevAttrIntegrated, the DGX Spark's GB10) CUDA counts only the RAM the kernel has
free: cudaMemGetInfo equals MemFree, not MemAvailable (measured: 62.59 GiB free = MemFree, MemAvailable 118.77 GiB). The
start reads every expert of the GGUF into the cache through the mapping, and those 47 GB of pages stay in the page cache
as a second copy of the cache's bytes. At READY the box had 1.3-1.6 GiB of MemFree, and the picture reader's own CUDA start
failed ("CUDA error: out of memory ... cudaSetDevice") in most starts, so a 2048x1536 picture took 91-105 s on the CPU
reader instead of about 3 s on the card.
When every expert is in the GPU cache on such a device (one GPU, the GGUF read in place), the engine now gives those
pages back after the prompt path is set up: madvise(MADV_DONTNEED) and posix_fadvise(DONTNEED) per expert blob, whole
pages inside the blob only. The experts of the slots the prompt path borrows keep their pages, because the refill after a
borrowed prompt reads them again. The cache holds the same bytes either way, so no output bit changes.
STRATA_UMA_DROP_PAGES=0 keeps the pages (for A/B runs).
Conflict: tools/test_setup_llama_archive.py, deleted on f-own-int (e43ff9885, no llama.cpp archive
download in the own stack) and changed on main (fd40eb0fd, its urlopen mock moved to netpolicy):
kept deleted.
The amdgpu driver suspends all GPU queues of a process while the kernel moves
or reclaims host pages the GPU maps, and counts the time per GPU in
/sys/class/kfd/kfd/proc/<pid>/stats_<gpu id>/evicted_ms. On p620 a slow
prompt read lost about exactly that time (RESULTS-GH-URGENT, option 1) and no
log showed it.
- include/strata/core/gpu_pause_time.hpp: header-only reader (sum over the
process's GPUs; a missing, unreadable or non-numeric counter = not
available, -1) and the two lines.
- generate.cpp: read once when a request begins and once at its end (a line
only when the request saw >= 100 ms), and in each pass of the stall report
beside the memory line (the change over the report's 2 s). HIP on Linux
only; every other build returns "not available" and prints nothing.
- tests/core/gpu_pause_time_test.cpp: fake KFD tree (present, several GPUs,
missing, unreadable, garbage) and the line formats.
Both lines are the owner-approved wording of 11-11. The test also reads a
missing KFD tree 10,000 times: not available, no line, mean cost printed.
The prompt-path line of the automatic RAM copy reads "A larger automatic
RAM copy (...)" (was "A larger the automatic RAM copy"), and the uncovered
lend-slots line asks to "Free more RAM for the automatic RAM copy (...)"
(was "Raise the automatic RAM copy"). With --resident-budget-gib given,
both lines stay byte for byte.
serve STOP on a closed pipe, the launch worker after quit, the stall report
asks the prompt's GPU work, ISA-floor parity legs, the sleep stand-in, a
Windows child in the kill-on-close job before it runs, and the approved
wording of their lines.
Conflict: CMakeLists.txt, where f-gh1110 and this branch both add test
targets after batch_telemetry_test (conversation_heap_test and
stream_watch_test). Both blocks are kept.
The line for a free-memory query that failed (#5708) and the clamp line of
the automatic RAM copy now read as the owner approved them on 11-11; the
placeholder markers are gone. The four other messages that named
--resident-budget-gib on the automatic path name "the automatic RAM copy"
there; with the flag given they stay byte for byte. resident_ram_copy_test
checks the automatic clamp line in full.
The engine read STRATA_RESIDENT_PIN only while parsing --resident-experts
and --resident-budget-gib. When the expert arena does not fit and the
engine takes the RAM copy by itself, the fallback set the pin
unconditionally, so STRATA_RESIDENT_PIN=0 left that copy page-locked
(the #5718 cap test's arm Z: "page-locked and mapped" with the variable
set). On the same path the clamp line said "--resident-budget-gib 47.07
exceeds available RAM" although no such flag was given.
New header include/strata/core/resident_ram_copy.hpp:
resident_pin_from_env (one reading of the variable: "0" pageable, unset
or anything else page-locked, as the two string compares before),
auto_ram_copy_mode (the fallback's mode, now reading it) and
resident_clamp_line (the clamp line by where the budget came from).
generate.cpp's two flag branches and the fallback use them; generate
tells the file source the budget is the automatic one
(FileExpertSource::budget_is_automatic) before pin_cache_complement.
Unset variable: the same mode and the same bytes as before on every
path except the automatic copy's clamp line. That line now carries a
placeholder wording marked [DRAFT] (resident_ram_copy.hpp, the
Automatic case); the flag's line and the what-fits line are unchanged
byte for byte (checked by the test).
Test: tests/core/resident_ram_copy_test.cpp (cpu-check). On the old
behaviour (the fallback's pin always on, the flag's line for any
budget) it fails 5 checks; now it passes.
A prompt read waits in cudaStreamSynchronize on its compute stream
(prefill.cpp, "waiting for the GPU (attention, router)"). When that wait
never returned, the watchdog's stall report and the release after it asked
only the verify window's streams, so a GPU that never finished the work
could not be told from a host that was not woken after it had finished
(#5718 follow-up).
New include/strata/core/stream_watch.hpp: a small list of the streams a
host may be waiting on. Prefill::run_impl names its compute stream there
while it reads; stall_report (both passes, before the release) prints one
line per named stream from cudaStreamQuery: finished, still running, or the
query's error. Works through the HIP shim and metal_compat (cudaStreamQuery,
cudaErrorNotReady). The line's wording is a PLACEHOLDER marked [DRAFT],
pending review.
Test: tests/core/stream_watch_test.cpp (cpu-check; faked queries, no GPU).
Prefill::bytes_needed answers for the current device (prefill.cpp fused_ring
decides the fused layout per card), and part_slots / ring_room priced every
participant of a layer split with whatever device was current, CUDA0's. On an
RTX 5080 + RTX 4090 split the 4090's loan was 2882 MiB for buffers that take
3014 MiB there, and its prompt path stepped down to small chunks.
New helper split_ring.hpp split_part_figure(on_device, dev, fn) evaluates
fn() with the participant's device current (OnDevice, put back after);
generate.cpp part_slots and ring_room's bytes_needed_no_ring go through it.
CUDA0's own part (dev -1) is priced as before. On like cards every device
gives the same figure, so the numbers are unchanged.
Test: tests/program/split_part_price_test.cpp (cpu-check, faked devices).
With the old pricing: CUDA1 lent 2880 MiB for 3014 MiB of buffers, reads
6144-token chunks (fail); now lent 3016 MiB, reads 8192; 2 and 4 like cards
give identical slot counts over the 256..32768 chunk grid. No mixed-card
machine was available: no real mixed-card run backs this.
A ConversationBuffer's segments are plain allocations of up to 16 MiB. Once
glibc's dynamic mmap threshold has risen (the first freed segment raises it)
they come from the heap, and free() returns only the heap's top: an entry
below a newer one stayed resident, so the physical-RAM gate evicted every
parked conversation and still refused ("evicted 2, 0 still parked"). Two
comments said the opposite.
evict_oldest() now calls release_free_heap() (glibc: malloc_trim(0); a no-op
elsewhere) after dropping the entry; make_room() keeps dropping entries without
it (drop_oldest), as the image allocated right after reuses that memory. The
admission gate in generate.cpp also hands freed memory back once before it
evicts anything, so memory freed by make_room or dropped checkpoints counts.
Nothing changes while the gate admits at the first check.
Test: src/core/conversation_heap_test.cpp (cpu-check). Boston, glibc 2.39,
3 x 512 MiB parked, evict the oldest: before 0 MiB returned (RSS 1539 ->
1539 MiB, 0.01 ms); after 511 MiB returned (1539 -> 1027 MiB, 8.8-9.3 ms).
The 8.0-and-up rule (nv_chunk.hpp) left Volta at 8192 as "not measured". Measured on one Tesla V100-SXM2 32 GB (gen3 x8 link, UD-Q4_K_XL,
33% of the experts in VRAM), 5 alternating pairs of 8192 against 32768: 4K +0.3%, 8K +0.2%, 20K +134.1%, 32K +111.2%; decode after the prompts unchanged;
first-token KL mean 3.7e-5 (20K) and 4.0e-4 (32K), top-1 13 of 13. Turing (7.5) and Pascal (6.x) keep 8192; a layer split keeps 8192 (four V100s read a
20K prompt 27-30% slower with larger chunks). nv_chunk_card_ok takes the lowest card's major and minor; the unit test pins 7.0 yes, 7.5 and 6.x no.
On Windows HIP, an auto expert cache with no --vram-reserve-mib kept a floor of 2560 MiB free on any card of 15 GiB or more (#1376, made for a 20 GB discrete
card that paged). On a Strix Halo that room is not free: the RAM budget's page-locked complement takes it straight back (cache + complement 71.72 GiB at 2560 and
71.73 GiB at 700 on UD-Q4_K_XL), so the prompt path's own buffers found 0 MiB and the engine stepped its chunk down 16384 ... 1024 for ever; strata launch of a
UD-Q4_K_XL config with no reserve (pictures off, or a model with no picture reader) never started.
The floor now goes through strata::core::wddm_auto_reserve_mib(integrated, total, current, floor): a discrete card of 15 GiB or more still gets 2560, an
integrated GPU (the device property the UMA sizing already reads) keeps the engine's default 700. Discrete cards, Linux and every config that passes
--vram-reserve-mib are unchanged (the block is under _WIN32 + STRATA_USE_HIP and behind !vram_reserve_given). Unit test in uma_cache_test.
CUDA sm_120 sm build (vendored ggml), base vs change from the same path: the binaries are bit-identical (sha256 2b603395...).
Strix (gfx1151, public-0.2.12-style config with no reserve) with the new engine: starts in 77 s and answers 3 chats; the old engine never started it.
Strix Halo (gfx1151): engine cap 5 -> 8 and the Terminal writes --spec 8; conf stays 0.35.
Measured (5 interleaved pairs, 5/5 faster): UD-Q4_K_XL +5.3%, UD-IQ4_XS-v31 +2.1%.
UD-Q4_K_XL greedy output differs from the old width's (deterministic run to run); v31 is identical.
Blackwell sm_120 (cc 12.0) with at least 48 GB: cap 6 -> 8, --draft-conf 0.55 (RTX PRO 5000 72 GB,
IQ3_S +2.4%, 5/5 pairs, output identical). The DGX Spark (cc 12.1) and consumer cards under 48 GB keep
conf 0.35 and cap 6. dflash2_auto_cap now takes the compute minor and the card's memory; drafting.py
writes --spec 8 only on these two classes (window_for), so no other card's effective window changes.
draft_cap_test, tests/terminal drafting tests (new test_drafting_card_window.py) and the snapshot
goldens (nv_resident and strix_halo_win only) are updated.
The warning now reads "the experts need X GiB of RAM and Y GiB is free, but free memory, file cache and reserved huge pages can hold
them, so they load anyway (same answers). STRATA_ARENA_FILE_CACHE=0 reads them from the file instead." It and the "not enough RAM for
the expert arena ... reads the experts from the file" notice go to stdout only with --serve (before READY, which the server ignores; a
service log has them). A plain generate run keeps its token stream clean: stderr only, as before the PR.
Removes AdaptiveGate, df2_gate_on() and df2_gate_row_ms() (window_rule.hpp), their three
sites in generate.cpp and their block in window_rule_test.cpp. The opt-in gate measured
2.7-4.9% slower; with it off (the default) the window rule is unchanged. The register
marks both retired in 0.2.13.
I/O path only: the same bytes are read, only HOW the experts outside the RAM copy are read (unbuffered or through the file cache) is chosen differently.
file_tier_unbuffered took its `avail` from cgroup_available_bytes, which credits the group's whole `file` counter as reclaimable. On a RAM-budget
config that credit includes pages the engine holds itself: P2003 (RTX 3060, 46 GB, 36 GiB group), UD-IQ4_XS-v31, 22 GiB RAM copy: the re-check read 18.7 GiB
available when the group had 11 GiB left (limit 36, current 24.8). With held = 0.52 >= 0.5 the timed drive probe was skipped and the file tier switched to the file
cache (direct reads 7.9 GB/s vs 2.5 GB/s cached): prompts 2.5-3x slower (pp2k 85 vs 273 tok/s, pp8k 195 vs 580), decode 10-14% slower. The one start that read
12.0 GiB kept the fast mode, which is why the first start of a session was sometimes fast.
Now the smaller of that figure and the conversation cache's sampler (only the clean inactive file cache is credited, the group's own limit, no operator
cap) decides. The --memory-limit-mib cap is not applied: it bounds the engine's own allocations, not the page cache (counting it sent IQ3_S unbuffered and cut its decode
2-3x). A flip now prints once: "strata: expert reads now go through the file cache (X GiB of RAM free for them, Y GiB limit)"; the technical line is behind STRATA_TRACE.
STRATA_UNBUFFERED_LOAD still forces either mode.
Measured on P2003 (build wip11, n >= 3 starts per arm, interleaved fresh engines, I/O-quiet before each start, memory watch on, floor 14336 MiB):
v31 unforced: main flipped in 5 of 6 starts, this change 0 of 9 (6 + 3): pp2k 85-94 -> 263-273 tok/s, pp8k 187-198 -> 580-590, code_py decode +14 to +20%;
v31 DFlash2 vs MTP in the kept state (3 rounds): DFlash2 +2 to +14% per kind (json_extract -3.5%);
IQ3_S: the file cache stays (9 of 9 starts), decode level with main (code_py 17.0 vs 15.6 tok/s, json_extract 14.2 vs 13.4, page cache evicted before every start);
low RAM (6-7 GiB ballast, budget 16 GiB): no regression, MemAvailable minimum 14911 MiB;
memory minimum with the unbuffered state 15.6-15.8 GB (floor 14.3 GB), no arm stopped.
Not P1.8: main and the P1.8 build flip alike.
(cherry picked from commit be3831e9d944fb44ac36d176f4764e30df0f9f6b)
In peer mode the adaptive overlap was refused, so every decode window first waited for the previous round's copies. With the overlap the peer
tier issues its copies in layer order, signals each layer's landing the way the primary does (a stream-ordered D2H copy of the layer number into
a pinned int, or host functions), its residency table takes the swaps at the window's start (flip_pending), and a layer waits for a tier's copies
only when that tier swapped in it (AdaptGate: peer_landed, peer_has, per-tier last). The wait before a window clears the peer's marks with the
primary's. Without the variable nothing changes.
Ported from #2720 (bulhenvaster), rebased by hand onto the current gate (the watchdog label stays). Not ported: STRATA_PEER_LAUNCH_IN_POOL
(the author measured no gain on his build), the new decode timing line and the documentation paragraph.
(cherry picked from commit e78b64a7348d685dfd11799fdb395661f2120436)
Decode reads missed expert blobs from host RAM three ways; the PCIe share's
blobs cross into VRAM anyway and were dropped after the window. With the
switch set, the share takes each layer's most-routed misses and a fetched
expert routed enough more than the layer's least-routed resident expert that
the window does not route is copied straight into that expert's slot
(fetch_blobs gets an optional dst2 target per blob). =2 leaves the tier's own
swaps out of a layer where an admission ran. STRATA_ADAPT_FETCH_VERIFY=1 reads
every admitted slot back. Off, with a log line saying why, where it cannot run.
Unset changes nothing.
Ported from PR 2964 (sergqwer) onto f-0216-core; the strata generate verify
loop was merged by hand (main's speculative-q lines kept) and the DETAILS.md
note became a row of the opt-in switch table.
l620 (RTX PRO 5000, IQ3_S, 3,896-slot cache, --pcie-frac 0.25): decode =2 +10.2%,
=1 +5.0% (4 rounds); token forcing over 14,167 tokens: mismatch 2.73% vs 2.53% /
2.53% for two unset arms (+0.19 pt, 90% CI -0.02..+0.42), PASS.
(cherry picked from commit b2bfaef906acee4f86bdf9f052aee6a4d295fb4e)