mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3820] [CLOSED] [Engine] Decode past 64K cells: a multi-CTA top-k and a shuffle-free block scorer in their own window graphs (STRATA_SELECT_LONG=1, opt-in, GP100 builds) #4793
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4793
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3820
Author: @ruibeikaa
Created: 10/23/2026
Status: ❌ Closed
Base:
main← Head:select-long📝 Commits (3)
3ae71d2qsa_select: decode top-k over several CTAs per query and decode block scores without shuffles, for the long-context select (SM60 build; not called yet)210aa20verify: the long-context QSA select in separate window graphs past 64K cells (STRATA_SELECT_LONG=1, default off)2e25f5bverify: pipelined windows take the long-context QSA select too (STRATA_SELECT_LONG=1: both variants captured up front, pl_launch picks by the window's context)📊 Changes
5 files changed (+608 additions, -16 deletions)
View changed files
📝
include/strata/core/verify.hpp(+7 -3)📝
include/strata/kernels/qsa_select.hpp(+16 -0)📝
metal/src/engine/stubs_0145.cpp(+4 -0)📝
src/core/verify.cpp(+53 -13)📝
src/kernels/cuda/qsa_select.cu(+528 -0)📄 Description
Problem and result
Everything below was measured on four GP100 dies (two PH402 SKU 200 boards, 32 GB HBM2 per die, 128 GB in all) with every expert resident in VRAM: no CPU share, no PCIe share, no adaptive tier. A rig that keeps experts in RAM or streams them over PCIe was not measured. HIP, SYCL and Metal were not built.
A decode window's QSA select runs one CTA per query for the top-k (
block_topk_wide_kernelpast ~135K cells) and the warp-shuffle block scorer (block_scores_multi_kernel), in each of the 12 QSA layers. Both grow linearly with the context: on one GP100 die at 300K cells a top-k call takes 0.39 ms with 1-5 SMs busy and a scores call 0.22 ms (two queries), about 7.4 ms of a window over the four dies. At short contexts the same work is small, and an extra kernel is pure overhead.This adds a multi-CTA decode top-k and a shuffle-free decode scorer, which return the same ids and the same score bits as the kernels they stand for. With
STRATA_SELECT_LONG=1the verifier keeps a second set of window graphs that uses them once a window reachesSTRATA_SELECT_LONG_ATcells (default 65536); below that the graphs are today's. On four GP100 dies with--pipeline-windows 3, the 400 tokens decoded at 115K context went 51.0 -> 52.5 tok/s (+2.9%; 30.75 -> 29.86 ms a window), the prompts below 64K stayed where they were, and every reply and engine state hash stayed the same on 15 requests. Unset (the default), nothing is allocated or captured and every graph is the one before.Related discussion
None (opt-in kernels in the
STRATA_EXPERIMENTAL_SM60build, no default change). This branch is main plus three commits and needs none of my other PRs. The maine88ee39drun below was on a branch that also carried #3455, #3760, #3819 and #3751, all on in the arm before this one.Approach
qsa_select.cu, inside!__HIPCC__ && STRATA_EXPERIMENTAL_SM60:block_topk_multi_*: six kernels over several CTAs per query (one per 2,048 blocks of capacity, at most 32), exchanging through caller scratch - no clusters, no spin waits, capturable, nothing carried between calls. The digit rule isblock_topk_kernel's as a scan and the emit isblock_topk_wide_kernel's row emit offset by the earlier CTAs' counts, so the ids are the same.block_scores_dx_kernel<1..8>: the multi scorer's per-head sums built in registers as the same 32-leaf xor-butterfly tree, without__shfl_xor_sync, then relu over the heads in the warp kernel's order; the tail block staysblock_scores_tail_kernel's. The score bits are the same.qsa_topk_multi_scratch_ints,qsa_block_topk_long,qsa_block_scores_long. Outside the build gate, or outside their conditions (scratch given, no active-block count, at most 16 / 8 queries), they forward toqsa_block_topk/qsa_block_scores. The existing declarations and bodies are unchanged.STRATA_TOPK_MULTI=0/STRATA_SCORES_DX=0turn either half off inside the long graphs (both default on at compute capability 6.x).verify.cpp:exec_[2][9], the #871 doorbell set and the launched flags get the variant as first index;sel_long_picks it before a capture.run()hands the choice to the next stage before capturing that stage's window, andprelaunch()derives it from the window's position, so a stage never launches the other variant.capture_allcaptures both variants with the switch on, andpl_launchpicks by the window's context, so--pipeline-windowstakes the long select too.Validation
Rig: four GP100 dies (compute capability 6.0, application clocks 1050 MHz graphics / 715 MHz memory, 140 W cap), Windows 11, driver 581.80 (TCC), CUDA 12.9, VS 2022. Build
-DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=60, ggml at the pinned 3cf03257f, unpatched. Model: Swift 1.5 IQ3_S (abliterated GSQ-RCO GGUF, dense matrices in Q8_0).Passed:
e88ee39d(engine 0.1.45.3) plus my GP100 stack, one exe for every arm, one engine start per arm, greedy; a ladder in which each arm adds one switch to the arm before. Arm S4 = #3455, #3760, #3819 and #3751 on; arm S5 = S4 +STRATA_SELECT_LONG=1(threshold at its default).--serve --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.85 --mtp <drafter> --max-context 1048576 --kv int8 --layer-split 12,24,36 --mtp-window 8192 --pipeline-windows 3 --conversation-cache-mib 32768 --conversation-cache-slots 8 --rope-scaling yarn --rope-scale 4. Environment, the same in every arm:STRATA_Q8_SM60=1 STRATA_STAGE_TRIM=1 STRATA_PREFILL_PIPE=70 STRATA_MMQ_RESIDENT_SORT_NE=1 STRATA_DF_BRANCH=1 STRATA_FUSE_DECODE=1 STRATA_FUSE_WAIT=2 STRATA_SIDE_MIXER=2 STRATA_GR_UP75=1 STRATA_B6_MMVQ_ROWS=1 STRATA_ADAPT_LAG=2 STRATA_ADAPT_NOWAIT=1 STRATA_DECODE_TIMING=1. Each start's switches were checked in the engine process's environment.STRATA_STATE_HASH=1and a 250K-token read added (15 requests), and a timing pass without debug switches (14 requests).STRATA_STATE_HASHitem equal on all 15 requests, including the two that decode past 64K cells, where the long graphs run (400 tokens at 115K, 16 tokens after the 250K read).STRATA_SM60_TABLE=0in both arms, addingSTRATA_SELECT_LONG=1together withSTRATA_IQ_STAGE_TABLES=1took the 115K request 52.0 -> 53.6 tok/s and the five short prompts +0.15%, the same replies; the two switches were not separated there.qsa_block_topk_refandblock_scores_kernel: contexts 1K-1M, 1-5 queries, 1/3/7/32 CTAs per query, capacities 131K-1M, tie-heavy scores (7 values, mostly zeros, -0.0 / 0.0 / negatives, NaN).5c8dd322: sm_60 withSTRATA_EXPERIMENTAL_SM60=ON(strata) and sm_86 without it (strata), both built without errors. The sm_60 exe containsblock_scores_dx_kernelandblock_topk_multi_*; the sm_86 exe contains neither.Failed: none observed.
Not run:
5c8dd322: the numbers above are from the revisions named there; the rebased branch was only built.e88ee39dhad--pipeline-windows 3, where decode windows go throughpl_launch. Serial decode with the long select was measured only on the older tree, which predates #871.Limits
STRATA_EXPERIMENTAL_SM60only. In another build the switch still keeps the second graph set, with the plain kernels in it: no effect but the graphs' memory.CI note: the red
metal-linkcheck is not caused by this PR. The job fails while compiling upstream'smetal/src/mtl_rt.mm(lines 69 and 92:MTLGPUFamilyMetal4,MTLCompileOptions.mathMode,MTLMathModeFast/MTLMathModeSafe), which themacos-14runner's SDK does not provide, so it stops before linking. The only file this PR changes undermetal/ismetal/src/engine/stubs_0145.cpp(a link stub for the new entry point).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.