mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1525] [CLOSED] prefill: swiglu + the down product's q8_1 rows, and the MoE combine + hyper-connection write, each in one kernel (the same bits; NVFP4 packs: 8K prompt -5.1%) #3509
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#3509
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/1525
Author: @sergqwer
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:pr/prefill-fused📝 Commits (1)
759c8b9prefill: swiglu + the down product's q8_1 rows, and the MoE combine + hyper-connection write, each in one kernel (the same bits; NVFP4 packs included)📊 Changes
8 files changed (+474 additions, -8 deletions)
View changed files
📝
CMakeLists.txt(+12 -0)📝
include/strata/prefill/kernels.hpp(+7 -0)📝
include/strata/prefill/moe_mmq.hpp(+7 -0)📝
src/prefill/kernels.cu(+81 -0)📝
src/prefill/moe_mmq.cu(+79 -0)📝
src/prefill/prefill.cpp(+49 -8)➕
tests/cuda/prefill_combine_write_test.cpp(+103 -0)➕
tests/cuda/prefill_swiglu_quant_test.cpp(+136 -0)📄 Description
Rebased on
477ac13c(0.1.45), with a narrower scope.dequant_q8_0_kernelandSTRATA_DEQUANT_WIDEcover it now.swiglu_scaled,row_sd) and the FP16xn16image.Two places in the prompt path write a value to memory and read it straight back:
swiglu_scaledfor NVFP4 experts) writes H in FP32, thenquantize()reads it to q8_1 for the down product. That is two launches per group of 16 experts, ~31 groups per layer and chunk.bo(T x 2560 floats), thengr_write_norm_rsreads it back for each of the 4 hyper-connection rows.Change (CUDA, the same bits):
mmq::swiglu_quant(STRATA_PREFILL_SWIGLU_QUANT=0keeps the two kernels): swiglu andquantize_mmq_q8_1<D4>'s rows of H in one pass. H is never stored.{s_gate, s_up}applied as read. The last is NVFP4:swiglu_scaled's values, with the row's expert taken from the group's bounds.fp4_activations).moe_combine_write_norm_rs(STRATA_PREFILL_COMBINE_WRITE=0keeps the two kernels): one block per token.moe_combine4's sum in registers: the same thread-to-element mapping, the same k order, and the samerow_sd(NVFP4's per-rows_down).gr_write_norm_rs's four rows: R, rs, the BF16 or FP16 image (xf16), andxn16_lo.bois never stored.gr_write_norm_rs: not steered, not the last layer, not before layer 1's PLE block, notSTRATA_GR_UNFUSED, Dm and shared 16-byte aligned, and not with the peer's sums.STRATA_DBG_NAN, which reads H andbo.prefill_combine_write_test: R, rs,xn16andxn16_loagainst the two kernels. T 1 / 333 / 1000 / 517, a padded token stride,row_sd, and the FP16 image.prefill_swiglu_quant_test: the q8_1 bytes against swiglu (orswiglu_scaled) + quantize. Q2_0 / IQ4_NL / Q8_0 split and interleaved, NVFP4 groups of 1 / 3 / 16 experts that start past row 0, 1 / 37 / 4113 rows, a zero row and a 3e4 outlier.Identity: first-token logits (sha256) and greedy tokens are identical to
477ac13c, with--pcie-frac 0 --adapt-every 1000000 --expert-cache 3000: p2k1e9c612c, 32Kf5b2872c.A/B. Setup:
--expert-cache auto --vram-reserve-mib 1500 --prefill auto --spec 6 --spec-min-p 0.7 --kv int8 --max-context 262144.At 32K the run-to-run spread (sd of the differences 237 ms) is larger than the difference. Upstream's own build read 2K in 1088.0 ms and 32K in 5198.5 ms in the first session (3 runs), the same as the switched-off arm within that spread.
STRATA_PREFILL_TIMING=1at 2K shows the fused path runs: "gemm down" 88 / 90 ms against 100 / 102 with the switches at 0, because the separate quantize is gone. At 2K the prompt path also waits 265-287 ms for expert copies, so most of the kernel time saved there turns into waiting.Earlier, with the dequant part included (
6674a006, IQ2_XS,--expert-cache 12000 --pcie-frac 0.25): 32K -4.0%, 8K -2.8%. Most of that was the dequant, which upstream covers now (dequant_q8_0_kernel; IQ4_XS throughSTRATA_DEQUANT_WIDE). That model is no longer on this PC.How to reproduce: install with upstream setup
--family nvfp4 --model NVFP4. Add--vram-reserve-mib 1500to the engine arguments. Read fresh 2K / 8K / 32K prompts with and withoutSTRATA_PREFILL_SWIGLU_QUANT=0 STRATA_PREFILL_COMBINE_WRITE=0. We ran--spec 6 --spec-min-p 0.7; setup writes 4 / 0.5, which the prompt path does not use.Not measured: HIP, GPUs other than sm_120, the Q2_0 / GGUF packs on 0.1.45 (they are covered by the tests only),
--peer-device,--prefill auto:32768, and NVFP4's w4a4 mode (the fusion is off there). Decode does not call these kernels.🤖 Generated with Claude Code
https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.