[PR #108] [CLOSED] prefill: bit-identical kernel speed-ups (batched indexer append, parallel GDN conv, column-split GDN recurrence, one-launch embedding gather) #2461

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/108
Author: @q8atnight
Created: 9/29/2026
Status: ❌ Closed

Base: main ← Head: pr/prefill-kernels


📝 Commits (1)

  • acd4872 prefill: bit-identical kernel speed-ups - batched QSA indexer append, GDN conv parallel over tokens, GDN recurrence split over value columns (+ software-pipelined loads), one-launch embedding gather; STRATA_PF_*_CHECK debug compares

📊 Changes

5 files changed (+452 additions, -13 deletions)

View changed files

📝 include/strata/kernels/native_qsa_indexer.hpp (+6 -0)
📝 include/strata/prefill/kernels.hpp (+5 -2)
📝 src/kernels/cuda/native_qsa_indexer.cu (+106 -0)
📝 src/prefill/kernels.cu (+193 -4)
📝 src/prefill/prefill.cpp (+142 -7)

📄 Description

What

Four prompt-path kernels that were launch- or latency-bound, rewritten so that every output stays bit-identical
(each change has an env switch back to the old path and a debug self-check that runs both from the same state and
compares every byte):

change before after switch / check
QSA indexer append one 1-block launch per token (8,192 per QSA layer per chunk) 2 launches per chunk (native_qsa_indexer_append_chunk: each block does what the per-token kernel does at a completing position; placeholders/tail written by a finishing kernel) STRATA_PF_IDX_BATCH=0 / STRATA_PF_IDX_CHECK=1
GDN 4-tap conv 80 blocks, one thread per channel walking all T tokens one thread per (token, channel) + a tiny history kernel (same expression) STRATA_PF_CONV_PAR=0 / STRATA_PF_CONV_CHECK=1
GDN recurrence 48 blocks (one per value head, 16-warp barriers), loads on the critical path software-pipelined loads, and split over value columns (192 blocks of 4 warps; each column's FMA chains / reductions unchanged; the output RMS norm is finished by a second kernel from the same per-warp partial sums) STRATA_GDN_PIPELINE=0, STRATA_PF_REC_SPLIT=0 / STRATA_PF_REC_CHECK=1
token embeddings (GGUF-form table) one dequant launch per token one gather_dev launch per chunk (same dequantizer); picture rows uploaded over it STRATA_PF_EMBED_BATCH=0

Measured

RTX 3090, IQ3_S, 34K-token prompt (STRATA_PREFILL_TIMING=1, GPU timeline of the prompt path):

  • qsa indexer 1,082 ms → 2 ms, gdn conv 501 → 183 ms, gdn recurrence 1,671 → 1,188 ms, embedding host time 180 → 0 ms
  • ~2 s less per 34K prompt; in our setup the prompt rate went 1,680 → 1,851 tok/s from these four alone.

The self-checks printed IDENTICAL for every layer and chunk, including chunk boundaries (p0 = 8192, 16384) and a
continuation starting at a non-4-aligned position (p0 = 9229).

Measured on 2x RTX 3090 / Ryzen 9 3950X / 121 GB RAM (the numbers above are the primary card's own work, so they apply
to a single card too). Developed with an AI coding assistant; all numbers measured on the hardware above.


🔄 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/108 **Author:** [@q8atnight](https://github.com/q8atnight) **Created:** 9/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/prefill-kernels` --- ### 📝 Commits (1) - [`acd4872`](https://github.com/Niko1221/Strata/commit/acd487233c0bbe2217a6881c5bb43f8a283b0de5) prefill: bit-identical kernel speed-ups - batched QSA indexer append, GDN conv parallel over tokens, GDN recurrence split over value columns (+ software-pipelined loads), one-launch embedding gather; STRATA_PF_*_CHECK debug compares ### 📊 Changes **5 files changed** (+452 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/kernels/native_qsa_indexer.hpp` (+6 -0) 📝 `include/strata/prefill/kernels.hpp` (+5 -2) 📝 `src/kernels/cuda/native_qsa_indexer.cu` (+106 -0) 📝 `src/prefill/kernels.cu` (+193 -4) 📝 `src/prefill/prefill.cpp` (+142 -7) </details> ### 📄 Description ## What Four prompt-path kernels that were launch- or latency-bound, rewritten so that **every output stays bit-identical** (each change has an env switch back to the old path and a debug self-check that runs both from the same state and compares every byte): | change | before | after | switch / check | |---|---|---|---| | QSA indexer append | one 1-block launch per token (8,192 per QSA layer per chunk) | 2 launches per chunk (`native_qsa_indexer_append_chunk`: each block does what the per-token kernel does at a completing position; placeholders/tail written by a finishing kernel) | `STRATA_PF_IDX_BATCH=0` / `STRATA_PF_IDX_CHECK=1` | | GDN 4-tap conv | 80 blocks, one thread per channel walking all T tokens | one thread per (token, channel) + a tiny history kernel (same expression) | `STRATA_PF_CONV_PAR=0` / `STRATA_PF_CONV_CHECK=1` | | GDN recurrence | 48 blocks (one per value head, 16-warp barriers), loads on the critical path | software-pipelined loads, and split over value **columns** (192 blocks of 4 warps; each column's FMA chains / reductions unchanged; the output RMS norm is finished by a second kernel from the same per-warp partial sums) | `STRATA_GDN_PIPELINE=0`, `STRATA_PF_REC_SPLIT=0` / `STRATA_PF_REC_CHECK=1` | | token embeddings (GGUF-form table) | one dequant launch per token | one `gather_dev` launch per chunk (same dequantizer); picture rows uploaded over it | `STRATA_PF_EMBED_BATCH=0` | ## Measured RTX 3090, IQ3_S, 34K-token prompt (`STRATA_PREFILL_TIMING=1`, GPU timeline of the prompt path): - qsa indexer 1,082 ms → 2 ms, gdn conv 501 → 183 ms, gdn recurrence 1,671 → 1,188 ms, embedding host time 180 → 0 ms - ~2 s less per 34K prompt; in our setup the prompt rate went 1,680 → 1,851 tok/s from these four alone. The self-checks printed `IDENTICAL` for every layer and chunk, including chunk boundaries (p0 = 8192, 16384) and a continuation starting at a non-4-aligned position (p0 = 9229). Measured on 2x RTX 3090 / Ryzen 9 3950X / 121 GB RAM (the numbers above are the primary card's own work, so they apply to a single card too). Developed with an AI coding assistant; all numbers measured on the hardware above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:21 +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#2461
No description provided.