[PR #4876] [Engine] STRATA_GDN_TC=2: the tensor-core GDN recurrence on Turing (sm_75), 2.2x faster #5225

Open
opened 2026-11-07 16:33:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4876
Author: @xrip
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: pr/gdn-tc-sm75


📝 Commits (1)

  • 5f53320 prefill: STRATA_GDN_TC=2 runs the tensor-core GDN scan on sm_75 (Turing)

📊 Changes

4 files changed (+71 additions, -27 deletions)

View changed files

📝 docs/DETAILS.md (+1 -0)
📝 docs/GDN_CONTRACT.md (+2 -1)
📝 src/prefill/gdn_tc.cuh (+43 -16)
📝 src/prefill/kernels.cu (+25 -10)

📄 Description

Problem and result

On Turing cards (sm_75), the prompt's DeltaNet (GDN) recurrence always runs on the old CUDA-core kernel, gdn_rec_cols_pipe_kernel. The tensor-core scan behind STRATA_GDN_TC=1 needs sm_80 (mma m16n8k16, cp.async) and 98-125 KB of shared memory per block. Turing has only 64 KB.

With this PR, STRATA_GDN_TC=2 runs the same scan on sm_75. On a CMP 50HX (sm_75, 56 SMs), the time for one layer's recurrence:

New tokens in the call Old kernel (pipe) STRATA_GDN_TC=2
8,192 11.19 / 11.18 ms 5.12 / 5.13 ms
2,048 2.77 / 2.77 ms 1.28 / 1.28 ms
1,024 1.38 / 1.38 ms 0.64 / 0.64 ms
512 0.68 / 0.68 ms 0.33 / 0.33 ms
300 0.39 / 0.39 ms 0.21 / 0.21 ms

That is 1.9x faster at 300 tokens and about 2.2x faster from 1,024 tokens up. The default path does not change: =1 (the 0.2.9 server default on Linux CUDA) still leaves sm_75 on the old kernels, and sm_80+ cards run the same code as before.

None. This takes the existing opt-in STRATA_GDN_TC to sm_75 and does not change the default path (see Validation), so I opened the PR directly. If you want to agree on the scope in an issue first, I can do that.

Approach

Three things in the scan need sm_80. Each one has a Turing form:

  • mma.sync m16n8k16 becomes two m16n8k8 steps on the same registers: k 0-7 with a0, a1, b0, then k 8-15 with a2, a3, b1. ldmatrix already exists on sm_75.
  • cp.async becomes the plain-copy fallback that gdn_cp_* already has below sm_80. redux.sync becomes the existing shuffle max.
  • Shared memory: a new plan, ONE (gdn_tc_scan_kernel<false, true, 3, 1, true>), keeps every buffer single. That is 62,480 B, inside the 64 KB opt-in. With no second buffer, the next chunk is loaded after this chunk's state update, so the load does not overlap the products.

gdn_rec_tc takes ONE on cc 7.5 only when the dispatch asks for it (STRATA_GDN_TC=2). With =1 it returns "not supported" there, as before. The split variants are not supported on sm_75. The prep kernel does not change. The output has the same rounding as =1 (f16x3 split products), so it is not bit-identical to the old kernel.

Validation

Revision 5f533205, on c62d5e3a (0.2.9).

Passed:

  • Builds, CUDA 13.3 and g++-14 (a Docker image built on nvidia/cuda 13.3 devel, Ubuntu 24.04), Release: CMAKE_CUDA_ARCHITECTURES=75 (targets strata and gdn_harness) and =120 (target gdn_harness, which links the prefill and kernel libraries). No errors.
  • sm_75 correctness against gdn_harness's FP64 reference: CMP 50HX, driver 610.43.03, Ubuntu 24.04, CUDA_VISIBLE_DEVICES=2.
    • gdn_harness --T 8192 --chunk 8192 --paths pipe,tc --ref-heads 0,17,47: pipe PASS-bitwise, tc PASS (output error to the reference ref_y 2.27e-4, pipe 2.28e-4; state ref_state 5.8e-7, pipe 1.4e-7). 0 failed verdicts.
    • gdn_harness --T 3000 --chunk 1500 --stress --paths pipe,tc --ref-heads 0,17,47: all 10 cases PASS, 0 failed verdicts.
    • Default path: STRATA_GDN_TC=1 gdn_harness --T 5000 --chunk 2500 --cuts 37 --paths auto,pipe --ref-heads 0,17,47: auto runs pipe and gives the same hash as pipe (h=5218a839), PASS-bitwise. So sm_75 with =1 is unchanged.
    • Opt-in: the same command with STRATA_GDN_TC=2: auto runs tc for the long calls and pipe for the 37-token call. PASS.
  • sm_80+ unchanged: RTX 5060 Ti (sm_120, 36 SMs), STRATA_GDN_TC=1 gdn_harness --T 3000 --chunk 1500 --any-sms --ref-heads 0,17,47. Upstream c62d5e3a and this PR give the same verdicts and the same hashes on every path: auto/tcs d031486f, keyhead/pipe 8dc3ae4f, chunked 475fd185.
  • HIP sees the same text: every changed line is inside #if !defined(__HIPCC__), and gdn_tc.cuh is included only from inside that block. g++ -x c++ -E -P -undef -D__HIPCC__ of src/prefill/kernels.cu (with the #include lines removed) gives the same output before and after this PR (2,034 lines, md5 d4471402). Without -D__HIPCC__, the outputs differ, as they should.
  • Timing (the table above): gdn_harness --T N --chunk N --paths pipe|tc --bench --no-ref --reps 15 --warmup 30, with pipe and tc taking turns. Each cell gives the median of the 15 repeats, for each of the two rounds.
  • In daily use (not an A/B): our box (2x CMP 50HX on the layer split) has served a Claude Code workload with this kernel switched on since 2026-10-31, through our fork's dispatch (=1 on cc 7.5; same gdn_tc.cuh). Over 1,300 requests in about 13 hours, the log shows no errors. Prompt reads of 4K-46K new tokens after a cached 10K-token start took 6.0 % +- 5.6 % less time than on 0.2.8 (6 reads against 28). This compares two releases, so it is not a measurement of this change alone. The recurrence is about 7 % of a prompt read on this box (STRATA_PREFILL_TIMING=1 on 0.2.0: 201-205 ms of a 2.9-3.0 s GPU timeline per 8,192-token chunk), so I expect prompt reads to be about 3-4 % faster.

Failed: none observed.

Not run:

  • HIP build: no ROCm here. The preprocessor check above shows that HIP sees the same text. SYCL builds its own migrated copy (sycl/src/prefill/kernels.dp.cpp), and Metal does not build this file.
  • Model output checks (KL, task suites) with =2 on Turing. The rounding was checked only against the harness reference.
  • A clean engine A/B (=0 against =2, same build): the box is in daily use.
  • Turing cards other than the CMP 50HX.

Limits

  • Like =1, it needs 48+ SMs (one block per value head). Smaller Turing cards keep the old kernels.
  • With a single buffer, the next chunk's load does not overlap the products: about 1 ms per layer at 8,192 tokens. The kernel uses 255 registers and spills 144 B.
  • Measured on one card model only.
  • Opt-in only. Making it the sm_75 default would first need the checks under Not run.

🤖 Generated with Claude Code


🔄 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/4876 **Author:** [@xrip](https://github.com/xrip) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/gdn-tc-sm75` --- ### 📝 Commits (1) - [`5f53320`](https://github.com/Niko1221/Strata/commit/5f5332058535e37540741d08414b72711b35bde8) prefill: STRATA_GDN_TC=2 runs the tensor-core GDN scan on sm_75 (Turing) ### 📊 Changes **4 files changed** (+71 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+1 -0) 📝 `docs/GDN_CONTRACT.md` (+2 -1) 📝 `src/prefill/gdn_tc.cuh` (+43 -16) 📝 `src/prefill/kernels.cu` (+25 -10) </details> ### 📄 Description ## Problem and result On Turing cards (sm_75), the prompt's DeltaNet (GDN) recurrence always runs on the old CUDA-core kernel, `gdn_rec_cols_pipe_kernel`. The tensor-core scan behind `STRATA_GDN_TC=1` needs sm_80 (`mma m16n8k16`, `cp.async`) and 98-125 KB of shared memory per block. Turing has only 64 KB. With this PR, `STRATA_GDN_TC=2` runs the same scan on sm_75. On a CMP 50HX (sm_75, 56 SMs), the time for one layer's recurrence: | New tokens in the call | Old kernel (`pipe`) | `STRATA_GDN_TC=2` | |---|---|---| | 8,192 | 11.19 / 11.18 ms | 5.12 / 5.13 ms | | 2,048 | 2.77 / 2.77 ms | 1.28 / 1.28 ms | | 1,024 | 1.38 / 1.38 ms | 0.64 / 0.64 ms | | 512 | 0.68 / 0.68 ms | 0.33 / 0.33 ms | | 300 | 0.39 / 0.39 ms | 0.21 / 0.21 ms | That is 1.9x faster at 300 tokens and about 2.2x faster from 1,024 tokens up. The default path does not change: `=1` (the 0.2.9 server default on Linux CUDA) still leaves sm_75 on the old kernels, and sm_80+ cards run the same code as before. ## Related discussion None. This takes the existing opt-in `STRATA_GDN_TC` to sm_75 and does not change the default path (see Validation), so I opened the PR directly. If you want to agree on the scope in an issue first, I can do that. ## Approach Three things in the scan need sm_80. Each one has a Turing form: - `mma.sync m16n8k16` becomes two `m16n8k8` steps on the same registers: k 0-7 with `a0, a1, b0`, then k 8-15 with `a2, a3, b1`. `ldmatrix` already exists on sm_75. - `cp.async` becomes the plain-copy fallback that `gdn_cp_*` already has below sm_80. `redux.sync` becomes the existing shuffle max. - Shared memory: a new plan, `ONE` (`gdn_tc_scan_kernel<false, true, 3, 1, true>`), keeps every buffer single. That is 62,480 B, inside the 64 KB opt-in. With no second buffer, the next chunk is loaded after this chunk's state update, so the load does not overlap the products. `gdn_rec_tc` takes `ONE` on cc 7.5 only when the dispatch asks for it (`STRATA_GDN_TC=2`). With `=1` it returns "not supported" there, as before. The split variants are not supported on sm_75. The prep kernel does not change. The output has the same rounding as `=1` (f16x3 split products), so it is not bit-identical to the old kernel. ## Validation Revision 5f533205, on c62d5e3a (0.2.9). **Passed:** - Builds, CUDA 13.3 and g++-14 (a Docker image built on `nvidia/cuda` 13.3 devel, Ubuntu 24.04), Release: `CMAKE_CUDA_ARCHITECTURES=75` (targets `strata` and `gdn_harness`) and `=120` (target `gdn_harness`, which links the prefill and kernel libraries). No errors. - sm_75 correctness against `gdn_harness`'s FP64 reference: CMP 50HX, driver 610.43.03, Ubuntu 24.04, `CUDA_VISIBLE_DEVICES=2`. - `gdn_harness --T 8192 --chunk 8192 --paths pipe,tc --ref-heads 0,17,47`: `pipe` PASS-bitwise, `tc` PASS (output error to the reference `ref_y` 2.27e-4, `pipe` 2.28e-4; state `ref_state` 5.8e-7, `pipe` 1.4e-7). 0 failed verdicts. - `gdn_harness --T 3000 --chunk 1500 --stress --paths pipe,tc --ref-heads 0,17,47`: all 10 cases PASS, 0 failed verdicts. - Default path: `STRATA_GDN_TC=1 gdn_harness --T 5000 --chunk 2500 --cuts 37 --paths auto,pipe --ref-heads 0,17,47`: `auto` runs `pipe` and gives the same hash as `pipe` (h=5218a839), PASS-bitwise. So sm_75 with `=1` is unchanged. - Opt-in: the same command with `STRATA_GDN_TC=2`: `auto` runs `tc` for the long calls and `pipe` for the 37-token call. PASS. - sm_80+ unchanged: RTX 5060 Ti (sm_120, 36 SMs), `STRATA_GDN_TC=1 gdn_harness --T 3000 --chunk 1500 --any-sms --ref-heads 0,17,47`. Upstream c62d5e3a and this PR give the same verdicts and the same hashes on every path: `auto`/`tcs` d031486f, `keyhead`/`pipe` 8dc3ae4f, `chunked` 475fd185. - HIP sees the same text: every changed line is inside `#if !defined(__HIPCC__)`, and `gdn_tc.cuh` is included only from inside that block. `g++ -x c++ -E -P -undef -D__HIPCC__` of `src/prefill/kernels.cu` (with the `#include` lines removed) gives the same output before and after this PR (2,034 lines, md5 d4471402). Without `-D__HIPCC__`, the outputs differ, as they should. - Timing (the table above): `gdn_harness --T N --chunk N --paths pipe|tc --bench --no-ref --reps 15 --warmup 30`, with `pipe` and `tc` taking turns. Each cell gives the median of the 15 repeats, for each of the two rounds. - In daily use (not an A/B): our box (2x CMP 50HX on the layer split) has served a Claude Code workload with this kernel switched on since 2026-10-31, through our fork's dispatch (`=1` on cc 7.5; same `gdn_tc.cuh`). Over 1,300 requests in about 13 hours, the log shows no errors. Prompt reads of 4K-46K new tokens after a cached 10K-token start took 6.0 % +- 5.6 % less time than on 0.2.8 (6 reads against 28). This compares two releases, so it is not a measurement of this change alone. The recurrence is about 7 % of a prompt read on this box (`STRATA_PREFILL_TIMING=1` on 0.2.0: 201-205 ms of a 2.9-3.0 s GPU timeline per 8,192-token chunk), so I expect prompt reads to be about 3-4 % faster. **Failed:** none observed. **Not run:** - HIP build: no ROCm here. The preprocessor check above shows that HIP sees the same text. SYCL builds its own migrated copy (`sycl/src/prefill/kernels.dp.cpp`), and Metal does not build this file. - Model output checks (KL, task suites) with `=2` on Turing. The rounding was checked only against the harness reference. - A clean engine A/B (`=0` against `=2`, same build): the box is in daily use. - Turing cards other than the CMP 50HX. ## Limits - Like `=1`, it needs 48+ SMs (one block per value head). Smaller Turing cards keep the old kernels. - With a single buffer, the next chunk's load does not overlap the products: about 1 ms per layer at 8,192 tokens. The kernel uses 255 registers and spills 144 B. - Measured on one card model only. - Opt-in only. Making it the sm_75 default would first need the checks under Not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5225
No description provided.