Skip to content

bench_niah_cpp: expose ddtree/fa/kv params and auto-max-ctx as CLI flags - #90

Merged
davide221 merged 3 commits into
Luce-Org:mainfrom
ppsx:cli-flags-bench-niah-cpp
May 4, 2026
Merged

davide221 merged 3 commits into
Luce-Org:mainfrom
ppsx:cli-flags-bench-niah-cpp

Conversation

@ppsx

@ppsx ppsx commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Pure ergonomics change to pflash/tests/bench_niah_cpp.py and the underlying DflashClient. Six existing daemon knobs and one new helper become reachable from the CLI:

  • --ddtree-budget (default 16, matches existing DflashClient default)
  • --ddtree-temp (default unset → daemon default)
  • --no-chain-seed (default off → chain seeding stays on)
  • --fa-window (default 0, full attention)
  • --kv-tq3 {0,1} (default 1, matches existing default)
  • --auto-max-ctx (off by default; when on, sizes max_ctx from src_tokens x keep_ratio x 1.15 + n_gen + 512, aligned up to 1024, and treats --max-ctx as a floor)

DflashClient.__init__ gains two new optional kwargs (ddtree_temp, chain_seed) that are forwarded to the daemon as --ddtree-temp=... and --ddtree-no-chain-seed only when set. The other knobs already had DflashClient kwargs; this PR just plumbs them through the bench.

Motivation

Parameter sweeps for tuning configs on different GPUs (in my case Blackwell
sm_120, RTX 5090 32 GB at 117K NIAH) previously required editing the Python
source between runs. With these flags every sweep step is a single CLI
invocation, so configs can be captured in shell scripts and reproduced.

No upstream defaults change — anyone running the existing bench command unchanged sees the same ddtree_budget=16 / kv_tq3=1 / fa_window=0 / chain_seed=True behavior they have today.

Adds --ddtree-budget, --ddtree-temp, --no-chain-seed, --fa-window,
--kv-tq3, and --auto-max-ctx CLI flags to bench_niah_cpp.py. Each maps
1:1 to existing daemon CLI flags via DflashClient kwargs.

Pure ergonomics change. Defaults preserve current behavior:
- ddtree_budget=16 (matches existing DflashClient default)
- kv_tq3=1 (matches existing default)
- fa_window=0 (full attention, matches existing default)
- chain_seed=True (matches existing daemon default)

DflashClient gains two new optional kwargs (ddtree_temp, chain_seed)
with backward-compatible defaults; they are translated to the daemon's
--ddtree-temp / --ddtree-no-chain-seed flags only when set. Existing
callers that don't pass the new kwargs are unaffected.

--auto-max-ctx computes max_ctx from src_tokens, keep_ratio, and n_gen,
then aligns up to 1024. Treats --max-ctx as a floor (max(max_ctx,
computed)) so existing scripts setting --max-ctx explicitly continue
to work.

Motivation: parameter sweeps for tuning configs on different GPUs (e.g.
Blackwell sm_120) previously required editing Python source between
runs. This makes such sweeps reproducible from the CLI.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 4, 2026 13:43

Copilot AI 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.

Pull request overview

Adds additional CLI ergonomics to the bench_niah_cpp.py harness by exposing daemon tuning parameters as flags and introducing an --auto-max-ctx helper, with corresponding support in DflashClient for mapping new options to daemon flags.

Changes:

  • Expose daemon tuning params (ddtree_budget, ddtree_temp, chain_seed, fa_window, kv_tq3) as bench_niah_cpp.py CLI flags and wire them into DflashClient.
  • Add --auto-max-ctx logic to compute and round max_ctx based on the first case’s prompt token estimate.
  • Extend DflashClient to optionally append --ddtree-temp and --ddtree-no-chain-seed to the daemon command line.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pflash/tests/bench_niah_cpp.py Adds CLI flags for daemon knobs and implements --auto-max-ctx sizing logic.
pflash/pflash/dflash_client.py Adds optional kwargs to emit new daemon flags during subprocess spawn.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pflash/pflash/dflash_client.py Resolved
Comment thread pflash/tests/bench_niah_cpp.py Resolved

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

ppsx and others added 2 commits May 4, 2026 15:48
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Insert `*` before the optional tuning kwargs in DflashClient.__init__
(ddtree_temp, chain_seed, fa_window, kv_tq3, lm_head_fix, boot_*) so
they cannot be bound positionally. The previous diff introduced
ddtree_temp and chain_seed in the middle of the positional list, which
would silently rebind any caller passing fa_window positionally.

The keyword-only marker prevents this class of bug for all future
tuning-knob additions; the only in-tree caller already uses kwargs.

Addresses the dflash_client.py:19-20 review finding. The companion
bench_niah_cpp.py auto-max-ctx finding is already addressed by
8a2e24b (Copilot Autofix).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@davide221

Copy link
Copy Markdown
Contributor

@ppsx thanks for your first contribution. This cleaning is very welcomed

@davide221
davide221 merged commit 937814c into Luce-Org:main May 4, 2026
1 check passed
@ppsx

ppsx commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, @davide221. I hope it will be useful.

@ppsx
ppsx deleted the cli-flags-bench-niah-cpp branch May 4, 2026 14:13
smpurkis pushed a commit to smpurkis/lucebox-hub that referenced this pull request May 10, 2026
…ance

Six review-feedback fixes on the new RTX 5090 long-context section:

1-3. Throughput unit consistency: rename Decode t/s → Decode tok/s in all
     three throughput tables (headline, budget sweep, alpha sweep) to
     match the rest of dflash/RESULTS.md and the short-context section.

