mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #109] [MERGED] decode: batch the verify window's per-token kernels (bit-identical, +~10% decode) #2459
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#2459
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/109
Author: @q8atnight
Created: 9/29/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @Niko1221
Base:
main← Head:pr/decode-batch📝 Commits (1)
1e4515cdecode: batch the verify window's per-token kernels (bit-identical); skip the PCIe path with --pcie-frac 0; decode timing/profile switches📊 Changes
16 files changed (+387 additions, -10 deletions)
View changed files
📝
include/strata/core/verify.hpp(+13 -0)📝
include/strata/kernels/bf16_gemv.hpp(+4 -0)📝
include/strata/kernels/elementwise.hpp(+4 -0)📝
include/strata/kernels/fused_gr.hpp(+2 -1)📝
include/strata/kernels/native_moe.hpp(+3 -0)📝
include/strata/kernels/native_router.hpp(+2 -0)📝
include/strata/kernels/verify_kernels.hpp(+2 -0)📝
src/core/verify.cpp(+173 -8)📝
src/kernels/cuda/elementwise.cu(+31 -0)📝
src/kernels/cuda/fused_gr.cu(+5 -1)📝
src/kernels/cuda/native_bf16.cu(+68 -0)📝
src/kernels/cuda/native_moe.cu(+12 -0)📝
src/kernels/cuda/native_router.cu(+10 -0)📝
src/kernels/cuda/shared_expert.cu(+8 -0)📝
src/kernels/cuda/verify_kernels.cu(+10 -0)📝
src/program/generate.cpp(+40 -0)📄 Description
What
The verify window's graph launched a few hundred tiny kernels per window token (≈450 extra graph nodes per token;
the window is launch-latency bound: ~3-5 µs per small kernel). This batches them over the window's rows, keeping every
row's arithmetic identical to the single-token call (outputs bit-identical):
bf16_gemv_fp32_mmvf_multi(reads the 2.6 MB weight once, per-token accumulators in exactly thesingle-row order) + one multi-row top-10 launch (the kernel takes
blockIdx.x= token)blockIdx.y= token)mapped position array), the q/gate split (one 2-D copy) and the output gate - one launch each instead of one per token
(
copy_rows_from_mapped; the GPU-planned rows are +0.0 there anyway)--pcie-frac 0the window skips the PCIe path completely (no flag-B wait, no empty grouped launch)STRATA_DEC_BATCH=0restores the per-token launches.Diagnostics (off by default):
STRATA_DECODE_TIMING=1prints per request where the window time goes (GPU wait, hostper layer, commit, draft);
STRATA_VERIFY_PROFILE=1stamps%globaltimerinside the captured window and prints the GPUtime per stage (GDN vs QSA layers);
STRATA_VERIFY_NODES=1prints each window graph's kernel histogram.Measured
IQ3_S on an RTX 3090 (+ a second card holding experts, see the multi-GPU PR), window-weighted over flashbench 1K/8K
greedy + sampled: 80.1 → 88.6 tok/s from the batching. Exactness: greedy output identical to the per-token path on the
flashbench
gateprompts (withSTRATA_MMQ_NO_STREAMK).One observation, not changed here: once most experts are on GPUs, the PCIe share made the GPU wait 2.5-5 ms per
window on flag B for the few missed experts;
--pcie-frac 0(the CPU computes them) was +13 % decode in thatsetup. On a single card with many misses the trade-off is likely different.
Developed with an AI coding assistant; all numbers measured on 2x RTX 3090 / Ryzen 9 3950X.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
__shared__ alignas(16) int4does not compile (clang 18 / ROCm 6.3.3) #4441__shared__ alignas(16) int4does not compile (clang 18 / ROCm 6.3.3) #4923