mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5047] [CLOSED] [Benchmark] prompt experts: the same expert weights are dequantized once per 64-row block (15x at 900 rows) #5298
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#5298
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/5047
Author: @dingyiyuan
Created: 11/3/2026
Status: ❌ Closed
Base:
main← Head:prompt-experts-two-phase📝 Commits (1)
c76c5e6bench: prompt experts dequantize the same weights once per 64-row block (15x at 900 rows)📊 Changes
1 file changed (+89 additions, -0 deletions)
View changed files
➕
bench/results/2026-11-03-prompt-experts-two-phase/README.md(+89 -0)📄 Description
Problem and result
While porting the DeepSeek-V4.1 expert kernels to SYCL I measured the prompt path and found that the
fused expert kernel re-dequantizes the same expert weights once per 64-row activation block.
src/dsv41/ds4_iq.cu:1595(gate/up) and:1614(down) build the grid as(ceil(max_rows/64), n_col_blocks, n_exp); the work unit is (row-block, column-block, expert) and eachone dequantizes its weight tile from the trellis again. An expert with
Rrows therefore has itsweights dequantized
ceil(R/64)times: 15 passes at 900 rows/expert.That is the right trade for decode (
R == 1, one pass, no f16 scratch). It is the expensive choice forthe prompt, where the same bytes are decoded fifteen times.
Result, on the SYCL translation of this tree I can run here: dequantize each expert once into an
f16 scratch and use one library f16 GEMM per matrix. At 900 rows/expert, gate/up goes from 58,334 us
to 4,011 us (14.5x), down 8.3x. End to end a 62,290-token prompt goes from 375.8 to 944.1 tok/s
(2.51x), decode unchanged, output identical.
This PR adds only the measurement report under
bench/results/; it changes no engine code.Related discussion
none
Approach
The report records the measurement, an attribution, and the shape of the CUDA change, because I cannot
run CUDA here (no CUDA hardware) and sending untested CUDA seemed worse than sending the number.
Attribution is measured, not estimated: inside the two-phase path I repeated only the dequantize N
times. The cost is linear at 1,704 us/pass, so of the 14.5x, 6.95x is the redundancy going away
(4,011 -> 27,870 us at N = 15, which is also what the fused kernel spends) and 2.09x is the inner
product moving from a fused F32 dot product to a tensor-core f16 GEMM (27,870 -> 58,334 us).
Two controls that matter for the shape of the change: at 96 rows/expert the redundancy is only 2x and
the speedup drops to 3.7x, and at
R <= 64a two-phase path is slower than the fused one, so anysuch path must be gated on row count (96 by measurement) and decode must stay fused.
If a maintainer wants the CUDA side, the shape is: thread the per-stream cuBLAS handle that
ds4_model.cukeeps for the dense path throughrun_setinto the two set entry points, gate onmax_rows >= 96, dequantize each expert once into an f16 scratch, keep the fused kernel as thefallback. Two things that cost me a cycle and are worth knowing:
SetArgs::boundsis device memory,so a host-side path has to copy it back first, and
stream == 0means the default stream here.Validation
Passed:
DS4_EXP_2PHASE=1 ds4_iq_test_tc --bench-tiles 16 6 900- revision: my local port, commitd9d0ffb2; Arc Pro B70 32 GB, oneAPI 2026.2, DeepSeek-V4.1-Flash IQ2_XXS (2.06 bit/weight),n_embd 5120,n_ff 2304, 6 experts/word, 6 experts timed. gate/up 4,011 us against 58,334 usfor the fused kernel; down 2,054 us against 16,968 us.
DS4_EXP_2PHASE=1 DS4_EXP_2PHASE_DUP=<N> ... --bench-tiles 16 6 900for N = 1, 2, 15:4,011 / 5,715 / 27,870 us, i.e. linear at 1,704 us/pass (the attribution above).
DS4_EXP_2PHASE=1 DS4_EXP_2PHASE_MINROWS=1 ds4_iq_test_tc --type 16- numerics against the samedouble-precision reference the existing harness uses:
set gate_upworst 3.34e-04 (tol 1e-02),set down1.42e-04 (tol 3e-03), ALL OK. The fused path on the same inputs: 7.02e-03 / 4.19e-04,so f16 weights with an f32 accumulator round less than per-value f32.
the server's slot cache otherwise answers from KV and reports a meaningless rate): prefill
165,732 ms -> 65,975 ms. Note: the sampler is not deterministic run to run on this build (the same
configuration gives 114-117 tokens on a repeated greedy request), so end-to-end text equality is not a
usable check; the correctness evidence is the kernel-level parity above. Decode checked separately with a matched A/B (48-token prompt, 160 tokens,
engine restarted between runs): unchanged at 20.8-20.9 tok/s steady state.
Failed:
none observed
Not run:
written for that reason.
remove, but I only measured 62K.
Limits
grid and the algorithmic redundancy are the same code (the CUDA lines cited above), the absolute
throughput is not.
off for
R <= 64.about 42% of the 4,011 us at these shapes. Avoiding the scratch (feeding the tensor cores directly)
is the next step, not part of this report.
kTokin the vendor paths (vendor/exl3.cu), which I didnot measure.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.