4. Runtime config interface ambiguity: replace shorthand names
   (keep_ratio=, alpha=, ddtree_budget=, ...) with the actual
   reproducible interfaces — bench_niah_cpp.py CLI flags added in Luce-Org#90
   (--keep-ratio=, --alpha=, --ddtree-budget=, --fa-window=, --kv-tq3=,
   --n-gen=) and daemon env vars (DFLASH_FP_USE_BSA=, optional
   DFLASH27B_FA_WINDOW=). One concrete way to reproduce, not three
   shorthand aliases.

5. niah_gen.py path: reference becomes a relative markdown link to
   ../pflash/tests/niah_gen.py.

6. P2 — sweep provenance and apparent headline-vs-table mismatch:
   the headline 210.7 tok/s comes from Phase 4 (n=20 reliability run at
   the V4 config: keep=0.05/alpha=0.70/budget=22), but the budget table
   was at keep=0.08/budget=varying and the alpha table was at
   keep=0.08/budget=28/alpha=varying. A reader who notices both
   "budget=22 → 217.4" (sweep) and "budget=22 → 210.7" (headline)
   would correctly conclude the section is mixing configs.

   Fix: each sweep table now declares its held-fixed parameters in the
   subsection title (Phase 1 / 2 / 3, with "held: ..."). Added the
   missing keep-ratio sweep (Phase 3) so the reader can see why
   keep=0.05 was chosen over the per-token-faster keep=0.08 (TTFT and
   compression-ratio tradeoff). New paragraph between the headline and
   the sweeps spells out the methodology so the cross-table comparison
   is grounded.
oliveagle pushed a commit to oliveagle/lucebox-hub that referenced this pull request May 22, 2026
bench_niah_cpp: expose ddtree/fa/kv params and auto-max-ctx as CLI flags
oliveagle pushed a commit to oliveagle/lucebox-hub that referenced this pull request May 22, 2026
…ance

Six review-feedback fixes on the new RTX 5090 long-context section:

1-3. Throughput unit consistency: rename Decode t/s → Decode tok/s in all
     three throughput tables (headline, budget sweep, alpha sweep) to
     match the rest of dflash/RESULTS.md and the short-context section.

4. Runtime config interface ambiguity: replace shorthand names
   (keep_ratio=, alpha=, ddtree_budget=, ...) with the actual
   reproducible interfaces — bench_niah_cpp.py CLI flags added in Luce-Org#90
   (--keep-ratio=, --alpha=, --ddtree-budget=, --fa-window=, --kv-tq3=,
   --n-gen=) and daemon env vars (DFLASH_FP_USE_BSA=, optional
   DFLASH27B_FA_WINDOW=). One concrete way to reproduce, not three
   shorthand aliases.

5. niah_gen.py path: reference becomes a relative markdown link to
   ../pflash/tests/niah_gen.py.

6. P2 — sweep provenance and apparent headline-vs-table mismatch:
   the headline 210.7 tok/s comes from Phase 4 (n=20 reliability run at
   the V4 config: keep=0.05/alpha=0.70/budget=22), but the budget table
   was at keep=0.08/budget=varying and the alpha table was at
   keep=0.08/budget=28/alpha=varying. A reader who notices both
   "budget=22 → 217.4" (sweep) and "budget=22 → 210.7" (headline)
   would correctly conclude the section is mixing configs.

   Fix: each sweep table now declares its held-fixed parameters in the
   subsection title (Phase 1 / 2 / 3, with "held: ..."). Added the
   missing keep-ratio sweep (Phase 3) so the reader can see why
   keep=0.05 was chosen over the per-token-faster keep=0.08 (TTFT and
   compression-ratio tradeoff). New paragraph between the headline and
   the sweeps spells out the methodology so the cross-table comparison
   is grounded.
oliveagle pushed a commit to oliveagle/lucebox-hub that referenced this pull request May 22, 2026
…ance

Six review-feedback fixes on the new RTX 5090 long-context section:

1-3. Throughput unit consistency: rename Decode t/s → Decode tok/s in all
     three throughput tables (headline, budget sweep, alpha sweep) to
     match the rest of dflash/RESULTS.md and the short-context section.

4. Runtime config interface ambiguity: replace shorthand names
   (keep_ratio=, alpha=, ddtree_budget=, ...) with the actual
   reproducible interfaces — bench_niah_cpp.py CLI flags added in Luce-Org#90
   (--keep-ratio=, --alpha=, --ddtree-budget=, --fa-window=, --kv-tq3=,
   --n-gen=) and daemon env vars (DFLASH_FP_USE_BSA=, optional
   DFLASH27B_FA_WINDOW=). One concrete way to reproduce, not three
   shorthand aliases.

5. niah_gen.py path: reference becomes a relative markdown link to
   ../pflash/tests/niah_gen.py.

6. P2 — sweep provenance and apparent headline-vs-table mismatch:
   the headline 210.7 tok/s comes from Phase 4 (n=20 reliability run at
   the V4 config: keep=0.05/alpha=0.70/budget=22), but the budget table
   was at keep=0.08/budget=varying and the alpha table was at
   keep=0.08/budget=28/alpha=varying. A reader who notices both
   "budget=22 → 217.4" (sweep) and "budget=22 → 210.7" (headline)
   would correctly conclude the section is mixing configs.

   Fix: each sweep table now declares its held-fixed parameters in the
   subsection title (Phase 1 / 2 / 3, with "held: ..."). Added the
   missing keep-ratio sweep (Phase 3) so the reader can see why
   keep=0.05 was chosen over the per-token-faster keep=0.08 (TTFT and
   compression-ratio tradeoff). New paragraph between the headline and
   the sweeps spells out the methodology so the cross-table comparison
   is grounded.

Co-Authored-By: Claude Opus 4.7 (1M context) <[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.

3 participants