Files
leleka/docs/experiments/2026-10-03-serving-gpu-ple.md
T
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

8.1 KiB
Raw Blame History

Experimental GPU PLE cache in Strata serving, 2026-10-03

Scope and implementation

This is an opt-in PLE-only integration into the Linux CUDA Strata fork. The normal expert, projection, embedding, and KV paths still use the native pack. --ple-kar ARCHIVE --ple-kar-level 2 --ple-kar-gpu-cache-mib N keeps selected 50-byte compressed PLE rows in bounded 64-byte VRAM slots, uploads only cache misses, and decodes requested rows into the existing F32 PLE consumer buffer on CUDA. Prefill and ordinary token decode use it. Speculative verification still gathers the same KAR rows on CPU because its captured graph reads mapped host memory. The option is disabled by default.

The CUDA component owns pinned update and slot-ID staging buffers. It waits for its previous CUDA completion event before reusing them, including when callers change streams. An overfull batch is rejected before mutating LRU state; the engine divides a prefill gather by slot capacity so a small cache can proceed. The archive is payload-CRC-verified before the cache opens. This does not constitute full compressed-weight serving or a model quality gate.

Correctness on the target GPU

Hardware was a Linux RTX 5090, NVIDIA driver 595.91.07, CUDA 13.2.86 and a 600 W reported power limit. The private Qwen3.8-Flash-Next IQ3_S KAR v4 archive and source-shard identities are recorded in the CPU KAR comparison. The test preserved the verified source shards and archive on the external model volume.

An isolated component probe read rows on both sides of the boundary at global row 200,000,000. Across three batches and 18 accesses it produced a byte-exact CUDA/independent CPU match, with 8 hits and 10 misses in a 1 MiB cache. The probe also rejected a batch with more distinct rows than slots. The archive's payload CRCs passed.

The integrated engine probe then gathered 32,768 adjacent rows starting at 199,990,000, crossing the same part boundary. Its 1 MiB cache had 16,384 slots, so the engine issued two CUDA batches. The complete F32 output matched the engine's CPU KAR gather byte for byte; FNV-1a64 was 7e6a191b508d0461. This probe had zero cache hits and 32,768 misses by design, and uploaded 1,966,080 argument bytes. It checks the small-cache batch split and the two-part row mapping.

After lifting the prefill gather's 4,096-token guard, a final engine build compared 65,552 rows (4,097 tokens) from the same start row, again crossing the part boundary and splitting over the 16,384-slot cache. CPU/CUDA F32 output was byte-exact, FNV-1a64 450b9dc4bfd7320d; zero hits, 65,552 misses, 3,277,600 compressed row bytes, and 3,933,120 H2D argument bytes were reported. This covers a prefill batch larger than the old guard. The final rebuilt engine binary SHA-256 was f00569d3071577d3f9ecb0bc92d3f9f86c4b1eb7ca0059b1443f52b7410874ed.

First full-model functional pair and order reversal

One process per arm used a 2,048-token synthetic prompt containing token IDs 1 through 2,048, 16 greedy output tokens, one 256K context, INT8 K+V with 32,768 resident cells, MTP depth 4, the same native pack and source GGUF shards, and a 64 MiB GPU PLE cache in the candidate. CPU KAR and GPU-cache arms ran sequentially. The first pair used --expert-cache 10000; profile packing made the actual expert counts differ (12,691 CPU, 12,656 GPU), so it is a functional comparison only. Both arms produced the same 16 output IDs, SHA-256 b4dd327bdcee9ad184003caf38747352ca5689b9208d2b46ef366fa1f50147a6.

The next four runs used --expert-cache 9000, resulting in 11,763 expert slots in every arm. The order was GPU, CPU, CPU, GPU. All four produced the same 16 greedy IDs. The process binary for this four-run sequence was SHA-256 a27d1fc9c9f240d499346f93c1f184c7d30c076819af66691ceac0cd6b4a9b9c.

Order PLE arm Prefill tok/s Decode tok/s PLE time within prefill Output IDs
1 GPU cache 67.34 34.68 29,278.2 ms Same
2 CPU KAR 1,970.40 78.73 214.0 ms Same
3 CPU KAR 2,182.63 89.41 138.9 ms Same
4 GPU cache 640.16 75.59 2,429.9 ms Same

