[GH-ISSUE #4118] [Engine] Opt-in two-pass QSA prompt selection: 3xTF32 only near the top-k cut-off, the same cells #1801

Closed
opened 2026-11-04 01:54:11 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @bitaccesscomau on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4118

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Read long prompts faster on sm_80+ cards without changing any output.

On an RTX 3090 a cold 256K prompt spends about 13% of its read in the QSA selection (STRATA_PREFILL_TIMING=1 on
v0.2.4.1: qsa select 17.4 s of a 136.3 s GPU timeline), most of it in the block scores. qsa_block_scores_tc
computes every block score of every query in 3xTF32 (48 m16n8k8 MMAs per indexer head and block), although only the
blocks near each query's top-k cut-off need that precision.

Proposed behaviour, opt-in with STRATA_SELECT_TWO_PASS=1 (off by default): score every block once in single-pass
TF32, bound per block how far that score can be from today's 3xTF32 score, and score again with today's 3xTF32
arithmetic, bit for bit, only the blocks whose bound reaches the cut-off. qsa_block_topk then returns today's cells
in today's order, ties included. With the variable unset nothing changes.

Measured on a working branch (one commit on main 7dd5cf18; one RTX 3090 24 GB on PCIe 3.0 x16 at 250 W, release
defaults, the same binary with the switch off and on, 2 pairs of 2 runs): 256K prompt read 1,887 to 1,984 tokens/s
(+5.2%, run ratios 1.047 to 1.055), 128K +2.2%, 32K +0.2%, decode within the spread of the runs. Replies are
byte-identical to main at 1K, 32K, 128K and 256K with the switch off and on, and the switch's own check found 0
queries with other cells out of 1,523,556 at 128K and 3,046,896 at 256K.

Tradeoffs:

  • About 1,020 lines of CUDA and host code and 670 lines of tests (one commit, +1,710 lines).
  • CUDA sm_80+ and the prompt path only. The HIP builds compile the file but get stubs and today's path; Metal and
    SYCL are unchanged.
  • Long prompts only: nothing changes below 16K cells (STRATA_SELECT_TWO_PASS_MIN, default 4096 blocks), and 32K is
    about even.
  • The bound rests on a stated model of the MMA's FP32 accumulation (within 16 ulps of the absolute sum per MMA). On
    real prompts the largest error used 0.21 of the bound.
  • A row the rule cannot settle falls back to today's 3xTF32 scorer for its 16-query tile: exact, but slower than
    today. None did on the prompts above.

Is this in scope as an opt-in switch? If so I will open the pull request; the code, tests and measurements are ready.

What do you do today instead?

Nothing: the 3xTF32 scorer scores every block. The closest existing work is #3498 (HIP, STRATA_SELECT_SPLIT2), which
drops the lo pieces and changes rounding (253 of 256 selections at 262K); this proposal keeps the selection bitwise.

Originally created by @bitaccesscomau on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4118 ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? Read long prompts faster on sm_80+ cards without changing any output. On an RTX 3090 a cold 256K prompt spends about 13% of its read in the QSA selection (`STRATA_PREFILL_TIMING=1` on v0.2.4.1: `qsa select` 17.4 s of a 136.3 s GPU timeline), most of it in the block scores. `qsa_block_scores_tc` computes every block score of every query in 3xTF32 (48 m16n8k8 MMAs per indexer head and block), although only the blocks near each query's top-k cut-off need that precision. Proposed behaviour, opt-in with `STRATA_SELECT_TWO_PASS=1` (off by default): score every block once in single-pass TF32, bound per block how far that score can be from today's 3xTF32 score, and score again with today's 3xTF32 arithmetic, bit for bit, only the blocks whose bound reaches the cut-off. `qsa_block_topk` then returns today's cells in today's order, ties included. With the variable unset nothing changes. Measured on a working branch (one commit on `main` `7dd5cf18`; one RTX 3090 24 GB on PCIe 3.0 x16 at 250 W, release defaults, the same binary with the switch off and on, 2 pairs of 2 runs): 256K prompt read 1,887 to 1,984 tokens/s (+5.2%, run ratios 1.047 to 1.055), 128K +2.2%, 32K +0.2%, decode within the spread of the runs. Replies are byte-identical to `main` at 1K, 32K, 128K and 256K with the switch off and on, and the switch's own check found 0 queries with other cells out of 1,523,556 at 128K and 3,046,896 at 256K. Tradeoffs: - About 1,020 lines of CUDA and host code and 670 lines of tests (one commit, +1,710 lines). - CUDA sm_80+ and the prompt path only. The HIP builds compile the file but get stubs and today's path; Metal and SYCL are unchanged. - Long prompts only: nothing changes below 16K cells (`STRATA_SELECT_TWO_PASS_MIN`, default 4096 blocks), and 32K is about even. - The bound rests on a stated model of the MMA's FP32 accumulation (within 16 ulps of the absolute sum per MMA). On real prompts the largest error used 0.21 of the bound. - A row the rule cannot settle falls back to today's 3xTF32 scorer for its 16-query tile: exact, but slower than today. None did on the prompts above. Is this in scope as an opt-in switch? If so I will open the pull request; the code, tests and measurements are ready. ### What do you do today instead? Nothing: the 3xTF32 scorer scores every block. The closest existing work is #3498 (HIP, `STRATA_SELECT_SPLIT2`), which drops the lo pieces and changes rounding (253 of 256 selections at 262K); this proposal keeps the selection bitwise.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660029818 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1801
No description provided.