Skip to content

[ROCm/gfx1201] PFlash scorer: FP stage ~45x slower than the CUDA reference (343s for S=120k vs 7.68s on a 3090), so PFlash is net-negative at long context #752

Open

Description

@aiworkeryuan-chuxi

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 confirms fp_use_bsa = ON and 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, mclk locked at 1258 MHz, 175 W, no throttling during the run.
  • Not --max-ctx (Oversized --max-ctx silently 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.gguf and 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 16 and 8 behave the same for the compression stage.
  • Not the KV type: q8_0 and q4_0 give 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:

What I'm asking for

  1. 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-compression is 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 reported prefill_ms.
  2. 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.
  3. 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

  1. Graffioh commented on Sep 23, 2026

    @Graffioh
    Collaborator

    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.

  2. Graffioh commented on Oct 15, 2026

    @Graffioh
    Collaborator
  3. aiworkeryuan-chuxi commented on Oct 15, 2026

    @aiworkeryuan-chuxi
    Author

    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?

  4. aiworkeryuan-chuxi commented on Oct 15, 2026

    @aiworkeryuan-chuxi
    Author

    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 (sha256 cedf89af31c9041b601fa58303285bc46d99c51baee1b13f5e919626ca526ee5, 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:

    [qwen35-scorer] forward 11.09s (blocks 0-14, S=119926, resumed at 0, 119926 new) score 0.22s total 11.30s head=trained
    [compress] 119926 -> 37990 tokens
    

    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:

    prompt tokens full prefill PFlash v2 speedup
    20,248 18.9 s 5.7 s 3.3x
    40,553 45.9 s 11.5 s 4.0x
    119,926 233.3 s 43.0 s 5.4x

    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:

    1. 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.

    2. 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 that PFLASH_UNIFIED taking over, or does --prefill-curve need a different form? If 0.225 is reachable there is more on the table than the numbers above.

    Comparability note: no --draft in these runs. This box also has the Qwen3.8-27B DFlash2 draft, but both forms are rejected by the new build — the GGUF loads with unexpected draft arch: dflash (expected qwen35-dflash-draft, dflash-draft, or gemma4-dflash-draft), and the FP8 safetensors loads with safetensors: 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.

  5. Graffioh commented on Oct 20, 2026

    @Graffioh
    Collaborator

    hey thanks for the report

    regarding your 2 doubts:

    1. the new pflash gains come from the new architecture and also from optimized kernel path for qwen 3.5 (instead of the old pflash that used qwen 3 as a drafter)
    2. it's probably a parsing bug on our side, i'll get it fixed!
  6. aiworkeryuan-chuxi commented on Oct 20, 2026

    @aiworkeryuan-chuxi
    Author

    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 suspect PFLASH_FALLBACK_SPREAD=0.11 / PFLASH_COLD_HISTORY=raw sending 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-GGUF loads fine (arch qwen35-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:

    40,553 tok:  [spec-decode] tokens=15 time=0.116s speed=129.36 tok/s accepted=15/23 (65.2%)
    119,926 tok: [spec-decode] tokens=15 time=0.376s speed= 39.86 tok/s accepted=15/69 (21.7%)
    

    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 = ON report 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 that PFLASH_UNIFIED simply overrides --prefill-curve above 16K? If 0.225 is reachable at 120K I will re-run on the same box and post the delta against the table above.

  7. Graffioh commented on Oct 28, 2026

    @Graffioh
    Collaborator

    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:

    • [pflash-spread] spread=X >= 0.110000 ...: full prefill of the raw prompt
    • [pflash-fallback] serving the raw prompt (N tokens) reason=...

    /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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions