mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #593] [CLOSED] prefill: run BF16 GEMMs through FP16 tensor cores on sm_70/sm_75 #2712
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#2712
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/593
Author: @fks
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:feature/v100-bf16-via-f16📝 Commits (1)
b2fddaeprefill: run BF16 GEMMs through FP16 tensor cores on sm_70/sm_75📊 Changes
3 files changed (+117 additions, -0 deletions)
View changed files
📝
include/strata/prefill/gemm.hpp(+14 -0)📝
src/prefill/gemm.cu(+100 -0)📝
src/prefill/prefill.cpp(+3 -0)📄 Description
Cards without BF16 tensor cores (Volta, Turing) ran every BF16 projection (hyper-connection, router, indexer, ...) as an FP32 SIMT kernel in cuBLAS (
magma_sgemmEx): 17% of the GPU time of a 28,650-token prompt on a V100 (nsys, 0.1.35). Related: #139, which addressed the same kernels with a separate SGEMM.Gemm::bf16now converts W (into the existing dequantization scratch) and X (into an FP16 copy) to FP16 and takes the tensor-coref16()path. The conversion is exact for every BF16 value inside FP16's range; on that prompt no value overflowed, and the values below 2^-14 have an absolute error of at most 2^-25.The X copy (T x the widest K: 42 MB at T = 2048, 168 MB at the 8,192-token chunk the server used here) is carved from the prompt path's own buffers in
carve()/bytes_needed(), like its other buffers, and only on cards that need it, so nothing is allocated after init. If it does not fit, or on a card with BF16 tensor cores,bf16()keeps thecublasGemmExBF16 path.One V100, same binary, greedy output identical: 28,650-token prompt read in 26.9 s -> 23.8 s (1,063 -> 1,205 tok/s); 7,194 tokens +15%, 114,338 tokens +13%.
STRATA_BF16_VIA_F16=0|1forces the old/new path;STRATA_BF16_VIA_F16_CHECK=1counts the values FP16 could not hold and prints them at exit.Not covered: sm_75 takes the same path but was not measured; only the Unsloth IQ4_XS pack was run. Written and measured with Claude Sonnet 5.5.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.