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>
This commit is contained in:
Pavlo Ratushnyi
2026-10-29 11:07:46 +01:00
co-authored by Claude Sonnet 5.5
parent 6e58e77548
commit eef6f598b4
3 changed files with 38 additions and 15 deletions
@@ -179,10 +179,11 @@ impl ExpertTierConfig {
profile: None,
reserve_mib: 700,
// measured (jobs 989/990/988): the per-request verifier needs ~450 MiB, so 1024 left ~550 MiB idle (180k smoke
// included); 300 gives the auto-sized cache ~+330 slots. 5090, 5 x 245k session (speedtrain-ab): the verifier took
// 514 MiB and the card never had less than 563 MiB free (nvidia-smi at 10 s, every turn), while vanilla Strata runs
// down to 315 MiB. 130 keeps the floor at `VANILLA_FREE_FLOOR_MIB` (700 + 130 - 514 = 316) for about +90 slots.
decode_reserve_mib: 130,
// included); 300 gives the auto-sized cache ~+330 slots. 5090, 5 x 245k session (speedtrain-ab): with 300 the card
// never had less than 563 MiB free (vanilla runs down to 315), so 130 would be safe on the card (E: +87 slots),
// but the first slots-footprint A/B showed the Context BUDGET is a second ceiling the planner now respects
// (`usable_room`); 130 stays an opt-in (`LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=130`) until its own arm measures it.
decode_reserve_mib: 300,
// the PCIe share that equalises the legs when the CPU pool and the DMA share the host's memory ceiling
// (P/(P+C) = 0.45, job 987-b/909; 0.45 vs 0.55: +0.5 % / +4.7 % at the auto-sized cache, equal at 2048 slots)
pcie_frac: 0.45,
@@ -1248,14 +1249,15 @@ mod tests {
use super::*;
#[test]
fn the_default_reserves_keep_at_least_the_free_vram_vanilla_runs_with_at_decode() {
fn the_default_reserves_keep_more_free_vram_at_decode_than_vanilla_runs_with() {
let config = ExpertTierConfig::off();
// 700 + 130 less the 514 MiB verifier assembly
assert_eq!(config.decode_headroom_mib(), 316);
// 700 + 300 less the 514 MiB verifier assembly
assert_eq!(config.decode_headroom_mib(), 486);
assert!(config.decode_headroom_mib() >= VANILLA_FREE_FLOOR_MIB as isize);
// the old 300 MiB default left 486: the 170 MiB difference is what the cache gains (about 87 slots of 1.95 MiB)
let old = ExpertTierConfig { decode_reserve_mib: 300, ..ExpertTierConfig::off() };
assert_eq!(old.decode_headroom_mib() - config.decode_headroom_mib(), 170);
// the opt-in 130 MiB is the vanilla floor to the MiB (700 + 130 - 514 = 316)
let tight = ExpertTierConfig { decode_reserve_mib: 130, ..ExpertTierConfig::off() };
assert_eq!(tight.decode_headroom_mib(), 316);
assert!(tight.decode_headroom_mib() >= VANILLA_FREE_FLOOR_MIB as isize);
}
#[test]
+17 -2
View File
@@ -9,10 +9,11 @@ Labels: M measured in those logs, E estimate, U unverified. Nothing below is a p
| item | commit | VRAM freed | expert slots | status |
| --- | --- | ---: | ---: | --- |
| driver rounding of the ~700 dense weight buffers (0.5-10 MiB each, 2 MiB granule): pack into 64 MiB slabs | 8c9748a3 | 688 MiB minus slab tails (E: 600-650) | +310 (E, +6 or +7 quota steps of 48) | default ON, `LELEKA_DENSE_SLAB=0` rolls back |
| decode reserve 300 -> 130 MiB (free at decode 563 -> 316 MiB; vanilla runs down to 315) | 981c7aad | 170 MiB | +87 (E, +1 or +2 steps) | default |
| decode reserve 300 -> 130 MiB (free at decode 563 -> 316 MiB; vanilla runs down to 315) | 981c7aad | 170 MiB | +87 (E, +1 or +2 steps) | OPT-IN since the first A/B (default stays 300): `LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=130`, arm `slots-res130-noseed` |
| prompt-path token table aliased onto the native embedding's mapped host copy (a second copy sits in VRAM and in pinned RAM) | 521bfc91 | 324 MiB VRAM + 322 MiB pinned RAM | +166 (E) | EXPERIMENTAL, `LELEKA_PROMPT_EMBED_ALIAS=1`, own A/B arm and identity arm |
| per-call-site allocation ledger, low-water mark | bea07c3d | diagnostic | 0 | `LELEKA_VRAM_LEDGER=1` |
| total of the three reductions | | about 1.2 GiB | about +560 (11,280 -> about 11,840) vs vanilla's 12,575 | slots are read from the log of the first A/B arm |
| cache sized against the Context budget as well as the card (fix of the failed first A/B, section 6) | next commit | 0 | 0 | default |
| total of the default reductions (slab; with the alias +166, with reserve 130 +87) | | about 0.55 GiB | about +290 (11,280 -> about 11,570) vs vanilla's 12,575 | slots are read from the log of the A/B arm |
Greedy identity: a slot count change moves expert placement, and GPU-resident experts round differently from CPU ones (`bench/results/2026-09-27-cache-parity`), so equal slot counts are the only
valid identity comparison. `scripts/e2e/decode/slots-id.sh` replays the 256k capture with a static tier and a fixed `EXPERT_SLOTS=8000` on the base and the new build and requires zero flips and
@@ -86,3 +87,17 @@ sets its own `DECODE_RESERVE_MIB` (1024) and keeps it.
* The slot gain is arithmetic from the log (1.952 MiB per slot, 48-slot quota steps), not a measurement.
* That 316 MiB free at decode is safe for the whole 256k session (vanilla's floor is the only evidence). The A/B job samples the card every 100 ms and prints the lowest free value per arm.
* That the alias does not slow the drafter.
## 6. First A/B (7823672f): every request failed, why, and the fix
`runs/slots-footprint/slots-noseed-r2/r4` (both INVALID, turn 1 `status:failed` after 2 s): the cache opened with 11,664 slots (22,765 MiB) and the first 8192-token chunk died in layer 27 (QSA) with
`driver error: BudgetExceeded`. Not the card: 869 MiB were physically free. The **Context budget** (`E2E_GPU_BUDGET` / profile `gpu_budget_bytes`, 30 GiB = 30,720 MiB) is charged with the *requested* bytes
of every allocation, not the driver's rounding. Accounted before the cache: 7,626 + 24 (slab padding) = 7,650 MiB; plus 22,765 for the cache = 30,415, leaving 305 MiB of budget for everything allocated later
(the lazy QSA/prefill buffers of the first chunk, then the 514 MiB verifier). The base build had 1,080 MiB of budget slack (22,014 + 7,626 = 29,640) and the planner never looked at the budget: it sized from the
card (`memory_info().0`) alone, and for the base the two coincided to a MiB. The slab saved physical bytes the budget never counted, so the card-only planner grew the cache into the budget.
Fix (`usable_room` in `original_cache_startup.rs`): every sizing step (auto count, per-layer cap, profile cap, the shrink loop after the cache opens) uses `min(card free, budget - allocated)` and subtracts the
same reserve from that, so the reserve is kept under the budget exactly as on the card. Unit tests pin the arithmetic with the numbers of the failed run. The decode reserve default went back to 300.
The slab gain exists only if the budget is raised by about what it saved: with 30 GiB the budget-aware planner gives ~11,300 slots (no gain); with 31,300 MiB (the job's new default; the card has 31,603 MiB free at start,
the governor only notes `free < budget`) the card binds again and the cache is ~11,570 slots with the same 1,000 MiB reserve under both ceilings. The product profile `deploy/rust-runtime/profiles/rtx5090-32g.json`
still says 32,212,254,720 and must be raised (and its `required free at start` checked) for the gain to reach the product; that is a deploy decision, not made here.
+9 -3
View File
@@ -13,12 +13,16 @@
# base-noseed ours, /data/leleka-e2e/decode/dt/bin-speedtrain (claude/speed-train 47d2d389), env of speedtrain-ab.sh seed OFF
# slots-noseed ours, /data/leleka-e2e/decode/dt/bin-slots (claude/slots-footprint), same env, defaults of the new build (dense slabs ON, decode reserve 130 MiB)
# slots-embed-noseed slots-noseed plus LELEKA_PROMPT_EMBED_ALIAS=1 (prompt-path token table aliased onto the mapped host copy: -324 MiB VRAM, -322 MiB pinned RAM; EXPERIMENTAL)
# slots-res130-noseed slots-noseed plus LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=130 (free VRAM at decode ~316 MiB, +87 slots; opt-in)
# slots-ledger slots-noseed plus LELEKA_VRAM_LEDGER=1 and a short session (2 turns, ~60k tokens): the full allocation account; the ledger takes a backtrace per allocation, so this arm is never a performance arm
# v-def vanilla Strata 0.2.6 as in speedtrain-ab.sh (not in the default ARMS)
# Workload (the only valid one): the FROZEN corpus /data/leleka-e2e/decode/corpus/src/crates (MANIFEST.txt), 5 turns, target 245000 tokens, --max-output 300.
# Validity per run (VALIDITY.txt): no turn failed, 5 turns, final-turn input tokens >= 200000, turn-5 window.ple mean < 5 ms (as speedtrain-ab.sh).
# Footprint per run (FOOTPRINT.txt): the expert-cache slot count, the DBG vram lines (free after each opening stage, at decode, lowest note), the memory ledger table, the
# dense-weights slab line, and the card's peak used memory from a 100 ms nvidia-smi sampler (gpumem.csv; nvidia-smi total 32607 MiB = CUDA total 32110 + 497).
# GPU context budget: E2E_GPU_BUDGET defaults here to 31,300 MiB (the speed-train jobs used 30 GiB). The Context charges allocations (not the driver's rounding) against the budget, so
# slabs that save physical bytes need a budget that leaves the same reserve above them; the cache planner now sizes against min(card free, budget - allocated). Both arms run with the same budget
# (the base build is card-bound at either value). The first slots-footprint run (30 GiB, 7823672f) failed every request with BudgetExceeded at layer 27: no budget room for the lazy buffers.
# Metric: per-turn decode_tok_s of the client, per-turn mean of the repeats, never a single run. Quality: the arms are greedy but the auto-sized caches differ in slot count, so
# placement (and with it GPU-vs-CPU expert rounding) differs: the lossless claim is the static-tier identity job slots-id.sh at an equal fixed slot count, not these arms.
set -uo pipefail
@@ -27,6 +31,7 @@ LOCK=/data/leleka-e2e/gpu.lock
OUTR=/data/leleka-e2e/runs/slots-footprint
CORPUS=/data/leleka-e2e/decode/corpus/src/crates
UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin # ranked upstream profile; run-e2e.sh refuses any other digest
RUN_TAG=${RUN_TAG:-} # suffix of the run directories (a rerun next to earlier ones)
ARMS=${ARMS:-"base-noseed slots-noseed base-noseed slots-noseed"}
SESSION_ARGS="--turns 5 --target-tokens 245000 --max-output 300 --min-final-tokens 200000"
for f in "$UP" "$D/tools/long-session.py" "$D/scripts/e2e/run-e2e.sh" "$D/bin-speedtrain/leleka-inference" "$D/bin-slots/leleka-inference" "$CORPUS/backend-api/src/lib.rs" \
@@ -40,7 +45,7 @@ ours() { # $1 tag, $2 arm
( export E2E_BIN=$D/$bin E2E_OUT=$OUTR/$tag
mkdir -p "$E2E_OUT"
export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=32212254720
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=${GPU_BUDGET:-32819404800}
export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p 0"
export E2E_SAMPLE_S=10 LELEKA_CHAIN=all
export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$UP
@@ -50,6 +55,7 @@ ours() { # $1 tag, $2 arm
case $arm in
base-noseed|slots-noseed) ;;
slots-embed-noseed) export LELEKA_PROMPT_EMBED_ALIAS=1 ;;
slots-res130-noseed) export LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=130 ;;
slots-ledger) export LELEKA_VRAM_LEDGER=1; session="--turns 2 --target-tokens 60000 --max-output 100 --min-final-tokens 40000" ;;
*) echo "unknown ours arm $arm" >&2; exit 2 ;;
esac
@@ -162,7 +168,7 @@ PY
n=0
for arm in $ARMS; do
n=$((n + 1)); tag="$arm-r$n"
n=$((n + 1)); tag="$arm-r$n$RUN_TAG"
got=0
for _ in $(seq 1 1080); do
if mkdir "$LOCK" 2>/dev/null; then echo "speedtrain-ab $tag $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi
@@ -175,7 +181,7 @@ for arm in $ARMS; do
fi
case $arm in
v-def) vanilla "$tag"; kind=vanilla ;;
base-noseed|slots-noseed|slots-embed-noseed|slots-ledger) ours "$tag" "$arm"; kind=ours ;;
base-noseed|slots-noseed|slots-embed-noseed|slots-res130-noseed|slots-ledger) ours "$tag" "$arm"; kind=ours ;;
*) echo "unknown arm $arm" >&2; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; exit 2 ;;
esac
validity "$OUTR/$tag" $kind