Commit Graph
689 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Opus 5.5 a8171b2cc0 scripts: hugepages A/B, identity gate, analyser, installer; owner script for shmem THP (not run)
hugepages-ab.sh: one binary, hpoff vs hpon (LELEKA_HUGEPAGES=on), 8 ABBA-balanced pairs of the 5-turn
~245k session at the product PCIe share 0.45, baseline-sampler state record (buddyinfo, AnonHugePages,
process smaps_rollup) per run. hugepages-id.sh: bitwise replay identity at 8,000 static slots.
hugepages-analyze.py: pairs, predecessor split, exit fragmentation. owner-shmem-thp.sh: root-only
shmem_enabled toggle, not needed by the decode path. huge_pages.rs: mapped_len test-only (dead-code warning).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 00:16:35 +01:00
Pavlo RatushnyiandClaude Opus 5.5 e0141e510a model-format: opt-in huge-page placement of the resident expert banks (LELEKA_HUGEPAGES)
LELEKA_HUGEPAGES=on|thp (off by default; LELEKA_BANK_THP=on now selects thp) places each of the 144
resident bank copies in its own 2 MiB-aligned anonymous mapping instead of a heap Vec: MAP_HUGETLB when
HugePages_Free covers the bank (mode on only; nothing reserved), else MADV_HUGEPAGE + MADV_POPULATE_WRITE.
After the bank load and the shard page-cache drop, before cuMemHostRegister, huge_pages::settle() reports
the coverage from /proc/self/smaps and MADV_COLLAPSEs any 2 MiB range that fell back (best effort).
Pure placement: the bytes are the file's (read_tensor_into, same bounds and size fences). No system
setting is read-write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 00:11:36 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 bba658f204 cpu-service: register-built single-token IQ3_S/IQ3_XXS dot (bitwise the generic tree, LELEKA_IQ_SINGLE=legacy keeps it); vectorized finiteness scan of the verify group's CPU output (LELEKA_SINK_SCAN=legacy keeps the element-wise one)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 18:03:19 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 9e13fc809e footprint: share the MTP dense roles with the RT bank when proven byte-equal (about 126 MiB driver), drop the pack's copy
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 02:39:12 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 4a1b9bfec7 Merge claude/slots-footprint2: free 1,084 MiB VRAM (unused MTP pack bank, lazy legacy QSA key mirrors); 11,568 -> 12,144 expert slots, +1.75% paired tok/s (n=3), bit-identical at equal slots; LELEKA_FOOTPRINT_LEGACY=1 restores. Placement-class gate on the larger cache still to run
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 23:49:06 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 1a99397032 footprint: do not hold the MTP pack expert bank next to the RT-directory copy (675 MiB) and allocate the legacy QSA index-key mirror lazily (384 MiB); LELEKA_FOOTPRINT_LEGACY=1 restores both; ledger probe job
Both buffers are written or sized at startup and never read on the serve path: the draft layer of the product (--mtp-rt-dir) streams its own experts (original_mtp_rt_bank) and the serve QSA layers keep their keys in OriginalQsaResidentIndex; the host-canonical QsaIndexKeyCache is the legacy scalar path. Together 1,084 MiB of VRAM (about 11 quota steps, 528 slots) for the expert cache; bit-identical at an equal slot count, placement class when the auto count grows.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 22:52:28 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 e1bd61f59b Merge claude/draft-vocab: opt-in LELEKA_DRAFT_VOCAB (default off). Identity 353/353 rows, 0 flips; paired A/B +0.08% tok/s: no speed claim
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 22:42:10 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a1c5e352f9 Normalize line endings: convert 10 CRLF files back to LF, add narrow .gitattributes
Ten files touched by this branch had been rewritten with CRLF line endings
(base versions are LF), inflating the diff against the merge-base to
13685/13039 lines. Content is otherwise unchanged: the diff ignoring line
endings was and remains 661 insertions / 15 deletions.

