mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #655] [CLOSED] sm_75: run the prompt path's BF16 products on the FP16 tensor cores (+15-18 % prefill on RTX 2080 Ti) #2744
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#2744
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/655
Author: @rafatxf
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:pr/sm75-bf16-tc📝 Commits (2)
671a387sm_75: run the prompt path's BF16 products on the FP16 tensor cores7b2dcd3BF16 tensor-core path: default on for all of compute capability 7.x (Volta too)📊 Changes
4 files changed (+221 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+5 -0)📝
include/strata/prefill/gemm.hpp(+6 -0)📝
src/prefill/gemm.cu(+57 -0)➕
src/prefill/gemm_bf16_parity.cu(+153 -0)📄 Description
What
Turing (sm_75) and Volta (sm_70) have FP16 tensor cores but no BF16 ones, so
cublasGemmExonCUDA_R_16BFinputs falls back to a SIMT fp32 kernel (magma_sgemmEx). On an RTX 2080 Ti that was the largest kernel of the prompt path, 20 % of a 4K prompt (nsys). It runs everyGemm::bf16product: the hyper-connection down / up projections, the router and indexer rows, and PLE key / value.On compute capability 7.x,
Gemm::bf16now:Gemm::f16product (fp32 accumulate) on the tensor cores.BF16 → FP16 is exact for every value inside FP16's range, because the 7-bit mantissa fits in 10 bits.
#if !defined(__HIPCC__)).STRATA_BF16_TC=0/1forces the path off or on.Gemminstance (there is one, inPrefill::Impl) and is freed with it. With Qwen3.8-Flash-Next it peaks at about 45 MiB: the 2560×2560 PLE value weight plus one activation slice.Accuracy
New test
gemm_bf16_parity. It comparesGemm::bf16with cuBLAS's own BF16 product on the same inputs. GPU, synthetic, no model;--benchadds timings. It covers:beta = 1accumulation (the bf16x2 low parts);On the 2080 Ti the worst relative difference is 1.7e-5. With
STRATA_BF16_TC=0it is 0, so the test also passes unchanged on other cards.Real products. I also checked every
beta = 0product of a real 32K prompt (400 products) against the cuBLAS BF16 result, with a temporary diagnostic that is not in this PR:Greedy output. It matches the unpatched engine for the first 52 (4K) and 105 (32K) tokens, then diverges the usual way for a change in summation order.
gr_paritystill passes.Numbers
Setup:
--resident-experts,--spec 4.STRATA_BF16_TC=0vs1.Decode does not use
Gemm::bf16and is unchanged within noise.Per product (
gemm_bf16_parity --bench):After the change, the conversion kernel is 3.8 % of a 32K prefill. Writing FP16 directly from the producers would take that back, but it touches more code, so I left it out of this PR.
Measured on sm_75 only (Volta was added in review, unmeasured). Other cards keep the default off, so their path is the same code as before.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.