Skip to content

chore(pflash): drop env switches, /props fields and code PFlash no longer reads - #863

Merged
davide221 merged 1 commit into
Luce-Org:mainfrom
Graffioh:chore/pflash-env-cleanup
Oct 25, 2026
Merged

davide221 merged 1 commit into
Luce-Org:mainfrom
Graffioh:chore/pflash-env-cleanup

Conversation

@Graffioh

@Graffioh Graffioh commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Why

#746 replaced the Qwen3-0.6B drafter, whose forward ran the FlashPrefill sparse kernels (BSA on CUDA, rocWMMA on HIP), with the Qwen3.5-0.8B scorer. The new scorer runs blocks 0–14 on the qwen35 graph (Gated DeltaNet plus ggml flash-attention) and scores with block 15's Q/K attention mass. The switches and code only the old drafter read were left behind, still presented as PFlash configuration. In a recent report on an R9700, fp_use_bsa = ON in the banner was read as "BSA runs on ROCm", and the 30x scorer speedup was nearly attributed to it.

What goes

Item Why it's dead
/props pflash.bsa_alpha, pflash.lm_head_fix LUCE_FP_ALPHA and LUCE_LM_HEAD_FIX have no reader
/props pflash.bsa_enabled LUCE_FP_USE_BSA only picks Gemma 4's sliding-window prefill launcher, so it isn't PFlash state
src/pflash_ggml_adapter.{h,cpp}, test_flash_attn_sparse, its CI wiring Registered the FlashPrefill kernel as the ggml sparse flash-attention op, which no graph builds. Gemma 4 calls the FlashPrefill kernels directly
DflashClient LUCE_LM_HEAD_FIX env, lm_head_fix arg No reader. LUCE_FA_WINDOW stays: test_dflash reads only the env var (it has no --fa-window flag) and defaults to 2048, so the client keeps setting it, 0 when fa_window is unset
bench_niah_cpp --bsa/--alpha, phase_split_dual_gpu --pflash-alpha/--pflash-use-bsa, laguna_pflash_niah defaults, quality A/B LUCE_FP_USE_BSA arms Set variables the drafter and the Qwen targets don't read. quality_ab_simple's bsa_on arm was identical to baseline
ENVIRONMENT.md / variables.md: LUCE_FP_ALPHA, LUCE_FP_CHUNK_S, LUCE_FP_NOPE_TAIL, LUCE_FP_SKIP_PREWARM, LUCE_FP_DEBUG_LAYER0, LUCE_PFLASH_K_TYPE, LUCE_LM_HEAD_FIX No reader (most pointed at the deleted qwen3_graph.cpp/qwen3_drafter.cpp)

props_schema goes to 3. The props spec counts a removed field as a breaking change, so the schema is bumped with a changelog entry in props-endpoint.md and openapi-props.yaml. Nothing in luce_box reads the three fields.

PFlash docs. The PFlash README and SPEC_PREFILL.md now describe the current scorer and selection instead of BSA and alpha. The 10.4x RTX 3090 table is labelled as PFlash v1; SPEC_PREFILL.md had credited it to the 0.8B drafter. The LUCE_FP_* switches are no longer listed as PFlash tunables.

Kept:

  • LUCE_FP_USE_BSA and its PFlash-on default, because Gemma 4 still uses them.
  • LUCE_FP_PROFILE / LUCE_FP_DUMP_COUNTS / LUCE_FP_HIP_ROW, which the FlashPrefill kernels read.
  • The ggml FLASH_ATTN_SPARSE op in the vendored ggml.

Overlap with #861. The server still sets LUCE_FP_ALPHA / LUCE_FA_WINDOW when PFlash is on, and the banner still prints fp_use_bsa / fp_alpha. #861 removes both, so this PR leaves those lines alone and the two merge independently.

