scripts/dev/path_to_modules.py moves each module declared with #[path] to the file the compiler looks for without the attribute, moves the children of a path-loaded file with it (such a file owns its directory like mod.rs) and rewrites include_str!/include_bytes! paths. Only the two declarations that point into the crate's tests/ directory keep their attribute. No code changes: parent files lose attribute lines. Gates that quote source paths follow: smoke-groups.json (directory patterns for runtime-gr/gdn/moe/qsa/ple/mtp; 7 real-model smokes now classify as model-assets, 3 fallback smokes now sit in their runtime group), docs/gpu-bringup.md table, docs and the qsa oracle pin path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 KiB
Plan 6g: concurrent agent sessions, time-sliced today and simultaneous decode tomorrow (feasibility, 2026-11-12)
Read-only analysis of code and docs; no GPU, no queue stub, no engine change. Owner idea (2026-11-12): sessions and telemetry let Leleka serve several agent sessions at once and be several times faster in aggregate. Owner clarification the same day: the sessions already are a queue that switches per-session caches without a full prefill. Both layers are analysed, in that order. This is a separate axis from the stage 7 metric (single-session decode tok/s); nothing here changes single-session speed except through the memory it would take.
Labels: M = measured in a document or log named; C = read from code; E = estimate by arithmetic from M numbers (the arithmetic is shown); U = unknown / guess. A number without a label is quoted from the page named next to it.
0. Result
| Time-sliced multiplexing (TODAY, in the product) | Simultaneous decode (NOT implemented) | |
|---|---|---|
| What runs | one request owns the engine from prefill to EOS; the next one queued starts after it (C: attach.rs::serve_claimed awaits serve_one; engine generation_full -> ResourceExhausted; one owner thread) |
N sessions inside one verify graph (rows of several sessions per window), or two graphs overlapped on two streams |
| Sessions' state | per-session K/V + GDN/PLE + draft ring parked in host RAM as hash-chain blocks and nodes, restored on the next request (docs/prefix-cache.md) |
N LIVE state sets in VRAM/pinned RAM at the same time (new) |
| Aggregate decode tok/s over N sessions | about the single-stream speed (M: 158-165 tok/s on LEL cells; one stream at a time). E: 0.97-1.0x of N sequential sessions | E: N=2 1.0-1.3x (central 1.1-1.15x), N=4 1.0-1.55x (central ~1.2x) of the same N sessions run one after another; not "several times" |
| Per-session tok/s while N are active | 1/N of the single-stream speed on average (the others wait), full speed while it owns the engine | each session slower than alone (joint round is longer), faster than 1/N |
| Cost of switching sessions | M: no-copy hit 1-3 ms (resume path 5.5-7 ms, A3); copy of the blocks the other session overwrote 101 ms at 98k, 175-194 ms at 172-180k tokens; E 30 ms at 30k, 250 ms at 243k. Plus the decode-graph re-record 98-109 ms per request (Q7) which is paid with or without a switch | none for switches, but a new scheduler and tier-sharing cost (U) |
| TTFT of a returning session | M: 2.3-2.8 s at 100k, 2.7-4.8 s at 180k (grid only, chunk 8192) against 28-31 s and 51-55 s cold; M: median 0.71 s, p90 1.06 s at about 70k with --prefix-cache-tail reply |
queueing wait is removed, prefill of the suffix still blocks the shared device unless chunk-interleaved |
| Wall-time gain over a single-slot engine that re-prefills on a switch | E: 2.0-2.9x at 30k, 3.5-5.5x at 70k, about 4x at 100k (section 2.4); M on the synthetic 4-session trace: sum of TTFT 1200 s -> 244 s | not applicable (starts from the time-sliced baseline) |
| Gain over N sessions served strictly one after another with warm caches | E: 1.00-1.08x (fills the 4-8 % tool/idle gaps of LEL cells; minus switch overhead 1-3 %) | E: the numbers above |
| Memory per extra session at 30-100k | host RAM 14.2 KB/token + 127 MB per kept node (M): 0.56 / 1.1 / 1.6 GB at 30k / 70k / 100k; VRAM 0 | pinned host K/V fixed at the serving context (M: 3.32 GB at 262,144, 1.66 GB at 131,072) + VRAM about 0.55-1.2 GiB (E) taken from the expert tier |
| 256k sessions | N is bounded by RAM only; 2-3 parked sessions in the usual 8-14 GiB budget | N=1 today; N=2 barely (needs about 4.4 GB RAM + 1 GiB VRAM, the host has 7-8 GB spare); N>=3 impossible as configured |
| Engine work | none (exists); missing pieces: queue order aware of cache residency, session-aware eviction, telemetry of switch cost | large: scheduler, N live session objects (the engine is Rc/RefCell, one owner thread, one set of QSA owners), kernel changes (kVerifyMaxT = 8, sealed PTX), gRPC/gateway concurrency, identity story |
| Vanilla Strata | has the same (conversation parking, on by default with an auto budget) AND an opt-in --parallel N (see 2.5) |
vanilla already has it, opt-in (docs/BATCHING.md at the pinned commit) |
Recommendation (details in section 4): do not build simultaneous decode yet. First (a) characterise what exists with two and four concurrent
Codex sessions through the gateway (about 2-3 GPU-hours), (b) take one routing dump per session for an offline expert-union simulation (about 0.5
GPU-hour), (c) optionally run vanilla with --parallel 2/4 --batch-mtp on the same card as the reference of what batching gives on this hardware
(about 1.5 GPU-hours; needs the owner's word because vanilla is not re-measured by rule). Decide after these.
Correction to the premise. Vanilla Strata is not one-request-at-a-time only: engine/strata/docs/BATCHING.md (same tree as our pin, docs/upstream.md)
documents --parallel N (1..8 slots, opt-in, default 1), --batch-mtp (one MTP proposal per slot), per-slot conversation caches and batch windows. Our
codex-compare ran vanilla with --parallel 1 (scripts/e2e/codex/compare/cmp_codex_job.sh, vanilla launch line). So "Strata does not have it" is wrong; "the
benchmark did not use it" is right.
1. Where the sessions are today (code)
- Gateway (
control-plane):POST /v1/responseshandlers are bounded bymax_in_flight_requests(default 17, 429runtime_overloadedbeyond;docs/api-contract.md"Admission lifecycle"). They enqueue on onempsc::channel(16)(serve/engine.rs,state.attach_engine(16)); an optional queue budget expires a waiting request (queue.rs). One worker task (backend_worker/attach.rs::serve) takes commands in arrival order and awaits eachserve_oneto its terminal event before taking the next. The contract text says it plainly: "The worker still executes serially ... does not implement batching". The session id (session_idheader Codex sends) is only logged (request_log.rs,SESSION_HEADERS); no scheduling decision reads it. - Engine process (
desktop-coreruntime gRPC):reserve_generationallows one active generation; a secondGenerategetsResourceExhaustedgeneration_capacity(runtime_rpc/generate_rpc.rs::generation_full). The gateway never sends it, because it serialises. - Engine (
engine-qwen35-cuda): one owner thread,command_loop->serve_generate->engine_core::request::run_request(admit, resume, prefill, decode, finish) runs a whole request synchronously. OneOriginalServeStack: one positional K/V buffer (12 QSA layers), one GDN/PLE state, one MTP draft ring, one expert tier. - The verify graph is captured per window width T = 1..8 plus a commit graph, per request, bound to that request's QSA owners, GDN image and PLE history
(
docs/experiments/decode-graph-reuse.mdsection 1; 54-62 ms capture + 27-30 ms instantiate, 98-109 ms per request, ledger Q7). A window carries the rows of ONE sequence;kVerifyMaxT = 8is compiled into the window kernels (acc[kVerifyMaxT],GMAX >= kVerifyMaxT,docs/adaptive-spec.md"Wider windows than 6"). Mean T per round is 2.7-4.1 (M: 2.74 at 245k, 4.09 in a Codex replay); 3.3-3.4 tokens per round on Codex sessions (Mdocs/e2e-run.md). Rows of two requests cannot share a graph today: the GDN recurrence, the QSA page tables and the PLE history are per sequence and the kernels index them by one base. - So today there is no batch>1 anywhere, and the only way two sessions meet is the cache switch below.
2. Layer 1: the time-sliced baseline (what the owner asked to analyse first)
2.1 What a switch costs
Mechanism (docs/prefix-cache.md, C): the prompt is read on a token grid; after each chunk the policy may keep a node (GDN + PLE host images, draft-ring snapshot,
index tails; about 127 MB at the 5090 profile) plus K/V blocks (INT8 K+V and pooled index rows, 14,208 B per token, shared by reference). A request walks the
hash chain and import_parked copies back only the blocks the live positional buffer no longer holds, installs the GDN/PLE images, re-anchors the draft ring, prefills the suffix.
| piece | measured | source |
|---|---|---|
| lookup over a 40k-186k token prompt | 29 us mean (59 us max) at 40k; 0.2 ms at 186k | prefix-cache.md sections 2, 3 |
| same session continues (buffer already holds its prefix) | 1.3 ms for a hit that copies nothing; resume path in a live run 5.5-7.0 ms (request.resume 2.2-2.9, begin_request 0.8, import_session 0.6-1.4, draft_resume_at 0.8, mtp_kv_restore 0.7, layer_index 0.4) |
prefix-cache.md section 2; step-ledger A3 |
| another session had overwritten the cells | 20-37k tokens (up to 524 MB): 34 ms mean, 43 ms max; 98k tokens (1.4 GB): 101 ms; 172-180k (2.4-2.6 GB): 175-194 ms (13-14 GB/s) | prefix-cache.md sections 2, 3 |
| 30k / 243k (not measured) | E: 0.43 GB -> about 32 ms; 3.45 GB -> about 255 ms at 13.5 GB/s | arithmetic from 14.2 KB/token |
| cold VRAM resident-window refill after an import | +0.5 to +5 %, at most 30 ms per request on identical output | prefix-cache.md section 2 |
| graph re-record + verifier assembly | 98-109 ms per request, with or without a switch (ledger Q7, fix wired behind LELEKA_DECODE_GRAPH_REUSE, off) |
decode-graph-reuse.md |
| prefill of the part the grid cannot restore (partial block + reply + new tokens) | median re-prefilled 1.6-2.7k tokens per request (about 0.7-1.1 s at 2-3k tok/s); with --prefix-cache-tail reply median prefill 706 ms, p90 1,064 ms at about 70k context. This is paid by the same session when it continues alone, so it is NOT switch overhead |
e2e-run.md 7, prefix-cache.md |
| expert tier left in the previous session's shape | not measured. The tier adapts on routing counts (up to 96 swaps per 4 windows); a different task starts on the other task's layout. Cold request 1 is -3.7 hit points against vanilla and requests 1-3 are -3.1 (hit-gap-causes H7), which is the size of a "tier not yet fitted" penalty; for alternating sessions it is U | hit-gap-causes-2026-11-11.md |
Cold prefill for comparison (M): 28-31 s at 100k and 51-55 s at 180k with 8192-token chunks (3.2-3.5k tok/s); about 1.8k tok/s with 2048 chunks (a 256k prompt is about 2.5 minutes, ledger). E: 30k about 9-17 s, 70k about 21-39 s, 243k about 75-135 s.
Net cost of one switch (E): copy 30-250 ms (30k..243k) + state install and ring re-anchor under 10 ms + window refill up to 30 ms = about 0.07-0.3 s, against a request that takes 7-10 s on a Codex workload (M: model time per request LEL ttt 9.7 s, nestng-crm 8.3 s; compare.csv). About 1-3 % of the request, before the unmeasured tier penalty.
2.2 How the queue is ordered and what N = 5..20 does to RAM
- Order: strict arrival order (FIFO
mpsc(16)), no priority, no cache-aware reordering, no preemption of a running prefill (cancel takes up to one chunk, 1.6 s at 2048, e2e-run.md). A cold 180k prefill (55 s) therefore blocks everyone behind it. A router that picks the longest cached prefix exists as a protocol (/v1/prefix_match,PrefixSummary::match_tokens) but "the router itself is not part of this work" (prefix-cache.md). - Request wait with N busy sessions (E): each request waits for the N-1 ahead, 7-10 s each, so about (N-1) x 8 s: N=5 about 32 s, N=10 about 72 s, N=20 about 150 s (and HTTP 429 beyond 17 in flight, Codex retries). Aggregate stays at one engine; per-session speed is 1/N.
- Is every request a switch? With N >= 2 sessions all busy, practically yes: the live buffer holds whoever ran last. The system prompt and tools (about 9.3k tokens, M e2e-run.md) are shared across Codex sessions, so the shared part (a 2048- or 8192-grid prefix) is never copied.
- Host RAM (M budget, E arithmetic): the cache budget is
auto= 75 % ofMemAvailableabove 4 GiB at open, 7.3-13.7 GiB measured (7.8 GiB in the 4-session trace; 13.7 GiB in job 922); during live Codex CRM runsMemAvailablefell to 7.4-8.3 GB because RSS grew 6-7 GB (e2e-run.md 7, 7d). Per session = 14.2 KB x tokens + 127 MB per node kept (a long session settles on 1-2 nodes):
| context | per session | sessions in 8 GiB | in 13 GiB |
|---|---|---|---|
| 30k | 0.43 + 0.13..0.25 = 0.56-0.68 GB | 12-14 | 19-23 |
| 70k | 1.0 + 0.13..0.25 = 1.1-1.25 GB | 6-7 | 10-11 |
| 100k | 1.42 + 0.13..0.25 = 1.55-1.67 GB | 5 | 8 |
| 180k | 2.56 + 0.13..0.25 = 2.7-2.8 GB | 3 | 4-5 |
| 243k | 3.45 + 0.13..0.25 = 3.6-3.7 GB | 2 | 3 |
So N=5 sessions at 70k fit with margin, N=10 only at the larger budget, N=20 only at about 30k. Beyond capacity the value-based policy rejects candidates and evicts the idle sessions' frontiers (M: 12 sessions growing to 184k, 13 GB budget: budget held, reuse 62.2 %, 8,212 candidates rejected, prefix-cache.md section 5); the evicted session's next request re-prefills from the last surviving ancestor, up to a full cold prefill. Retention is 60 minutes per node, displacement favours recently used sessions. Extra imports caused by switching: none beyond the block copies of 2.1; extra evictions: only through capacity, not through switching itself (a node is immutable host memory; the restore does not consume it).
- The budget competes with the engine's own RSS growth and with
--expert-source resident(about 50 GB pinned copy) on the 121 GB host;--expert-source mappedwould free tens of GiB (prefix-cache.md, 3).
2.3 Why this is not simultaneous decode (c)
The engine decodes one session at a time, so the total decode rate across sessions is the single-stream rate (M: LEL cells 158-165 tok/s; 184 tok/s on the stage-7 profile). The gains of the
time-sliced scheme are exactly two: (1) no re-prefill of the shared history on a switch (section 2.4), (2) the GPU does not idle during one session's tool calls.
Gain (2) is small here: in the recorded real sessions consecutive requests never overlap and the gap before the next request is 56-448 ms (median 115-191 ms; 0 overlaps in 223
consecutive pairs of 943b, 945, 943d, 945d, docs/e2e-data/*-trace.csv); wall minus model time is 2.0 % / 1.0 % / 1.4 % / 1.6 % of wall in those four sessions and 3.7 % (ttt) and 8.3 % (nestng-crm)
for LEL in codex-compare (vanilla CRM: 17-19 %, because its model time is shorter). So two sessions can fill at most 4-8 % of LEL's wall (1.04-1.09x), and 20 % of vanilla's CRM wall.
Fair interleaving trades per-session latency for fairness; it does not add tokens per second.
2.4 Aggregate wall-time gain against a single-slot engine that re-prefills on a switch (E, with M anchors)
"Single-slot" = the Original's conversation cache (--prompt-cache, checkpoints of the ONE conversation whose K/V the buffer holds; after another session runs only the pinned root survives).
- M, job 921 (3 sessions interleaved, 10k -> 26k): reuse 41.3 % -> 68.0 %, TTFT mean 8.3 s -> 4.4 s, p95 13.0 -> 4.5 s; legacy TTFT grows with context, prefix-cache TTFT stays flat.
- M, job 923/927 (4 sessions x 24 requests, 3k -> 40k, 96 requests): reuse 26.5 % -> 88.0 %, mean TTFT 12.5 -> 2.5 s, p95 27.6 -> 5.5 s, sum of TTFT 1,200 s -> 244 s.
- M, 100k and 180k, two sessions alternating: legacy TTFT 28.2-28.6 s and 53.1-53.7 s every request; with the cache 2.3-2.8 s and 2.7-4.8 s (11-20x).
- E per request, with model time 8.4 s and cold prefill 3.3k tok/s (8192 chunk) to 1.8k tok/s (2048 chunk): context 30k: single-slot 8.4 + 9..17 = 17-25 s against 8.5 s warm (2.0-2.9x less wall); 70k: 8.4 + 21..39 = 29-47 s against 8.5 s (3.5-5.5x); 100k: about 8.4 + 30 = 38 s against 8.6 s (about 4x); 180k: about 7x at 3.3k tok/s, more at 1.8k tok/s. The first request of each session is cold in both schemes, so for short sessions (the 15-60 requests of a Codex task) the gain is diluted by the cold starts; on the 4-session trace the measured end-to-end TTFT sum improved 4.9x.
- Against serving N sessions strictly one after another (each warm from its own history, which is what a user with one agent sees): 1.00-1.08x aggregate (section 2.3). The honest statement is therefore: time slicing makes N sessions about as cheap as N sequential ones, instead of 3-6x more expensive than that; it does not make them cheaper than sequential.
- The comparison to quote for an owner demo is not "faster than sequential" but "N sessions served concurrently finish in about the sum of their times, each seeing 1/N of the speed, with TTFT of 1-5 s per turn instead of 30-55 s".
2.5 Does vanilla keep per-session caches? (read from engine/strata, not assumed)
- Yes, two ways. (1) Conversation parking:
--conversation-cache-mib N --conversation-cache-slots N"park conversations in a bounded host-RAM cache so alternating requests (controller and worker histories, sub-agents) reuse their prompts"; without the flag the budget is 40 % of the RAM left above the minimum free, at most 8,192 MiB, off when under 1,024 (docs/DETAILS.mdline 624), i.e. on by default on a big host. A request that starts at a checkpoint inside a parked one borrows that prefix. "It preserves histories; it does not run requests at once." (2) With--parallel Neach slot is a conversation cache; the next turn's state is copied back in 50-60 ms for a short conversation; a long prompt gives way to a short one (BYIELD). - Vanilla also has simultaneous decode, opt-in (
docs/BATCHING.md):--parallel N(1..8), "every verify window carries one token of each conversation",--batch-mtpadds one MTP proposal per slot, per-slot GDN/QSA/PLE state. The server solo-path rule: one request alone runs the fast solo path with MTP; a second request moves the first into a slot. A slot costs 0.56 GiB VRAM at 32K context with INT8 K/V and, with K/V streaming, pinned RAM (1.6 GB at 128K). - Its own measurements bracket our situation (BATCHING.md, all vendor/community numbers, not ours):
- 12 GB card, most experts on the CPU (Q2_0): 4 concurrent requests 70.7 tok/s one after another against 63.1 with
parallel 4(-11 %); the text says why: "a batch also reads about as many distinct experts as the requests one by one (different conversations route to different experts), so the gain is in latency". - RTX PRO 6000 Blackwell, all 24,576 experts in VRAM, MTP: 1 stream 179 tok/s, 2: 204-219, 3: 243-277, 4: 268-312, 8: 308-375 (+50 % at 4 without, +74 % with the launch-merging switches; 1.7-1.9 ms per added row).
- 2x RTX 3080 layer split, experts mostly off-card: 89.2 vs 77.3 tok/s with
--batch-mtp(+15 %); RTX PRO 5000 owners: +31 % to +39 % with 2 to 4 clients. - Setup recommends
parallelonly where "the expert cache must still hold at least half of the model's experts beside the slots"; "IQ3_S needs 32 GB or a split". Our 5090 tier holds 12,192 of 24,576 experts (49.6 %), right at that threshold.
- 12 GB card, most experts on the CPU (Q2_0): 4 concurrent requests 70.7 tok/s one after another against 63.1 with
- Consequence: the claim "unlike vanilla Strata we could multiplex" is not available as a differentiator of kind; at best it is a differentiator of quality of implementation (our telemetry, our prefix cache, N-way fairness). A fair comparison for any future "several times" claim is vanilla
--parallel N --batch-mtpon the same card.
3. Layer 2: simultaneous decode feasibility
3.1 Real concurrency patterns in Codex agent sessions (question 3)
- One Codex session is strictly sequential: request k+1 starts only after the tool results of request k return. In all four recorded live sessions (227 requests,
docs/e2e-data/{943b,945,943d,945d}-trace.csv) there is no overlap (0 negative gaps); gap before the next request: min 56-77 ms, median 115-191 ms, p90 184-282 ms, max 448 ms (one 10.2 s outlier at the start of 943b);queue_wait_msis 0 in every row. - Parallel tool calls: 114 of the 750 rounds in
docs/e2e-data/codex-compare/rounds.csv(723 have at least one call; none has more than two) issue two tool calls in ONE response; they are executed by Codex between model requests, so they do not create two model requests. The tools seen areexec_command(824 calls) andwrite_stdin(12); nomulti_agent_v1/ sub-agent spawn call occurs in any recorded round, although the tool is advertised (multi_agent_v1namespace, 10 KB, e2e-run.md 7). Not recorded does not mean impossible: sub-agents would create overlapping requests from one task, and no task used them. - Therefore any benchmark of simultaneous decode must run N parallel Codex sessions (or an explicit sub-agent task); a single session never produces concurrent requests. The existing harness can:
cell.pytakes a free port per cell, a cell directory and an--active-dir, and the logging proxy records per-request times (section 4). - A real deployment with 5-20 sessions is mostly one user's several terminals / sub-agents; their requests arrive nearly at random, each session issuing a request every 8-10 s of model time plus 0.1-0.3 s of tools. So at N sessions the engine is saturated from N=2 on (utilisation per session 92-96 %): the queue, not the GPU idle time, is the bottleneck, which is what the owner observes ("5-20 requests in the queue").
3.2 Why multiplexing may or may not multiply here (question 2)
Facts (M): 48 layers, 512 routed experts per layer, 10 routed per token (tier simulator, hit-gap-causes appendix: L, E, K = 48, 512, 10); VRAM tier 12,192 slots = 254 per layer (49.6 % of experts), 1.952 MiB per slot;
hit share of entries about 90-92 % (replay mean 90.2, entry-weighted 92.2); about 480 entries per row, so 2,000 entries is about 4.1 rows per round; round 17.93 ms = graph 13.20 (mixer 5.75, FFN 6.85 of which host/tier wait 3.81, other 0.6) + 4.7
between graphs (4.30 on consecutive pairs; of it GPU fully idle 1.95 ms, verify launch call to first kernel 1.345 ms, MTP chain 1.76 ms); only 31 % of layers are not host-bound (step-ledger "Critical path"). Decode misses are bound by host DRAM:
CPU leg + PCIe DMA reach 74.5 GB/s together (roofline.md).
Row economics (M, replay 9b1 era, docs/adaptive-spec.md): window time T1 13.0, T2 15.1, T3 18.3, T4 22.3, T5 26.2, T6 31.2, T7 34.8, T8 38.9 ms: the first extra row costs about 2.1 ms (16 %), later rows 3.2-5 ms; a verified row of the SAME sequence costs 28 % of a one-row window.
Speculation already spends the batch dimension on rows of one sequence, which is why batching across sessions has less left to amortise than in a non-speculative engine. Pure non-speculative batching of N sessions (N rows per window, one token each) gives N/T(N):
N=4 4/22.3 = 179 tok/s, N=8 8/38.9 = 206 tok/s against 3.3/17.9 = 184 tok/s for one speculative session (E; mixed eras, indicative): no gain over speculation alone. Speculative rows per session and rows across sessions compete for the same marginal cost per row.
Miss traffic (E): 2,000 entries x 9 % = 180 missed entries x 1.952 MiB = 351 MiB per round = 4.7 ms at 74.5 GB/s, which is 26 % of the round and matches the measured 3.8 ms host/tier wait. Different sessions route to different experts, so the missed set of N sessions is the sum, not the union (E): the wait term grows about linearly in N, plus a hit-rate loss because the tier of 254 slots per layer must now serve N working sets (E: 91 % -> 85-88 % for unlike tasks, U; slope M 0.0021 point per slot). Loose outer bound: DRAM time per session-round is 4.7 ms of 17.9, so even with everything else hidden perfectly the miss traffic caps aggregate at about 3.8x (about 3x with the hit-rate loss). That bound is not a prediction: nothing in the dependency chain (48 layers, each waiting for the host) hides perfectly.
Model (E): joint round time = sum over components of base x (1 + s x (N-1)), s = how linearly the component grows (0 fully shared, 1 fully per-session). Baseline N sessions one after another = N x 17.9 ms.
| component (base, ms) | optimistic s | middle s | pessimistic s | reason |
|---|---|---|---|---|
| mixer: GDN step, attention, router (5.75) | 0.3 | 0.6 | 0.9 | per-sequence state and K/V, small latency-bound kernels amortise partly |
| FFN device (3.04) | 0.6 | 0.8 | 1.0 | more distinct experts, grouped GEMM scales with rows |
| host / tier wait (3.81) | 0.8 | 1.0 | 1.1 | miss bytes add; tier shared -> more misses |
| other graph (0.6) | 0.5 | 0.75 | 1.0 | |
| between graphs (4.7) | 0.5 | 0.75 | 1.0 | launch idle 1.3 ms and commit shareable; each MTP chain is per sequence unless batched |
| N | optimistic | middle | pessimistic |
|---|---|---|---|
| 2 | joint 27.2 ms, 1.32x | 31.6 ms, 1.13x | 36.0 ms, 0.99x |
| 4 | 45.6 ms, 1.57x | 58.9 ms, 1.22x | 72.2 ms, 0.99x |
Certain: the baseline, the components, the miss arithmetic, the existing kernel limit. Guesses: every s (they are the whole result), the hit-rate loss, and the assumption that cross-session rows cost as much per row as same-session rows (they likely cost more:
fewer shared experts). The data that would turn guesses into numbers is section 4 step 2-3. Two more caveats on N=4: (i) 4 sessions x 3.3 rows = 13 rows exceeds the 8-row kernels, so either the kernels change or each session drops to 2 rows
(then tokens per round fall from about 3.3 to about 1.9-2.2 and E aggregate is at or below 1.0x), (ii) vanilla's PRO 6000 numbers (+50..+74 % at 4) come from a card where the whole model is in VRAM, so s for the wait term is near 0 there: that is the regime our tier is not in.
An alternative to joint graphs is overlapping two independent verify graphs on two streams (no kernel change): it can fill the GPU idle 1.95 ms + part of the 3.8 ms wait (up to 32 % of the round, E), but the CPU leg and DRAM are shared, so the upper bound is about 1.3x at N=2 and it needs two live stacks (below). No evidence either way; U.
3.3 What it would take (question 4)
- Scheduler: a continuous-batching policy per round that picks, per session, the window width by marginal tokens per ms (the existing adaptive policy
choose/draft_plangeneralised to a joint cost modelT(rows, sessions)), admission of a new session's chunked prefill between decode rounds (vanilla: slots decode for half the chunk time between chunks; our prefill is 2048-8192 token chunks of 0.6-2.4 s), fair order, cancellation per session. New code inengine-core(pure) plus the adapter. - Per-session state isolation in the engine: today one
OriginalServeStackowns one set of 12 QSA layers (positional K/V, index images, pinned journals), one GDN/PLE state, one draft ring, one MTP actor, one verifier assembly. N live sessions need N sets or a slot indirection (vanilla: "each slot gets its own state, a session carved like the stage's own"). The engine is built onRc<Context>andRefCell(C:serve_loop.rs), process-wide singletons (RECONFIGURING,INSTANCE,settings::process(),Governor::global(), hexagonal.md "not a port") and aServeDeviceport that is one-request-at-a-time (Lifecycle/run_request). This is a rewrite of the request lifecycle, not a flag. - Graph shape: a joint window carries rows of several sessions, so GDN recurrence (state chain per session), QSA gather (per-session page table and K/V pointers), PLE history, the commit graph and the accept step all need a row -> session indirection (vanilla passes per-row state as kernel params
and captures per row layout,
STRATA_BATCH_ATTN_ROWS,STRATA_BATCH_GDN_GROUPS).kVerifyMaxT = 8must grow for N x 3.3 rows; sealed PTX for sm_120 and sm_86 must be re-sealed; graph variants multiply with the layout (rows per session). Verification: vanilla itself needsSTRATA_IQ_MT_MIN=1,--pcie-frac 0and a frozen tier to make batch output equal solo output; with the defaults "the outputs stay coherent but drift apart". For us that means a new equivalence class (like the tier placement class) and its own gate, not bitwise identity. - Prefix cache sharing: works unchanged by construction (blocks keyed by hash chain, immutable host memory); what changes is that the live set is no longer one buffer: the "one engine, one buffer" limitation in prefix-cache.md goes away only if the live K/V is per session. The grid import path would write into the session's own buffers.
- Gateway/contract: the worker loop must dispatch several
serve_oneat once; the gRPCgeneration_fullsingle slot andBackenddoc ("one generation at a time") become a capacity N;max_in_flightalready allows 17; the request log and monitor already carry session id and per-request times, so telemetry is mostly there (queue wait =engine_start - admitted). - Memory governor: add N x (pinned K/V + VRAM window + verifier assembly) to the plan; the expert tier shrinks by the VRAM taken.
Memory per extra live session (K/V numbers M from docs/kv-streaming.md and prefix-cache.md; the rest E):
| item | size |
|---|---|
| pinned host K/V, 12 QSA layers x 1,056 B/cell, allocated for the whole serving context | 3.32 GB at 262,144; 1.66 GB at 131,072; 0.83 GB at 65,536 |
| pooled index rows (device image) | 128 B/cell/layer: 0.4 GB at 262k |
| VRAM resident K/V window, 12 x 35 MB at 32,768 cells (20,480: about 264 MB) | 0.26-0.42 GB |
| GDN/PLE state + MTP draft ring | about 0.13 GB (the parked node is 127 MB) + ring |
| verifier assembly (graphs, arenas) at decode | 514 MiB today; vanilla slot total 0.56 GiB at 32K context with INT8 K/V |
| VRAM per extra session | about 0.55-1.2 GiB, taken from the tier at 512 slots per GiB |
| effect of 1 GiB on the tier | -512 slots = -4.2 % of the tier, about -1.1 hit point (0.0021 point/slot), about -1.8 % single-stream decode (H4: +0.67 % per +192 slots) |
- N concurrent 256k sessions: impossible on this card and host as configured. The VRAM floor is 316-355 MiB free at decode (vram-footprint-5090.md; 340 MiB at 243k): there is no spare VRAM, every extra session takes it from the tier (about -2 % per GiB).
The host is the harder limit: 3.32 GB pinned per session plus the prefix cache, with
MemAvailableat 7.4-8.3 GB in a live 123k session; N=2 at 256k needs about 4.4 GB of RAM (3.32 + 0.4 + 0.7) and a prefix-cache budget that can hold only one 243k session (3.6 GB). N=2 is borderline, N>=3 does not fit unless--expert-source mapped(frees tens of GiB, costs expert-fetch speed) or the resident copy shrinks. - Practical N at 30-100k (cap the serving context at 131,072 for a multi-session profile: 1.66 GB pinned per session): VRAM allows N=2-4 at a cost of 2-6 % single-stream speed (1-3 extra sessions x 0.55-1.2 GiB x 1.8 % per GiB, E); RAM allows N=4 live (6.6 GB pinned) only with the prefix cache shrunk to a few GiB. So N=2 comfortable, N=4 with trade-offs, N=8 only with mapped experts. Because the speed model gives at most about 1.2x at N=4, memory is not the first blocker; the missing amortisation is.
4. Measurement plan and recommendation (question 5)
Step 1, no new engine feature: two and four concurrent Codex sessions through the gateway (the existing cmp harness).
The harness runs cells sequentially in run_cells (cmp_codex_job.sh); cell.py itself is concurrency-safe (free proxy port per cell, separate cell dir, --active-dir). New stub cmp_codex_pair_job.sh (test tooling, not serving): same stack start and guards, then per block:
(1) one ttt and one nestng-crm cell alone (sequential reference inside the same boot), (2) two ttt cells started together, (3) two nestng-crm cells together, (4) four ttt cells together; task copies in separate --active-dir, CMP_REPS=1 2 3 as three blocks; unlike tasks in a mixed pair (ttt + crm) as the cross-task tier case.
Metrics per cell and per block: aggregate output tokens / wall for the whole set against the sum of the sequential walls; per-session decode tok/s and TTFT from requests.log (admitted, engine_start, first_token, session id) rather than proxy first-byte; queue wait = engine_start - admitted; reused_tokens, import_ms, prefix-cache stats; tier VRAM share per request (alone vs alternating = the unmeasured switch penalty of 2.1);
VRAM, RSS, MemAvailable from mon.csv/env.tsv; accepted 56/56 and 14/14. Expected result by construction: aggregate about 1.0-1.08x of sequential, TTFT p50 1-5 s, queue wait about (N-1) x 8 s; its value is the switch cost and the tier penalty with real numbers, plus the baseline for any later feature.
GPU time (E): per block boot about 6 min + warm-up, ttt alone 2.5 min, ttt pair 5, crm alone 8, crm pair 16, ttt x 4 about 10, mixed pair 11 = about 60 min; 3 blocks = about 3 GPU-hours; a first block alone (one repetition) is 1 hour and already answers the switch-cost question.
Quality rule: temperature 0 injected as in the existing cells; no performance claim without the paired sequential cell in the same boot.
Step 2, no GPU beyond two short dumps: offline expert-union simulation. LELEKA_ORIGINAL_SERVE_DUMP_ROUTING=<file> exists (settings/memory.rs; records of layer + 10 expert ids per row; E1 of hit-gap-causes), a tier simulator is in the appendix of hit-gap-causes-2026-11-11.md, and one trace (735 windows, mean 2.68 rows) exists at
/data/leleka-e2e/runs/single-copy-ab/route-sparse/routing.bin. Need one dump of a ttt replay and one of a nestng-crm replay (E1 jobs, 2 x about 12 min = about 0.5 GPU-hour). Offline: pair windows of two sessions round by round and compute (a) distinct (layer, expert) pairs of the joint window against the sum (the s of the FFN and wait terms), (b) hit share of one shared adaptive tier serving both against each tier alone (the tier penalty), (c) missed bytes per joint round
(the DRAM term). This replaces the guessed s of section 3.2 for the two components that dominate by measurements, with zero engine change.
Step 3, optional: vanilla reference. strata launch ... --parallel 2 and --parallel 4 --batch-mtp on the same 5090 and the same two tasks, N concurrent Codex sessions against --parallel 1 (about 1.5 GPU-hours, plus the owner's word because "vanilla is not re-measured" is an owner rule, and this is a new arm, not a re-measurement).
It shows what batching gives on this card with an engine that has it (the 49.6 %-in-VRAM regime), and whether the benchmark must include a concurrent arm to stay "stably faster than vanilla". Vanilla's --parallel also moves expert slots (0.56 GiB per slot), so its single-session speed is the reference too.
Step 4, optional, cheap: refresh the row-cost curve (T = 1..8 on the current build, LELEKA_SPEC=N fixed windows over the 30-request replay, about 1 GPU-hour): the s of the mixer term is bounded by the marginal row cost; the 2.1..5 ms per row above is from the 9b1 era.
Recommendation.
- GO: step 1 (it is the honest measurement of the owner's observation, "5-20 requests queued, caches switched"), step 2 (it is the cheapest predictor of any simultaneous scheme and is already planned as E1), and add to the telemetry the three missing numbers: queue wait per request, switch (import) ms and the tier VRAM share by request ordinal after a switch. Add a cache-aware dequeue (pick the queued request with the longest
prefix_match, bounded by a maximum wait) as a small gateway feature to evaluate: it removes copies and, more importantly, keeps a session's tier shape; expected gain is small (the copy is 1-3 % of a request), so it is only worth it if step 1 shows a larger tier penalty than E. - NO-GO for now: the simultaneous-decode engine work (E: several weeks of engine work, a new sealed-PTX cycle and a new equivalence class) until step 1-2 show a joint-round estimate of at least about 1.4x at N=2 on real routing, or until the owner wants the product claim against vanilla
--parallel. On today's numbers the plausible gain at N=2 is 1.0-1.3x (middle 1.13x), at N=4 1.0-1.55x (middle 1.22x), at a price of about 2-6 % of single-session speed through the VRAM taken, and it is capped by DRAM miss traffic, not by launch overhead. - Do not promise "several times". The one regime where it holds in vanilla's own data is a card with the whole model in VRAM; ours reads 9 % of 2,000 entries per round from host RAM and that term does not amortise.
5. What is not known
- The expert-tier penalty of alternating sessions (the largest hidden cost of time slicing) and the cross-session expert overlap (the largest hidden term of simultaneous decode). Both are answered by steps 1-2.
- Whether Codex sub-agents (
multi_agent_v1) produce overlapping requests in real use; no recorded task used them. - The marginal cost of a cross-session row on the current build; 9b1-era table only.
- 243k switch cost (E, not measured) and the live behaviour of
--prefix-cache-tail replyunder alternation (its equivalence gate STRA-328 is still open). - Vanilla's
--parallelbehaviour on the 5090 with IQ3_S at our tier size; BATCHING.md has no row for it.
6. Sources
docs/experiments/plan-faster-than-strata.md (6g), docs/prefix-cache.md, docs/worker-pool.md (CPU gpt-oss: 4 agents, 1 slot against 4 cache slots 1.73x; second device alone about 1.1x; shows the same split: cache gain large, concurrency gain small),
docs/e2e-run.md 7, 7d, docs/e2e-data/*-trace.csv, docs/e2e-data/codex-compare/{compare.csv,rounds.csv}, docs/experiments/codex-compare-5090-results.md, docs/experiments/step-ledger.md (A1-A3, Q7, critical path), docs/experiments/hit-gap-causes-2026-11-11.md,
docs/experiments/vram-footprint-5090.md, docs/experiments/decode-graph-reuse.md, docs/adaptive-spec.md, docs/kv-streaming.md, docs/roofline.md, docs/architecture/hexagonal.md, docs/api-contract.md, engine/strata/docs/BATCHING.md, engine/strata/docs/DETAILS.md;
code: control-plane/src/backend_worker/{attach,serve_one}.rs, control-plane/src/serve/engine.rs, control-plane/src/request_log.rs, desktop-core/src/runtime_rpc/generate_rpc.rs, crates/engine-core/src/request.rs,
crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs, crates/engine-qwen35-cuda/src/backend/serve_loop.rs, crates/cuda-driver/src/mtp_original_full_verify.cu (kVerifyMaxT).