mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2145] [CLOSED] prefill: the fused int8 prompt experts on Turing (sm_75), opt-in (+9 % prefill on RTX 2080 Ti) #3882
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#3882
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/2145
Author: @rafatxf
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:pr/sm75-fused-experts📝 Commits (1)
7827c80prefill: fused int8 experts on Turing (sm_75), opt-in📊 Changes
3 files changed (+157 additions, -29 deletions)
View changed files
📝
src/prefill/moe_fused.cu(+27 -5)📝
src/prefill/moe_fused_iq.cu(+120 -22)📝
tests/cuda/prefill_fused_iq_test.cpp(+10 -2)📄 Description
On Turing the prompt path's experts always go through llama.cpp's MMQ: the fused int8 kernels (
moe_fused.cufor the Strata Q2_0 pack,moe_fused_iq.cu'snative_kernelfor the native packs, #136) need sm_80. On an RTX 2080 Ti MMQ's Q2_0 kernel runs at ~20-30 TOPS (255 registers with spills, one CTA per SM) and is the largest single cost of a long prompt read.This ports both to sm_75, opt-in on top of
STRATA_PF_FUSED=1withSTRATA_PF_FUSED_SM75=1:cp.async→ plain 16-byte copies (the barriers around them stay),prefetch.global.L2kept;mmam16n8k32 / m16n8k16 with s8 operands → four / twom8n8k16(rows g / g + 8 by k 0-15 / 16-31). The int32 sums are exact in any order, sodis what the sm_80 instruction gives; MAGIC is passed as the C operand of each pair's firstm8n8k16;smem_bytes/ the launch / the occupancy query take the device's depth (host_astages());native_kerneltakes Q2_0 gate/up (64-value blocks: a block per stage, as the down rows already read theirs), so the canonical Q2_0 pack (Q2_0 / Q2_0 in every layer) runs fused.gu_covered()lists Q2_0 on CUDA;DevInfo::t75:native_supportedanswers false for the others, which keep MMQ);T75_DEV): a stage's two 32-value halves share the block'sd, so a row's dot isd (dx_0 dot_0 + dx_1 dot_1)- 11 % fewer instructions (the kernel is bound by its FP32 epilogue on Turing, not the tensor pipe). sm_80+ keeps its code and bits.prefill_fused_iq_testgets the Q2_0 / Q2_0 pair, and skips the pairs a Turing card does not set up instead of failing.Setup
RTX 2080 Ti 22 GB (sm_75), i7-6700, CUDA 13.0, SM 1650 MHz, 240 W;
v0.1.43. Canonical Q2_0 pack,--prefill auto:16384,STRATA_BF16_TC=1,STRATA_SELECT_SIMT=2.Kernels (
prefill_fused_iq_test --only="Q2_0 / Q2_0", one layer, 512 experts, top 10)* before the Q2_0 epilogue change. Fused vs MMQ rel RMS 1.6e-5 - 2.7e-5; both 1.09e-2 against the FP32 reference (the int8 activations' own error).
prefill_fused_moe_test(Strata pack) passes too: 5.29 ms fused vs MMQ 3.67×, rel RMS 6.7e-5.Engine
98K prompt (16K chunks, two runs each, deterministic run to run): 58.3 → 53.3 s (+9.4 %). 4K: 3.63 → 3.54 s.
Accuracy in the engine: layer 0 of a 32K prompt (identical input on both paths), every one of the 163,840 (token, expert) rows of the expert output against MMQ's: median rel 1.6e-7, p99.9 2.6e-3, max 7.6e-3 (the rows where H's int8 rounding falls the other way); against the FP16 expert path (
STRATA_PREFILL_MMQ=0) MMQ and fused have the same error (median 1.08e-2).Teacher-forced, as in #655 / #2071 (the first P tokens through the prompt path, the next 2,048 through the verify windows,
STRATA_LOGPOS_TOPK=20):The perplexity moves either way (+3.4 %, −4.5 %, +0.6 %) - trajectory noise: the QSA selection is discrete, so any change of the prompt path's rounding gives KLs of this size (enabling only one layer's fused experts already moves the first logit by KL ~1e-3, as much as the FP16 path in every layer). The verify phase's time over the same 2,048 tokens: MMQ 42.36 s, fused 42.28 s.
The server here will run with
STRATA_PF_FUSED=1 STRATA_PF_FUSED_SM75=1.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.