Files
leleka/docs/laptop-profile.md
T
Pavlo RatushnyiandClaude Opus 5.5 cfd80e9452 docs: laptop profile (memory map, the Original's low-RAM modes, port gaps, paired laptop numbers)
docs/laptop-profile.md: what lives in VRAM / RAM / NVMe on the RTX 3080 Laptop 16 GB + 48 GB machine for the
Original and the port, why both GGUF shards are strictly needed, the WSL2 cgroup bug that keeps the Original's
resident modes off there, the port's gaps and what this branch adds, and the measured arms (n = 6 each):
unmodified Original 8.15 decode / 12.4 prefill tok/s / TTFT 7.2 s vs port 2.70 / 3.1 / 28.4 s on the same
token IDs and KAR PLE; traced: all port decode time is in run_window (~1.0 s per verify window).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:08:44 +02:00

17 KiB

Laptop profile: Qwen3.8-Flash-Next IQ3_S on a 16 GB laptop GPU

Status: experimental profile, measured on one laptop. Nothing here is a production default or a quality claim.

The target is the one machine below, not the RTX 5090 server: what has to live where, which of the Original's low-memory modes apply, what the Rust port lacked to run there, and paired numbers on the same prompts.

Machine

CPU Intel i9-11900H, 8 cores / 16 threads, AVX-512 (VNNI, VBMI)
RAM 48 GB (47 GiB usable); WSL2 gets half by default: MemTotal 24,447,308 kB
GPU NVIDIA GeForce RTX 3080 Laptop GPU, 16,384 MiB, sm_86, driver 617.42 (WDDM, WSL2 passthrough); 14.89 GiB free to CUDA in WSL with nothing running
Disk NVMe, 1.2 TB free on C:; the WSL ext4 VHDX lives on it
Software Windows 11 Pro 26200, WSL2 Ubuntu 24.04, CUDA 13.2.86 (nvcc), cuBLAS 13.4 (Original) / 12.9.1.4 (port), Rust 1.99, gcc 13.3

Pinned host memory under this WSL2: cudaHostAlloc of 16 x 512 MiB and cudaHostRegister of 1-16 GiB all succeeded (probe, 2026-10-16). The Original's setup.py comment "the driver pins only about 1 GB" under WSL is not true for this driver; the limit is the VM's RAM.

Model components and where they can live

Sizes are from the files (native_experts.txt, the MTP pack, the KAR provenance) and the Original's formulas.

component size must be can be
routed experts (48 layers x 512, IQ2_S..IQ4_NL) 50,292,326,400 B (46.84 GiB), blob 1.51-2.66 MB, mean 2.05 MB read per token for the 10 routed experts of every layer VRAM cache (hot), RAM (warm), SSD (cold, via the OS file cache or direct reads)
dense pack (attention, GDN, shared experts, routers, norms) dense.bin 1,538,035,200 B VRAM -
native head (Q5_K output.weight 248,320 x 2,560) 521,472,000 B (Original log) VRAM -
token embedding ~0.4 GB (Q5_K) read per token mapped host memory
PLE n-gram table (per_layer_token_embd, 320,001,536 rows) 28,800,138,240 B (90 B/row, GGUF shard 2) or ~16 GB of level-2 KAR parts (50 B/row) 16 rows per token SSD (direct reads) + a bounded row cache
MTP draft layer (data/mtp-rt) dense 116,099,072 B + experts 707,788,800 B (802 MiB of VRAM loaded) + draft head 212.9 MiB (106,299-token CJK subset) VRAM -
QSA KV, INT8 1,056 B per cell per layer, 12 QSA layers + draft layer = ~13.7 KB per token: 8K 0.11 GB, 32K 0.45 GB, 128K 1.8 GB, 256K 3.6 GB the attention window in VRAM the rest in pinned RAM (--kv-resident)
prompt (prefill) buffers Original: borrowed from expert-cache slots (--prefill auto); port arena 2.0 / 2.8 / 4.3 GiB at chunk 2048 / 4096 / 8192 VRAM while a prompt is read -

The routed experts are the whole problem: 46.84 GiB against 14.9 GiB of usable VRAM and 23 GiB of WSL RAM.

VRAM budget (16 GiB card, 14.9 GiB free to CUDA)

Measured (logs of the runs below):

Original (--expert-cache auto, --max-context 8192) port (Original serve stack, 8K ceiling)
free before the expert cache 9.67-9.73 GiB (after dense, native Q5_K head 521 MB, MTP 802 MiB, KV, state) not printed; KV alone 0.391 GiB + 0.258 GiB prompt stage (262,144-cell geometry, 32K window)
reserve --vram-reserve-mib 700 + 218 MiB draft head _VRAM_RESERVE_MIB 700 + _DECODE_RESERVE_MIB 1024 (per-request verifier assembly)
expert slots 4,597-4,632 slots, 8.76-8.83 GiB, sized per blob by the profile 3,133 slots, 6.00 GiB
prompt path borrows the last 1,965 slots (3.72 GiB) during a prompt borrows the last 1,157 slots
left free 459-461 MiB "with everything loaded" (nvidia-smi peak 14,195 MiB used of 16,384)
decode hit rate (per request) 48-77 % 40-53 % of window entries on the GPU

Every GiB of VRAM is ~520 more cached experts (2.05 MB each) out of 24,576.

RAM budget (48 GB physical, 23.3 GiB in WSL by default)

Original low-RAM resident mode port before this work port, laptop profile
experts --resident-experts: the complement of the GPU cache (~36 GiB) does not fit, so the soft path keeps what fits (MemAvailable - 4 GiB headroom), hottest by the profile, page-locked; the rest through the OS file cache from the GGUF in place 50 GB copied into RAM (load_resident_expert_source, needs MemAvailable >= 58 GB) and page-locked whole read-only shared mapping of shard 0 (load_mapped_expert_source): nothing copied, the OS file cache keeps what is used
KAR archive --ple-kar: mapped from the file 55,295,529,472 B sealed memfd (shmem) for the life of the process read-only file (open_read_only_file): file cache only
PLE (GGUF) --ple-io direct: never in RAM, 1M-row (90 MB) cache not used (KAR PLE only) not used (KAR PLE only)
KV host copy none at 8K (streaming is off below 64K, and setup turns it off under WSL) 12 x 276,825,088 B = 3.32 GB pinned (always 262,144 cells) same: 3.094 GiB pinned

Under WSL2 the unmodified Original's resident modes do not engage. available_memory_bytes() (expert_source.cpp:219) requires the cgroup-v2 path of /proc/self/cgroup ("0::/init.scope") to exist unde /sys/fs/cgroup; WSL2 mounts cgroup v2 at /sys/fs/cgroup/unified (hybrid layout), so it returns false and --resident-experts / --resident-budget-gib fall back to plain mmap with "cannot determine available RAM". With that check relaxed (2 lines, built as a separate labeled arm, not committed to engine/strata) the resident mode works: "RAM budget 16.83 GiB: 8892 of the 38.07 GiB of experts the GPU cache does not hold", page-locked.

NVMe

  • PLE direct reads: 16 rows per token, one 4 KiB read each, ~64 KB/token: negligible at any decode rate.
  • Experts: a miss that is neither in VRAM nor in RAM is a 1.5-2.7 MB read. That is the term that decides decode speed once the RAM cannot hold the complement.
  • The shards are verified once per start by the port (SHA-256 of 83.6 GB) and the KAR archive likewise (55.3 GB).

Files on the laptop and why

file size needed by why
qwen-iq3-s-l2-v4.kar + provenance 55.3 GB port (KAR PLE), Original --ple-kar arm the compressed PLE source; level 2 is lossy (an experimental arm, not the control)
data/iq3_s (dense.bin, index, native_experts.txt, tokenizer) 1.5 GB Original its native pack
data/mtp-rt 0.8 GB both the MTP draft layer
data/expert-profile.bin 196,632 B, sha256 8f59b4aa...6388975baf both (VRAM tier ranking, resident budget) upstream data/expert-profile.bin at the pinned Strata commit d9ab8435; the imported subtree omits it
GGUF shard 1 54,817,524,224 B both, strictly the routed experts (no non-lossy compressed source exists: the KAR archive's level-2 experts have relative L2 ~0.33 and no quality gate), the dense GGUF projections and the native head
GGUF shard 2 28,800,138,432 B both, strictly Original: --native opens every shard of the split (gguf_split_paths, generate.cpp:1544) and --ple-io direct reads the table from it; port: Qwen4ExpArtifact::bind and KarPleBinding::new verify both shard digests and the PLE descriptor even when the rows come from KAR

All model files live on the WSL ext4 disk (~/laptop/model, ~/laptop/data): /mnt/c is a 9p mount, far slowe for mapped and direct reads. Nothing of it is in Git.

The Original's low-memory modes (engine/strata, unmodified)

From generate.cpp, expert_source.cpp, setup.py and docs/DETAILS.md:

mode flags experts in RAM fits this laptop
resident arena (default) none all 50.3 GB, pinned no
low-RAM mapped --mmap-experts (GGUF in place when the pack has no experts.bin) OS file cache only yes
low-RAM resident --resident-experts = --mmap-experts --resident-cpu-experts, page-locked, 4 GiB headroom, soft the complement of the GPU cache if it fits, else (#467) what fits, hottest by profile yes (the "what fits" path)
RAM budget --resident-budget-gib N N GiB, hottest by profile, rest mapped; lookahead page prefetch of the next layer's predicted experts yes
PLE --ple-io direct (default) / --ple-kar (KAR-enabled build, experimental) 90 MB row cache / file cache yes
KV --kv int8, --kv-resident 32768 from 64K (setup turns streaming off under WSL) none at 8K yes

setup.py's argument set for IQ3_S: --pack --native SHARD1 --ple-gguf SHARD2 --expert-profile data/expert-profile.bin --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp DIR --max-context N [--kv int8] [--resident-experts | --mmap-experts]. setup.py's table lists IQ3_S at 62 GB of RAM (48 GB: IQ2_XS or Q2_0); for a PC whose RAM cannot hold the experts it picks the low-RAM resident variant, which is what is measured here.

What the port lacked for this laptop

The Original serve stack of the port (docs/original-serve.md) opened only with server-sized sources:

mechanism Original port before port now (this branch)
expert source without a 50 GB copy --mmap-experts, GGUF in place none: load_resident_expert_source copies 50 GB and needs MemAvailable >= 58 GB load_mapped_expert_source: read-only shared mapping of shard 0; MappedExpertBank pageable mode (copies staged by the driver, no 50 GB cuMemHostRegister)
RAM budget / resident complement --resident-budget-gib, --resident-experts none LELEKA_ORIGINAL_SERVE_RESIDENT_BUDGET_GIB: hottest non-VRAM experts page-locked in place (read-only registration of the file pages), same clamp
KAR PLE without holding the archive in RAM PleTable::open_kar maps the file 55.3 GB sealed memfd (shmem) InheritedKarArchive::open_read_only_file: regular read-only file, verified at load
PLE direct from the GGUF --ple-io direct not ported (the Original serve stack needs KAR PLE) not ported
VRAM expert tier sized for 16 GB --expert-cache auto + profile merged from claude/expert-residency, never run on a real model used here, first real-model run
MTP --spec 4 --mtp present (--mtp-rt-dir / pack) unchanged
KV sized by --max-context yes always 262,144 cells: 3.32 GB pinned host copy + 0.42 GB VRAM window at any ceiling LELEKA_LAPTOP_CELLS (bench only, experimental)
sm_86 companion of qsa_prompt_resolver.ptx n/a stale after the kv-streaming reseal (2 arch_ptx tests failed; the 3080 would load the sm_120 image) regenerated
lookahead page prefetch of predicted experts STRATA_LOOKAHEAD none none
PCIe share of misses --pcie-frac 0.55 over the pinned complement _PCIE_FRAC default 0 0 (pageable bank)

Results, 2026-10-16 (one laptop, WSL2, n = 6 requests per arm)

Workload: benchmarks/laptop/prompts.txt (3 user turns, thinking off, 88 / 83 / 78 tokens, tokenized once with chat_tokens and fed as the same IDs to both engines), 128 new tokens, greedy, each prompt served twice in one process (pass 0, pass 1), conversation cache off, --max-context 8192 / ceiling 8192, INT8 KV, spec 4 + MTP (data/mtp-rt), --spec-min-p 0.5, expert profile sha256 8f59b4aa... , 7 CPU expert workers. Cache state: no root, so page caches could not be dropped; each arm starts with whatever the previous one left (recorded per arm in ~/laptop/results/*.cache). Engine: Original engine/strata at this branch, built for sm_86 with CUDA 13.2.86 (STRATA_NEXT_EXPERIMENTAL_KAR_PLE=ON); port: branch claude/laptop-profile, --features sm86, release. Model: the two IQ3_S shards (sha256 4c1eb2ce..., 316b46f3..., verified on copy) and the level-2 KAR archive (536d612c...). TTFT is measured from sending the request to the first emitted token; decode tok/s is produced tokens over the decode phase; prefill tok/s is prompt tokens over the prompt phase. VRAM is nvidia-smi's peak fo the whole GPU; RAM is the process's peak RSS (file-backed pages are reclaimable).

arm PLE experts decode tok/s mean (median, range) prefill tok/s mean TTFT mean (range) load to ready peak VRAM peak RSS (anon / file / shmem)
Original, --resident-experts (falls back to mmap under WSL2, see above) GGUF direct 4,632 VRAM slots + mmap 5.64 (5.61, 4.45-7.12) 8.7 10.0 s (8.0-12.0) 34 s 15,093 MiB 22.4 GB (2.3 / 19.8 / 1.1)
Original, same, KAR PLE (--ple-kar ... --ple-kar-gpu-cache-mib 64) KAR L2 same 8.15 (7.45, 6.75-10.17) 12.4 7.2 s (4.6-9.1) 150 s 15,111 MiB 22.9 GB (2.0 / 22.3 / 1.1)
Original + WSL cgroup fix (diagnostic arm), resident 16.83 GiB page-locked, KAR PLE KAR L2 4,597 VRAM + 16.8 GiB RAM + mmap 10.61 (10.93, 7.00-14.44) 18.6 5.0 s (3.6-8.4) 161 s 15,111 MiB 22.2 GB (1.9 / 15.1 / 18.1); MemAvailable fell to 2.2 GB
port, mapped experts + VRAM tier (profile, auto) KAR L2 3,133 VRAM slots + mmap 2.70 (2.63, 2.15-3.68) 3.1 28.4 s (20.6-36.6) 212 s 14,195 MiB 20.5 GB (2.1 / 17.8 / 3.9)
port, adaptive swaps off, decode reserve 512 MiB KAR L2 3,397 VRAM slots + mmap 2.62 (2.67, 1.81-3.13) 3.5 25.2 s (21.0-30.7) 193 s 14,709 MiB 20.3 GB
port, + resident budget 16 GiB (clamped to 11.42 GiB page-locked) KAR L2 3,133 VRAM + 11.4 GiB RAM + mmap 2.39 (2.27, 1.48-3.44) 3.1 30.2 s (21.2-46.9) 214 s 14,195 MiB 14.0 GB

The paired comparison is row 2 (unmodified Original, the mode it actually runs in under WSL2) against row 4 (port): same prompts, same PLE source, same profile, same VRAM-tier policy, greedy. The port is 3.0x slower in decode (2.70 vs 8.15 tok/s), 4.0x slower in prefill (3.1 vs 12.4 tok/s) and 3.9x later to the first token (28.4 vs 7.2 s), with 1.5 GB less RAM, 0.9 GB less VRAM and 1,500 fewer VRAM expert slots. Greedy outputs of the two agree on the first 47 / 43 / 57 tokens of the three prompts and then diverge (GPU and CPU experts round differently and the two place different experts on the GPU; the Original itself diverges from its GGUF-PLE run after 44 / 42 / 128 tokens). This is not a quality gate. Rows 1 and 2 differ in the PLE source and in page-cache state at the start; they are not a PLE A/B.

Where the port's time goes (traced run, LELEKA_BRINGUP_TRACE=1, 3 prompts x 48 tokens): every decode millisecond is inside run_window (62 windows, 62.8 s, 1,014 ms mean per verify window; begin_adaptation 13 ms, draft 10 ms, everything else < 1 ms). The Original spends ~0.35-0.45 s per round on the same prompts. In the window, the routed-expert CPU tier (CpuExpertPool::run_entries) prepares every job on the calling thread (prepare_scoped copies the expert's three matrices out of the bank, i.e. page faults on the mapped shard, serially) before the workers compute; the Original's pool reads the blobs where they are, fetches a layer's missing experts on 8 threads and prefetches the next layer's predicted experts. Neither the resident budget nor turning adaptive swaps off changed the port's rate beyond the run-to-run spread, which points at that path rather than at residency. The prompt path likewise copies each borrowed expert with a host-blocking pageable cuMemcpyHtoDAsync on one thread, where the Original stages through pinned buffers with helper threads.

Recommendations and open items

  1. Port next (largest measured gap): parallel, zero-copy CPU expert preparation over the mapped bank (literal expert_pool_dispatch_multi + FileExpertSource fetch threads and routing lookahead), then pinned staging fo the prompt copy ring. Re-measure with the same harness.
  2. VRAM: the port leaves ~1,500 fewer expert slots than the Original; the 1 GiB per-request verifier reserve, the 262,144-cell KV geometry (3.1 GiB pinned host + 0.65 GiB VRAM at an 8K ceiling) and the verifier being assembled per request are the candidates (LELEKA_LAPTOP_CELLS exists in the bench for an experiment; not run here).
  3. WSL memory: with the default 50 % (23.3 GiB) the Original's resident mode (fixed) left 2.2 GB available. A %UserProfile%\.wslconfig with [wsl2] memory=40GB swap=8GB would let the complement grow toward ~30 GiB of the 38 GiB the GPU does not hold. Needs wsl --shutdown; not applied.
  4. The Original's available_memory_bytes() hybrid-cgroup bug (WSL2) is worth an upstream-style fix in the fork; this branch does not modify engine/strata.
  5. Native Windows would give the Original the full 47 GiB and its Windows paths (PrefetchVirtualMemory, working-set trimming); it needs a Windows CUDA toolkit install (not present), so it was not tried.
  6. Statistics: n = 6 per arm (2 passes x 3 prompts), single process per arm, uncontrolled page-cache state; the charter's paired-A/B requirements (>= 30 repeats, CIs) are not met. Treat the ratios as indicative.