File size: 9,942 Bytes
bb6c4d1 3841953 ee05680 bb6c4d1 3841953 c59a8e8 bb6c4d1 3841953 bb6c4d1 635a60c bb6c4d1 3841953 c59a8e8 3841953 635a60c bb6c4d1 c59a8e8 ee05680 bb6c4d1 ee05680 1405d18 bb6c4d1 c59a8e8 3841953 635a60c bb6c4d1 635a60c bb6c4d1 c59a8e8 bb6c4d1 c59a8e8 3841953 635a60c 4061adc 635a60c 4061adc bb6c4d1 3841953 bb6c4d1 3841953 c59a8e8 bb6c4d1 c59a8e8 bb6c4d1 635a60c bb6c4d1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | ---
license: other
language:
- en
tags:
- lucebox
- pflash
- prefill-compression
- gguf
- qwen3.5
base_model: Qwen/Qwen3.5-0.8B
---
# PFlash
PFlash is Lucebox's prefill compression stack for long prompts and agentic sessions.
A small drafter ([`Qwen3.5-0.8B`](https://huggingface.co/unsloth/Qwen3.5-0.8B-GGUF)) reads the prompt once
(blocks `0..15` only), and four lightweight components on its activations decide what the large reader model
prefills:
1. **Segment probe** (`segment-probe.gguf`) cuts the prompt into whole structural units (statements and
definitions, sentences, records, chat turns, tool calls) and emits container boundary probabilities;
2. **Request probe** (`request-probe.gguf`) finds which tokens carry the user's request, wherever it sits in
the prompt;
3. **Stage-1 scoring head** (`seg-scoring-head.gguf`) computes calibrated NoPE query→context attention density
plus both uniform (`k_bar`) and attention-mass-weighted (`k_att`) L2-normalized per-segment key centroids;
4. **Dual-key bidirectional segment reranker** (`seg-reranker.gguf`) refines segment relevance with full
cross-segment context (`~1.5–4 ms` on GPU) over concatenated `[k_bar, k_att]` (`1024`-dim) representations
and drives the PFlash November Update adaptive keep-ratio safety net.
All Stage-1 signals read the same tap — the drafter's block-14 residual (`post_block14_residual_before_block15`)
— from the same single forward pass. The highest-ranked units that fit the budget go to the reader in their
original order, plus the pinned request.
## Files
| file | component | architecture / schema | sha256 | size |
|---|---|---|---|---:|
| `segment-probe.gguf` | Segment probe | `segmentprobe` (`qwen3_5_0_8b_segment_probe_v2`, ~263K params) | `470b7b0efe3736518dcb4c1ba8eb5b806107007e378a74668c17e26434602e68` | 1,062,976 bytes |
| `request-probe.gguf` | Request probe | `requestprobe` (`qwen3_5_0_8b_request_probe_v1`, ~265K params) | `5915557d4b60f5a08c8ef18fdd7a30cba56c3a24fda1c2b988da4a41313ebf49` | 1,060,192 bytes |
| `seg-scoring-head.gguf` | Stage-1 scoring head | `pflash_scoring_head` (`qwen3_5_0_8b_nope_qk_mass_v1`, 2.62M params) | `95e13076bff5c9b204c615366dfe08dbfa56aaa0bb417ff3dbf7d09c5906c1d6` | 10,486,400 bytes |
| `seg-reranker.gguf` | Dual-key bidirectional segment reranker | `pflash_seg_reranker` (`pflash_seg_reranker_v1`, 3L/384d/6H `kbar_katt` 1024d, `delta >= 0`) | `978bcb34c443927708fe25321704f67a969cf381660475f103f2bb2d6264c7a0` | 25,012,768 bytes |
- **Drafter** (required, verified by sha256 at load):
[`unsloth/Qwen3.5-0.8B-GGUF`](https://huggingface.co/unsloth/Qwen3.5-0.8B-GGUF) `Qwen3.5-0.8B-BF16.gguf`,
sha256 `cedf89af31c9041b601fa58303285bc46d99c51baee1b13f5e919626ca526ee5`. Each component refuses to load
against any other drafter file.
## How it works
- **Segment probe (`segment-probe.gguf`)**: LayerNorm(1024) → Linear(1024, 256) → GELU → three 5-tap Conv1d +
residual heads emitting per-token `unit`, `container`, and `sub-unit` logits. Cuts at unit threshold `0.8`
with `min_segment=32`, `max_segment=512`, and line-aligned oversize splitting preferring sub-unit starts.
Container probabilities feed directly into the segment reranker as left/right boundary features.
- **Request probe (`request-probe.gguf`)**: LayerNorm(1024) → Linear(1024, 256) → GELU (erf) → Linear(256, 1).
Locates the user's request inside long pastes, RAG prompts, or multi-turn chats, trims each connected
request component to the 1D convex hull of its positive-logit (`s1 >= 0`) runs (`run >= 2`, falling back to
`run >= 1` then full extent) so inline question tokens stay intact without bridging disjoint spans, pins
whole request units verbatim (up to 512 tokens), and uses score-calibrated blend weight
(`PFLASH_QUERY_TW=score`) without prose-vs-paste heuristics. On autonomous tool turns and Lucebox Mix
switches, active tool observations are promoted as the query role.
- **Stage-1 scoring head (`seg-scoring-head.gguf`)**: Two projection matrices (`attn_q` `[1024, 2048]`, `attn_k`
`[1024, 512]`) computing GPU-reduced NoPE query→context attention mass density per unit plus L2-normalized
mean key centroids (`k_bar`) and attention-mass-weighted key centroids (`k_att`) in a single GPU pass.
Calibrated Stage-1 `.lift` is preserved separately for recall gating (`PFLASH_RECALL_GATE`).
- **Dual-key bidirectional segment reranker (`seg-reranker.gguf`)**: 3-layer bidirectional Transformer
encoder (`d_model=384`, `n_heads=6`, `head_dim=64`, `d_ff=1024` SwiGLU, Pre-RMSNorm, 1D segment-index NeoX
RoPE with `theta=10000`, no causal mask) over non-mandatory, positive-mass body segments (`N_seg ~ 200–1500`).
Consumes concatenated `[k_bar, k_att]` (`1024`-dim), pooled `[q_bar, q_bar]` (`1024`-dim), multiplicative
interaction `W_int(k_d * q_d)`, and 12 per-segment scalars (z-scored density, relative density, mass, max,
top-4, peak ratio, length, position, left/right container probabilities, and left/right adjacent segment key
cosine similarity `adj_kcos`), emitting a sparse, bounded non-negative residual promotion (`delta in [0, 100]`,
metadata `reranker.delta_min`/`reranker.delta_max`) on Stage-1 `log_density` so isolated needles cannot be
suppressed while multi-hop and cross-segment reasoning evidence is promoted.
- **Stage-1 nucleus mass-floor + one-sided adaptive keep-ratio safety net**: Computed in `<0.1 ms` from the
optional-segment scores:
- **Stage-1 nucleus mass-floor (`p = 0.90`, cap `0.58`)**: monotonically widens the keep budget to cover
`90%` of the calibrated Stage-1 optional attention mass (capped at `0.58`), keeping sharp queries on the
fast base curve (`~28–29%` kept) while giving diffuse, multi-hop, or implicit-needle prompts the evidence
budget they need;
- **Adaptive perplexity safety net** (`eff = exp(H_tok) / N_opt`, `T = 0.85`): `eff >= 0.42` monotonically
widens to `max(curve, eff)`, and `eff >= 0.58` (diffuse/global query) bypasses to `100%` raw verbatim full
prefill whenever the prompt fits `max_ctx` (while preserving warm KV prefixes on continuations).
## Using it
The PFlash November Update runs inside the Lucebox server with built-in defaults (no tuning flags needed).
All four components are required whenever PFlash is selected (if any component is missing, `--pflash auto`
stays off and `--pflash on` refuses to start). Download this repository alongside the drafter GGUF, then set:
```bash
export PFLASH_SCORING_HEAD_GGUF=/path/to/pflash/seg-scoring-head.gguf
# segment-probe.gguf, request-probe.gguf, and seg-reranker.gguf are auto-discovered
# beside PFLASH_SCORING_HEAD_GGUF (or can be pointed to individually via
# PFLASH_SEGMENT_PROBE_GGUF, PFLASH_REQUEST_PROBE_GGUF, PFLASH_SEG_RERANKER_GGUF)
# server: --pflash auto
```
- **Default quality-first curve**: activates from **8,192** tokens (`8192:0.450`, `16384:0.350`,
`32768:0.270`, `65536:0.260`, `120000:0.240`).
- **Built-in defaults**: Stage-1 nucleus mass-floor (`0.90`, cap `0.58`), one-sided adaptive keep-ratio safety
net (`0.42`/`0.58`), pure-neural query candidates (`PFLASH_QUERY_TW=score`), Lucebox Mix cold-history paging,
and autonomous tool-turn recall are all enabled automatically.
- Runtime support: [Luce-Org/lucebox PR #1048](https://github.com/Luce-Org/lucebox/pull/1048) (building on
[PR #746](https://github.com/Luce-Org/lucebox/pull/746)).
## Results
Measured end-to-end with all four components enabled (default launch, zero extra flags), reader
`Qwen3.8-27B IQ4_XS`, AMD Radeon AI PRO R9700, single GPU, `max_tokens = 2048` (matched with Full Prefill):
### Public Long-Context & Code Suite (Full Prefill vs PFlash November Update)
| Benchmark | Full prefill | PFlash November Update | Full TTFT | PFlash Nov TTFT | Speedup | Median kept |
|---|---:|---:|---:|---:|---:|---:|
| Document QA | 27/30 | **27/30** | 29.8 s | **8.35 s** | **3.57×** | 29% |
| RULER QA | 13/15 | **13/15** | — | **6.05 s** | — | 35% |
| NoLiMa | 14/24 | **17/24** | 15.2 s | **8.94 s** | **1.70×** | 57% |
| CodeDebug | 23/30 (76.7%) | **25/32 (78.1%)** | 140.7 s | **54.55 s** | **2.58×** | 49% |
| BRIGHT | 23/28 | **24/28** | 35.5 s | **9.49 s** | **3.74×** | 28% |
| LongCodeQA | 57/114 | **59/114** | 42.5 s | **12.80 s** | **3.32×** | 33% |
| LongBench-v2 | 7/12 | **5/12** | 27.5 s | **11.52 s** | **2.39×** | 44% |
### 8K–11K Threshold Suite (70 items)
| configuration | avg TTFT | med TTFT | speedup vs full | LongMemEval-10k (18) | NoLiMa-10k (16) | QASPER-10k (18) | QuALITY-10k (18) | **macro** |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| full prefill | 7.30 s | 7.35 s | 1.00× | 0.8889 | 0.3750 | 0.3383 | 0.8333 | **0.6089** |
| PFlash v2 (`r=0.35`) | 3.93 s | 3.55 s | 1.86× | 0.8889 | 0.3750 | 0.3312 | 0.7778 | 0.5932 |
| **PFlash November Update (adaptive)** | **4.90 s** | **4.18 s** | **1.49× avg / 1.76× med** | **0.8889** | **0.3750** | **0.3875** | **0.8333** | **0.6212** |
### Agentic & Lucebox Mix Coding Workloads (Default Launch)
| workload | full prefill | PFlash v2 default | **PFlash November Update** |
|---|---|---|---|
| Lucebox Mix 45K cold model switch (8 sessions) | 8/8 (100%), med TTFT 114.50 s | 8/8 (100%), med TTFT 114.54 s | **8/8 (100%), med TTFT 23.97 s** (4.8× faster) |
| Autonomous 3-turn tool-loop recall (6 sessions) | — | 3/6 (50%), med T3 TTFT 10.23 s | **6/6 (100%), med T3 TTFT 10.23 s** (+50 pp) |
## Limits
- Even with the Stage-1 nucleus mass-floor and one-sided adaptive safety net, compression is still lossy on
sharp queries (`eff < 0.42`): a rare edge case can drop a detail if both Stage-1 and the reranker under-rank
it.
- Diffuse/global prompts (`eff >= 0.58`) intentionally fall back to full prefill (when within `max_ctx`),
trading speedup for exact lossless coverage.
- All four GGUFs are bound to the pinned `Qwen3.5-0.8B-BF16.gguf` drafter (`cedf89af…`).
|