.gitattributes: crates/**/*.rs and scripts/gpu-bringup/**/*.py are text=auto
eol=lf, so CRLF cannot re-enter these LF files at commit time. text=auto leaves
files that are already CRLF in the index untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 08:51:22 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a33ab0bdba conversation: pin that a restored conversation's retained K/V never serves another conversation (upstream f8ff3420 check)
Characterization test, no code change: A, B, A (restored, K/V retained), C (resume 0) and back to A, B, C, each restore checked cell by cell by the harness. The production serve stack binds no parking (NO_PARKING in original_serve_conversation.rs), so retain() is unreachable there; the library path clears the retained image with limit_reuse(read_from) at every request start.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:41:57 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 03e891cd72 ple_reader: a source that panics is a failed read, not a ticket that waits for ever
The failed-read path of the reader itself already releases every ticket (upstream ebe3383a does not apply: the worker keeps running, issue after a failure queues nothing, collect reports the error), now pinned by tests with several tickets in flight at io_threads 0/1/2/default. The one remaining way to leave a ticket pending was a panic in PageSource::read_at: the worker thread died with the job's ticket still counted and the caller's collect blocked for ever. run() now turns a panic into the same sticky read error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:34:19 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 b5d5b24faa decode: a verifier graph that runs out of device memory costs the widest windows, not the engine
cuGraphInstantiateWithFlags answering out of memory used to poison the whole CUDA context (every call after it failed, so the engine was lost; upstream a8c1d4b7 / 2a9a67c1). The refusal is not sticky and changes no state, so now:
- the instantiate step does not poison the context on that one code (every other failure still does), the half-built graph is destroyed, and a line is logged;
- a failed cuGraphUpload (a warm-up) is skipped with a line;
- OriginalVerifier::record_all names the graph that did not fit (Error::GraphOutOfMemory { window }, 0 = commit graph);
- the serve stack repeats the assembly with the windows that fit (assemble_with_window_fallback; owners come back from each failure), logs each step, and narrows the settings, controllers and MTP draft cap of every arm to the window it ended with, for the later requests too. No cap below T=2: a failure with nothing left is returned as before, but with the context intact.
Test hook for a card with room: LELEKA_TEST_WINDOW_INSTANTIATE_OOM_AT=N fails the N-th window instantiation once.

CPU tests: poison decision, error classification, cap computation, retry loop (terminates, stops at the floor, no retry on other errors), settings cap. Not verified on a GPU.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:33:18 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 4232adaf44 cuda-driver: opt-in LELEKA_DRAFT_VOCAB selects an upstream draft subset (en, cyrillic, fr or a file)
The MTP draft head projects over the rows listed in rt/draft_vocab.bin (106,299 ids). Upstream ships
draft_vocab_en.bin (40,525 ids, 65,774 head rows fewer: ~110 MiB of VRAM and a shorter draft GEMV, at the
price that CJK/Cyrillic tokens can never be proposed). LELEKA_DRAFT_VOCAB=en|cyrillic|fr|<path> picks one;
unset (or 0/off/default) keeps rt/draft_vocab.bin and reads, logs and changes nothing.

