Conflict in docs/DETAILS.md (the conversation-cache paragraph, same place as before): kept the new f-ink-025 text (a file only when the conversation leaves memory, the newest file per chat) and the sentence f-ink-025-term adds at its end (Strata starts the CUDA engine with it by default, conversation_cache_gb).
Design (3 lines): with a RAM park cache (--slot-cache-mib) a park writes no file; a conversation goes to a file when the RAM cache drops it, when it does not fit there, and when the engine stops
(the slots' conversations are parked, then everything in RAM is written, most recently used first, at most one cap's worth); with no RAM park cache it is still written when its slot is overwritten
(the only place it can go). ConvDisk::save removes the earlier turns of the same chat (tokens a strict prefix of the new file's, same pictures) right after the write, and covered() lets the serve loop skip a
conversation that a file (its own or a longer turn of the chat) already serves. Restore, identity checks, the cap and the near-cap handling are unchanged.
Why: REPROC's real app e2e (restart 25 s -> 3.8 s at 43K) found that every park also wrote about 770 MiB in 0.5 s per title or summary request (doubling its cost, many GB per hour of agent chat, SSD wear) and that one
chat left 3 files (2.3 GB). ink_serve.h: disk_write() (serialize + save + log) used by park_make_room (drop), park_current (does not fit; no RAM cache) and the stop pass; ink_conv_disk.h: covered(),
superseded(), the removal; docs/DETAILS.md.
Tests: unit (ink_conv_disk_test): a longer turn removes the shorter file at once and a restart sees one file per chat, covered() (own file, a prefix of a longer turn, not a longer turn, not with another picture);
mock (test_shared_prefix.py, real serve loop, 4 new): with a RAM cache a park writes no file and the stop writes the chat and the helper, a conversation dropped from the RAM cache is written and read back
(reuse 39 of 40), only the newest file of a chat stays (2 files, not 3, and the newest serves the next turn), another chat's file is kept. 4 host tests pass on p1006 (mock suite 51 tests). Not run: the app e2e (REPROC reruns e2e_chain3.sh).
Conflict in docs/DETAILS.md (the conversation-cache paragraph): kept the new f-ink-025 text (room made before a write, earlier turns first, shutdown writes at most one cap) and the sentence added by f-ink-025-term at its end (Strata starts the CUDA engine with it by default, conversation_cache_gb).
Design (3 lines): the planner (df2_total_mib) reserves the DFlash 2 context rings of the first 8 slots only; the rings of slots 8 and up are taken lazily and only while 1 GiB stays free, so on an
RTX 5090 at 64 slots (1,910 MiB free after start-up, 11-27 bench logs rel0223/bench71: "no GPU memory for slot 25's context ring") slots 25 to 31 of the drafter's 32 had no drafter. With
STRATA_INK_DF2_RING_PLAN=1 the planner counts the rings of every slot the drafter serves (32 on 24 GB and more, 16 below), so the K/V split leaves their room and the 1 GiB rule stays for the rest.
Default OFF: byte-identical reserve and the same refusals as before (up to 8 slots nothing changes either way); the switch flips on the 5090 C64 e2e A/B (1,193 / 1,576 tok/s reference).
ink_df2_budget.h (new, host-only): the ensure_slot room rule (df2_ring_room, now used by InkDFlash2::ensure_slot itself), the drafter's slot count, the planned ring count, a replay of the lazy sequence.
ink_dflash2_path.cuh: df2_total_mib(v, slots, ring_slots = -1) and df2_planned_rings_here; ink_runner.cuh: the two reserve sites pass it. Register entry (opt-in) + docs/SETTINGS.md.
Test ink_df2_budget_test: the rule's edges (slot 1: 170 MiB, slot 8: 1,066 MiB), the 5090 logs reproduced (1,910 MiB free, other lazy buffers 160 MiB: slots 8..24 fit, 25..31 do not; 80 MiB: 27 and up
do not), with the rings in the plan all 24 of slots 8..31 get one also with 800 MiB of other buffers, the ring counts, the switch. Not measured: speed (no 5090 yet); drafting is exact, the tokens do not depend on it.
Design (3 lines): ConvDisk::save made room AFTER writing the new file, so a folder at its cap held the old files and the new one at once, and the chat's own earlier turns stayed next to the
turn that extends them. Now room is made before the write: the file of the same key is replaced, then files this conversation supersedes (their tokens are a strict prefix of it, same pictures),
then the least recently used. The pass at engine stop writes at most one cap's worth (with many slots the later files would only evict the earlier ones).
Why now: Inkling's default context is moving to 128K and a 128K conversation file is about 2.4 GB against the 8 GB default cap (the owner made the cache default ON in the launcher).
ink_conv_disk.h: make_room(), written_bytes(); ink_serve.h: the shutdown loop stops after one cap; docs/DETAILS.md. Test (host-only, ink_conv_disk_test): two 60 KB files under a 100 KB cap leave
one file and never more than the cap on disk, a file replacing itself near the cap, a file larger than the cap refused with the stored one kept and no .tmp left, turn 1 (used last) goes before turn 2
when turn 3 needs room, a different chat is only evicted by use.
--slot-cache-mib was announced in INFO (and so in /metrics, where the host reads
it to decide whether to ask for a chat title) whatever the load. A layer split
over two cards, and every backend without park_slot/unpark_slot (HIP, Metal, CPU),
cannot park: there the title request wiped the chat and the next agent step read
the whole prompt again (27 s at 42K tokens, two RTX A6000, packaged host).
InkBackend::can_park() (CUDA: initialized and no layer split; the mock: not
INK_TEST_NO_PARK) decides. A budget the load cannot use is not announced
(INFO slot_cache_mib=0, one line on stderr) and the serve loop does not keep it.
A load that can park is unchanged.
Mock test: a load that cannot park answers slot_cache_mib=0.
PLAN-0224 item 23 (a 16 GB card at 64 slots keeps almost no expert on the card) re-measured on a rented RTX 5060 Ti 16 GB (SQ-20 v2, ctx 16K, --parallel 64, 128 new tokens per request):
- headless: COMPACT, all 3072 experts on the card, K/V and sliding-window rings in host memory: e2e 154.6 / steady 211.2 tok/s. This is the path item 7 / 22 made for 16 slots and more.
- with 800 MiB held (what a display holds; a VRAM ballast taken before the first allocation): COMPACT needs 15,102 MiB at 64 slots, 14,896 are free, the loader refuses it and the old path ran: the engine did NOT
start ("not enough free GPU memory for the working buffers", every chunk size down to 64). Cause: the VRAM plan is made BEFORE the loader decides, with COMPACT's memory plan (the 40 sliding-window rings of 64
slots, 5.4 GiB, counted as host memory); after the refusal the old path puts them on the card, and the experts had been placed without room for them (1,884 experts, 2,103 MiB left).
Changes (CUDA backend only):
- plan_vram_reserve (ink_cuda_backend.cu): the rings count as host memory from 16 slots on whenever the table's COMPACT runs (compact_vram, as the runner's swa_in_host), not only with C64_SPEC: the 12 / 8 GB
hybrid rows have no C64_SPEC and held 5.7 GB back for rings that then went to the host (0 experts on the card at 64 slots on an 8 GB class card). The bytes left out are handed to the loader
(sm120_plan_swa_host_bytes_ref).
- ink_runner.cuh, the loader's COMPACT check: (1) when COMPACT is refused and the plan had left the rings out, they are added to the experts' reserve ("held back from the experts" line); (2) the COMPACT_HYBRID
fallback of item 17 also applies from 16 slots (it stays refused for 2..15 slots, as before).
Measured on the same card (SQ-20 v2, 16K per slot, 800 MiB held, 1 round, all requests answered):
- --parallel 64: not started -> COMPACT_HYBRID, 2,404 experts on the card, e2e 57.3 / steady 101.0 tok/s; headless unchanged (157.5 / 216.2 against 154.6 / 211.2).
- --parallel 32: e2e 36.6 / steady 62.2; --parallel 16: e2e 51.6 / steady 107.8 (both started on the hybrid; --parallel 4 still takes the old path and answers).
- the refusal path itself (STRATA_INK_SM120_COMPACT_HYBRID=0 at 800 MiB, 64 slots): before the change not started, now starts with 695 experts on the card and answers (e2e 8.1 tok/s: the rings fill the card, a start that works, not a fast one).
- 3.2 GiB free, 64 slots: a refusal with the message of the previous commit ("not enough free GPU memory to load the model ... 3197 of 15850 MiB free ... --parallel").
Builds: Linux sm_120 (CUDA 13.0) on the 5060 Ti, MSVC + CUDA 13.0 sm_120 on the owner PC. Not measured: RTX 5080 / 5070 Ti (their rows are default off), the 12 / 8 GB hybrid rows with the smaller plan (no such card;
the 5070 12 GB at 64 slots before this change: 0 experts on the card, 3.9 GiB free after the start), a real display's compute use.
Design (3 lines): a conversation parked because another request overwrites its slot, and every idle slot's conversation when the engine stops, is also written as a file (ink_conv_disk.h: identity
string, prefix tokens, pictures, hash; capped, LRU); the first request that continues it, also after a restart, reads it back through the same unpark path as #7620. The backend exports its
ParkedState as bytes (CUDA: the checkpoint plus the global K/V of [0, seq_len), bounds-checked on read) and states what the bytes mean (K/V type and layout, window, drafter state); a file of another
engine build, model, layout, a damaged or cut file is refused and removed (the turn reads cold). No file with a layer split, the elastic 1M tiers, or a backend without the hooks (one log line).
ink_backend.h: ParkedState::serialize, InkBackend::parked_from_bytes / conversation_identity (defaults: cannot). ink_cuda_backend.cu: CudaParked serialize / from_bytes, the identity, and a fix that
unpark_slot grows the global K/V to the conversation's length first (an engine that has just started has not grown it; 8,189 tokens fit the initial capacity, 16K and 32K did not: "could not be
put back"; the in-memory park of #7620 never hit it because the K/V had grown in the same session). ink_serve.h: the disk layer in park_current (write), the park block of prepare_req (read, after the
in-memory store), the shutdown save, ServeConfig conv_cache_dir / conv_cache_bytes; ink_main.cpp: the two flags. docs/DETAILS.md has the section.
Tests: 8 new mock tests (restart reads back and answers as cold, a request that overwrites the slot writes a file and it comes back, another identity ignored and removed, damaged file, larger than the
cap, a backend that cannot export, a picture conversation after a restart only for the same picture) + the unit test of the file layer (47 mock tests pass). Real card, RTX A6000, SQ-20 v2, --draft off,
turn 2 = turn 1 + its answer + a follow-up, first token after an engine restart / the same engine warm / a fresh engine reading it cold: 8K 0.34 / 0.15 / 3.44 s, 16K 0.48 / 0.09 / 7.23 s, 32K 0.78 / 0.11 /
15.79 s (files 218 / 350 / 613 MB, written at stop in 0.6 to 1.1 s). The restored turn's tokens equal the cold read's in 5 of 6 runs (3 sizes, default and STRATA_INK_EXACT=1); the sixth (8K, default mode)
is a pass in which turn 1 itself differed between two identical runs.
The 16 GB COMPACT set (RTX 5060 Ti row, kSm120SmallFast) runs only when every expert fits next to the compact trunk: 15,534 MiB for SQ-20 v2 + DFlash 2 on a card that has 15,696 MiB free headless
(162 MiB to spare). A card that drives a display has less, the loader's precheck refused COMPACT ("COMPACT refused: not enough free VRAM") and the whole fast set went to the old path: no drafter
(DFlash 2 needs the Q8 unembed screen), 2 to 5 times slower. The 12 GB and 8 GB rows already carry COMPACT_HYBRID (the compact trunk, the experts that fit on the card, the rest in RAM through the
adaptive tier); the 16 GB rows did not (NV-ADA note: with 2..15 slots it let COMPACT start with 3 MiB free).
- ink_sm120_table.hpp: ink_sm120_hybrid_fallback_parts() (the parts of the 12 GB row's set: PACK, PREFILL, PLD, CORE_GRAPH, C64_SPEC out, COMPACT_XCODE + COMPACT_HYBRID in, the KV rule of the hybrid, parts
named by the person kept), Sm120Decision::forced_off (what STRATA_INK_SM120_<PART>=0 switched off); ink_sm120_table_test covers both.
- ink_sm120_cfg.cuh: sm120_compact_to_hybrid(dev) rebuilds the device's decision with those parts and the 12 GB row's numbers; ink_rtx5060ti_fill() is the 5060 Ti view the loader reads.
- ink_runner.cuh (the loader's COMPACT precheck): when the experts are short, the run is ONE slot, the model is all SF4 / MX8, at least 3 GiB of experts still fit next to the compact trunk, and the person
did not switch COMPACT_HYBRID off, COMPACT_HYBRID runs (one line says so) instead of the refusal. 2..15 slots keep the refusal (unchanged), headless cards keep the all-VRAM COMPACT (unchanged).
Measured (rented RTX 5060 Ti 16 GB, driver 595, CUDA 13.0, SQ-20 v2, DFlash 2, ctx 8192, 3 rounds, VRAM ballast taken before the first allocation = what a display holds; prose / chat / code / doc4k decode tok/s):
- headless (no ballast): unchanged, 100 / 149 / 259 / 112 (all 3072 experts on the card, COMPACT).
- 800 MiB held: old path 51.4 / 52.3 / 49.0 / 35.1, now 73.7 / 88.7 / 88.9 / 43.4 (+43 / +70 / +81 / +24 %; prompt reading 79-60-48-747 -> 134-114-91-1194 tok/s); 2,200 MiB held (1 round): 49 / 50 / 49 / 32 -> 69 / 90 / 90 / 43.
- 6,000 MiB held (9.7 GiB free): 40.9 / 42.4 / 41.1 / 28.5 -> 45.5 / 58.5 / 54.2 / 36.5; 9,500 MiB held (6.2 GiB free): 28.9 / 28.0 / 27.5 / 21.7 -> 28.8 / 36.5 / 34.7 / 29.2 (never slower).
- --parallel 4 (the refusal stays): starts and answers with 0 and 800 MiB held, e2e 45 and 42 tok/s.
- STRATA_INK_SM120_COMPACT_HYBRID=0 restores the refusal (old path), checked at 800 MiB.
Builds: Linux sm_120 (CUDA 13.0, source = main 03bb4f48ba + this change) on the 5060 Ti; MSVC + CUDA 13.0 sm_120 (jobq owner). Not measured: RTX 5080 / 5070 Ti (their rows are default off), quality of the hybrid path on this card (it is
the 12 GB row's set, FASTQ and KL as measured there), a real display (the ballast imitates the memory it holds, not its compute use).
One history for the Inkling conversation work of 0.2.25: items 2 (pictures), 6 (governor) and the disk layer of item 1 on top of REPROC's park / unpark hooks (21699a4c08, tip 85cad3f51c).
Conflicts: ink_prefix_mock.cpp and test_shared_prefix.py only (both lanes extended them); resolved by keeping both sides. The mock's global K/V is int64 (a picture row is 1<<40 | a hash
of its embedding row), so MockParked stores int64 too. ink_serve.h merged without a conflict, plus one addition so the two features meet: a parked conversation now records the pictures
inside it (the SHA-256 spans of ink_pic_reuse.h), the search for a parked conversation and the "already parked" test compare them, and the pictures come back with the checkpoint.
Without it the same ids behind another picture could have been matched to a parked conversation.
Tests (mock, real serve loop, 39 pass on p1006): the two new ones are a parked picture conversation coming back for the same picture only, and the same ids with another picture not getting
it (that one fails when the picture comparison is removed from the park match: negative control).
Design (3 lines): the window governor (--draft-adapt, passed by the Terminal) measures 12 speculative steps and, when the gain is below 0.93, runs plain steps before probing again;
the pause was always 40 steps, so at 65K to 131K tokens of context, where every probe loses, about one step in five was a losing speculative step for the whole reply. The pause now
grows 40, 80, 160, 320 with consecutive failed windows and returns to 40 as soon as a window pays. Drafting is exact, so the output is the same; only when drafting runs changes.
ink_gov.h (the schedule as a pure function) + ink_gov_test.cpp; ink_serve.h uses it per request (gov_fail); the register has STRATA_INK_GOV_BACKOFF.
Measured (SQ-20 v2, one slot, product arguments --draft dflash2 --draft-beam 1 --draft-adapt, 768 new tokens, 2 alternating rounds, greedy tokens identical in every arm):
RTX A6000 (CUDA) decode tok/s, backoff / fixed 40 / --draft off: 33K 111.1 / 108.3 / 58.0; 65K 47.1 / 46.8 / 49.4 (a second run 48.8); 131K 36.0 / 34.9 / 38.2 (second run 36.5).
Radeon AI PRO R9700 (HIP), 384 tokens: 33K 95.6 / 95.2 / 56.4; 65K 49.7 / 49.5 / 47.6 (tokens identical in all arms and rounds).
The gain is small (+0.6 % at 65K, +3.2 % at 131K on CUDA) and the product still runs about 4.5 % under --draft off at 131K there, from the probe windows that remain. Not the cause:
the drafter's tap ingest on plain steps (an experiment that skips it on governor-plain steps gave 47.7 / 36.7 tok/s against 48.8 / 36.5 with it). The Olares 128K gap (9.8 vs 11.05)
is not reproduced by this change; it needs a card with host-offloaded K/V.
PLAN-0224 item 24: an 8 GB card at --parallel 32 or more "crashed instead of refusing" (BENCH71 11-28, builds up to 0.1.70 / e473dc980). Re-measured on current main (03bb4f48ba) on a rented
RTX 5070 12 GB made into an 8 GB class card with a VRAM ballast taken before the engine's first allocation (SQ-20 v2, ctx 16384, drafter default): with 7.6 GiB free (the 5060 Ti 8 GB's case) and
with 4.0 GiB free, --parallel 32 and 64 start AND answer every request (32 x 124 and 64 x 124 tokens; slow, 5.4 and 7.1 tok/s e2e, since the experts are all in host RAM). So the start-up
crash of the old builds is gone (the 0.2.24 loader keeps the embedding on the host and the adaptive tier takes what is left). What is left is how a start that cannot work ends:
- about 2.2 GiB free, 64 slots: a clean refusal already ("ERR init: ... not enough free GPU memory for the working buffers even at the smallest size") but without a number to use;
- 1.2 GiB free and less (the shared layers do not fit): INK_CK(cudaMalloc(&d_trunk)) ended the engine with exit 3 and "ERR fatal GPU error" (the server's restart path), with no hint.
Changes (CUDA backend only):
- ink_cuda.cuh: INK_CK sends an out-of-memory result through ink_alloc_failed (the check that already names the free memory and throws InkAllocFailure while the backend starts), so an allocation
that did not go through dalloc takes the same path; the message says "(N of M MiB free)" and names --parallel.
- ink_cuda_backend.cu: the model load runs with allocation failures thrown (ink_alloc_throws, thread-local, so loader threads still end the engine as before) and a failure is a normal
"ERR init: not enough free GPU memory to load the model: ... (N of M MiB free). Close other programs ..., use fewer parallel requests (--parallel; now N), a smaller --max-context, or a smaller model."
with exit code 1; the working-buffer failure at the smallest chunk adds what one parallel request costs on this card (40 sliding-window visits x 1,056 positions x the K/V bytes + the ShortConv
state: 89 MiB in FP8) and "--parallel N or fewer may fit" from the free memory left.
Checked on the 5070 with ballasts of 9.5 / 10.5 / 11.2 GiB: the three messages above (the second and third were exit 3 "fatal GPU error" before); MSVC + CUDA 13.0 sm_120 build OK (BUILD-RC 0).
Not changed: the planner (strata_control/inkling_fit.py) already refuses a --parallel that does not fit its plan (kv_fits).
pool_tasks_test stalled on boston (i9-13900K) and sometimes on p1004: "the CPU expert pool stalled after a phase (N-1 of N workers parked)", abort after 60 s; 12 of 12 runs here.
The stall report now shows what was missing before (the pool's own diag(): every worker's state, the host's, the batch counters and mode; the Linux thread table; and, with glibc, a call stack of every pool thread, resolved with addr2line). It showed one worker, always spinning, always inside ExpertPool::prefetch_task.
Cause: prefetch_next() publishes a per-worker batch that nobody waits for ("the next batch of any kind stops it", wait_parked). A worker that slept through that publish still counts as parked, so the host's next wait_parked passed at once, cleared the abort flag and went on. The late worker then woke for the stale prefetch, entered its all-workers barrier (pf_arrive_ < W) with nobody left to arrive and no abort flag set, and spun for ever; the host waited for it to park, and the batch counters of the next phase were disturbed (done_ above the task count).
Fix: every worker records the epoch it last finished (wack_), and while a prefetch is in flight wait_parked also waits until all of them have finished the prefetch's epoch. The abort flag stays set meanwhile, so a late worker leaves the prefetch at its next check. Nothing changes for batches without a prefetch.
pool_tasks_test on boston: before 12 of 12 aborted (60 s); after 10 of 10 passed in 7.8 s.
Read against the current code (the issues were closed 11-30 with the benchmark items, without a fix):
- #6312 `strata bench run` from a git checkout marked the run nonconforming: bench_facts looked for .git in terminal/ only. checkout_root() also takes the folder above terminal/ when it holds engine/ (an install inside somebody else's repository is not taken for a checkout); the commit and build_kind "source" follow. Test: test_bench_commit_checkout_6312.py.
- #7170 `engine calibrate --measure` lost the whole ~25 minute sweep when its result held --prefill-pipe (the layer-split chunk winner): the report validator did not know the flag and refused after the sweep. --prefill-pipe is accepted (a whole number of tokens, like the other counts) and listed in the preview. Test: test_calibration.py::test_a_sweep_that_picked_a_prefill_pipe_chunk_is_saved_not_lost fails on the old code with "calibration report has unsupported settings".
- #7150 --layer-split is read by the CUDA backend only; the SYCL, HIP and Metal engines accepted it and ran as if it were absent. They now print one line saying it is ignored (nothing else changes).
Design (3 lines): one file per parked conversation: a header (identity string built by the backend: model files, engine build, K/V type and layout, window; the prefix
token ids; the pictures inside it with their SHA-256), then the opaque payload a backend exports. A file of another identity, with a wrong hash, or cut short is refused and
removed (the turn reads cold); writes go to a temporary name and are renamed; the total is capped and the least recently used files go first. The hash is for accidental
damage (not cryptographic): only files this engine wrote are restored.
ink_conv_disk.h (host only, no GPU, no backend) and ink_conv_disk_test.cpp (round trip, restart, longest prefix wins, foreign identity, flipped payload byte, cut file, other
picture behind the same ids, cap with LRU order, a conversation larger than the cap, files that are not ours stay). The engine side (a ParkedState serialize / deserialize on
the park / unpark hooks of #7620, --conversation-cache-dir, the restore on the first matching turn) follows once #7620 is in.
A slot holds one conversation; a request that continues nothing of it (a title, a summary request, a helper agent) wiped it, and the next step of the chat
read its whole prompt again (RTX 3060, 11K tokens: 30 to 46 s a step). With --slot-cache-mib N (or STRATA_INK_SLOT_CACHE_MIB, 0 = off, the default) the
serve loop parks the slot's conversation first: InkBackend::park_slot(slot, seq_len) copies the global K/V of [0, seq_len) to a host buffer and moves the
slot's prompt-end checkpoint into the parked object; unpark_slot writes the K/V back and restores the checkpoint, so the slot holds the conversation exactly
as it was. The scheduler keeps the parked conversations under a byte budget, least recently used first, parks only conversations of 512 tokens or more,
parks nothing for a normal follow-up, and reads from the start when a put-back fails.
CUDA backend (one GPU, not the layer split): the K/V copy follows the descriptor layout (card part, virtual-memory range or mapped host tail; FP16 K and V,
FP8 / K8V8 / K8V4 also the scale arrays). Other backends keep the default (cannot park). Tests: test_shared_prefix.py (7 new, GPU-free, mock backend that
aborts on a restore over a different K/V).
Decision of 12-02 (coordinator, the owner may still flip it): default ON, because a resumed picture turn differs from the same turn read cold exactly where a resumed
text turn already does (parity table in phaseA-tests/notes-ink-025.md: CUDA A6000 and HIP R9700, text and picture, 40 greedy tokens), a wrong hit is excluded by the
SHA-256 comparison of the pictures' exact pixels, and the gain is clear (time to first token of turn 2 and 3: CUDA 0.63 -> 0.12 s, HIP 0.45 -> 0.16 s).
The default is now one constant in ink_serve.h (kPicReuseDefault); with it false the variable needs STRATA_INK_PIC_REUSE=1. The register note is unchanged (status default).
STRATA_BUILD_HY4_FLASH=ON failed on Windows with CUDA 12.9 (the cuda12 package): gpu_sampler.cu and vision_kernels.cuh include CUB, every CUB header pulls in CCCL's <cuda/ptx>,
and that includes cuda/__ptx/instructions/generated/clusterlaunchcontrol.h, whose asm statements pass `reinterpret_cast<long2*>(...)->x` for a 64-bit "l" constraint. `long` is 32 bits
on Windows, so nvcc stops in the sm_120 pass with "asm operand type size(4) does not match type/size implied by constraint 'l'" (10 errors). Probed on the owner PC (MSVC 2022,
CUDA 12.9.86): cub/cub.cuh, the device radix sort and scan headers, and cub/block/block_reduce.cuh alone all fail the same way, so smaller includes do not help.
Nothing in CUB 12.9 uses that header (it only declares cuda::ptx::clusterlaunchcontrol_try_cancel and friends, which no CUB algorithm calls), and neither do we. New
src/hy4flash_gguf/cub_msvc12.h sets the header's include guard for MSVC + CUDA 12.8 / 12.9 (CUDA 13.0 has the fix, Linux has a 64-bit long) and is included first in both files.
The CUB calls and their results are unchanged (the radix sort, the double scan, the block reductions of the vision kernels).
Verified: MSVC + CUDA 12.9.86, the release configure line of tools/packaging/build_cuda_windows.py (cuda12 variant, STRATA_BUILD_HY4_FLASH=ON, STRATA_EXPERIMENTAL_SM60=ON),
sm_120 + sm_89: the whole strata_hy4_flash library builds (BUILD-RC 0), gpu_sampler.cu.obj and vision_gguf.cu.obj carry sm_120 and sm_89 cubins. Not run on a GPU (the owner PC was
in use; the change adds no code).
Design (3 lines): a resident prefix (the slot's last prompt, or its prompt-end checkpoint) is reused for a prompt with pictures only when the pictures
inside it are the same pictures: each is keyed by a SHA-256 (all 256 bits compared) of the exact encoder input (pixels after resize and padding, grid, size)
and by the position of its pad run; encoded pictures are kept in a byte-capped LRU so a later turn does not run the ViT again; a prompt without pictures takes
the id test it always did. STRATA_INK_PIC_REUSE=0 restores the old behaviour (read whole every turn), STRATA_INK_PIC_CACHE_MB sets the cap (default 256).
ink_pic_reuse.h is new (digest, span test, PicCache). ink_serve.h: the reuse block and the prompt-end checkpoint also run for picture prompts (the tail-role
position only when it is not inside a picture); the shared (pinned) prefix stays text only. ink_prefix_mock.cpp + test_shared_prefix.py: the real serve loop
against the mock backend with a Vision folder: same picture reused and equal to a cold run, another picture behind the same ids never reused (3 of the 7 new tests
fail when the picture check is disabled), prompt-end checkpoint with a picture, a changed second picture, a text turn after a picture turn, the off switch
(greedy tokens identical, no cache), cache cap 0. Both settings are in the register (settings_register --check green).
Which experts of a token run on the CPU and which on the GPU depends on timing (the adaptive tier's copies landing, the prefill's CPU share),
the CPU and GPU kernels do not give the same last bits, and the draft policy picks each verify window's size from live round times (a different
window is a different batch for the verifier), so two runs of one prompt could diverge after a few hundred tokens (ioq-sweep, 2026-12-01:
first differing hidden state between layers 8 and 14, argmax flipped at token 240, 20 percent of same-context window rows differed).
The switch sets --pcie-frac 1 when none is given (every missed expert is computed on the GPU), STRATA_PREFILL_CPU_SHARE=0 when it is not set
(the prompt does not use CPU experts) and STRATA_SPEC_FIXED=1 when it is not set (the engine's fixed window-cost table), and prints one start-up
line. A value the person sets wins and is said. RTX A6000, IQ3_S pack, MTP spec 4, default cache: 6 of 6 runs gave the same tokens (the default
flags: 2 runs, 2 different answers) and two runs with STRATA_LOGITS_DUMP gave byte-identical logits; decode about 3 percent slower (median 49.3
against 50.9 tok/s), prompt speed the same within noise (4K and 16K). With the switch off the logits of the old and the new build are
byte-identical (cache 1500 default flags, and the fixed-flag identity set).
strata launch --deterministic writes STRATA_DETERMINISTIC=1 into the run configuration (the copyable line says --deterministic).
Settings register entry (opt-in), docs/DETERMINISTIC.md, docs/SETTINGS.md regenerated, launcher test.
The elastic global K/V grew one visit at a time (new buffer, copy, free the old one), so the card needed one old visit buffer extra and a long request stopped 1.2 to 1.8 GB short of the
context that had been planned ("VRAM exhausted growing elastic global KV cache", 503), and the plan was set before the drafter (DSpark's fused weights, DFlash 2 codebooks and rings)
took its memory.
- ink_runner.cuh: with ONE slot on ONE card (no layer split, no elastic 1M mode, K/V not split to host at the start) every global visit's K, V and scale buffers are address ranges for the
requested context (strata::core::VmmRange, src/core/vmm.cpp, now also linked into the CUDA backend) and physical memory is mapped behind them as the context grows; the pointers never
move, so no peak of old + new. A failed mapping falls back to the host tail (kv_spill_tail, the earlier code, now a function) or to a refused request, as before.
STRATA_INK_KV_VMM=0 takes the earlier growth back.
- ink_dspark.cuh: the classic drafter's global context grows the same way (ctx_vmm).
- ink_cuda_backend.cu: after the drafter has loaded (--kv-offload off), max_ctx is set to what the card holds (ink_kv_reach_ctx, 256 MiB kept free), up or down, never above
--max-context ("max_ctx A -> B" line); --kv-prealloc / STRATA_INK_KV_PREALLOC=1 maps that whole context at start-up (and refuses to start, with a message, if the mapping fails); a request
that fails to grow says how much video memory is free now and what to do.
- ink_serve.h + InkBackend::kv_reachable_tokens(): a prompt the card can no longer hold (another program took video memory after the plan, --kv-offload off) is refused at the start with
a message instead of ending with 0 tokens; the engine stays up.
- strata/core/ink_kv_grow.hpp: ink_kv_reach_ctx() and its test (ink_kv_grow_test). Register: STRATA_INK_KV_PREALLOC (opt-in), STRATA_INK_KV_VMM (rollback); docs/INKLING_KV.md, SETTINGS.md.
Measured (RTX 4090, SQ-20 v2, --kv fp8 --kv-offload off, prompts of 90K / 100K / 110K / 128K tokens; VRAM ballast taken before the first allocation to get the Windows 4090's room;
phaseA-tests/rel0224/ink-kv/RESULTS.md, REPLY-6770.md): no ballast: tokens identical old / new / --kv-prealloc, decode equal; 700 MiB ballast, classic drafter: old ends the 110K request at
100,864 tokens with 0 tokens, new answers it; default drafter: old plans 104,192 and refuses 110K and 128K, new answers both; 1,300 MiB: old plans 74,240, new raises it to 109,568 and
answers a 100K prompt; every answer identical to the unballasted run; short prompts: same tokens, speed within 0.5%; ballast after the start: --kv-offload auto answers (host tail), off
refuses with a message. An RTX A6000 with a 128K prompt: identical tokens. Builds: CUDA sm_86 and sm_89 (Linux), sm_120 (MSVC), HIP gfx1151.
COMPACT (RTX 50 16 GB rows) reads only SF4 / MX8 experts. The loader checks that and refuses, but only after the backend has planned the run for COMPACT: FP8 K/V, DFlash 2 loaded on the compact budget. On a 16 GB card with SQ-15 the refused run kept that plan (global K/V entirely in mapped host memory) and decoded 4K / 8K documents at 26 / 19 tok/s against 46 / 46 with STRATA_INK_SM120=0 (RTX 5060 Ti 16 GB, rented, quiet box, ABBA, 2 rounds, 7 prompts).
The backend now runs the loader's same conditions (compact on, not the hybrid rows, no explicit expert budget or SSD, card within the row's compact size) over the expert directory before the sizing and calls sm120_compact_refuse there. Result for packs with other experts (SQ-10, SQ-15, IQ3_S, UD-Q4_K_XL): exactly the old path, planned as such. SQ-20 (all SF4 / MX8) and the 12 / 8 GB hybrid rows are unchanged. Compiles for sm_120 (CUDA 13.1).
One stderr line after the layer tables are built: how many layers have S_K, SF4, MX8 or other (GGUF or mixed) gate_up and down experts. The FP8 prompt-row MoE and the K-coalesced decode MoE of the R9700 set run on the SF4 and MX8 layers only, so the line shows the coverage per pack. No behaviour change (p620 build gfx1200 + gfx1201: 0 errors).
The measurements (phaseA-tests/rel0224/ink-kv/RESULTS.md) made FP8 a good default where the card likes it and a bad one where it does not:
- CUDA: FP8 on every card and slot count (KL 0.005, top-1 95-98%, FASTQ subset SQ-20 v2 201/213 FP16 against 202/213 FP8, 64 slots +24 to +27% and a 32K
decode x2.5 on 12 and 16 GB cards because the cache is half the size and stays on the card; -1 to -3% on an RTX A6000 that has no native FP8).
- HIP (AMD): the 0.2.23 rule is back, unchanged: FP16, FP8 from 16 slots on a card of 36 GiB or less, STRATA_HIP_KV_FP8_SMALL and the Strix Halo FP8_KV_C64 set as before.
On the Radeon AI PRO R9700 FP8 costs 7% decode at 4K and 17% at 32K (prefill -8% at 32K); the retirement of STRATA_HIP_KV_FP8_SMALL is undone.
- Metal (Mac): FP16 ("auto: Mac default"); --kv fp8 (#6983) and the opt-in M5 Max fast set are as they were.
- SYCL (Intel): FP16, FP8 from 16 slots and in the Intel Arc fast set, as before (Arc A750: FP8 decode -6%, KL 0.0044 at 4K and 0.0054 at 32K).
ink_kv_auto_rule() now takes the parallel slots, the card's memory and what the backend's default is (fp8_by_default / fp8_from_slots / card cap / its sentence), so
the rule and its reasons stay in one place; every backend prints "[kv] <backend>: K/V cache <type> (auto: <reason>)". ink_main no longer sets FP8 at 16 slots for every
backend (that made a Mac and an Intel card take FP8 by the back door); the CPU reference keeps its own FP8-from-16-slots rule in its backend. The plan
(inkling_fit.auto_fp8_kv) follows: FP8 for CUDA and an unnamed backend, the 0.2.23 rule for HIP, FP16 for Metal and SYCL. Tests: ink_kv_rule_test (host only),
test_inkling_kv_auto.py, and the planner tests that pinned FP16 numbers pin them with fp8_kv=False.
After #6983 an explicit `--kv fp8` is honoured on every Metal GPU (the M5 Max fast set still picks FP8 by itself). `--kv auto` stays FP16 outside the M5 Max set: INK-PR measured
FP8 on an M5 Max at KL 0.0053 / top-1 96% against FP16 with the K/V halved, but decode -10 to -12% at 4K to 16K, so it is a choice there, not a default (the owner decides).
The [kv] line says which of the two happened, and says so when `--kv fp16` meets the M5 Max set's own FP8.
`--kv auto` (the default) now stores the K/V cache as FP8 wherever the backend can (CUDA, HIP; SYCL stays FP16 by default until its A750 / B70
numbers are in, Metal takes FP8 only in the M5 Max set) and FP16 where it cannot. K8V8 and K8V4 are only chosen when asked for (--kv k8v8, --kv k8v4).
An explicit --kv always wins. Before, every backend had its own rule (CUDA: FP16 unless 16+ slots, a card of 13 GB or less with the K/V offload off, sm_89+ with a
context over 16K, three RTX 50 rows; HIP: FP16 below 16 slots; SYCL: FP16).
- engine/include/strata/core/ink_kv_rule.hpp: the one rule (host only) and the one start-up line, "[kv] cuda: K/V cache fp8 (auto: default)"; the CUDA, HIP, SYCL
and Metal backends call it. Test: engine/tests/core/ink_kv_rule_test.cpp.
- CUDA: plan_vram_reserve() takes the type from the rule; STRATA_INK_ELASTIC_1M + STRATA_INK_KV_K8V4 remains the tester's way to K8V4. HIP: the old small-card
switch STRATA_HIP_KV_FP8_SMALL is retired (register entry marked retired in 0.2.24).
- ink_main --help: the --kv line says what auto is.
- --dump-ref / --kld-eval: a row-selected form for long documents (INK_KLD_TAIL=N INK_KLD_STRIDE=s keep the logits of every s-th of the last N positions; the file
then starts with -n_tokens; INK_KLD_CHUNK / INK_KLD_CHUNK_TAIL set the prompt chunk of the head and of the scored part). The old file format and behaviour are unchanged;
the --kld-eval line gains refPPL and dNLL at its end.
- terminal: the memory plan (inkling_fit.auto_fp8_kv) sizes FP8 for every backend except SYCL and Metal; compute_unified and recommend take fp8_kv like compute does.
Tests that pinned the FP16 numbers now pin them with fp8_kv=False; test_inkling_kv_auto.py covers the new rule, the launcher's k8v8 / k8v4 clamp and that every backend
calls the one rule. docs/INKLING_KV.md; docs/SETTINGS.md regenerated.
Measurements (phaseA-tests/rel0224/ink-kv/RESULTS.md): teacher-forced KL of FP8 against FP16 K/V 0.005-0.007 and top-1 95-98% on 4K / 32K / 128K documents
on RTX A6000 (SQ-20 v2), RTX A4000 (SQ-15), R9700 (SQ-15), Arc A750 (SQ-10, 4K), RTX 5070; the needle misses are the same with FP16.
Found by the python suites on the merged tree (next-0224: 0 failures in py-tests / py-serve, 1 known in py-tools; merge: 2 / 1 / 7 + the settings register).
- strata_tokenizer.py: only the Hy4 pre-tokenizer name hy_v4 is added; qwen3 / joyai-llm / hunyuan-dense are refused again as before, and the
qualified special-id keys are folded in only for hy_v4.
- iq_pack.py: the expert-layout messages say "layer N" as ever; "block N" only where a dense prefix makes the two differ (hy4-flash).
- launch/catalog.py: the 4096 start context is for the GGUF engine (Q4_K_M) only; the native hy4-flash default stays 128K.
- serve/replicas.py, serve/server.py, test_replicas.py: the PR's inference_turn / replica queue-wait rewrite (all families) is not carried over;
only the hy4-flash shared-arena refusal stays. serve/web/app.js: the expert_slots != null display change is not carried over.
- strata_control/models.py: the mixed-architecture shard refusal (all families) is not carried over; the hy_v4_flash acceptance stays.
- serve/frontend.py: thinking_enabled() counts reasoning_effort no_think only when the family is hy4-flash.
- engine program/generate.cpp: --families keeps the literal printf forms (test_shape_engine) with hy_v4_flash added by STRATA_HY4_FLASH_RUNS.
- tests: test_family_name lists hy4-flash; test_no_debugger_children lists hy4_flash.py (nvidia-smi); terminal/data/settings-register.json gets the 129
names the Hy4 engine reads (status opt-in where the default is off, else unsure; additions only).
- cmake/hy4_flash_gguf.cmake: the CUDA Hy4 builds define STRATA_HY4_FLASH_RUNS, so `strata --families` lists hy_v4_flash (setup, the feed and
`strata launch` read that list). Before, nothing defined it and even an ON build stayed silent.
- program/generate.cpp: an engine build without the Hy4-Flash GGUF engine (Metal, HIP, SYCL, CPU-only, a CUDA build with the option OFF) refuses a
hy_v4_flash file with one message that says where it is (NVIDIA CUDA builds) instead of falling into the Flash-Next path.
- terminal/strata_control/hy4_flash.py: capability "gguf" (the engine's own strings, present only with the engine); defaults() refuses an engine
without it at plan time and a computer without an NVIDIA card with a message that names the cards found. Tests: 3 new, 18 fake engines now
carry the marker; 269 tests of the hy4 / launch files pass (p1006).