[PR #593] [CLOSED] prefill: run BF16 GEMMs through FP16 tensor cores on sm_70/sm_75 #2712

Closed
opened 2026-11-04 02:02:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 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)

  • b2fddae prefill: 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::bf16 now converts W (into the existing dequantization scratch) and X (into an FP16 copy) to FP16 and takes the tensor-core f16() 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 the cublasGemmEx BF16 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|1 forces the old/new path; STRATA_BF16_VIA_F16_CHECK=1 counts 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.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/593 **Author:** [@fks](https://github.com/fks) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/v100-bf16-via-f16` --- ### 📝 Commits (1) - [`b2fddae`](https://github.com/Niko1221/Strata/commit/b2fddae6d8743f7e9f9ef118bf4a19aec74d761b) prefill: run BF16 GEMMs through FP16 tensor cores on sm_70/sm_75 ### 📊 Changes **3 files changed** (+117 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/prefill/gemm.hpp` (+14 -0) 📝 `src/prefill/gemm.cu` (+100 -0) 📝 `src/prefill/prefill.cpp` (+3 -0) </details> ### 📄 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::bf16` now converts W (into the existing dequantization scratch) and X (into an FP16 copy) to FP16 and takes the tensor-core `f16()` 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 the `cublasGemmEx` BF16 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|1` forces the old/new path; `STRATA_BF16_VIA_F16_CHECK=1` counts 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:33 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2712
No description provided.