* a selected file must have the sha256 of a recorded upstream subset (a name: that name's digest);
  another digest, a symlink, a wrong size or a too-large file is refused (the arm fails to load)
* a file that does not exist falls back to rt/draft_vocab.bin with one `FALLBACK` log line
* the startup VRAM reserve follows the selected file's size, so the freed VRAM reaches the expert slots
* one `leleka-serve draft-vocab: ... subset=en ids=40525 sha256=... file=...` line per bind when set
* sha2 becomes a dependency of leleka-cuda-driver (already in the workspace)

Unit tests (CPU only): setting parsing, table consistency, default reads/logs nothing, missing file
falls back, wrong digest refused for a name and a path, accepted digest reads the selected ids and the
reserve probe sees its size, malformed/oversized/symlink refused, subset index <-> full id round trip
and ids outside a subset. A real-file test runs when LELEKA_TEST_DRAFT_VOCAB_DIR names a directory
with the upstream draft_vocab*.bin (digests, counts, en ascending and inside the default list).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:28:10 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 58305a193d cuda-driver: guard that chain_swiglu_quant_kernel divides like the pair it replaces (q8_1 division flavour)
Read-only analysis of the sealed PTX (sm_120 and sm_86): the fused kernel and swiglu_entries_kernel + quantize_q8_1_kernel of mtp_original_full_head_iq (the window's routed-expert path) all use div.rn.f32; the fast-math quantizer copies (native_head_iq / native_head_native, div.approx.ftz.f32) are not used for this pair. CPU tests compare the numeric instruction multiset, flavour for flavour, and check a fast-math quantizer would be flagged. No kernel changed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:25:46 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 7d0166258d residency: LELEKA_ADAPT_DECAY outside 0..1 falls back to 0.7 with a logged line
Above 1 the usage counts grow without end (inf after a few hundred adaptations) and swap gains turn NaN, which breaks the swap sort; below 0 the counts flip sign (upstream 4a7e373d). Experiment knob only; the default is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:21:18 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 b63a91b2fa deploy: rtx5090-32g gpu_budget_bytes 30 GiB -> 32,819,404,800 (31,299 MiB) so the dense-slab slot gain reaches the product
Needed for the slot gain: the slabs save physical bytes the Context never charged, so the
budget must rise by about that much. Smoke with this budget: ~11,568 slots, lowest free VRAM
1,035 MiB. Also the systemd unit template, the config and reconfigure tests, and the docs.
Preflight now needs 31,299 MiB free at start (was 30,720; idle 5090 reports 32,110).
Revert by restoring 32212254720. Owner confirmation required before merge.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 11:59:55 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 83df1cfa7f Merge claude/slots-footprint (eef6f598, planner fix) into speed-train3
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 11:12:30 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 eef6f598b4 decode reserve back to 300 MiB (130 stays opt-in), A/B job: budget 31,300 MiB, RUN_TAG, slots-res130 arm; docs: the failed first A/B and its fix
The reserve cut was not the cause (the budget was) but it is unproven on the card; per the conservative rule only the slab ships by default. The job runs
both arms with E2E_GPU_BUDGET 31,300 MiB (the slab's savings need budget headroom; the base is card-bound at either value) and RUN_TAG lets a rerun sit beside the
earlier run directories.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 11:07:46 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 6e58e77548 expert cache planner: size against min(card free, Context budget - allocated), reserve kept under both (fixes BudgetExceeded at the first chunk)
First slots-footprint A/B (7823672f): every request failed in layer 27 with BudgetExceeded. The Context charges requested bytes against its budget (30 GiB);
the dense slabs saved 540 MiB of driver rounding that the budget never counted, and the planner sized the cache from the card's free VRAM alone, so the
cache (22,765 MiB) left only 305 MiB of budget for the lazily allocated first-chunk buffers and the verifier. usable_room() = min(card free, budget -
allocated) now feeds the auto count, the per-layer and profile caps and the post-open shrink loop; the reserve is subtracted from it. Base behaviour is
unchanged (card and budget coincided to 1 MiB). Tests pin the arithmetic with the failed run's numbers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 11:07:45 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 f762fc5502 Merge claude/draft-tail into speed-train2
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:36:06 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 2d38ffb1c5 Merge claude/slots-footprint into speed-train2
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:36:01 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 c2198a7b9c kar ple cache: persistent staging buffers for the scatter's update records instead of a cuMemAlloc and cuMemFree per token
`KarPleCache::gather` (one decode token: 16 rows) allocated a device buffer for the update records of its misses, copied into it, ran
the scatter and freed the buffer on every call. cuMemFree also waits for the whole device. With ple.device at 0.046 ms per call and
2.5 calls per round (speedtrain-ab spans) the allocation pair is a measurable part of a 0.116 ms per round span that runs before every
window launch. The cache now owns sixteen buffers, `scratch[k - 1]` of `k * 56` bytes, because the scatter's layout names the exact
byte length of its update block (a single 16-record buffer would be refused for fewer misses).

Output identity argument: the same bytes are copied into a device buffer of the same length before the same kernel call with the same
count; the kernel and the decode that follows are unchanged, and every `kar_ple_*` launch is followed by a context synchronize
(`execute`), so a reused buffer is never overwritten while the scatter reads it. The decoded rows depend only on the packets.

Test: the staging sizes are the record sizes the layout and `gather` use (CPU). Not run on a GPU: covered by the replay identity job.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:25:16 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 521bfc91d5 prompt path: optional alias of the token table onto the native embedding's mapped host copy (EXPERIMENTAL, LELEKA_PROMPT_EMBED_ALIAS=1; -324 MiB VRAM, -322 MiB pinned RAM)
OriginalPromptEmbedding::load and OriginalNativeOutput::load(.., true) both stream the GGUF TokenEmbedding tensor (IQ4_XS, 248,320 rows of 1,360 B):
the first uploads a 324 MiB copy to VRAM for the prompt path and the MTP prefill, the second keeps the same bytes in a pinned host mapping that the
decode gather reads over PCIe. Vanilla keeps one (mapped). With the switch on, OriginalNativeEmbed::table_alias() hands the prompt path a borrowed
DeviceBuffer over that mapping (not charged, frees nothing), the native head and embedding open first, and the stack closes the prompt table before
the native embedding it aliases.

Off by default: the drafter gathers a row per draft step over PCIe beside the expert staging traffic and the effect on decode is unmeasured; the
A/B job has an arm for it and slots-id.sh a bitwise-identity arm. Tests: the switch is opt-in; a CUDA test of a borrowed alias over a cuMemHostAlloc
block (reads the host bytes, costs no device memory, survives drop; passes on the RTX 3080 laptop); an sm_120-only test of table_alias itself
(ignored, for the server).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:21:45 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 8735bbc5d5 kar ple: a decode token reads its 16 rows on the calling thread when the archive answers from memory (8 threads otherwise, as before)
`VerifiedKarPleArtifact::read_rows` (one token's 16 rows, 48 positional reads) started and joined eight scoped threads on every call.
The speedtrain-ab spans show ple.read_rows at 0.119 ms per call and 2.1 calls per round (0.25 ms of a 15.0 ms round, before the window
launches), while a memory-served pread of 10-20 bytes takes about a microsecond. The call now reads the first row itself and times
it: at 20 us or less (a row is three reads) the other fifteen rows are read on the same thread; slower means the file waits for a
device, and the previous eight-thread read runs, with the next 256 calls skipping the probe so a cold archive pays one probe per 256
tokens at most. The prefill's batch and read-ahead paths are untouched.

Output identity argument: the same `read_rows_chunk` reads the same offsets into the same packet slots in every path, with the same
bounds, length and non-finite-scale refusals; only the number of threads differs. The test reads random rows of a two-partition
synthetic file through the probing, the post-cold-verdict parallel and the non-probing paths and compares every packet with the
single-thread reference, plus the refusals (row outside the table, changed archive length, row beyond the partitions).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:20:39 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 2f267df973 serve: the per-round checks over the whole token history examine only the tokens appended since the last round
Five passes over up to 262,144 i32 ran on the host every round: the controller's validate_current and the ledger's begin_window each
compared `committed` with `consumed`, with_sampling authenticated them twice more and range-checked the whole tail, after_verified
range-checked `consumed` once more. In the speedtrain-ab spans the host work outside the GPU grows linearly with the context:
window.sampling_setup 0.021 ms at 45k to 0.112 ms at 247k, the un-spanned part of verify_commit 0.038 to 0.098 ms, of finish_round
0.024 to 0.068 ms (about 0.19 ms per round at 247k, 1.3 % of a round, all of it before a launch or after a read-back).

`token_memo::PrefixMemo` remembers (address, length, first/middle/last token, criterion) of the buffer a check last passed over; the
next check starts at that length, and every 32nd use examines everything again. `consumed` (reserved at the request's start) and
`committed` only ever grow within a request, so a pass over the first n tokens stays true for them. Ledger, penalty history and
controller each own a memo; a request has its own ledger and controller request, so nothing carries across requests.

Output identity argument: these are assertions between two host copies of the same tokens. A passing check is the same answer as
before; a new token that differs, a different length, another buffer or a rewritten first/middle/last token fails exactly as before;
a rewrite of any other old token, which no owner can do (both vectors are append-only inside their owner), would be reported up to
32 rounds later instead of at once. Nothing the GPU runs reads these results.

Tests: token_memo (tail-only examination, address/length/criterion/probe reset, periodic full pass, random growth against the slice
comparison), ledger (100 rounds of growth, newest-token mismatch, length mismatch, rewritten old token found within FULL_EVERY, copy
at another address), the existing controller/engine suites (99 tests) pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:20:39 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 3cf185a34a serve: the MTP draft stream no longer waits for the verifier's commit event (upstream's order); LELEKA_SERVE_DRAFT_AFTER_COMMIT=on restores the wait
Upstream enqueues the commit graph on the verifier's stream and launches the draft round graph on the drafter's own stream with no
dependency between them (core/verify.cpp set_commit_async: "the drafter (its own stream) reads only this window's final rows and its
own K/V"). The port made the draft stream wait the commit event on the device, so the commit graph (36 GDN layers, 12 QSA appends, the
PLE history; the host sees ~0.36 ms from enqueue to event) ran in front of every draft's first graph. With the 5090 spans of
speedtrain-ab (draft_committed 1.66 ms = launch 0.03 + deferred adapt 0.08 + commit.wait 0.25 + publish 0.12 + finish 1.18) the commit
is on the critical path of every round; running it beside the draft is worth up to its length per round (estimate 0.2-0.35 ms of a
15.0 ms round, not measured).

Output identity argument: the draft reads the completed window's final residual rows (verifier arena span "R"), the head ids staged in
its own mapped block, its own MTP ring and weights; it writes its own scratch, ring and mapped outputs. The commit graph reads the
window intermediates (qkv_L, h_L, gate_L, beta_L, z), writes the canonical GDN state, the QSA index images, the PLE history and the
"commit" span (verify_gdn_conv_commit_kernel, verify_gdn_step_norm_multi_kernel, verify_qsa_append_*, verify_copy_*). No span is
written by one graph and read or written by the other; neither module declares a device global. Host-side publication already ran
beside the draft's first graph, and the next window still starts only after both the commit event and the draft read-back.
The decoded ids cannot depend on which of two independent graphs ends first.

Not run on a GPU. Gate: replay logprob identity (rt-speedtrain against rt-draft-tail) and the paired A/B of scripts/e2e/decode/drafttail-ab.sh.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:20:17 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 981c7aad42 expert tier: decode reserve 300 -> 130 MiB (free VRAM at decode 563 -> 316 MiB, vanilla runs down to 315; about +90 slots)
5090, 5 x 245k session (runs/speedtrain-ab): the per-request verifier assembly takes 514 MiB (1,077 MiB free after the expert cache, 563 after),
and nvidia-smi at 10 s shows the card never had less than 563 MiB free in any turn, while vanilla Strata 0.2.6 starts with 389 MiB and
captures its windows down to 315 MiB. 700 + 130 - 514 = 316 MiB keeps the same floor. ExpertTierConfig::decode_headroom_mib() states that
arithmetic, a startup warning fires when an auto-sized configuration leaves less, and the default is pinned by a test. Laptop profiles
set their own DECODE_RESERVE_MIB (1024) and are untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:16:14 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 8c9748a301 dense weights: pack the ~700 resident weight buffers into 64 MiB slabs (-688 MiB measured rounding, about +300 expert slots)
The driver rounds every cuMemAlloc above 1 MiB up to a multiple of 2 MiB (laptop probe: 3 MiB takes 4 MiB, 2.5 MiB takes 4 MiB; the 5090
token table: 322.1 MiB takes 324 MiB). The dense-weights stage of the 5090 load ledger asked for 3,890 MiB and the driver took 4,578: 688 MiB
of rounding across ~700 matrices of 0.5-10 MiB (the 48 routers of 2.5 MiB alone lose 72 MiB). The parity audit listed it as "unaccounted".

SlabAllocator packs requests of up to 16 MiB first-fit into 64 MiB slabs (a multiple of the granule), 512-byte aligned (cuMemAlloc
guarantees 256); larger ones keep their own allocation. A DeviceSlice derefs to the ordinary &DeviceBuffer every kernel entry point takes, so
no kernel code, byte, or arithmetic changes: only buffer addresses move. DeviceBuffer gets a `borrowed` flag (an alias frees nothing and is
not charged) which the view uses; the new id-less tests pin the placement (aligned, non-overlapping, in-slab, hole filling, direct limit),
the dense mix saves the rounding in a model, and a CUDA test (ignored by default, passes on the RTX 3080 laptop) reads every view back and
checks neighbours stay intact and the context is charged only the slab.

LELEKA_DENSE_SLAB=0 restores one allocation per weight (A/B arm, rollback). The dense stage prints one summary line.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:16:13 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 bea07c3d64 vram: per-call-site device allocation ledger (LELEKA_VRAM_LEDGER=1) and a free-VRAM low-water mark
The fixed VRAM footprint of ours is 2.1-2.3 GiB above vanilla's and the load ledger could not say where: the dense-weights stage shows
4,578 MiB taken for 3,890 MiB accounted. LELEKA_VRAM_LEDGER=1 records every Context::allocate by call site (innermost workspace frames of a
backtrace), removes it on free, and prints at each `vram_note` the sites that changed since the previous note, with the bytes the driver is
estimated to reserve (allocations above 1 MiB rounded up to 2 MiB, packed below, as probed on the WDDM laptop and as the 5090 token table
shows: 322.1 MiB takes 324 MiB). Off by default; the off cost is one cached bool per allocation.

`DBG vram` lines now carry the lowest free VRAM seen so far, and a new note "decode end before disassemble" reads the card after the graph
pools and every window are captured: the real low-water mark of a request, for sizing the reserve.

scripts/dev/alloc-granularity-probe.py is the offline ctypes probe of the driver's rounding.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:14:22 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 fcb4f02ba9 deploy: RTX 5090 profile sets LELEKA_ORIGINAL_SERVE_SEED=off (placement class, owner confirmation required)
Seed OFF is a profile setting only: the engine default (seed on) and the laptop profile are unchanged. Placement-class change, NOT bit-identical; it does not fit the strict Original
envelope (p99 <= 0.22, max <= 0.43) and neither does the control; it meets the relative criterion on 1,717 teacher-forced rows (p99 0.2500 vs control 0.2278, max 0.7567 vs 0.6751,
flips 2.10 % vs 2.59 %; limits 1.5x control and 2.8 %). Gain: 108.1 -> 137.2 tok/s decode over turns 1-4 of the frozen 245k session (3 runs per arm). Revert: remove the key or set
LELEKA_ORIGINAL_SERVE_SEED=on in the operator environment. Test: only_the_server_profile_turns_the_prompt_routing_seed_off; leleka-deploy tests 125 passed in WSL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 10:09:44 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a741f8e54e sm120: ATTN_DAILY and GU_SWIGLU default off (opt-in); paired e2e A/B showed no measurable gain
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 08:28:28 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 47707480d0 Normalize line endings to LF in files the decode-tail/sm120 branches had converted to CRLF (whitespace only)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 08:27:39 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 94af186c8c Merge claude/fix-batch-326-329 into speed-train
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 08:26:40 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 046e15fea2 Merge claude/decode-sm120-switches into speed-train
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 08:26:40 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a73d090601 kar ple cache: evict from a recency queue instead of scanning the whole row map (turn-5 decode stall)
Once the 1,048,576-slot device row cache is full, KarPleCache::gather picked the victim of every missed row with a scan of all
entries (filter + min_by_key), and assign_slots collected every entry into a Vec per prompt chunk. A decode token with a new trigram
misses its 8 trigram-head rows (input_hash::rows), so it cost 8 full scans: ~53 ms per such token in window.ple at turn 5 of the
245k session (the cache fills only then), against 0.14 ms before.

Residents keeps the row map plus a queue of (age, row) items, pushed at every age change and valid while the map still holds the
row at that age. oldest() reads the front of the queue: O(victims + skipped), with the full scan only as the fallback when the
queue gives fewer rows than asked (the caller then refuses the chunk, as before). The planning and publishing of a gather are now
the pure functions plan_gather/publish_gather so the tests drive the production code.

The cache only decides which slot holds which row, so the decoded values are unchanged. Tests: gather victims, slots and final state
equal to the scan implementation on random sequences (4 cache sizes, 6000 gathers each, every gathered row is its own row); chunks
and gathers interleaved keep every row in its own slot and every victim among the oldest untouched rows; eviction in a full cache of
200,000 rows examines <= 40 items per miss (the scan: 200,000); the queue stays bounded.
Measured (laptop, release, full 1,048,576-row cache): old scan 7.3 ms per missed row, queue 61 ns (ignored timing probe).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 03:27:11 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 6fd2e897d2 kar ple cache: profile spans around the archive read and the device scatter/decode
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 03:14:06 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 d6aee34af4 sm120 ATTN_DAILY for the MTP draft step: opt-in LELEKA_SM120_ATTN_DAILY_MTP=1 (default off, not run on the GPU yet)
The draft step attends over the 32,768-cell MTP window (512 chunks, one query): with the opt-in, the Original chunk kernel and chain_qsa_decode_merge_n of that
step become sm120_attn_daily.ptx's leleka_qsa_decode_chunk_daily / leleka_qsa_decode_merge_v2 (module slot 22 after the chain slot; the window_ids pre-launch
keys on the new chunk entry too). sm120_probe `attn512` byte-compares the pair against the Original on the draft shape and times them; it has not been run
yet (no GPU slot), so the switch stays default off.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 03:04:43 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 321c233539 sm120 switches: a card below compute capability 12.x never takes a switch; sm86 manifest records the two new PTX as not built (sm86-feature tests pass)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 02:59:24 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 bb47b296c0 serve: plan and queue the adaptive swaps while the GPU runs the draft, not before the commit (LELEKA_SERVE_ADAPT_DEFER=off restores the earlier order)
begin_adaptation (choose_swaps over 24,576 counts, up to 96 span lookups and swap queueings, the count decay) ran on the host between the window and the commit/draft launch:
0.6 ms on an adaptation round, 0.15 ms per round on average, during which the GPU sat idle. The host now records the round at begin_adaptation and runs the same work right after
launch_draft (span round.adapt_deferred), at the latest at join_adaptation, always before the next round's apply_pending. The decision inputs (counts, residency) cannot change in between,
so the swaps are the same ones in the same order; only the host time they take moves into the draft's shadow. Not yet measured on the 5090.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 02:24:02 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 359b4b5a6a residency: the seed row cap is an experimental setting, not a default (orchestrator: placement-class change, no quality gate yet)
LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS stays available (default 0 = no cap, behaviour unchanged); the earlier commit's default of 4096 is removed and the docs say so.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 02:10:28 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 5ef2c6eb7a residency: no prompt-routing seed for a prefill that routed more than 4096 rows (LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS, 0 = no cap)
At 45k-247k prompt tokens the seed (default on, keep 0) replaced the ranked profile's resident set by the prompt's top experts and cost 25-35 % of decode on the frozen
245k session: VRAM share 80-85 % against 93-96 % with the seed off, windows 0-20 serving ~240 CPU + ~245 PCIe experts against 23-79 + 13-60, 17.5-20 against 13.4-15.4 ms per round,
107-110 against 132-149 tok/s (turns 1-4; one run each, bin-e2e4, upstream profile). Behaviour for prompts up to 4096 routed rows is unchanged. Placement-only; greedy ids can differ (GPU/CPU rounding).
Not yet measured with this binary; the paired evidence is the env switch run of the same code path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 02:08:26 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 75f166c9ba sm120 decode switch SIDE_MIXER (GDN part): gates and gate projection on side streams of the verify window graph (off by default until its gates pass)
Upstream STRATA_SIDE_MIXER=2, GDN half: each GDN layer's alpha/beta gates (gdn_alpha_beta) and gate projection (mmvq GdnGate) are issued on two side
streams that fork from the capture stream right after the q8_1 quantization (before the qkv projection) and join before the recurrence; no kernel changes,
only the dependency edges of the captured graph. OriginalCapture owns the side streams and their fork/join events (created before cuStreamBeginCapture
for a VerifierWindow capture when the switch is on, destroyed after the capture ended) and hands out the side stream from stream_handle() between
side_fork(i) and side_end(i). Not in a split (two-group) window, as upstream. The QSA half of upstream's switch (indexer chain, queries chain) is not ported.

Switch: policy.side_mixer, LELEKA_SM120_SIDE_MIXER=0|1, replay arm flags !side / !noside. Default OFF: no identity or timing result yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:52:15 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 0a3cda3769 residency: choose_swaps selects the victims it can pair instead of sorting every resident expert (same swaps, same order)
Per layer only min(candidates, residents) victims can pair; select_nth + a sort of those, with (value, expert) as the total order (= the earlier stable sort), and the
per-layer vectors are reused. Test: 40 random usage/resident cases with ties against the kept reference implementation, identical swaps and order for max_swaps 1/5/96/4096.
Micro timing (laptop, synthetic 46 % resident): 580 -> 480 us per call; one call per adaptation (every 4th round). Not measured on the 5090.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:52:08 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 1c5a6c7378 residency: profile spans inside begin_adaptation (choose, queue, arm, decay)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:44:50 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 ee4f261775 cuda-driver: chunked persistent page list for MTP ring snapshots (the per-round snapshot copied every page Rc)
finish_original_graph_mutation built the next snapshot's page vector by cloning one Rc per page below the first changed one: 65,536 clones at 256k per
round, and the same number of decrements when the previous snapshot was dropped. Pages are now held in chunks of 256 behind Rc; a new snapshot shares every
whole chunk and copies at most one partial chunk plus the new pages, so the per-round cost no longer grows with the context. Contents and lineage identical
(unit tests: get/iter equal the vector, prefix pointer-identical, whole chunks shared). Not yet measured on the 5090.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:42:28 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 9750539d4d STRA-329: native-cpu-expert AVX2 IQ4_XS multi-token route, fused Q2_0 correction, KAB1 ext case set
Confirmed against the C++ in engine/strata and fixed:
- rust_native_general.rs group_dot_bytes_policy omitted the `gu == 23 && !avx512` multi-token branch of
  native_expert.cpp native_gu_rows (`nt >= mt_min && (iq512_supported || (!cpu512 && iq256_supported))`);
  rust_pool.rs had it since STRA-324. The choice is now one function, gu_multi_route, shared in shape with the
  pool. Regression: a differential test (re-runs itself with STRATA_FORCE_AVX2=1 on an AVX-512 CPU) fails
  with a 1-ULP difference on the old code, plus a routing-table test.
- rust_legacy.rs row256 (STRATA_CPU_YMM=1 on an AVX-512 CPU) now fuses `corr += d*(hx0+hx1)` like expert.cpp
  row_dot (line 242) and row_dot_multi (line 294) under GCC -mfma. Regression: scalar model, fails on old code.

NOT changed, unconfirmed (need the pinned ggml source, which is not in the repo): rust_kq.rs small_dot
`sums += m*s`, rust_k_blocks.rs mins_sum, rust_ggml_extra.rs iq1 scalar.

KAB1: new `--cases ext` (72 cases; the 40 of `all` are untouched) adds token counts 4-7 for the row-type list
and IQ2_XXS / IQ2_XS at 1..8 tokens; GateUpFormat gains Iq2Xxs / Iq2Xs (additive; the runtime still admits only
18/21/22/23/42). The C++ driver edits are list-only and were NOT compiled here (no ggml). 16 tokens exceed MAXT
and the KAB1 header and are not covered. New Rust-only test token_count_invariance: the first two tokens of a
group are bit-identical for groups of 2..8 tokens on all 14 gate/up x down pairs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:26:26 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 85616ca186 sm120 switches: per-arm overrides and replay arm flags (!attn !noattn !gus !nogus) for in-process identity and A/B arms
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:23:34 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 0765a20958 sm120 decode switch GU_SWIGLU: fused expert gate/up + SwiGLU + q8_1 (upstream native_gu_swiglu_kernel) in the verify window (default on for cc 12.0)
Replaces window_moe_gu_<T> + swiglu_entries_kernel + quantize_q8_1_kernel of every routed-expert group launch (VRAM and PCIe tier) by one launch of upstream's
native_gu_swiglu_kernel (16-lane sub-warp rows, gate and up row at once) for the gate/up types 16 17 18 21 22 23 at n_embd 2560, n_ff % 32 == 0; every other
format keeps the three-kernel plan. New sealed asset sm120_gu_swiglu.cu (group sm120-decode) textually includes sm120_iq_prefix.cuh, the pinned
iq_kernels.cu up to the dequant banner (generated and checked by scripts/decode-sm120/make_iq_prefix.py; the whole file would instantiate 24 MB of PTX).
Kernel parameter: upstream's 88-byte NativeExpertLayout (the window's 64 bytes + tail_off, had_block, d_signs = 0).

Switch: policy.gu_swiglu, resolved at window recording from the card (cc 12.0), LELEKA_SM120_PERF=0 and LELEKA_SM120_GU_SWIGLU=0|1.

Model-free probe (tools/decode-sm120/sm120_probe.cpp gu, RTX 5090): the q8_1 blocks the down kernel reads are byte-identical to the old three-kernel path in
30 cases (types 16 17 18 21 22 23, 1-8 rows, 1-40 groups, 1-7 entries a group, random blobs with valid block scales); per layer at 4 rows 20.9 -> 14.2 us (16),
29.8 -> 20.7 us (18), 24.9 -> 19.6 us (21), warm L2. Types 29 and 42 are not probed and not routed to the new kernel. Not yet measured end to end.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:20:32 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 ea657e3eb5 cuda-driver: LELEKA_MTP_SNAPSHOT_MEMO=off restores the full page scan (A/B control for the snapshot validation memo)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:12:19 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 0ca709cad1 sm120 decode switch ATTN_DAILY: upstream pre75 attention chunk + merge v2 in the verify window (default on for cc 12.0)
Ports engine/strata qsa_decode_attn.cu attn_chunk_kernel_pre75<mode 1, NC 2> and attn_merge_v2_kernel<16> as sm120_attn_daily.cu (new sealed asset,
group sm120-decode) and selects them in QsaWindow::decode_attention when policy.qsa.attn_daily is set. The policy bit is resolved at window recording
from the card (cc 12.0), LELEKA_SM120_PERF=0 (whole set off) and LELEKA_SM120_ATTN_DAILY=0|1 (wins in both directions, any card).

Model-free probe tools/decode-sm120/sm120_probe.cpp on the RTX 5090: chunk partials, merge(old) of both partial sets and merge_v2 are byte-identical to
the sealed Original kernels on 66 cases (T 1,2,4,5,6,8 x n_ids 2051..0, masked pages, two score ranges). Per call at T=4: chunk 29.8 -> 20.3 us,
merge 6.5 -> 2.9 us (warm L2, graph-timed); 12 QSA layers per window. Not yet measured end to end.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:07:31 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 286c2538ef cuda-driver: remember that an immutable MTP ring snapshot was validated (validate_snapshot scanned every page, several times per round)
validate_snapshot walked all end/4 pages (65,536 at 256k) and checked four run lengths each, and the speculation round called it about seven
times (checkpoint_draft, launch ring, launch_inner, begin/finish mutation, transition ring). The snapshot is immutable, so the answer is
memoized in a Cell; a snapshot built from a validated prior plus freshly sized pages (finish_original_graph_mutation) is born validated.
No numeric change. Not yet compiled on Linux (the driver is cfg'd out on Windows) and not measured.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:03:28 +01:00