feat(pflash): prefill compress up to 128k -> 2-12× prefill (content-dependent), decode at parity
TL;DR
Adaptive composition stack: pflash compression + dflash spec-decode + ee7 drafter + anchor-transitive cascade + gated rare-token bridge + adaptive anchor_radius (64K NIAH cliff fix) + per-request fa_window_override + C2 mechanism gate + type-gate regime router (default-OFF).
Prefill speedup is content-dependent:
- ~12× prefill-TPS on sparse/NIAH cells (Round5),
- ~2.2× wall on dense agentic 64–128K (full-sweep 2026-05-29),
- 3.00× prefill-TPS / 2.91× wall on real dense >32K agentic turns with the router ON (verified on this branch's tip, 2026-05-31 — see §Verified A/B).
Decode at parity (composition); +35% with the router on (shorter compressed KV).
Adaptive levers
-
Adaptive
anchor_radius(4a838dd):<32K=2 / 32–64K=4 / ≥64K=8based onn_chunks. Eliminates the 64K NIAH cliff. Override viaPFLASH_COMPRESS_ANCHOR_RADIUS. -
Per-request
fa_window_override(2726608, Design 1): when pflash compresses,http_serversetsfa_window_override = effective_prompt + 256. Never caps visibility. -
C2 mechanism gate (
2726608+ refactor548be0a): ifeff_fa_window ≤ 2 × cfg_.fa_window(= 4096 default), spec-decode runs. Else AR fallback. Extracted toserver/src/qwen35/c2_gate.has a pure tested predicate + 5 unit tests. Zero behavior change. -
Effective-size admission gate + keep-ratio guard (
8c1f37d): the context-window admission check gates on the post-compression effective size, not the raw prompt — a prompt larger thanmax_ctxthat compresses to fit is admitted (previously a hard 400) without forcing an oversized KV reservation. Default--prefill-keep-ratio0.05→0.10 (anchors yield ~40% effective;keep=0.25over-forces the cascade to ~100% = near-no-op). Verified at >128K: raw 166,911 → eff 71,110 (42.6%), admitted atmax_ctx=139264. -
Type-gate regime router (
fbc2d41/b31544f/8fc961b, default-OFF behindPFLASH_ROUTER_ENABLE): correct-by-construction admission-time gate.server/src/common/regime_router.his pure stdlib (96 LOC, 59 standalone-Werrortests). Logic:- agentic request (structured
toolsarray /tool_use/tool_callspresent) → keep floor 0.25, transitive cascade OFF. The cascade keys on rare-token co-occurrence, and the 151K drafter vocab makes ~every token "rare" → it over-forces dense agentic content to 70–100% keep (a near-no-op). Disabling it + flooring at 0.25 is what delivers the win below. - retrieval request → full keep, cascade ON (cascade is correct for QA/NIAH recall).
- empty/degenerate guard: a compressed agentic turn that returns empty/degenerate skips the keep-bandit and one-shot recovers to full keep next turn (
PFLASH_GUARD_MIN_TOKENS, default 8). - floor-clamp: the online keep-bandit (PR #264) is clamped up to the 0.25 agentic floor so it can't undercut the router.
- agentic request (structured
Verified A/B (router ON vs OFF) — 2026-05-31
Binary built from this branch tip (8fc961b), verified to contain both the admission-gate (dflash::common::check_admission symbol) and the router. 4 cold-prefill turns on real organic agentic sessions (claude-code transcripts, user turns at 34–37K est tokens, native tool blocks + tools array → agentic path fires). Fresh server per arm (true cold prefill). Run dir: bench/2026-05-31_definitive_ab/run_20260531_111334/.
| Metric | ROUTER OFF | ROUTER ON | Speedup |
|---|---|---|---|
| keep % | 72.3% (44.7–100) | 24.9% (25) | — |
| prefill_TPS | 1248 | 3747 | 3.00× |
| wall_s | 64.9 | 22.3 | 2.91× |
| decode_TPS | 20.6 | 27.8 | +35% |
| tool_parse | 4/4 OK | 4/4 OK | held |
All 4 ON turns routed type=agentic, keep=0.25, cascade=off. 0 floor-clamps, 0 guard fires. The admission-gate does not suppress the cascade over-forcing (OFF still 72% avg), so the router win is real on the shipped base. N=4 cold turns; numbers match the earlier-base measurement (2.85×/2.89×) within noise.
Reproducibility
./server/build/dflash_server /path/to/Qwen3.6-27B-Q4_K_M.gguf \
--draft /path/to/dflash-draft-3.6-q4_k_m.gguf \
--prefill-drafter /path/to/Qwen3-0.6B-Q8_0.gguf \
--prefill-compression always --prefill-keep-ratio 0.10 \
--prefill-threshold 32000 --max-ctx 139264 \
--chat-template-file qwen3-coder-chat-template.jinja
Env: PFLASH_COMPRESS_ANCHOR_TRANSITIVE=1 PFLASH_DRAFTER_EARLY_EXIT_N=7 PFLASH_DRAFTER_SCORE_LAYERS=7 DFLASH27B_KV_K=tq3_0 DFLASH27B_KV_V=tq3_0. Router: add PFLASH_ROUTER_ENABLE=1.
Bench dashboard: bench/2026-05-28_adaptive_stack/Round5_4arm_matrix_174641/DASHBOARD.md. Public evidence: https://github.com/dusterbloom/pflash-evidence.
Notes
- The "+47% decode TPS" figure is C_pflash_only vs A_baseline, not D_composition vs A_baseline. Pflash compression delivers it. Composition decode TPS is at parity-or-slightly-below pflash-only because the C2 gate (correctly) disables spec-decode on compressed KV.
- The router (lever 5) is default-OFF; merging it changes no default behavior. It adds opt-in code + 401 LOC of tests.