Tests

  • Full gfx1201 HIP build (luce_server, test_server_unit) on main 32a3137; test_server_unit 0 failures. The props_schema assertions are updated to 3.
  • Python files byte-compile, and ci.yml parses.
  • Not run: a CUDA build, or the Python bench against a daemon.

🤖 Generated with Claude Code

View guided diff

@Graffioh
Graffioh marked this pull request as ready for review October 20, 2026 14:35

@davide221 davide221 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

Found 1 issue.

Copy to agent

Use the copy button in the top-right corner of the block, then paste into your agent.

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.

Repository: Luce-Org/lucebox
Reviewed commit: 8839603ec2bf880f85baf46570177024de347f08
Verify the findings against the current code, run relevant checks for any fixes, and explain any findings you reject.

<file name="optimizations/pflash/pflash/dflash_client.py">

<violation number="1" line="105" end_line="106">
fa_window no longer reaches the spawned daemon; default is 2048, not 0

`DflashClient` spawns `test_dflash` (the binary `bench_niah_cpp.py` and the README use as the daemon). The old code forced `LUCE_FA_WINDOW=0` in the child env, which `test_dflash.cpp:706-708` reads to override `g_fa_window`. This PR replaces that with a `--fa-window=N` argv flag, but `test_dflash`'s argument loop (server/test/unit/test_dflash.cpp:813-986) has no `--fa-window` case — only `--fa-window` exists on `luce_server`/`server_main.cpp:730` — so the flag is silently ignored. Meanwhile `g_fa_window` defaults to **2048** (test_dflash.cpp:163), not 0, and the client no longer sets the env var. Result: the daemon runs with a 2048-token sliding window on full-attention layers, so NIAH needles more than 2048 tokens back cannot be retrieved and the benchmark's `--fa-window 0` default is a no-op. This also contradicts the new docstring claim that "unset keeps the daemon default 0 = full attention, as before". Fix: keep setting `LUCE_FA_WINDOW` in `env_overrides` (or add `--fa-window` parsing to `test_dflash`).

<suggestion>
        env_overrides = {
            "LUCE_KV_TQ3": "1" if (kv_tq3 if kv_tq3 is not None else True) else "0",
        }
        if fa_window is not None:
            env_overrides["LUCE_FA_WINDOW"] = str(fa_window)
</suggestion>
</violation>

</file>
Issue overview
  1. fa_window no longer reaches the spawned daemon; default is 2048, not 0 · confirmed (optimizations/pflash/pflash/dflash_client.py:105-106)

Reviewed 8839603e · 2 candidate issues checked, kept at ≥70% confidence · add the code-review label to review again

