The 0.55 default (3e8e10e) also applied to the laptop's pageable low-RAM
mapped bank, whose PCIe share is DMA'd from pageable pages (the copy kernel
needs aliases): the coordinator's 3080 runs decoded at 6.66 tok/s against
~10-12 with 0. Unset, the share is now 0 for a pageable bank and 0.55 for a
registered one; an operator's LELEKA_ORIGINAL_SERVE_PCIE_FRAC applies as given.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job 804 (RTX 5090, rt-b8): with the parked executables on (the default),
both arms broke the stack in the smoke's cancellation sequence (a window
failed with CudaExecution after a few requests, the stack went Broken)
while every arm with LELEKA_GRAPH_EXEC_REUSE=off passed. The executable
update path is withdrawn; the instantiation it would have saved is ~21 ms
per request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
generate.cpp's --dump-routing writes every routed expert so tools/make_profile.py
can rank the (layer, expert) pairs a workload uses; the expert-cache profile then
decides what starts resident. The port's tier writes the same records (layer,
k, ids, weights) for every decode window row it serves (prompt routing is not
traced). Off unless the variable names a file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job 803 (static vs adaptive tier, paired): with the context synchronizes
gone from the publication, the adaptive swap copies (96 experts, ~0.2 GB
every 4 rounds) overlap the next window and its CPU share; the CPU pool
time per round rose by ~1-2 ms and the fenced publication lost against the
serial one with the tier adapting (62.6/63.8 vs 63.7/64.4 tok/s), while it
was neutral to positive with static residency. The swaps now land before
the next window (wait_swaps at apply_pending, after the draft): what the
synchronizes used to enforce, made explicit, and the resident set of a
window no longer depends on when the copies finished.
LELEKA_SERVE_SWAP_WAIT=off polls as generate.cpp's apply_pending(false).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Laptop A/B/A (RTX 3080, mapped experts, 3 prompts x 2 passes, 128 tokens, warm page cache, same binary
7c584c2): decode tok/s on 7.21/8.54/11.49/9.44/10.00/12.94 and 8.17/6.20/10.47/8.29/9.92/12.98 vs off
9.29/8.97/11.82/8.15/9.82/13.53 (means 9.94, 9.34 vs 10.26), identical outputs in all three arms. The
thread warmed ~175k experts and spent ~11 s of CPU on router GEMVs per run on an 8-core CPU that already
runs 7 workers and the host. Off by default until a cold-cache measurement shows a gain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each request's verifier instantiated its seven window/commit graphs again
(~19 ms of the ~110 ms assembly on the 5090, job 803 profile). A drained
verifier executable is now parked with its context (at most 16, destroyed
with the context) and the next verifier's graph of the same policy and node
count is applied to it with cuGraphExecUpdate; when the driver refuses the
update (topology or node kinds differ) the parked executable is destroyed
and the graph instantiated as before. LELEKA_GRAPH_EXEC_REUSE=off keeps the
per-request instantiation (A/B control).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every request's verifier bank loaded (and SHA-256 checked) the window's
sealed PTX modules again, ~1 MB of PTX for the expert kernels alone, and
unloaded them at the end of the phase. The context now keeps the modules
an earlier bank loaded (Context::window_modules, unloaded with the context)
and later banks share them: the same sealed image and entries, admitted
once. LELEKA_WINDOW_MODULE_CACHE=off loads per bank as before (A/B control).
The serve profile reports record.modules (window module loading inside
record_all).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iq_avx512.cpp templates row_dot<TY, NT>; the Rust kernels looped over a runtime token slice with the
format matched per half block. dot_multi512, rust_q2::dot512 and iq4nl now dispatch once per row to
const-generic bodies (format x 1..8 tokens) with the same operations in the same order per token.
Proof: tests/borrowed_group_parity.rs prints a digest of every output bit of its 120 synthetic groups (all
10 format pairs, 1..8 rows); the digests of the previous and this build are identical. Model-free group
cost on the i9-11900H laptop, 7 workers: 226/250 -> 206/218 ms per 48-group round.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The direct pool's caller drains beside the workers, which are pinned to every physical core but the
first. Like the Original's session loop, the caller is now pinned once (on its first group) to that free
core and its previous mask is restored when the pool drops; unpinned, its drain and doorbell spin can
land on a worker's core or SMT sibling (the Original measured 26.9 vs 36.3 GB/s for this). Placement
only: no arithmetic changes. LELEKA_CPU_POOL_PIN_HOST=off is the A/B arm.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the direct CPU tier starts layer l over a mapped bank, a background thread applies layer l+1's
router (BF16 host copy) to layer l's MoE input, takes each row's top-10, drops the experts the VRAM tier
holds for l+1 and advises their pages (MADV_WILLNEED) so the reads are in flight while layer l computes.
Advice only: what is computed, and how, is unchanged. Started once on the first mapped group (routers and
per-layer bank layout loaded then); a prediction still running makes the next submit skip. Off with
LELEKA_CPU_POOL_LOOKAHEAD=off (A/B arm); the resident source never starts it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
with_moe_routed_group_source opens one routed source loan per layer group (one size observation at
begin and one at finish) and MoeRoutedSourceScope::retarget moves it from job to job with the same
member checks a fresh per-expert scope applies; inside, every job is still validated individually
(binding, its actual gate/up/down descriptors and formats, its bank spans, first-use row admission) with
the same refusals. The direct CPU tier opens its group this way, the mapped-source prefetch runs inside
the same fence, and the VRAM tier's PCIe sources of a group share one fence too.
LELEKA_CPU_POOL_FENCE=job keeps one fence per job (A/B arm).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The issuer thread of 80627bc made the prompt path slower (job 707: 1,083
vs 1,413 tok/s at chunk 2048, 2,419 vs 2,624 at 8192): every stage of the
compute path drains with cuCtxSynchronize, which also waits for the copy
stream, so each drain waited while the free-running issuer filled the ring.
The stream (same stream_all order, slots and events) is now driven by the
calling thread only: a layer's MoE queues its own entries up to the ring
(as the per-layer ring did), and the GDN prompt producer calls
prefetch_point right after its last drain before its sync-free kernel batch,
which queues as many of the upcoming MoE layer's entries as 90% of its
previous batch window covers at LELEKA_PREFILL_PCIE_GBPS (45), so those
copies run under the GDN kernels and are complete by the batch's closing
drain. Same bytes, slots, gathers and products.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job 802 (RTX 5090, paired a/b/b/a, one binary, copy-kernel staging, expert
tier on, 6 prompts x 2 passes x 128 tokens): pcie_frac 0 decodes at 41.9 /
42.7 tok/s mean, 0.55 at 62.2 / 63.6 (+48%), TTFT unchanged (1214/1209 vs
1212/1207 ms). Placement differs between the two (PCIe experts run on the
GPU, which rounds differently from the CPU pool), so outputs differ as
documented for the tier; the tier itself stays opt-in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
capture_owned sums its host time (capture, then instantiate + upload) per thread;
the serve profile reports record.capture/record.instantiate for the window and
commit graphs and mtp.capture/mtp.instantiate for the drafter's per-request
round programs. Docs: the verified-window publication order, the per-request
verifier analysis and the PCIe copy kernel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job 801 (RTX 5090, paired, same binary): TTFT unchanged (1215 vs 1218 ms
mean over 12 requests). The ~49 ms refill is host time, not copy time:
queueing 720 slots spends it in original_expert_spans' per-call scan of
every expert's blocks, so moving it into the capture only moved it.
The cached span admission of claude/pool-zero-copy (admitted_expert) is
what would shorten it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the first MoE layer of a chunk of at least 1024 rows, an issuer thread
copies every expert the arena cache does not hold, layer by layer in id
order, from the page-locked bank into the copy ring (entry k in slot
k % ring), the Original's stream_all with its D-5 issuer thread. The copies
for the next layers therefore run while the mixers, GR reads and routers
compute instead of only during each layer's MoE (the skip-DMA diagnostic of
job 705 put the DMA at ~0.77 s of the 1.1 s ring of an 8192-token chunk).
The issuer only enqueues (no compute), waits for entry k - ring's 'used'
event before reusing a slot and keeps at most LELEKA_PREFILL_STREAM_INFLIGHT
(4) copies queued, so the compute path's context-wide synchronizations wait
for a few copies at most. The per-layer copy ring consumes the stream:
gather waits for the entry's 'copied' event, records 'used', and entries a
layer does not route are released in order. Every routed entry is checked
to copy exactly the bytes its admitted span names. The stream ends with the
last layer, on any layer failure and on every forward error before the
transaction rolls back. Same bytes into ring slots, same gather and grouped
MMQ: products unchanged. LELEKA_PREFILL_STREAM=0 keeps the per-layer ring;
pageable banks keep the HostStage path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PromptDeviceRows::initialize concatenated every row's 10240 stream values
and 2560 PLE values into two host vectors, then the driver scanned them for
non-finite values and converted them to bytes: three passes over ~420 MB at
an 8192-token chunk. The driver's initialize_rows takes the row slices and
builds the two byte buffers in one pass each, with the same finite refusal
and the same device bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Root-only (LELEKA_VERIFY_WINDOW_GPU=yes): verify_fetch_spans_kernel and
verify_rebase_ptrs_kernel with pcie_stage's launch geometry stage five
experts' gate/up/down spans into staging slots exactly as the DMA path lays
them out and point ptr2[q] at each slot, leaving later table entries alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- LELEKA_BRINGUP_TRACE + LELEKA_PREFILL_PROFILE_SYNC: the GDN prompt producer
drains after every kernel/GEMM and a PREFILL-COMMANDS line per chunk sums
them (driver command_profile).
- LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA=1 (EXPERIMENTAL diagnostic, wrong
outputs): the copy ring moves no expert bytes, to time its compute alone.
- The long-context smoke reads every request from the empty prompt unless
LELEKA_ORIGINAL_SERVE_LONG_CONVERSATION=yes (the stack now defaults to
--prompt-cache 6); the laptop bench takes LELEKA_LAPTOP_PROMPT_CACHE=0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the expert tier's prompt loan, every request refilled the lent slots
(720 on the 5090 profile, ~49 ms of copies) at the end of the prompt phase
and only then assembled the verifier, whose window/commit graph capture is
~110 ms of host work. The refill is now queued once the canonical GDN image
is uploaded (assemble's after_prepare hook), runs during the capture, and is
completed (sync_queued) before the first window reads the cache, so every
window sees the same resident set as before. A decode phase that stops
before the capture refills as before. LELEKA_SERVE_REFILL_OVERLAP=off keeps
the previous order (A/B control).
The verifier itself is still assembled per request: its window resources
borrow the stack's dense/MoE caches, which the prompt path mutates, and the
QSA owners move one way into its journal (see docs/original-serve.md).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every GDN layer of every prompt chunk created a GdnStateFiniteGuard, which
loads its CUDA module (cuModuleLoadData) and allocates its status word, and
closed it again at the layer's end. The dense cache now keeps up to four
idle guards: a layer borrows one and gives it back after a clean finish; a
failed guard is closed, never reused. The guard resets its status word on
every check, so reuse changes no result. PREFILL-PROFILE also splits the
GDN mixer into state_in / compute / state_out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
admitted_expert bound a fresh top-10 route (moe_expert_weights: artifact borrow, topology and seven tensor
descriptors) for every CPU and PCIe expert of every group. The route is immutable bound metadata, so it is
now kept beside the admitted spans; every use still opens the source scope, which checks the route against
the binding and layer and validates the actual gate/up/down descriptors and bank spans.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
draft_committed settled the commit first: the host waited the commit event,
took and published the twelve witnesses, and only then launched the draft,
so the commit's GPU time, the publication and the draft ran back to back.
generate.cpp enqueues the draft on the commit's stream and waits only for
its tokens.
The drafter's draft_from_verifier is now also available in two halves
(launch_from_verifier: everything up to the first graph's enqueue, with the
draft stream waiting the verifier's pending commit event on the device;
finish_from_verifier: the read-back, the chain and the ring mutation's close).
The serve port launches the draft against the branch the commit will publish
(original_origin_after, validated with the session still at the window's
origin), publishes the session while the draft runs, and finishes the draft
only once the session holds exactly that origin. The device sees commit then
draft, as before; draft_from_verifier itself is launch + finish unchanged.
LELEKA_SERVE_OVERLAP=off keeps the serialized order (A/B control).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
publish_committed took the twelve resident QSA index checkpoints one by one:
each a cuMemGetInfo, a cuMemAlloc and a resident transfer that first
synchronizes the whole context, and the superseded checkpoints were freed by
cuMemFree; publish_original_verified_rows then synchronized the context once
more. Those context synchronizes also wait for work the Original runs beside
the commit (the adaptive tier's swap copies).
After the commit event the verifier is the only writer of the twelve images,
so the checkpoints are now one fenced batch (OriginalVerifier::
checkpoint_committed_qsa_all: 48 stream-ordered copies, one stream drain),
checkpoint buffers are pooled per index (a dropped checkpoint returns its
2564 bytes instead of cuMemFree), and the rows are published with
publish_original_verified_rows_fenced. Same copies of the same bytes.
LELEKA_SERVE_PUBLISH=serial keeps the previous path (A/B control).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
generate.cpp's default --pcie-mode is the copy kernel: the plan names each PCIe
expert's device alias, flag B rises at once, and the window graph copies the
blobs into staging after wait B (fetch_blobs + rebase_ptrs), so no host CUDA
call sits inside the window. The port staged the three per-tensor spans by
DMA instead (three or more cuMemcpyHtoDAsync per expert plus a host function,
issued by the pool thread between flag A and the CPU's own share).
The port's source keeps an expert as three registered spans, so the new
verify_fetch_spans_kernel (original_verify_window_pcie.cu, fetch_blobs_kernel's
uint4 grid-stride copy over three aliases per expert; nvcc 13.2.86 sm_120 PTX,
sm_86 companion) writes gate|up|down into staging slot q exactly as the DMA
path did, and rebase_ptrs points ptr2[q] at it: the staged bytes and pointers
the PCIe expert groups read are unchanged.
LELEKA_ORIGINAL_SERVE_PCIE_MODE=auto|dma|kernel (--pcie-mode): auto takes the
kernel when the bank has device aliases (not the pageable low-RAM bank), dma
keeps the previous path. The recorded mode and the per-layer span lengths are
fixed in the verifier bank; publish_gpu_plan refuses a span of another length.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job 413: cancellation, periodic/root/turn checkpoints, reread mode and fallbacks pass; resumed requests are token-identical
to full reads whenever both cut the prompt at the same chunk boundaries (near-tie flips otherwise, as in the Original).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resumed requests are token-identical to reads that cut the same prefill chunks;
different chunks (a resume point, a root boundary only cut from 0, cache on vs off)
can flip a near tie, as in the Original. The stack is deterministic within and across
processes for identical inputs and chunks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Named wall-clock spans (request reset, prefill read/refill, verifier assembly
steps, per-round window/commit/publish/draft phases, the GPU pool's split,
PCIe spans and plan publication) summed per request and printed as one
DBG profile line. Off by default; one cached boolean test per span when off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StackConfig::new and OriginalServeOptions now enable the cache with the Original's
settings; --prompt-cache 0 turns it off. Tests pin the defaults. Real-model coverage:
jobs 411/412 (and 413 for this exact tree).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job 412 showed every resumed request whose prefill is cut into the same chunks as the
full read (root fallback, cancel then resume, and restore vs STRATA_CKPT_REREAD) is
token-identical, while two comparisons differed where the chunks differ (a resume point
the full read does not cut at; a root boundary only cut when reading from 0). The same
happens with the cache off: a full read with turn/root boundaries and one without give
different tokens. same_chunks() replays both prompt plans; equal chunks are checked,
others are reported as CONV-INFO, and at least one strict resumed comparison is required.
OriginalServeStack::resume_point() reports where the cache placed the request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a pageable, file-mapped expert bank (the laptop profile) the copy ring
copied every expert with a pageable cuMemcpyHtoDAsync on the launching
thread: the driver stages it, the mapped file is faulted in on one thread
and the GPU waits for each copy; the runtime had also rescanned every
first-seen expert's bytes for the finite admission, a second read.
The ring now keeps prefill.cpp's Stager in its copy schedule: helper
threads (4, or 32 when the experts are read in place from the model files;
STRATA_STAGER_THREADS) copy each staged expert's gate/up/down bytes, in
launch order, into a ring of page-locked buffers (16, or 4 x threads;
STRATA_STAGER_RING) and check every block scale finite on the copy; the
launching thread DMAs a buffer once it is ready and releases it when its
DMA completed (no CUDA call on a helper). Experts inside page-locked
pin_resident ranges, registered banks and arena-resident experts keep their
direct DMA. A staged expert skips the runtime's host rescan (the helpers
check the same scales). Same bytes reach the same device slots.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the mapped low-RAM source (load_mapped_expert_source, the Original's --mmap-experts) the direct CPU
tier opens every CPU expert of the group first without scanning it, then advises all their pages
(MADV_WILLNEED) and faults them in on every pool worker and the caller in one read-only phase
(expert_source.cpp prefetch on its fetch threads), and only then admits first-use experts and computes.
The resident source skips the phase. Trace slot 'fetch' times it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Laptop numbers (indicative, 3 prompts x 2): Original decode 8.15 tok/s / TTFT 7.2 s (KAR PLE), port 2.70 tok/s / 28.4 s;
both bottlenecks (serial CPU expert preparation, prompt-path expert copies) are being fixed on claude/pool-zero-copy and
claude/prefill-throughput. model-format now denies (instead of forbids) unsafe code for one audited mmap owner.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>