mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #783] [CLOSED] perf(cuda): fused decode/verify/MTP kernels and graph launch reductions on 0.1.39 #2822
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#2822
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/783
Author: @stuchapin909
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:perf/cuda-decode-wave2-6📝 Commits (5)
d18d8b7perf(cuda): multi-token GR/RMSNorm/post-op kernels and exact-T specializationsa46daecperf(cuda): IQ/MMVQ sub-warp & 2-row kernels and MoE/shared-expert fusionsb7222ccperf(cuda): batched KV append, QSA indexer/RoPE fusion, and parallel resident_plan4327807perf(core): wire multi-token kernels into Verifier and MtpDrafter CUDA graphsa748042style: normalise the 23 source files back to LF, and pin it in .gitattributes📊 Changes
34 files changed (+1518 additions, -533 deletions)
View changed files
📝
.gitattributes(+4 -0)📝
include/strata/core/verify.hpp(+2 -1)📝
include/strata/kernels/elementwise.hpp(+1 -1)📝
include/strata/kernels/gr.hpp(+8 -0)📝
include/strata/kernels/kv_q4.hpp(+4 -0)📝
include/strata/kernels/kv_q8.hpp(+4 -0)📝
include/strata/kernels/native_gr_norm.hpp(+3 -0)📝
include/strata/kernels/native_gr_postops.hpp(+6 -0)📝
include/strata/kernels/native_qsa_indexer.hpp(+6 -0)📝
include/strata/kernels/native_rope.hpp(+4 -0)📝
src/core/mtp.cpp(+83 -46)📝
src/core/verify.cpp(+254 -146)📝
src/kernels/cuda/elementwise.cu(+11 -4)📝
src/kernels/cuda/fused_gdn.cu(+6 -6)📝
src/kernels/cuda/fused_gr.cu(+108 -44)📝
src/kernels/cuda/gr.cu(+67 -0)📝
src/kernels/cuda/iq_kernels.cu(+167 -53)📝
src/kernels/cuda/kv_q4.cu(+21 -11)📝
src/kernels/cuda/kv_q8.cu(+21 -10)📝
src/kernels/cuda/kv_stream.cu(+1 -1)...and 14 more files
📄 Description
Summary
This is the follow-up to #646 rebased cleanly onto
0.1.39(6f32ec0). Since #646 merged only the initial commit on that branch (884c14e), this PR brings in the remaining verify-window, MTP, and batch-decode kernel and CUDA-graph fusions split into 4 self-contained commits by subsystem.Measured apples-to-apples on 2x RTX 3090 24 GB (
IQ2_XS,--layer-split25/23, 100% of all 24,576 experts resident in VRAM on both baseline and PR):IQ2_XS, 100% VRAM Resident)0.1.39(#646884c14e)0.1.39+ This PR (#783)lru_code,T = 5..8)15.92 ms/win~15.10 ms/win13.07 ms/win(13.07–15.02across suite)0.1.39(-17.9% vs pre-#646)lru_code/skiplist/prose)164.1 / 156.4 / 151.0 tok/s~170.2 / 162.0 / 156.5 tok/s186.6 / 177.1 / 170.4 tok/s0.1.39(+13.7% vs pre-#646)210.7 – 217.5 tok/s(Note: Compared to
0.1.38's default26/22split where GPU 0 held491/512experts at18.31 ms/win/149.2 tok/s, combining0.1.39's25/23all-resident split with #646 + #783 reduces verify window time from18.31 ms/winto13.07 ms/win.)All changes are scoped strictly to
include/strata/{core,kernels}andsrc/{core,kernels/cuda}(32 files), preserve 0-ULP bitwise parity across all 25 GPU parity tests, and maintain full HIP (gfx906wave64 + RDNA wave32) compatibility.Commits & What's Included
1. Multi-token GR / RMSNorm / post-op kernels and exact-
Tspecializations (fused_gr.cu,gr.cu,native_gr_norm.cu,native_gr_postops.cu,native_bf16.cu,quantize_act.cu)fused_gr.cu:Bf16x8,unpack8,dot8u,dot8u_ptr) so weight tiles are unpacked once across tokens.gr_up_multi_kernel<MAX_T, EXACT_T>andgr_down_staged_kernel<MAX_T, EXACT_T>to eliminate dynamic loop bounds forT = 1..8(STRATA_GR_DOWN_MAX4=0disables theMAX_T=4specialization forct <= 4).f16_from_f32,STRATA_DP4A, andSTRATA_LDGfromf166564for HIP/ROCm portability.gr.cu(gr_read_multi,gr_write_multi): Multi-token hyper-connection read and write acrossn_toktokens in one launch.native_gr_norm.cu(native_gr_rms_norm_weighted_multi): Multi-token weighted RMSNorm acrossn_tokrows.native_gr_postops.cu(native_gr_pre_gated_multi,native_gr_post_multi): Multi-token pre-gated mixing and residual post-ops.native_bf16.cu(bf16_f32_mmvf_multi_kernel<BLOCK_SIZE, NT, EXACT_T>): Compile-time token-count dispatch inbf16_gemv_fp32_mmvf_multi.quantize_act.cu: Warp-shuffle reduction inquantize_q8_0_scaled_kernel.2. IQ/MMVQ sub-warp & 2-row kernels and MoE / shared-expert fusions (
iq_kernels.cu,native_mmvq.cu,native_moe.cu,native_router.cu,s2_expert_grouped.cu,shared_expert.cu,elementwise.cu)iq_kernels.cu:row_dot_80_sub16<TY, NC, EXACT_N, STAGE_GRID>and templatesmmvq_multi_kernel<TY, NC, STAGE_GRID, EXACT_N>(launch_mmvq_multi_nc).gu_split) innative_gu_multi_kernelalongside0.1.39'sdown_iq4nl_multi_kernel.native_mmvq.cu: AddsSmallTraits<Q40Block, 4>,SmallTraits<Q50Block, 4>,SmallTraits<Q80Block, 8>, andSmallTraits<IQ4NLBlock, 4>2-row-per-warp (ROWS = 2) multi-column MMVQ specialization inlaunch_multi_nwhen!multi_exact.native_moe.cu(combine_k10_vec4):float4-vectorizedk=10expert output combination innative_moe_combineandnative_moe_combine_multi.native_router.cu(route_multi,native_router_top10_multi): Multi-token top-10 router kernel acrossn_toktokens in a single launch.s2_expert_grouped.cu(swiglu_quantize_q8_0_scaled_kernel): Fuses SwiGLU and scaledQ8_0quantization inmoe_grouped_s2while writing backgate_up[idx]sos2_expert_grouped_parityremains 100% bitwise identical (STRATA_OLD_GROUPED=1selects the previous path).shared_expert.cu(sigmoid_scale_rows_vec4_kernel,launch_sigmoid_scale_rows):float4-vectorized sigmoid gating inshared_expertandshared_expert_multi.elementwise.cu(copy_rows_from_mapped_kernel<ZERO_HITS>): Allowscopy_rows_from_mapped(zero_hits = false) to skip redundant zero-fill when all experts are resident.3. Batched KV append, QSA indexer/RoPE fusion, and parallel
resident_plan_kernel(kv_q4.cu,kv_q8.cu,native_qsa_indexer.cu,native_rope.cu,verify_kernels.cu,fused_gdn.cu,qsa_select.cu,kv_stream.cu)kv_q4.cu(kv_append_q4_steps) &kv_q8.cu(kv_append_q8_steps): Append K and V acrossn_toktokens in a single 3D grid launch.native_qsa_indexer.cu(native_qsa_indexer_append_steps): Multi-token QSA indexer append in a single launch.native_rope.cu(norm_rope_kernel<TAB>,native_qsa_rms_norm_rope): Fuses per-head QSA RMSNorm and RoPE application.verify_kernels.cu:resident_plan_kernel<ALL_RESIDENT>: KeepskResidentPlanMax = 128(f945515) and replaces thread-0's serialO(n^2)bubble sort with parallel shared-memory grouping and a single packed(my_cnt << 16) | (is_first ? 1 : 0)prefix scan using__shfl_up_sync(0xffffffffu, pref, d). Using width-32__shfl_up_syncwithout__ballot_synckeeps the scan identical on both 32-lane warps (CUDA / RDNA) and 64-lane wavefronts (gfx906).gdn_ab_multi_kernel<MAX_T, EXACT_T>andgdn_step_norm_multi_kernel<ALL_OUT>.4. Wire multi-token kernels into
VerifierandMtpDrafterCUDA graphs (verify.cpp,mtp.cpp,verify.hpp)verify.cpp:Verifier::record_windowwithnative_gr_rms_norm_weighted_multi,native_gr_pre_gated_multi,native_gr_post_multi,native_qsa_rms_norm_rope,kv_append_q8_steps,kv_append_q4_steps,native_qsa_indexer_append_steps, andnative_router_top10_multi.copy_rows_from_mappedzero-fill on the all-residentdirect_partspath.STRATA_FUSE_HEAD_GR=1(fused LM-head GR read) andSTRATA_VERIFY_PRELAUNCH=1(cross-stage prelaunch) are both opt-in (default off) so default--layer-splitcommit and stage ordering remain identical to0.1.39(deee447).mtp.cpp:gr_read_multi,gr_write_multi,native_gr_rms_norm_weighted_multi,native_qsa_rms_norm_rope,kv_append_q8_steps,kv_append_q4_steps,native_qsa_indexer_append_steps, andnative_router_top10_multiinsideMtpDrafter::record_forward.Verification
GPU Parity Suite (CTest — 25/25 Passed)
Built and ran the GPU parity test suite on Windows 11 / CUDA 13.2 (2x NVIDIA GeForce RTX 3090 24 GB):
mmvq_multi_parity— Passediq_multi_parity— Passediq_parity_fixtures/iq_parity— Passednative_grouped_parity— Passedshared_expert_parity— Passeds2_expert_grouped_parity— Passed (bitwise identical across all 22 checks)s2_gemv_parity/s2_gemv_q8_parity— Passedgr_parity— Passedgdn_parity— Passedqsa_parity/qsa_topk_parity— Passedrope_parity— Passedquantize_act_parity— Passedroute_window_parity/router_top10_parity— Passedelementwise_parity— Passedbf16_gemv_parity— Passedsampler_parity— Passedcvec_parity— Passedkv_q8_parity/kv_q4_parity/kv_hybrid_parity/kv_stream_parity— Passed🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.