[PR #283] [CLOSED] Prompt path: BF16 projections get the activation's BF16 remainder too #2551

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/283
Author: @sergqwer
Created: 9/30/2026
Status: ❌ Closed

Base: main ← Head: pr/prefill-bf16-split


📝 Commits (1)

  • 39db5de Prompt path: BF16 projections get the activation's BF16 remainder too

📊 Changes

3 files changed (+119 additions, -54 deletions)

View changed files

📝 include/strata/prefill/kernels.hpp (+10 -7)
📝 src/prefill/kernels.cu (+65 -29)
📝 src/prefill/prefill.cpp (+44 -18)

📄 Description

Summary

The prompt path fed BF16-rounded activations (2^-9 relative) to the BF16-weight projections, where decode feeds FP32.
Most of these projections feed discrete choices: the router (top-10), the indexer (block selection), SSM alpha/beta,
the shared-expert gate, the PLE key/value and the hyper-connection. A token whose router logits are close can pick
another expert on the prompt path than decode would.

Each such projection now takes x as hi + lo, both BF16 (lo = bf16(x - hi)), in two GEMMs summed in FP32. That
gives ~16 mantissa bits, decode's FP32 x to within ~1e-5. The kernels that write the BF16 images (gr_norm*,
gr_silu, gr_mix*, to_bf16) write the remainder alongside.

STRATA_PREFILL_BF16X2 picks the scope: 2 (default) all but the hyper-connection, 1 all, 0 off.

Measured

Measured on current main (0.1.29, d6708a4) with ISTA-DASLab's IQ2_XS, RTX 5090 32 GB, Ryzen 9 9950X3D, 128 GB DDR5, Windows 11. KL is first-token KL divergence (STRATA_DUMP_FIRST_LOGITS, #276); two runs of main itself differ by 0 on 5 of 6 short prompts and by 0.00013 on the sixth. First-token KL against mode 1 (every projection split):

prompt main (off) this PR (mode 2)
1K 0.0028 0.0014
2K 0.0069 (top-1 differs) 0.0024 (top-1 differs)
4K 0.0009 0.0012
32K 0.074 (top-1 differs) 0.072 (top-1 differs)

Mode 2 roughly halves the error on the shorter prompts. At 32K both stay 0.07 away from mode 1 and pick another first
token, so the hyper-connection's split is what matters there. Mode 2 is the default because on the NVFP4 fork mode 1
cost 8% of prompt speed (4,360 vs 4,726 tok/s; mode 2 4,726 vs 4,776 off). If 32K accuracy matters more than that,
mode 1 is the better default. It is a one-line change, and your call.

Switch

STRATA_PREFILL_BF16X2=0 is main's behaviour, 1 splits every projection.

🤖 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.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/283 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 9/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/prefill-bf16-split` --- ### 📝 Commits (1) - [`39db5de`](https://github.com/Niko1221/Strata/commit/39db5deb5afd103da90ad33dbda1a846b707de8b) Prompt path: BF16 projections get the activation's BF16 remainder too ### 📊 Changes **3 files changed** (+119 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/prefill/kernels.hpp` (+10 -7) 📝 `src/prefill/kernels.cu` (+65 -29) 📝 `src/prefill/prefill.cpp` (+44 -18) </details> ### 📄 Description ## Summary The prompt path fed BF16-rounded activations (2^-9 relative) to the BF16-weight projections, where decode feeds FP32. Most of these projections feed discrete choices: the router (top-10), the indexer (block selection), SSM alpha/beta, the shared-expert gate, the PLE key/value and the hyper-connection. A token whose router logits are close can pick another expert on the prompt path than decode would. Each such projection now takes x as `hi + lo`, both BF16 (`lo = bf16(x - hi)`), in two GEMMs summed in FP32. That gives ~16 mantissa bits, decode's FP32 x to within ~1e-5. The kernels that write the BF16 images (`gr_norm*`, `gr_silu`, `gr_mix*`, `to_bf16`) write the remainder alongside. `STRATA_PREFILL_BF16X2` picks the scope: `2` (default) all but the hyper-connection, `1` all, `0` off. ## Measured Measured on current main (0.1.29, d6708a4) with ISTA-DASLab's IQ2_XS, RTX 5090 32 GB, Ryzen 9 9950X3D, 128 GB DDR5, Windows 11. KL is first-token KL divergence (`STRATA_DUMP_FIRST_LOGITS`, #276); two runs of main itself differ by 0 on 5 of 6 short prompts and by 0.00013 on the sixth. First-token KL against mode 1 (every projection split): | prompt | main (off) | this PR (mode 2) | | --- | ---: | ---: | | 1K | 0.0028 | 0.0014 | | 2K | 0.0069 (top-1 differs) | 0.0024 (top-1 differs) | | 4K | 0.0009 | 0.0012 | | 32K | 0.074 (top-1 differs) | 0.072 (top-1 differs) | Mode 2 roughly halves the error on the shorter prompts. At 32K both stay 0.07 away from mode 1 and pick another first token, so the hyper-connection's split is what matters there. Mode 2 is the default because on the NVFP4 fork mode 1 cost 8% of prompt speed (4,360 vs 4,726 tok/s; mode 2 4,726 vs 4,776 off). If 32K accuracy matters more than that, mode 1 is the better default. It is a one-line change, and your call. ## Switch `STRATA_PREFILL_BF16X2=0` is main's behaviour, `1` splits every projection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:01:14 +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#2551
No description provided.