Repository navigation
Description
Summary
On a R9700 (gfx1201, RDNA4) with the official ghcr.io/luce-org/lucebox-hub:rocm image, PFlash's scorer forward spends 98% of its time in the FP stage, and that stage runs ~45× slower than the CUDA reference for a shorter sequence:
[qwen3-0.6b-fp] forward 343.31s (S=119925, A_setup=0.01s A_alloc=0.00s A_compute=2.16s FP=337.60s
B_warm=0.00s B_setup=0.00s B_alloc=0.00s B_copy_in=0.01s B_norm=0.15s B_compute=3.49s
B_copy_out=0.01s) tail-score 1.16s (layers 0-27) total 344.47s
Compare with the CUDA log in #147 for the same stage at a longer sequence:
[qwen3-0.6b-fp] forward 7.68s (S=130197, ...)
S=119925 → 343.3 s here, S=130197 → 7.68 s there. Both are the 0.6B scorer; A_compute (2.16 s) and B_compute (3.49 s) are entirely reasonable, so it is specifically FP that is pathological.
Effect on end-to-end prefill
The compression cost is not included in the reported prefill_ms, so the engine number looks excellent while the wall clock does not:
| prompt tokens | wall | engine prefill_ms |
compression (wall − prefill) |
|---|---|---|---|
| 40,553 | 55.4 s | 8.8 s (4,618.7 tok/s) | 46.6 s |
| 119,926 | 448.8 s | 100.7 s (1,190.8 tok/s) | 348.1 s |
Compression cost vs S: 20k → 15.5 s, 40k → 46 s, 120k → 348 s — close to O(S²), i.e. the scorer is behaving like dense attention over the whole sequence rather than a sparse/reduced path.
Resulting end-to-end gain at 120k is 1.38–1.51×, not the ~10× the engine figure implies. Same prompt, same box:
| configuration | wall | NIAH retrieval |
|---|---|---|
PFlash off (q4_0 KV, reference) |
618.3 s | YES |
PFlash always |
409.2–448.8 s | YES |
| plain llama.cpp Vulkan (same box, same class of weights) | ~235 s TTFT | YES |
So on this card PFlash is a net loss against the alternative at the top of the context range, even though retrieval quality survives.
Things I checked before filing
LUCE_FP_USE_BSA=1 LUCE_FP_ALPHA=0.85(per PFlash NIAH benchmark on RTX 5090 #82) makes no difference on gfx1201. Startup confirmsfp_use_bsa = ONand there is no fallback warning. 40k: 55.4 s vs 54.5 s without it. 120k: 448.8 s vs 445.5 s.- Not thermals: junction 54 °C,
mclklocked at 1258 MHz, 175 W, no throttling during the run. - Not
--max-ctx(Oversized--max-ctxsilently destroys attention throughput (20× prefill slowdown at 32K, 8× at 64K) #10): 131072 vs a tight 81920 at 76k differs by 1.2%. - Not the drafter GGUF: tried two (
unsloth/Qwen3-0.6B-BF16.ggufand a converted variant), same behaviour. Each request logs[compress] loading drafter— worth a separate look, but the 343 s is measured inside the forward, not the load. - Not n-max / block size:
--draft-block-size 16and 8 behave the same for the compression stage. - Not the KV type:
q8_0andq4_0give identical prefill at 40.5k (452.5 vs 452.2).
Hypothesis
The FP stage (flash-prefill / block-sparse scorer) has no working RDNA4 implementation in the published ROCm build, so it is silently running a fallback. Supporting evidence:
- HIP build (gfx1151) fails to link: undefined symbol flash_prefill_forward_bf16 #215: the HIP build gated
DFLASH27B_HAVE_SM80_FLASHPREFILLout asymmetrically, so flash-prefill kernels were compiled out entirely on HIP. - PFlash NIAH benchmark on RTX 5090 #82: on CUDA the scorer needs
DFLASH_FP_USE_BSA=1set explicitly; without it the path is 3.4× slower and NIAH fails at 32k. Here, setting it changes nothing — consistent with the flag having nothing to switch to. server/docs/HIP_PERF_PLAN.mddescribes RDNA effort concentrated onmul_mat_qpaths.- Related: gfx1100 (RX 7900 XTX, ROCm 6.4.1): dflash_server ~2x slower than llama.cpp, DDTree speculation never engages, SIGSEGV at long context #457 reports the rocWMMA flash-prefill kernels being unavailable on gfx1100 (DDTree silently falling back to AR decode), and the maintainer reply there confirms
#456only fixes the compile on ROCm ≥ 7.2.
What I'm asking for
- Is the
FP/flash-prefill stage expected to be usable on gfx1201/ROCm 7.2.4 today? If not, would you consider refusing or loudly warning when--prefill-compressionis enabled on an arch where the fast path is missing, rather than silently spending 45× longer? Right now the only symptom is a wall-clock that contradicts the reportedprefill_ms. - If it is expected to work, is there a build flag / env var we are missing beyond
DFLASH_FP_USE_BSA/DFLASH_FP_ALPHA? I'm happy to rebuild any branch and rerun on this box. - Worth documenting the "compression time is not in
prefill_ms" caveat next to the PFlash throughput claims — independently of the arch issue, it makes the headline number hard to compare with any other engine's end-to-end prefill.
Reproduction
Image ghcr.io/luce-org/lucebox-hub:rocm (built 2026-09-21, commit 2785c22), R9700 32 GB, ROCm 7.2.4:
docker run -d --name luceb \
--device /dev/kfd --device /dev/dri --group-add video --group-add render \
--security-opt seccomp=unconfined -p 8080:8080 \
-e LUCE_FP_USE_BSA=1 -e LUCE_FP_ALPHA=0.85 \
--entrypoint /opt/lucebox-hub/server/build/luce_server \
ghcr.io/luce-org/lucebox-hub:rocm \
<target.gguf> --host 0.0.0.0 --port 8080 --max-ctx 131072 \
--draft <dflash2-q8_0.gguf> --ddtree --ddtree-budget 22 --draft-block-size 16 \
--prefill-compression always --prefill-drafter <Qwen3-0.6B-BF16.gguf>then POST a ~120k-token prompt to /v1/chat/completions and read the [qwen3-0.6b-fp] forward line from docker logs. Per-request figures come from the response's own prefill_ms / decode_tokens_per_sec fields, compared against wall clock measured around the HTTP call.
Activity
Graffioh commentedon Sep 23, 2026
Hi, thanks for the report!
We are currently reworking the PFlash system, so keep an eye on this repo and our blog over the coming days and weeks, where we’ll be sharing updates
It’s a long journey, but we’ll keep improving the system to deliver the best possible user experience and speed without sacrificing quality.
Graffioh commentedon Oct 15, 2026
hi @aiworkeryuan-chuxi
can you try the new pflash? let me know how it goes: https://www.lucebox.com/blog/pflash-v2
aiworkeryuan-chuxi commentedon Oct 15, 2026
Thanks — and good timing: v2 looks aimed at exactly the case we could not get on AMD (84K CodeDebug prompt, 132.0 to 28.4 s to first token on one R9700 in your post).
The diagnosis behind this report, in case it is useful: on ghcr.io/luce-org/lucebox-hub:rocm the cost is almost entirely the drafter own forward — FP=337.60 s of a 344.47 s total at S≈120k (A_compute 2.16 s / B_compute 3.49 s / tail-score 1.16 s), while the CUDA log in #147 shows that stage roughly 45x faster at a longer sequence. Our read: the 0.6B drafter runs dense on gfx1201 because the official BSA sparse path is CUDA/cutlass (sm_80+) with no HIP build, so compression costs more than it saves.
Plan: re-run on the same box (R9700 / gfx1201, official ROCm image, S=120k) with v2 and post the same stage breakdown plus the drafter model used, so it is directly comparable to this report.
Two setup questions so the run is apples-to-apples: (1) does v2 keep the --prefill-drafter interface, or is there a new config for the 0.8B stage? (2) is the gain expected from a HIP path for the segment/relevance probe, or from the drafter stage itself?
aiworkeryuan-chuxi commentedon Oct 15, 2026
Reproduced on the same box with the v2 recipe — the FP-stage gap is gone.
Setup: R9700 (gfx1201),
ghcr.io/luce-org/lucebox-hub:main-rocm(built 2026-10-15 00:54), reader Qwen3.8-27B-IQ4_XS-pure, the three components plus the Qwen3.5-0.8B-BF16 drafter (sha256cedf89af31c9041b601fa58303285bc46d99c51baee1b13f5e919626ca526ee5, verified),--cache-type-k/v q4_0,--prefill-compression auto --prefill-threshold 16384 --prefill-curve "16384:0.315 32768:0.270 65536:0.270 120000:0.225" --prefill-skip-park. Same long-context prompts as this report, same box, both arms in one session.The stage that was 343.31 s (FP 337.60 s) at S=119,925 now reads:
So compress at ~120K: 344.5 s -> 11.3 s, about 30x, same hardware and context length.
First token end to end, both arms in the same session:
Decode improves too at 120K (11.3 -> 22.1 tok/s, smaller KV after compression), and needle-in-a-haystack at 120K returns YES in both arms.
Two things I would like confirmed or explained:
The ROCm image now reports
fp_use_bsa = ON. The root cause in this report was that the BSA sparse path had no HIP build, so everything fell back to dense. Is that path native HIP/ROCm now? The 30x says something structural changed, and I would rather state it correctly than guess.The effective keep ratio came out 0.317 at 120K (
kept=374 droppable=119552 keep_ratio=0.315000 effective=0.317145) rather than the 0.225 the release curve implies for 120K, and the server echoed only the first curve point ([server] pflash curve: 16384:0.315). Is thatPFLASH_UNIFIEDtaking over, or does--prefill-curveneed a different form? If 0.225 is reachable there is more on the table than the numbers above.Comparability note: no
--draftin these runs. This box also has the Qwen3.8-27B DFlash2 draft, but both forms are rejected by the new build — the GGUF loads withunexpected draft arch: dflash (expected qwen35-dflash-draft, dflash-draft, or gemma4-dflash-draft), and the FP8 safetensors loads withsafetensors: fc.weight dtype=F8_E4M3 expected BF16. So the decode numbers above are non-speculative; compress and first-token numbers are unaffected. If a compatible draft is published I will re-run with it.Graffioh commentedon Oct 20, 2026
hey thanks for the report
regarding your 2 doubts:
aiworkeryuan-chuxi commentedon Oct 20, 2026
Two corrections and two follow-ups while you fix the ratio parsing.
Correction to my previous comment. I reported the 120K needle test returning YES. That does not test the compressed path: both needle requests were served through a full uncompressed prefill (240.3 s and 251.9 s) even though compression ran and logged
[compress] 119936 -> 38012. So retrieval after compression is unverified in my setup, not verified. I suspectPFLASH_FALLBACK_SPREAD=0.11/PFLASH_COLD_HISTORY=rawsending those requests down the raw path, since the requests that did serve compressed (43.0-56.4 s) contain no needle. If you can say which condition forces the raw path, I will re-run the retrieval test properly and report back.Decode with the official draft.
Lucebox/Qwen3.8-27B-DFlash2-GGUFloads fine (archqwen35-dflash-draft) — so only the copies on my box were wrong. Spec-decode then behaves exactly as this report already documented, acceptance collapsing with context:Enabling it also costs prefill: first token at 119,926 goes 43.0 s (no draft) -> 55.8-56.4 s (with draft), so at long context it is a net loss.
On your answer (1). "Optimized kernel path for qwen 3.5" — I need the noun to be right before I write this up: is that path a native HIP kernel on gfx1201, or does
fp_use_bsa = ONreport sparse while the attention actually still runs dense/fallback? The 30x I measured is entirely the removal of the dense scorer cost (343.31 s forward -> 11.09 s at S≈120K), and I do not want to attribute it to BSA if BSA is not really running on ROCm.On your answer (2). My keep ratio came out 0.317 at 120K (
keep_ratio=0.315000 effective=0.317145) rather than the 0.225 the release curve implies, and the server echoed only the first curve point ([server] pflash curve: 16384:0.315). Once the parsing fix lands, can you confirm the expected form — or thatPFLASH_UNIFIEDsimply overrides--prefill-curveabove 16K? If 0.225 is reachable at 120K I will re-run on the same box and post the delta against the table above.Graffioh commentedon Oct 28, 2026
hey thanks for the reply
so you are right that compression ran and then the raw prompt was served. That's the failure-policy fallback and the most likely trigger is the relevance-spread check (
PFLASH_FALLBACK_SPREAD). When the scorer's relevance is too diffuse over the segments, it serves the raw prompt rather than risk a bad cut. PFLASH_COLD_HISTORY isn't the cause: it only covered earlier history, and it has since been removed. To see which condition fired, look for these in the logs:/props → pflash.failures also counts fallbacks by reason.
There's also a separate bug, fixed in #878. If the needle prompt is one long line (as niah_gen.py writes it), the unified view could only drop that line whole. It served ~90 tokens and the answer was wrong. With #878 that line goes to the chat view. On an R9700 that gives 3/3 correct at 120K, serving ~27K tokens, first token in ~42 s. So please re-run the retrieval test on a build with #878. If you want to test compressed retrieval with no safety net, set PFLASH_FALLBACK_SPREAD=off. Then every request serves the compressed prompt, and the spread is still logged.
(1) Regarding BSA question: the Qwen3.5-0.8B scorer doesn't use the BSA/FlashPrefill kernel at all. It runs plain ggml (Gated DeltaNet layers plus ggml_flash_attn_ext), built for HIP like the rest of the server. fp_use_bsa = ON was a misleading banner line: on that build the flag only picks a launcher for Gemma 4's sliding-window prefill. #861 removed it from the PFlash banner. So the 30x is the new scorer architecture running on standard ggml HIP kernels, not a sparse kernel that now works on ROCm. So don't credit BSA for it.
(2) the curve. This was the parsing bug, fixed in #861 (in main). A quoted --prefill-curve "16384:0.315 32768:0.270 65536:0.270 120000:0.225" was read as only its first point, so you got a flat 0.315. Quoted, comma-separated and separate arguments now all parse to the full curve, and a malformed point fails at startup. PFLASH_UNIFIED never overrode the curve, and #878 removes it anyway. With a scoring head set, the release profile applies that curve by default, so you can drop --prefill-curve entirely. 0.225 at 120K should be reachable now.
Also Flags after #878. --prefill-compression becomes --pflash on|off. A minimal launch is the three head/probe env vars, plus --prefill-drafter <Qwen3.5-0.8B.gguf> --pflash on --prefill-skip-park.