Comment on lines +105 to +106
if fa_window is not None:
cmd.append(f"--fa-window={fa_window}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fa_window no longer reaches the spawned daemon; default is 2048, not 0 · confirmed

DflashClient spawns test_dflash (the binary bench_niah_cpp.py and the README use as the daemon). The old code forced LUCE_FA_WINDOW=0 in the child env, which test_dflash.cpp:706-708 reads to override g_fa_window. This PR replaces that with a --fa-window=N argv flag, but test_dflash's argument loop (server/test/unit/test_dflash.cpp:813-986) has no --fa-window case — only --fa-window exists on luce_server/server_main.cpp:730 — so the flag is silently ignored. Meanwhile g_fa_window defaults to 2048 (test_dflash.cpp:163), not 0, and the client no longer sets the env var. Result: the daemon runs with a 2048-token sliding window on full-attention layers, so NIAH needles more than 2048 tokens back cannot be retrieved and the benchmark's --fa-window 0 default is a no-op. This also contradicts the new docstring claim that "unset keeps the daemon default 0 = full attention, as before". Fix: keep setting LUCE_FA_WINDOW in env_overrides (or add --fa-window parsing to test_dflash).

Checked (92%): dflash_client.py:105-106 now passes --fa-window=N to test_dflash, but test_dflash.cpp's argv loop (lines 813-986) has no --fa-window case, so it is silently ignored; g_fa_window defaults to 2048 (test_dflash.cpp:163) and is only overridden by the LUCE_FA_WINDOW env var (test_dflash.cpp:706-708) that this PR removed from env_overrides. bench_niah_cpp.py:31 defaults --fa-window to 0, so the daemon now always runs with a 2048-token sliding window, breaking NIAH needles beyond 2048 tokens and contradicting the new docstring at dflash_client.py:66.

Suggested change
if fa_window is not None:
cmd.append(f"--fa-window={fa_window}")
env_overrides = {
"LUCE_KV_TQ3": "1" if (kv_tq3 if kv_tq3 is not None else True) else "0",
}
if fa_window is not None:
env_overrides["LUCE_FA_WINDOW"] = str(fa_window)

…nger reads

The Qwen3.5-0.8B scorer (Luce-Org#746) replaced the Qwen3-0.6B drafter, whose
forward ran the FlashPrefill sparse kernels. What only that drafter read
stayed behind and still read as PFlash configuration.

- /props pflash drops bsa_enabled, bsa_alpha and lm_head_fix: PFlash reads
  none of them (LUCE_FP_ALPHA and LUCE_LM_HEAD_FIX have no reader at all;
  LUCE_FP_USE_BSA only picks Gemma 4's sliding-window prefill launcher).
  Removing fields is a breaking change, so props_schema goes to 3 with a
  changelog entry.
- src/pflash_ggml_adapter.{h,cpp} registered the FlashPrefill kernel as
  the ggml sparse flash-attention op, which no graph builds; it goes with
  test_flash_attn_sparse and its CI wiring. Gemma 4 still calls the
  FlashPrefill kernels directly.
- optimizations/pflash: DflashClient stops setting LUCE_LM_HEAD_FIX (no
  reader) and keeps LUCE_FA_WINDOW, which test_dflash reads (it has no
  --fa-window flag); bench_niah_cpp drops --bsa/--alpha.
- Scripts stop setting LUCE_FP_USE_BSA/LUCE_FP_ALPHA for Qwen and drafter
  runs (phase_split_dual_gpu --pflash-alpha/--pflash-use-bsa,
  laguna_pflash_niah, the quality A/B arms; quality_ab_simple's bsa_on arm
  was identical to baseline).
- Docs: ENVIRONMENT.md and variables.md drop variables with no reader
  (LUCE_FP_ALPHA, LUCE_FP_CHUNK_S, LUCE_FP_NOPE_TAIL, LUCE_FP_SKIP_PREWARM,
  LUCE_FP_DEBUG_LAYER0, LUCE_PFLASH_K_TYPE, LUCE_LM_HEAD_FIX).
  The PFlash README and SPEC_PREFILL.md describe the current scorer, label
  the 10.4x table as PFlash v1 (SPEC_PREFILL credited it to the 0.8B
  drafter), and stop listing the FlashPrefill switches as PFlash tunables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Graffioh
Graffioh force-pushed the chore/pflash-env-cleanup branch from 8839603 to 8d0e172 Compare October 22, 2026 17:37
@davide221
davide221 merged commit 3ef243e into Luce-Org:main Oct 25, 2026
9 checks passed
davide221 added a commit to dusterbloom/lucebox-hub that referenced this pull request Oct 25, 2026
…lash DeltaNet ladder branch

Clean 3-way merge against the tested Luce-Org#850 head: Luce-Org#851 changes and the
main-side changes (Luce-Org#876 sampler seeding, Luce-Org#863 PFlash cleanup) are both
kept exactly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
davide221 added a commit to dusterbloom/lucebox-hub that referenced this pull request Oct 25, 2026
…rg#850, Luce-Org#876, Luce-Org#863) into kvflash turn checkpoints branch

Clean 3-way merge against the tested Luce-Org#851 head: Luce-Org#852 changes and the
main-side changes are both kept exactly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants