mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2356] [CLOSED] pf_wmma: a second Volta prompt-expert kernel for IQ2_S gate/up and IQ4_NL down (STRATA_PF_WMMA2=1, opt-in): prompt +2.5-4.3% on a V100 + PG500 layer split #4001
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#4001
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/2356
Author: @Warabii1248
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:v100-pf-wmma2📝 Commits (9)
22966ebprefill: Volta runs the prompt experts on FP16 tensor-core tiles, a group per launch (STRATA_PF_WMMA)45f9397pf_wmma_parity: gemm_iq_f16_grouped against a double reference over the FP16 path's weights7fd8375bench/results: V100 prompt experts on FP16 tensor cores (+9.6% / +10.3% prompt speed); docs/NVIDIA_V100.md8750852pf_wmma: IQ4_NL (type 20) WK=128 lane for the down product (K=640); parity casesedf7bdcpf_wmma: take the FP16 prompt path for IQ4_NL down too (mmq_dt == 20)d5fdec0pf_wmma_parity: run on every sm_70+ card in one process, in turn (a layer split launches the tiles on its second card after the first)2cec5c3pf_wmma: set the tiles shared-memory attribute on each card, not once per process (a layer split stopped on its second card: "the WMMA expert tiles could not launch")6a7425dpf_wmma: STRATA_PF_WMMA2=1 (opt-in), a second Volta prompt-expert kernel for IQ2_S gate/up and IQ4_NL down - the dequantization spread over the whole block from a raw stage in shared memory (bitwise dq_iq2_s / dq_iq4_nl; prompt +2.5-4.3% with the IQ3_XXS pack on a V100 + PG500 split)dc6cd5fpf_wmma: say in the comment where the WMMA2 tile layout comes from📊 Changes
10 files changed (+794 additions, -6 deletions)
View changed files
📝
CMakeLists.txt(+8 -0)➕
bench/results/2026-10-07-v100-prompt-experts/README.md(+70 -0)➕
bench/results/2026-10-07-v100-prompt-experts/ab-runs.jsonl(+72 -0)📝
docs/NVIDIA_V100.md(+1 -1)📝
include/strata/kernels/iq_kernels.hpp(+5 -0)📝
include/strata/prefill/kernels.hpp(+2 -0)📝
src/kernels/cuda/iq_kernels.cu(+402 -0)➕
src/kernels/pf_wmma_parity.cpp(+160 -0)📝
src/prefill/kernels.cu(+16 -0)📝
src/prefill/prefill.cpp(+58 -5)📄 Description
Title
pf_wmma: a second Volta prompt-expert kernel for IQ2_S gate/up and IQ4_NL down (STRATA_PF_WMMA2=1, opt-in): prompt +2.5-4.3% on a V100 + PG500 layer split
Issue: stacked on #2355 (
v100-pf-wmma-layer-split, which carries #1771 and the layer-split fix). This PR's changes are its last two commits,6a7425danddc6cd5f(a comment). Like #2355, it carries #1771's conflict with main ated4773einsrc/prefill/prefill.cpp.Opt-in, so nothing changes without the variable.
Summary
gemm_iq_f16_grouped_kernel(#1771's FP16 tensor-core prompt experts) dequantizes each K chunk of 128 weight rows into shared memory before thetensor-core math: an IQ super-block (chunk 256) through
dq_dispatch, one warp a row; IQ4_NL and Q2_0 (chunk 128) with their own loops(IQ4_NL: one thread per row and 64-value half). The grid tables and the weight bytes are read from global memory as each chunk needs them.
We think that on a V100 this step does not fully hide behind the tensor-core math. The kernel below spreads it over the whole block; it also differs in
tile shape, static shared memory and launch bounds, and we did not isolate which part gives the gain.
The GSQ-RCO IQ3_XXS model that
setup.py --model IQ3_XXSinstalls mixes expert types per layer: gate/up is IQ2_S in 10 of 48 layers and down isIQ4_NL in 18 of 48. The new kernel takes those two types; the other layers keep the existing kernel, so the gain below comes from those layers only.
Behind the same entry point it adds a second kernel for these two types:
wmma16x16x16 fragments (FP32 sums).t % 128, sub-blockt / 128) from a "raw stage" in shared memory(one IQ2_S super-block or four IQ4_NL blocks a row) that the whole block reads as contiguous 4-byte words.
While the tensor cores work on a stage, the next raw stage and the next activations are already in registers (one barrier pair a stage).
kvalues_iq4nltable for IQ4_NL, live in shared memory.Y; an expert's last partial tile goes through a per-warp scratch.By design the dequantized values are the ones
dq_iq2_s/dq_iq4_nlgive, in natural order, so the tensor cores get the same FP16 weights in thesame k order as in the existing kernel. Every other type, shape and alignment keeps the existing kernel.
The layout (a raw stage in shared memory, one sub-block per thread per stage) follows a Volta MoE kernel we wrote for our own llama.cpp build
(local patches, not published; the comment in the code says so). The code here is new, written with
nvcuda::wmmaand Strata's own group layout (no ggml dependency).What changed
src/kernels/cuda/iq_kernels.cu: the second kernel, and withSTRATA_PF_WMMA2=1a branch that sends IQ2_S (K a multiple of 512) and IQ4_NL (K a multiple of 128) to it.The variable is read like
STRATA_PF_WMMA(on when its first character is1); unset or anything else: the existing kernel.#if !defined(__HIPCC__)block ofgemm_iq_f16_grouped(both HIP builds compile the stub that returns false,unchanged), and the SYCL build has no
gemm_iq_f16_grouped.HIP builds, without a GPU in ROCm 7.14 containers:
-DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906(themixa3607/rocm-gfx906:7.14-completeimage docs/AMD_HIP.md uses;
strataandpf_wmma_parity) and-DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DCMAKE_HIP_ARCHITECTURES="gfx1100;gfx1201"(rocm/dev-ubuntu-24.04:7.14.1-full;strata) both compile with 0 errors. Not run (no AMD card here). SYCL not built: it does not compile the changed file.Checks (Tesla V100-PCIE-32GB + Tesla PG500-216 (sm_70, 32 GB), layer split K=24, CUDA 12.9, Linux,
-DSTRATA_EXPERIMENTAL_SM60=ON)How we checked: a build of #2355's branch +
6a7425d(dc6cd5fchanges a comment only), the parity test on both cards, then the engine with and without the variable in ABBA order at two power limits.pf_wmma_parity(unset andSTRATA_PF_WMMA2=1): 0 failures on 2 devices both times. It compares the result against a double-precision reference;in the three cases the new kernel takes, its max |err| equals the existing kernel's (IQ2_S 1280x2560 0.000444 of 106, IQ4_NL 1280x2560 0.000393 of 97.5,
IQ4_NL 2560x640 0.000162 of 65.4), which fits the same weights summed in the same order.
(The first version rounded the IQ2_S sub-scale to FP16 before multiplying and gave 0.0435: within tolerance but not the same values, so we changed it.)
Engine: the GSQ-RCO IQ3_XXS model and pack that
setup.py --model IQ3_XXSinstalls (ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF), with setup'slaunch settings (
--mmap-experts, image input on,--spec 4 --spec-min-p 0.5), 256K context, int8 KV, layer split K=24,STRATA_SM70_TABLE=1,STRATA_PLE_PROBE=0(skips the start-up PLE read check and keeps direct reads). Every expert resident on both cards.A fresh engine start per run, on, off, off, on (ABBA), at 170 W and at 250 W.
Prompt tok/s (prompt tokens / time to the first content token, measured on the client). Fresh 26.7K, 52K and 104K prompts, then another 26.7K and 52K (nothing reused):
Every run with the variable is above every run without it; the two runs of a setting are within 0.6%. The first 26.7K after start (26,693 tokens)
is left out of the table because one run (170 W off, 1,517.1) was far below its pair; all eight values: 170 W off 1,517.1 / 1,764.4, on 1,827.4 / 1,826.1;
250 W off 1,864.3 / 1,869.8, on 1,939.3 / 1,938.6.
The kernel runs on the prompt path only; decode is not part of this comparison.
The long-prompt recall check (answer a passphrase placed in the middle) passed in all 40 requests (8 starts x 5).
Extra Notes
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.