[PR #600] [CLOSED] qsa_prompt_attn: tensor-core kernel for Volta (sm_70, mma.m8n8k4) #2717

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/600
Author: @fks
Created: 10/3/2026
Status: ❌ Closed

Base: main ← Head: feature/v100-prompt-attn-volta


📝 Commits (4)

  • ee0843d qsa_prompt_attn: tensor-core kernel for Volta (sm_70, mma.m8n8k4)
  • bb28e13 docs: NVIDIA_V100.md and the measurements of the Volta prompt attention
  • dbb1a08 bench: distribution check of the Volta prompt attention (teacher-forced KL, controls)
  • eb7fe10 docs: point the BF16 note at #540 (the BF16-via-FP16 PR #593 was closed in its favor)

📊 Changes

4 files changed (+576 additions, -3 deletions)

View changed files

➕ bench/results/2026-10-03-v100-prompt-attn/README.md (+104 -0)
➕ docs/NVIDIA_V100.md (+70 -0)
📝 src/kernels/cuda/qsa_prompt_attn.cu (+390 -3)
📝 src/kernels/qsa_prompt_attn_parity.cpp (+12 -0)

📄 Description

On sm_70 qsa_prompt_attn_batch refuses the device (#371), so the prompt path runs the QSA attention on the decode kernel, one query at a time with FP32 FMAs: 19.2% of the GPU time of a 28,650-token prompt on a V100 (nsys, 0.1.35, attn_chunk_kernel<1>).

prompt_attn_v70_kernel is the v1 kernel's structure with the two matrix products on mma.sync.m8n8k4 (FP16 in, FP32 accumulate): q.k with one 64-dim group (= one int8 scale group) per warp and 8 cells per quad-pair, p.v with 16 dims per quad-pair. q and p keep their hi + lo FP16 split, and the four dim groups' partials are added in a fixed order (deterministic). Int8, FP16 and K8V4 KV are handled; Q4_0 KV (mode 4, sm_80+ only) keeps the old kernel. The m8n8k4 fragment layout was measured on a V100 and agrees with turbomind's SM70_MMA_884. It is used for compute capability 7.0 - 7.4; STRATA_PROMPT_ATTN_OLD=1 is the old path.

Accuracy (qsa_prompt_attn_parity, synthetic, V100, 32K context, 2,048 queries per chunk, output scale ~3.6):

KV error vs FP64, old kernel error vs FP64, new kernel time per chunk, old -> new
int8 2.4e-6 5.1e-6 38.1 -> 13.4 ms (2.8x)
fp16 1.9e-6 5.3e-6 37.3 -> 28.3 ms (1.3x)

The 1,500- and 2,100-token contexts also pass. The test now skips its Q4_0 cases below sm_80 instead of exiting 2 there (the dispatcher keeps the old kernel for them).

Prompt speed (one V100-PCIE-32GB, i9-7960X, CUDA 12.8, origin/main at 99f3dbd, Unsloth UD-IQ4_XS, int8 KV; cold server, random-word prompts, greedy; same binary, STRATA_PROMPT_ATTN_OLD=1 against the default):

Prompt tokens old path (tok/s) new kernel (tok/s)
7,194 1,010 1,164 +15%
28,650 1,063 1,251 +18%
114,338 973 1,123 +15%

Decode is unaffected (it does not use this path).

Output checks

  • Needle recall (tools/needle_bench.py, 8k / 32k / 128k at five depths, a fresh server per configuration): 15 of 15 found with the old path, 15 of 15 with the new kernel.
  • Greedy output (48 tokens) is identical for the 28,650- and 114,338-token prompts. For the 7,194-token prompt it starts the same and differs later: another summation order in a greedy decode. I did not run a teacher-forced top-1 comparison.

Not covered: only the Unsloth IQ4_XS pack was run (not the GSQ-RCO quants); one request on one card. Method, profile and raw numbers: bench/results/2026-10-03-v100-prompt-attn/; build and kernel overview: docs/NVIDIA_V100.md (both in this PR). Independent of the BF16-via-FP16 change in #540: different code files, and it stacks with it (a user measured +9% on top of #540)

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/600 **Author:** [@fks](https://github.com/fks) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/v100-prompt-attn-volta` --- ### 📝 Commits (4) - [`ee0843d`](https://github.com/Niko1221/Strata/commit/ee0843da07ee8da96fa0b5afebfdd8dde6c0b587) qsa_prompt_attn: tensor-core kernel for Volta (sm_70, mma.m8n8k4) - [`bb28e13`](https://github.com/Niko1221/Strata/commit/bb28e1346a6120eb880312692b3d4764dea9b571) docs: NVIDIA_V100.md and the measurements of the Volta prompt attention - [`dbb1a08`](https://github.com/Niko1221/Strata/commit/dbb1a08aa263c9c3cc89d8d260053b4c4739abeb) bench: distribution check of the Volta prompt attention (teacher-forced KL, controls) - [`eb7fe10`](https://github.com/Niko1221/Strata/commit/eb7fe10cf3e86601c2df942afbe4b89a3bdf1e2a) docs: point the BF16 note at #540 (the BF16-via-FP16 PR #593 was closed in its favor) ### 📊 Changes **4 files changed** (+576 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `bench/results/2026-10-03-v100-prompt-attn/README.md` (+104 -0) ➕ `docs/NVIDIA_V100.md` (+70 -0) 📝 `src/kernels/cuda/qsa_prompt_attn.cu` (+390 -3) 📝 `src/kernels/qsa_prompt_attn_parity.cpp` (+12 -0) </details> ### 📄 Description On sm_70 `qsa_prompt_attn_batch` refuses the device (#371), so the prompt path runs the QSA attention on the decode kernel, one query at a time with FP32 FMAs: 19.2% of the GPU time of a 28,650-token prompt on a V100 (nsys, 0.1.35, `attn_chunk_kernel<1>`). `prompt_attn_v70_kernel` is the v1 kernel's structure with the two matrix products on `mma.sync.m8n8k4` (FP16 in, FP32 accumulate): q.k with one 64-dim group (= one int8 scale group) per warp and 8 cells per quad-pair, p.v with 16 dims per quad-pair. q and p keep their hi + lo FP16 split, and the four dim groups' partials are added in a fixed order (deterministic). Int8, FP16 and K8V4 KV are handled; Q4_0 KV (mode 4, sm_80+ only) keeps the old kernel. The m8n8k4 fragment layout was measured on a V100 and agrees with turbomind's `SM70_MMA_884`. It is used for compute capability 7.0 - 7.4; `STRATA_PROMPT_ATTN_OLD=1` is the old path. **Accuracy** (`qsa_prompt_attn_parity`, synthetic, V100, 32K context, 2,048 queries per chunk, output scale ~3.6): | KV | error vs FP64, old kernel | error vs FP64, new kernel | time per chunk, old -> new | | --- | ---: | ---: | ---: | | int8 | 2.4e-6 | 5.1e-6 | 38.1 -> 13.4 ms (2.8x) | | fp16 | 1.9e-6 | 5.3e-6 | 37.3 -> 28.3 ms (1.3x) | The 1,500- and 2,100-token contexts also pass. The test now skips its Q4_0 cases below sm_80 instead of exiting 2 there (the dispatcher keeps the old kernel for them). **Prompt speed** (one V100-PCIE-32GB, i9-7960X, CUDA 12.8, `origin/main` at `99f3dbd`, Unsloth `UD-IQ4_XS`, int8 KV; cold server, random-word prompts, greedy; same binary, `STRATA_PROMPT_ATTN_OLD=1` against the default): | Prompt tokens | old path (tok/s) | new kernel (tok/s) | | | ---: | ---: | ---: | ---: | | 7,194 | 1,010 | 1,164 | +15% | | 28,650 | 1,063 | 1,251 | +18% | | 114,338 | 973 | 1,123 | +15% | Decode is unaffected (it does not use this path). **Output checks** - Needle recall (`tools/needle_bench.py`, 8k / 32k / 128k at five depths, a fresh server per configuration): 15 of 15 found with the old path, 15 of 15 with the new kernel. - Greedy output (48 tokens) is identical for the 28,650- and 114,338-token prompts. For the 7,194-token prompt it starts the same and **differs later**: another summation order in a greedy decode. I did not run a teacher-forced top-1 comparison. Not covered: only the Unsloth IQ4_XS pack was run (not the GSQ-RCO quants); one request on one card. Method, profile and raw numbers: `bench/results/2026-10-03-v100-prompt-attn/`; build and kernel overview: `docs/NVIDIA_V100.md` (both in this PR). Independent of the BF16-via-FP16 change in #540: different code files, and it stacks with it (a user measured +9% on top of #540) 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:35 +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#2717
No description provided.