The GPU arm saw 32,752 PLE row accesses with only 3 hits in each run. Its 32,749 misses admitted 1,637,450 compressed bytes and sent 1,964,952 argument bytes across H2D, versus 20,961,280 F32 PLE bytes in the CPU prefill upload. Those are API payload sizes, not measured PCIe transactions. The lower transfer size did not translate into a demonstrated speedup: random reads and host packet assembly from the NTFS archive dominated this low-reuse prompt. Arm order and file-cache state changed PLE time by orders of magnitude. The final warm-order GPU arm was slower than the adjacent CPU arm, but these one-shot runs cannot isolate the cache's own steady-state effect. The prompt is synthetic and does not judge task quality.

Repeated requests in a loaded process

The native --serve protocol ran each arm in one process, with two warmup requests and five measured requests per prompt, --prompt-cache 0, and --conversation-cache-mib 0. The same 11,763 actual expert slots, 256K context, INT8 K+V, 32,768 resident cells, MTP depth 4, native pack, KAR archive, and 64 MiB candidate cache were used. One synthetic prompt had 2,048 distinct token IDs; the other repeated IDs 1–128 sixteen times. CPU started first. Every corresponding CPU/GPU request produced the same output IDs and finish reason. For the repeated prompt, output length changed within both arms in the same request order (16, 16, 16, 3, 3); this test therefore does not establish deterministic output for repeated requests.

Prompt CPU median prefill tok/s GPU median prefill tok/s CPU median prefill ms GPU median prefill ms CPU/GPU median decode ms
Distinct IDs 2,978.0 3,027.8 687.7 676.4 22.3 / 21.9 (2 generated tokens)
Repeated IDs 3,010.9 3,037.2 680.2 674.3 151.5 / 150.0 (mixed output lengths)

The measured prefill-rate differences are approximately +1.7% and +0.9%. Five repeats per arm, fixed startup order, synthetic prompts, and short or unstable generations do not establish a repeatable performance gain.

Reversed-order 128-token control

A second same-process sequence started GPU first, then CPU. Both arms used --adapt-swaps 0 for static expert residency and an unreachable EOS ID so each request completed 128 output tokens. Each prompt had two warmups and five measured repeats, with prompt/conversation reuse disabled. Actual expert slots were 11,763 in both arms; the binary SHA-256 was 0566013995d6d8b2fdf817bbe9e6fcbb6a1d7c0f756d2a4382967be9fcaef6de. All 10 CPU/GPU output pairs were token-exact (20 outputs total), and each prompt's five output hashes were stable within both arms. Draft acceptance matched exactly: 71/108 for distinct IDs and 90/108 for repeated IDs. On the final repeated request, both arms reported 83.2% decode expert-cache hits (54,326/65,298) and 99.29% KV-streaming hits (918,060 block reads; 26.3 MiB from RAM).

Prompt Arm Median prefill tok/s Median decode tok/s Median prefill ms Median decode ms
Distinct IDs CPU 2,984.6 133.04 686.2 962.1
Distinct IDs GPU 3,035.4 133.70 674.7 957.4
Repeated IDs CPU 3,015.3 147.75 679.2 866.3
Repeated IDs GPU 3,032.7 148.29 675.3 863.2

Paired GPU/CPU rate ratios over five repeats were 1.0146–1.0181 for distinct prefill, 1.0041–1.0075 for distinct decode, 1.0053–1.0080 for repeated prefill, and 1.0029–1.0058 for repeated decode. These narrow within-process ranges are encouraging but are smaller than startup/file-cache variation between processes. There were only five pairs per prompt, synthetic 2K prompts, and no native PLE arm in this control. The earlier native-versus-CPU KAR test found no overall gain. We therefore keep the GPU path experimental and make no accepted end-to-end speedup claim. A real 256K agent workload, tool-call quality gate, at least 30 pairs for a 1% claim, cold/warm stratification, and whole-model GPU memory-pressure measurement remain open.