mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3069] [CLOSED] perf(hip): enable wave32 head ops, MTP q8_mixed/HEAD_MIX_MULTI, and S2 <1> specialization #4433
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#4433
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/3069
Author: @bsorensen110
Created: 10/18/2026
Status: ❌ Closed
Base:
main← Head:perf/rdna4-d4-mtp-sampler📝 Commits (2)
dbf9407perf(hip): enable wave32 head ops, MTP q8_mixed/HEAD_MIX_MULTI, and S2 <1> specialization78a98f8fix(hip): guard mapped-copy fallback alignment, remove 1-col mmvq_pair, and add parity coverage📊 Changes
13 files changed (+692 additions, -230 deletions)
View changed files
📝
CMakeLists.txt(+2 -2)📝
src/core/mtp.cpp(+66 -31)📝
src/core/verify.cpp(+26 -10)📝
src/kernels/cuda/elementwise.cu(+25 -18)📝
src/kernels/cuda/fused_gr.cu(+10 -4)📝
src/kernels/cuda/quantize_act.cu(+13 -12)📝
src/kernels/cuda/s2_expert_grouped.cu(+223 -121)📝
src/kernels/cuda/shared_expert.cu(+6 -3)📝
src/kernels/cuda/verify_kernels.cu(+40 -12)📝
src/kernels/gr_parity.cpp(+67 -0)📝
src/kernels/s2_expert_grouped_parity.cpp(+7 -5)📝
src/kernels/shared_expert_parity.cpp(+40 -0)📝
src/kernels/verify_parity.cpp(+167 -12)📄 Description
Summary
This PR enables and optimizes several bitwise-identical paths across the MTP draft layer, the verify/draft head greedy sampler & top-probability kernels, the S2 grouped expert kernels, and the shared expert on RDNA HIP (
gfx1201):Wave32 multi-block
argmax_rowsandrow_top_prob_spliton RDNA HIP (src/kernels/cuda/verify_kernels.cu,CMakeLists.txt):argmax_rows_kernelandrow_top_prob_split_kernelwere previously compiled out under#if !defined(__HIPCC__), forcing wave32 RDNA GPUs (warpSize == 32) onto the single-blocksampler_greedy_kernel<<<n_rows, 1024>>>androw_top_prob_kernel<<<n_rows, 1024>>>(1..5 blocks total across 48 WGPs to scan 425 KB..4.97 MB of logits).#if !defined(STRATA_HIP_GFX906)(keeping wave64gfx906on the one-block kernels) and enablesmulti_block_head_ops()/argmax_rows_wanted()per device on HIP whenp.warpSize == 32(STRATA_MULTI_BLOCK_ARGMAX=0andSTRATA_ARGMAX_ROWS=0force them off).kTopBlocks = 32(32threads = 1 warp/block across 32 WGPs, avoiding intra-block__syncthreads()barriers whenblockDim.x == 32) and adds#pragma unroll 8to the stride-1024 reduction loop inrow_top_prob_kernelandrow_top_prob_split_kernel(preserving exact per-thread summation order while overlapping 8 global loads in flight).verify_paritytarget on HIP (STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP) and extendsverify_paritywithcopy_from_mapped_multi,quantize_q8_0_scaled, and--benchchecks.Fused HC
q8_mixed,STRATA_HEAD_MIX_MULTI, and shared-expertx_q8_1reuse in MTP and Verify (src/core/mtp.cpp,src/core/verify.cpp,src/kernels/cuda/fused_gr.cu,src/kernels/cuda/shared_expert.cu):fused_gr_read_multi(src/kernels/cuda/fused_gr.cu) to writeq8_mixedwithout aq8_cntbuffer whenqfuse_hc_local() && a[0].s_down == nullptr(gr_up_q32_kernelandgr_up_q8_q32_kernelassign one warp per 32-columnq8_1block and never touchq8_cnt).STRATA_HEAD_MIX_MULTIby default ongfx12inverify.cppandmtp.cpp(STRATA_HEAD_MIX_MULTI=0disables), replacing the 4-launchgr_readfallback on the MTP final mixer withfused_gr_read_multi.q8_mixed = xq_ + t * (N / 32) * 36to all 3fused_gr_read_multicalls inMtpDrafter(attn_hyper_connection,mlp_hyper_connection, andhyper_connection_mixer) and to the finaloutput_hc_*fused_gr_read_multiinVerifier, skipping redundant standalonenative_quantize_q8_1launches whenfused_gr_read_multiwritesxq_.shared_expert()(src/kernels/cuda/shared_expert.cu) to honornative->x_q8_1(set byMtpDrafterwhenq8_mlp && T == 1), matchingshared_expert_multi.S2 grouped expert
<1>specialization, LDS-only barriers, and fused SwiGLU+Q8_0 on hit paths (src/kernels/cuda/s2_expert_grouped.cu,src/kernels/s2_expert_grouped_parity.cpp):s2_sync_lds()(s_wait_dscnt 0x0; s_barrier_signal -1; s_barrier_wait -1ongfx12;s_waitcnt lgkmcnt(0); s_barrierongfx1030/gfx11xx) for LDS-only staging barriers.MAX_E = 1template specializationsgu_grouped_t_kernel<1>(LDS = 3,200 B,VGPR = 85vs<8>'sLDS = 25,600 B,VGPR = 89) anddown_grouped_t_kernel<1>(LDS = 800 B,VGPR = 47vs<8>'sLDS = 6,400 B,VGPR = 40) dispatched whencap_entries <= 16(covering single-token MTPT = 1, K = 10).swiglu_quantize_q8_0_scaled_kernelinmoe_hit_grouped_s2,moe_hit_grouped_s2_dev, andmoe_hit_grouped_s2_multiwhenfast && x_scales != nullptr && swiglu_q8_on()(STRATA_S2_SWIGLU_Q8=0disables), matchingmoe_grouped_s2.Warp-per-block
quantize_q8_0_scaledandcopy_from_mapped_multion HIP (src/kernels/cuda/quantize_act.cu,src/kernels/cuda/elementwise.cu,src/core/mtp.cpp):quantize_q8_0_scaled_kernelon HIP (STRATA_OLD_Q80_SCALED=1restores the thread-per-block kernel).copy_from_mapped_multi_kernelon HIP (STRATA_MTP_MULTI_COPY=0restores individual copies) and usescopy_from_mapped_multiinMtpDrafter::capture_roundandMtpDrafter::capture_step.Verification & Parity Evidence (AMD Radeon AI PRO R9700
gfx1201)All 7 parity and self-test suites pass with 0 failures and 100% bitwise equality:
Multi-architecture compilation verified cleanly on:
hipcc):gfx1100,gfx1101,gfx1102,gfx1103,gfx1151,gfx1200,gfx1201nvcc):sm_75,sm_89,sm_100,sm_120End-to-End 397B Speculative Decode A/B (Radeon AI PRO R9700
gfx1201)Workload: Qwen3.5-397B-A17B (
swift-iq3_spack + native GGUF + MTP drafter--spec 4 --spec-min-p 0.5 --pcie-frac 0.30 --kv int8),512prompt tokens,256generated tokens per trial,1warmup +5timed trials per arm (111verify windows/trial,147 / 224drafts accepted, identical token sequence SHA-256ced7b38252fd809dacross all trials and arms).d4_on(default)strata.d4(default switches)2747.3, 2765.6, 2769.8, 2778.3, 2778.592.14..93.18d4_all_off(same binary)strata.d4(STRATA_MULTI_BLOCK_ARGMAX=0 STRATA_HEAD_MIX_MULTI=0 STRATA_MTP_MULTI_COPY=0 STRATA_OLD_Q80_SCALED=1 STRATA_QFUSE_HC=0 STRATA_LFUSE=0 STRATA_S2_SWIGLU_Q8=0)2826.2, 2817.2, 2818.8, 2832.3, 2826.990.39..90.87origin/mainstrata.main(477ac13c)2794.6, 2796.1, 2801.2, 2805.7, 2808.091.17..91.61d4_onvsd4_all_off):-56.4 ms(+1.85 tok/s,+2.04%) end-to-end decode (24.95vs25.46 ms/window),-69 us/step(-6.8%) on the MTP step graph (0.947vs1.016 ms/step).origin/main(d4_onvsmain_base):-31.4 ms(+1.04 tok/s,+1.14%) end-to-end decode (24.95vs25.24 ms/window, non-overlapping 5-trial distributions[2747.3, 2778.5] msvs[2794.6, 2808.0] ms),-60 us/step(-6.0%) on the MTP step graph (0.947vs1.007 ms/step).Per-Stage MTP Step Graph Breakdown (
STRATA_MTP_PROFILE=1, 492 step graphs)k/v+append(skipsnative_quantize_q8_1viaq8_attn):0.046 ms->0.043 ms(-3 us)experts(quantize_q8_0_scaledwarp-per-block +gu/down_grouped_t_kernel<1>+s2_sync_lds()):0.046 ms->0.044 ms(-2 us)shared(skipsnative_quantize_q8_1viansw.x_q8_1reuse):0.036 ms->0.034 ms(-2 us)hc-read mixer(STRATA_HEAD_MIX_MULTI=1+q8_headfused intofused_gr_read_multi):0.049 ms->0.035 ms(-14 us)head gemv(skipsnative_quantize_q8_1(sample_, xq_)):0.344 ms->0.341 ms(-3 us)argmax+prob(wave32argmax_rows+row_top_prob_split):0.054 ms->0.025 ms(-29 us,2.16x)1.031 ms->0.980 ms(-51 us/stepinmtp profile;1.007 ms->0.947 ms=-60 us/stepwithout profile stamps).What This Does NOT Fix / Scope Notes
STRATA_HIP_GFX906/warpSize == 64) remains on the single-blocksampler_greedy_kernelandrow_top_prob_kernel.gfx1201(AMD Radeon AI PRO R9700);gfx1100..gfx1151and CUDAsm_75..sm_120were verified by compilation.STRATA_MULTI_BLOCK_ARGMAX=0,STRATA_ARGMAX_ROWS=0,STRATA_HEAD_MIX_MULTI=0,STRATA_QFUSE_HC=0,STRATA_MTP_MULTI_COPY=0,STRATA_OLD_Q80_SCALED=1,STRATA_LFUSE=0,STRATA_S2_SWIGLU_Q8=0.Reproduction Commands
Full-Stack Combined Integration Benchmark (All 8 Open RDNA4 PRs Merged)
For reference when testing the full RDNA4 series together (separate from PR #3069's isolated single-PR numbers in the description above), here are the combined parity and end-to-end 397B prefill + speculative decode results when merging all 8 open RDNA4 PRs onto
origin/main(477ac13c):Merged Stack (
32 files changed, +2,037 / -675 lines)HC_Q8dequant +gfx12Q8_0gr_upmix), #3001 (moe_fused_iq.cunative_w11_kernelLDS barrier), #3010 (wmma_gemm.cu+gdn_chunkedRDNA4 WMMA), #3013 (qsa_prompt_attn.cuRDNA4 WMMA,STRATA_HIP_WMMA=1opt-in)fused_gr.cugfx12tsum+gr_up_q32_kernel+gr_sync_lds), #3024 (iq_kernels.cuEXPDEC+STRATA_IQ_STAGE_GRID), #3064 (verify_kernels.cuGDN verifyvk_sync_lds+GS_COLS=32+ batched 36-layer commit underSTRATA_GDN_SPLIT=1), #3069 (this PR: wave32argmax_rows/row_top_prob_split, MTPq8_mixed+STRATA_HEAD_MIX_MULTI, shared-expertx_q8_1reuse, S2<1>specialization +s2_sync_lds+ hitswiglu_q8, warp-per-blockquantize_q8_0_scaled,copy_from_mapped_multi)1. Combined Parity Verification (AMD Radeon AI PRO R9700
gfx1201)All 14 parity harnesses pass with 0 failures on the combined build:
arch_defaults_test,gr_parity,gr_upmix_parity,hip_prefill_wmma_gemm_parity(3,529cases,max_abs = 0),hip_gdn_chunked,iq_multi_parity,gdn_parity(STRATA_GDN_SPLIT=0and1),verify_batch_parity --selftest,spec_verify_parity,verify_parity --selftest,s2_expert_grouped_parity,shared_expert_parity --selftest,sampler_parity,quantize_act_parity.2. End-to-End 397B Prefill + Speculative Decode A/B (
origin/mainvs Combined 8-PR Stack)Workload: Qwen3.5-397B-A17B (
swift-iq3_spack + native GGUF + MTP--spec 4 --spec-min-p 0.5 --pcie-frac 0.30 --kv int8 --prefill 4096),STRATA_HIPBLASLT_TUNING=tools/hip/gfx1201-hipblaslt-100500.txt STRATA_DENSE_MMQ=1 STRATA_PF_FUSED=1 STRATA_HC_Q8=1,1warmup +5timed trials per arm.A.
prompt = 512,gen = 256(111verify windows,147 / 224drafts accepted, bitwise-identical token hashced7b38252fd809dacross all trials)origin/main(477ac13c,STRATA_HIP_WMMA=1)2820.8, 2841.3, 2831.5, 2834.4, 2849.789.83..90.75STRATA_HIP_WMMA=1)2699.6, 2716.4, 2716.8, 2718.7, 2720.694.10..94.83B.
prompt = 4096,gen = 256(92verify windows,166 / 224drafts accepted, token hashb52b193b1859dbf7)origin/main(STRATA_HIP_WMMA=0default)1995.0, 2001.2, 2004.6, 2011.3, 2017.42,043.3 tok/s)2581.1, 2603.8, 2591.3, 2672.5, 2660.598.32 tok/s)origin/main(STRATA_HIP_WMMA=1)1420.3, 1426.7, 1425.7, 1428.2, 1449.02,871.0 tok/s)2486.0, 2509.3, 2491.9, 2495.2, 2513.8102.60 tok/s)STRATA_HIP_WMMA=1)1401.7, 1417.5, 1408.6, 1410.9, 1413.12,903.1 tok/s)2411.2, 2409.6, 2412.9, 2430.0, 2418.6106.10 tok/s)main(WMMA=1)main(WMMA=0)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.