How one token and one prompt are processed
Memory topology: NVMe holds the checkpoint and the expert store. The store is memory-mapped, and the OS page cache in RAM serves the CPU kernels at 24–29 GB/s effective in the v4 server (MEASURED). That is an end-to-end rate for the mapped file, lower than the 38.6 GB/s ceiling of the kernel probe used in the budget section. PCIe carries admissions and prompt staging, with pinned host-to-device transfers at 21.4 GiB/s (MEASURED on this host in the earlier research project). Resident experts are read from VRAM slots.
- Each layer is one CUDA graph of five fused Triton kernels: QKV, attention with split-K, output projection, router and top-k. These five kernels replace about 94 PyTorch kernels per layer. The whole core takes 3.4–4.0 ms per token instead of 10.0–10.7 ms (MEASURED).
- The router kernels write the normalized hidden state, 4 expert ids, 4 weights and a hit mask straight into pinned host memory, with no copy.
- The GPU runs MXFP4 GEMVs for the resident experts. A host thread waits on an event and calls the CPU kernel for 0–4 missed experts (8 threads, AVX-512). The original path uses OpenMP; v10's selected path uses a persistent native team.
- The next layer's graph reads the CPU result zero-copy. After layer 36 a tail graph applies the final norm, lm_head and argmax or Gumbel sampling.
Per-layer messages bypass the copy engine. Before that change, 13.2 MB admission copies queued ahead of them, and the GPU wait fell from 9.5 to 4.8 ms per token when it was fixed (MEASURED). The 4.8 ms is the same figure as in the Sep 30 (2) row of the budget table.
VRAM residency and admission
The original v4 layout had 250 static slots and 180 adaptive slots. The current selected profile retains 250 static slots and has about 500 slots in total. Static slots hold coding-hot experts and are never evicted; adaptive slots follow the current request. Admission is copy-on-compute. When a miss is an admission candidate and one of 16 capture buffers is free, the CPU kernel writes the expert's bytes into a pinned buffer as it reads them, so there is no second store read. A copy stream then uploads the bytes into a victim slot, and the slot table flips when the copy lands.
Before v9, candidates were refreshed every 8 tokens, or every 4 in the first 32; v9 changed the candidates per refresh with --refresh-m 16. The admission rate is a device-class lever, so answers can differ. Prompt routing counts as at most 16 generated tokens (--prefill-weight 16). The v3 first answer ran at 0.83× llama.cpp (2 runs: 0.67× and 0.99×, MEASURED). RESULTS.md gives two causes: admission chasing the prompt's experts, and page faults from RAM pressure. The prompt weighting addressed the first; VRAM hit rate on the first answer went from 0.177 to 0.311 (MEASURED). The v3-to-v4 step also changed RAM residency, so this is not an isolated ablation.
RAM residency
The Sep 24 explanation was that a long prompt makes Windows trim expert pages, and the next answer faults them back 4 KB at a time. First answers showed 1,000–1,500 page faults per token against 10–350 for follow-ups (MEASURED, v4). This fits the trim explanation but does not isolate it. Three fixes addressed this: --release-resident 1, a warm-up ranking that fills free RAM, and --ws-min 1, a soft minimum working set. A later audit (Sep 30) found that the remaining first-answer faults are mostly compulsory first touches of released adaptive-slot experts, worth at most +1–2% (MEASURED/audit), plus stall windows under RAM pressure.
The CPU kernel
The decode kernel streams experts from RAM with 8 threads. Its threads share rows dynamically (schedule(dynamic)) and meet at one spinning barrier that yields to the OS. Each output row is reduced in a fixed order by a single thread, so scheduling does not change the result. This was verified bit-identical by content-hash comparison at frozen residency (MEASURED).
v10 removes the repeated OpenMP team entry/exit from supported fused decode calls. The caller remains a worker alongside seven persistent native threads, retaining the same 64/32-row chunks, scalar activation, scratch materialization, capture bytes and expert accumulation order. Jobs, settings and shutdown are serialized; capture stores are fenced before completion is published. Request counters report actual persistent jobs and reference-path fallbacks. The separate DLL defaults off and requires --kdll gptoss_cpu_persistent.dll --kernel-persistent 1 --kernel-fuse 1.
Floating-point controls are sampled from the actual OpenMP team, reproduced for the native workers and restored after work. Nonstandard rounding/DAZ/FTZ callers and unsupported configurations fall back to the reference path. Exactness is bounded by the tested environments, not every possible thread floating-point state. The DLL was built with GCC 16.1, -O3 -march=native -fopenmp -shared, for this Windows/AVX-512 host; it is not a portable binary.
Prompt processing
Prompts run layer-major in blocks of up to 4,096 tokens. Tokens are grouped by expert on the GPU. Resident experts use a GPU GEMM from the slot. A non-resident expert with 16 tokens or fewer goes to a CPU multi-token kernel on a worker thread. A non-resident expert with more tokens is copied through a pinned 4-deep ring to a scratch slot for a GPU GEMM.
--prefill-order layer runs each layer over all blocks, so each staged expert is copied once per layer instead of once per block. A 13k prompt staged 8,460 (layer, block, expert) triples; in block mode that meant one copy for each, and layer mode needed 2,717 staging copies for the same 8,460 pairs (MEASURED).
In the sixth pass the GEMM tile height BLOCK_M was raised from 16 to 64: the 16-row tensor-core tiles wasted rows, and the 13k prompt went from 10.78 / 12.22 s to 7.67 / 7.73 s in mirrored runs (MEASURED, step22), bit-identical by the in-process check (logits, every layer's K/V and the ring buffers equal). A staging producer thread that runs the copies of staged experts ahead of the main thread was neutral at BLOCK_M 16, when the GPU was the wall and the main thread waited 4.0 s for staged copies, and useful at 64 (stage wait 0.3 s). A cached Triton launch path shipped with it, exact. A grouped bias/SwiGLU epilogue per slot group was also exact but measured neutral: host launch time fell from 4.4 to 2.7-3.4 s while the wait for staging grew by the same amount, so the 13k prompt is balanced between host and GPU at about 7.2 s (MEASURED, step25), and the grouping stays opt-in. The instrumented split at BLOCK_M 16 (12.3 s) was: host GEMM-launch time 4.0 s over about 12,500 expert-GEMM calls of about 10 pointwise launches each, synchronous staging copies 2.45 s, copy-ring wait 1.3 s, routing sync 3.45 s, with the CPU multi-token kernel's 3.9 s on its worker thread never waited on (MEASURED, step19).
The October 1 grouped GEMM is a different lever: it combines independent expert/block GEMMs into fewer launches while preserving each pair's tiles and ordered dot accumulation. The selected profile uses groups of three, a soft 1,024-row workspace target and a guard of 1,024–4,096 new rendered tokens in a single block. Tiny and multi-block inputs retain the stock path. Address/pitch guards preserve vectorized loads where valid and retain an unaligned fallback. Synthetic and full-model hidden/logit/K/V checks passed; larger workspaces and long-prompt grouping regressed in warm serving, so they are excluded.
At the synchronized prompt/decode boundary, the profile releases unused CUDA allocator blocks without changing live weights, slots, K/V or graph addresses. Long-prompt trials reduced reservation from about 10.830 to 9.715 GiB; the first release cost about 6 ms, charged to prompt time (MEASURED). This is a memory saving, not an independently established decode-speed gain. The warm 3k improvement measures the first-pass profile, not a new timing experiment with persistent CPU workers added.
K/V cache and API
A rolling K/V ring serves the sliding-window layers, which frees about 0.55 GiB of VRAM (CALCULATED; half of the 1.1 GiB K/V). Ring checkpoints let a conversation resume without reprocessing. The API is OpenAI-compatible: /v1/chat/completions (streaming and not) and /v1/models. Tool calls use the gpt-oss harmony format, one per response. The server takes one request at a time, with no concurrent requests and no batching; all throughput figures are single-stream.