Commit Graph
437 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Opus 5.5 858f42001e docs(serve): job 804 record (shared window modules, reverted executable reuse)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 00:13:51 +02:00
Pavlo RatushnyiandClaude Opus 5.5 a9f67649ee fix(serve): default --pcie-frac 0.55 only over a pinned expert bank
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>
2026-10-17 00:01:47 +02:00
Pavlo RatushnyiandClaude Opus 5.5 c45bcaafd7 Revert "perf(serve): update the previous verifier's graph executables instead of instantiating anew"
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>
2026-10-16 23:17:36 +02:00
Pavlo RatushnyiandClaude Opus 5.5 973e0d2fdf feat(serve): --dump-routing for the expert-cache profile (LELEKA_ORIGINAL_SERVE_DUMP_ROUTING)
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>
2026-10-16 21:58:46 +02:00
Pavlo Ratushnyi 7e930efc91 Merge branch 'claude/port-gpu-bringup' into claude/round-overhead 2026-10-16 21:56:41 +02:00
Pavlo RatushnyiandClaude Opus 5.5 cdf284c9c3 docs(serve): round-overhead A/B record (jobs 800-803)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 21:56:41 +02:00
Pavlo Ratushnyi 0850cfe272 Merge branch 'claude/prefill-throughput' into claude/port-gpu-bringup 2026-10-16 21:45:43 +02:00
Pavlo Ratushnyi b075aad4d6 Merge branch 'claude/round-overhead' into claude/port-gpu-bringup 2026-10-16 21:45:42 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3eb74054e0 perf(serve): wait for the adaptive tier's swaps at the round start
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>
2026-10-16 20:54:11 +02:00
Pavlo RatushnyiandClaude Opus 5.5 f2c5f5eb0e perf(serve): router lookahead opt-in (LELEKA_CPU_POOL_LOOKAHEAD=on)
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>
2026-10-16 20:14:03 +02:00
Pavlo RatushnyiandClaude Opus 5.5 6fa92c13e4 perf(serve): update the previous verifier's graph executables instead of instantiating anew
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>
2026-10-16 19:45:42 +02:00
Pavlo RatushnyiandClaude Opus 5.5 57c2558961 perf(serve): share the verify window's sealed modules across the per-request verifiers
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>
2026-10-16 19:42:09 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ae02262c08 perf(cpu-expert): specialise the AVX-512 IQ, Q2_0 and the IQ4_NL row kernels on format and token count
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>
2026-10-16 19:36:35 +02:00
Pavlo RatushnyiandClaude Opus 5.5 4726afa27e perf(cpu-expert): pin the host loop once to the first physical core (session.cpp SessionLoopScratch)
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>
2026-10-16 19:32:17 +02:00
Pavlo RatushnyiandClaude Opus 5.5 7c584c253a perf(serve): router lookahead for the file-mapped expert source (expert_source.cpp RouterLookahead)
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>
2026-10-16 19:28:31 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e4af9a643d perf(serve): one source fence per layer group for the CPU and PCIe experts
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>
2026-10-16 19:24:31 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e9b8a5e8b6 perf(prefill): enqueue the stream's copies on the calling thread, under the GDN kernel batches
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>
2026-10-16 19:24:11 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3e8e10ed5f perf(serve): default --pcie-frac to the Original's 0.55 with the copy kernel
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>
2026-10-16 19:20:53 +02:00
Pavlo Ratushnyi 8b544a7c5f Merge branch 'claude/port-gpu-bringup' into claude/round-overhead
# Conflicts:
#	crates/leleka-runtime/src/qwen_forward/original_serve_host.rs
#	crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs
#	docs/original-serve.md
2026-10-16 19:19:48 +02:00
Pavlo Ratushnyi 064e309f9b Merge branch 'claude/port-gpu-bringup' into claude/prefill-throughput 2026-10-16 19:19:11 +02:00
Pavlo RatushnyiandClaude Opus 5.5 468f34e1f5 test(serve): long-context smoke writes its prompt ids for the Original (LELEKA_ORIGINAL_SERVE_LONG_IDS_DIR)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 19:19:11 +02:00
Pavlo RatushnyiandClaude Opus 5.5 f845d86f47 merge: claude/pool-zero-copy (direct CPU expert pool: borrowed expert bytes, one dispatch per group, one-time admission, mmap page prefetch)
5090 decode mean 18.4 -> 56.5 tok/s on 6 prompts (verify window 169.5 -> 54.5 ms); laptop RTX 3080 mean 2.74 -> 8.10 tok/s
(Original 8.15). Real-model crosscheck: 4320 groups / 57556 expert rows, 0 differing floats. LELEKA_CPU_POOL=legacy keeps the
old path for A/B, =crosscheck runs both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 17:56:35 +02:00
Pavlo RatushnyiandClaude Opus 5.5 219e32a211 diag(serve): profile graph capture vs instantiate time of the verifier and the MTP drafter
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>
2026-10-16 17:40:17 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3fe7888262 Revert "perf(serve): refill the prompt's lent expert slots beside the window capture"
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>
2026-10-16 17:39:08 +02:00
Pavlo RatushnyiandClaude Opus 5.5 80627bc86d perf(prefill): prefill.cpp stream_all issuer for registered expert banks
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>
2026-10-16 17:31:29 +02:00
Pavlo RatushnyiandClaude Opus 5.5 84983abdb2 perf(prefill): stage the initial rows in one pass per buffer
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>
2026-10-16 17:31:29 +02:00
Pavlo RatushnyiandClaude Opus 5.5 d9313a95d3 test(driver): device proof of the PCIe span copy (staging layout and ptr2 rebase)
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>
2026-10-16 16:27:26 +02:00
Pavlo RatushnyiandClaude Opus 5.5 4780170fe3 perf(prefill): per-command timing of the GDN prompt producer; prefill benches can read from the empty prompt
- 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>
2026-10-16 16:09:34 +02:00
Pavlo RatushnyiandClaude Opus 5.5 bad3c6ebdb perf(serve): refill the prompt's lent expert slots beside the window capture
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>
2026-10-16 15:52:38 +02:00
Pavlo RatushnyiandClaude Opus 5.5 fdb1071783 perf(prefill): profile spans for input embedding/PLE and row init sources/upload
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:52:23 +02:00
Pavlo RatushnyiandClaude Opus 5.5 f6b48226e3 perf(prefill): reuse the GDN next-state finite guard across layers and chunks
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>
2026-10-16 15:51:00 +02:00
Pavlo RatushnyiandClaude Opus 5.5 447276fb42 merge: claude/prefill-throughput (row validation once per chunk, per-process expert scale check, prefill stager for mapped experts, PREFILL-PROFILE tracing)
5090, 16000-token prompt: 311 -> ~1435 tok/s at chunk 2048 (greedy tokens identical), ~2890 tok/s at chunk 8192.
Laptop RTX 3080 (mapped experts): prefill 0.7-3.1 -> 4.5-9.4 tok/s, identical output. Default chunk stays 2048.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:46:01 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ef06b77ad9 docs(prefill): mark the GDN state staging as a likely, unmeasured cause
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:45:32 +02:00
Pavlo RatushnyiandClaude Opus 5.5 125f7820fb docs(prefill): profile, fixes and before/after prefill numbers (RTX 5090, RTX 3080 laptop)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:45:25 +02:00
Pavlo RatushnyiandClaude Opus 5.5 0a1d4e771e perf(serve): retain each admitted expert's bound route instead of rebinding it per call
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>
2026-10-16 15:30:35 +02:00
Pavlo RatushnyiandClaude Opus 5.5 a75e8a8fd3 perf(serve): enqueue the MTP draft behind the verifier commit (generate.cpp order)
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>
2026-10-16 15:16:30 +02:00
Pavlo RatushnyiandClaude Opus 5.5 6f0d4e0f96 diag(serve): trace the PCIe span validation of the VRAM tier separately (pcie_spans, pcie_experts)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:13:59 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e618fa1b29 perf(serve): publish the twelve QSA witnesses per round without context synchronizes
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>
2026-10-16 15:11:55 +02:00
Pavlo RatushnyiandClaude Opus 5.5 cdb44943cb perf(serve): stage the window's PCIe share with the Original's copy kernel (pcie mode 2)
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>
2026-10-16 15:11:55 +02:00
Pavlo RatushnyiandClaude Opus 5.5 59c9102cd5 merge: claude/conversation-cache default on (--prompt-cache 6 as in the Original), coverage smoke and chunk-aware equality checks
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>
2026-10-16 15:08:48 +02:00
Pavlo RatushnyiandClaude Opus 5.5 75930fb8a1 docs(serve): conversation cache on by default; coverage (jobs 412/413) and the chunking finding
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>
2026-10-16 15:08:22 +02:00
Pavlo RatushnyiandClaude Opus 5.5 d166004a10 diag(serve): LELEKA_SERVE_PROFILE host phase profile of the Original serve path
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>
2026-10-16 14:55:01 +02:00
Pavlo RatushnyiandClaude Opus 5.5 51326a5880 chore(prefill): drop an unused import of the host stager
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:46:36 +02:00
Pavlo RatushnyiandClaude Opus 5.5 a9e1d0a3e6 feat(serve): conversation cache on by default (--prompt-cache 6, as in the Original)
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>
2026-10-16 14:02:50 +02:00
Pavlo RatushnyiandClaude Opus 5.5 15a755cadf test(serve): compare resumed requests only where the prefill is chunked alike
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>
2026-10-16 14:02:50 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ae283e6423 perf(prefill): stage pageable experts through page-locked buffers (prefill.cpp Stager)
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>
2026-10-16 13:21:32 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e32c39090a perf(serve): prefetch a file-mapped expert source on all pool workers before admission and compute
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>
2026-10-16 13:19:48 +02:00
Pavlo RatushnyiandClaude Opus 5.5 0bd4ebe529 merge: claude/port-gpu-bringup 3e05437 (laptop profile: mapped expert source, resident RAM budget) into claude/pool-zero-copy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:15:54 +02:00
Pavlo Ratushnyi d0c69fcf21 Merge branch 'claude/port-gpu-bringup' into claude/prefill-throughput 2026-10-16 13:12:34 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3e05437bf2 merge: claude/laptop-profile (RTX 3080 laptop: mapped experts instead of a 50 GB RAM copy, KAR read-only file source, resident RAM budget, regenerated sm_86 resolver image, paired bench harness, docs/laptop-profile.md)
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>
2026-10-16 13:10:56 +02:00