[PR #5498] [Engine] prefill: STRATA_IQ4_W4A8 on sm_75 (Turing): MMQ bits, prompt reads -2 % on 2x CMP 50HX #5471

Open
opened 2026-11-07 21:43:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: pr/iq4-w4a8-sm75


📝 Commits (1)

  • dbc14f9 prefill: STRATA_IQ4_W4A8 on sm_75 (Turing): register-staged K steps, m16n8k32 as four m8n8k16; MMQ's bits

📊 Changes

5 files changed (+86 additions, -15 deletions)

View changed files

📝 CMakeLists.txt (+1 -1)
📝 docs/DETAILS.md (+1 -1)
📝 src/prefill/moe_iq4_w4a8.cu (+79 -8)
📝 src/prefill/moe_mmq.cu (+2 -2)
📝 tests/cuda/prefill_iq4_w4a8_test.cu (+3 -3)

📄 Description

Problem and result

STRATA_IQ4_W4A8 (the opt-in int8 kernel for the prompt's IQ4_XS / IQ4_NL expert products, from #4871) runs only on sm_80..sm_88 and sm_120, because it uses cp.async and the m16n8k32 s8 MMA. Turing (sm_75) has neither, so there every product stays on MMQ. Turing does have ldmatrix and the m8n8k16 s8 MMA, which is enough for the same tile.

With this change the kernel also runs on sm_75. It still gives MMQ's bits, and it is still opt-in. On 2x CMP 50HX (sm_75) with Swift 1.5 IQ3_S, whose IQ4_NL down products cover 39 of 48 layers, STRATA_IQ4_W4A8=2 reads prompts about 2 % faster: a 64K cold read takes 29.81 -> 29.19 s, a 172K read 68.91 -> 67.61 s. The answers are the same.

#4871, where the kernel came from (it went into main through 7bf5ec4e). Not a default change: unset STRATA_IQ4_W4A8 behaves as before on every card.

Approach

Only the sm_75 path is new, under #if __CUDA_ARCH__ >= 750 && < 800 in moe_iq4_w4a8.cu:

  • There is no cp.async, so the next K step's weight and activation pieces are read into registers before this step's MMAs, then stored to the other shared-memory stage after them. The two stages and one barrier per step stay as before (STAGES == 2 is asserted).
  • Each m16n8k32 becomes four m8n8k16 MMAs from the same C. Rows g / g + 8 come from a0 / a1 and a2 / a3, against b0 (k 0..15) and b1 (k 16..31). The int32 sums are exact, so the C words are the same, and with them the existing epilogues (the EPI 1 magic-number trick included).
  • arch_ok() takes 7.5. The test's arch check, the DETAILS.md row and two comments now name sm_75.

The sm_80+ source is unchanged, with only #if lines around it. The SASS of all 8 kernels for sm_86 and for sm_120 is identical to before (cuobjdump; kernel names normalized, since the anonymous namespace carries the file name; nvcc gives the same sm_86 SASS for the same file three times).

Validation

Passed:

  • Hardware: 2x NVIDIA CMP 50HX (TU102, sm_75, 20 GB, 170 W limit, SM clock locked at 2,100 MHz), PCIe 2.0 x16, driver 610.43.03, CUDA 13.3.73, GCC 14.2, Ubuntu 24.04.4 (kernel 7.2.9-cmp50hx), 2x Xeon E5-2670 v2 (AVX only). Build: -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=75 -DSTRATA_ISA_FLOOR=avx. Revision: this commit's file on 0.2.12 (146df3c4); the box runs it inside a fork with other patches that do not touch these five files.

  • CUDA_VISIBLE_DEVICES=0 prefill_iq4_w4a8_test with no flags, --full, --tokens 97, --tokens 2049, --tokens 8191 and --wide: "all identical on NVIDIA CMP 50HX (sm_75)" for every one. That is 3 routings each, 0 words differ, and the kernel ran gate/up and down products in every case (for example 15,360 tokens uniform: 589,824,000 words, kernel 32 + 32 products).

  • prefill_iq4_w4a8_test --full --bench, MMQ time over the kernel's, 3 routings, by STRATA_W4A8_CFG:

    Config down (IQ4_NL) gate/up (IQ4_XS)
    0 +46.2 .. +59.1 % +23.3 .. +31.2 %
    1 +37.2 .. +45.2 % +18.1 .. +23.5 %
    2 +41.6 .. +55.1 % +22.6 .. +25.9 %
    3 +35.7 .. +48.4 % +11.2 .. +19.6 %

    ptxas for sm_75: 255 registers, 12-28 bytes of spill stores a thread.

  • Engine A/B, --serve, 2 cards on --layer-split auto, --prefill auto:16384, Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO IQ3_S. Each start had the page cache dropped, then a warm-up, a 64K cold prompt, a 172K cold prompt (another first line), and 6 x 512 greedy tokens at ~8K. Arms interleaved N W W N, where N = 0.2.12 and W = N + STRATA_IQ4_W4A8=2; every other setting the same:

    Arm 64K read 172K read
    N 29.62 / 29.99 s 68.56 / 69.25 s
    W 29.13 / 29.25 s 67.41 / 67.81 s

    Both W runs read faster than both N runs at both lengths. Exit counter: "ran 0 IQ4_XS and 20288 IQ4_NL products; declined ... MMQ would split K 128". Decode does not use this path; I saw 81.1 (N) and 83.2 (W) tok/s, which I count as noise between two binaries, not as a result.

  • Exactness in the engine (STRATA_PREFILL_CPU_SHARE=0, --adapt-swaps 0, --pcie-frac 0.17): three greedy 200-token answers after 2K / 20K / 70K-token prompts. N against N (the control) and W against N give the same texts.

  • SASS: nvcc -arch=sm_86 and -arch=sm_120 -cubin of moe_iq4_w4a8.cu before and after, cuobjdump -sass: 8 of 8 kernels identical on both.

Failed:

  • none observed.

Not run:

  • Hardware runs on sm_80+ cards (none here). Their SASS is identical, so I expect the same behavior, but no run is reported.
  • The HIP build (the file's HIP branch is the stub, which this change does not touch), SYCL, Metal and Windows builds.
  • Other Turing cards (RTX 20xx, T4). Only the CMP 50HX was run.

Limits

  • sm_75 only reaches the kernel through the same declines as other cards: shapes, types, and launches MMQ would split along K stay on MMQ.
  • The gain was measured on one box with a layer split over PCIe 2.0. Here only GPU 0's prompt kernels get faster, and other parts of the read (the CPU share, the second card's copies) stay the same. A single Turing card may see a different share.
  • One IQ4_XS gate/up layer in this model was left on MMQ (=2). =1 passed the bit test but was not run in the engine.

🤖 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/5498 **Author:** [@xrip](https://github.com/xrip) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/iq4-w4a8-sm75` --- ### 📝 Commits (1) - [`dbc14f9`](https://github.com/Niko1221/Strata/commit/dbc14f928ca0a2059c3baf44c0f80c2132490693) prefill: STRATA_IQ4_W4A8 on sm_75 (Turing): register-staged K steps, m16n8k32 as four m8n8k16; MMQ's bits ### 📊 Changes **5 files changed** (+86 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+1 -1) 📝 `docs/DETAILS.md` (+1 -1) 📝 `src/prefill/moe_iq4_w4a8.cu` (+79 -8) 📝 `src/prefill/moe_mmq.cu` (+2 -2) 📝 `tests/cuda/prefill_iq4_w4a8_test.cu` (+3 -3) </details> ### 📄 Description ## Problem and result `STRATA_IQ4_W4A8` (the opt-in int8 kernel for the prompt's IQ4_XS / IQ4_NL expert products, from #4871) runs only on sm_80..sm_88 and sm_120, because it uses `cp.async` and the `m16n8k32` s8 MMA. Turing (sm_75) has neither, so there every product stays on MMQ. Turing does have `ldmatrix` and the `m8n8k16` s8 MMA, which is enough for the same tile. With this change the kernel also runs on sm_75. It still gives MMQ's bits, and it is still opt-in. On 2x CMP 50HX (sm_75) with Swift 1.5 IQ3_S, whose IQ4_NL down products cover 39 of 48 layers, `STRATA_IQ4_W4A8=2` reads prompts about 2 % faster: a 64K cold read takes 29.81 -> 29.19 s, a 172K read 68.91 -> 67.61 s. The answers are the same. ## Related discussion #4871, where the kernel came from (it went into main through 7bf5ec4e). Not a default change: unset `STRATA_IQ4_W4A8` behaves as before on every card. ## Approach Only the sm_75 path is new, under `#if __CUDA_ARCH__ >= 750 && < 800` in `moe_iq4_w4a8.cu`: - There is no `cp.async`, so the next K step's weight and activation pieces are read into registers before this step's MMAs, then stored to the other shared-memory stage after them. The two stages and one barrier per step stay as before (`STAGES == 2` is asserted). - Each `m16n8k32` becomes four `m8n8k16` MMAs from the same C. Rows g / g + 8 come from a0 / a1 and a2 / a3, against b0 (k 0..15) and b1 (k 16..31). The int32 sums are exact, so the C words are the same, and with them the existing epilogues (the EPI 1 magic-number trick included). - `arch_ok()` takes 7.5. The test's arch check, the DETAILS.md row and two comments now name sm_75. The sm_80+ source is unchanged, with only `#if` lines around it. The SASS of all 8 kernels for sm_86 and for sm_120 is identical to before (cuobjdump; kernel names normalized, since the anonymous namespace carries the file name; nvcc gives the same sm_86 SASS for the same file three times). ## Validation **Passed:** - Hardware: 2x NVIDIA CMP 50HX (TU102, sm_75, 20 GB, 170 W limit, SM clock locked at 2,100 MHz), PCIe 2.0 x16, driver 610.43.03, CUDA 13.3.73, GCC 14.2, Ubuntu 24.04.4 (kernel 7.2.9-cmp50hx), 2x Xeon E5-2670 v2 (AVX only). Build: `-DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=75 -DSTRATA_ISA_FLOOR=avx`. Revision: this commit's file on 0.2.12 (146df3c4); the box runs it inside a fork with other patches that do not touch these five files. - `CUDA_VISIBLE_DEVICES=0 prefill_iq4_w4a8_test` with no flags, `--full`, `--tokens 97`, `--tokens 2049`, `--tokens 8191` and `--wide`: "all identical on NVIDIA CMP 50HX (sm_75)" for every one. That is 3 routings each, 0 words differ, and the kernel ran gate/up and down products in every case (for example 15,360 tokens uniform: 589,824,000 words, kernel 32 + 32 products). - `prefill_iq4_w4a8_test --full --bench`, MMQ time over the kernel's, 3 routings, by `STRATA_W4A8_CFG`: | Config | down (IQ4_NL) | gate/up (IQ4_XS) | |---|---|---| | 0 | +46.2 .. +59.1 % | +23.3 .. +31.2 % | | 1 | +37.2 .. +45.2 % | +18.1 .. +23.5 % | | 2 | +41.6 .. +55.1 % | +22.6 .. +25.9 % | | 3 | +35.7 .. +48.4 % | +11.2 .. +19.6 % | ptxas for sm_75: 255 registers, 12-28 bytes of spill stores a thread. - Engine A/B, `--serve`, 2 cards on `--layer-split auto`, `--prefill auto:16384`, Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO IQ3_S. Each start had the page cache dropped, then a warm-up, a 64K cold prompt, a 172K cold prompt (another first line), and 6 x 512 greedy tokens at ~8K. Arms interleaved N W W N, where N = 0.2.12 and W = N + `STRATA_IQ4_W4A8=2`; every other setting the same: | Arm | 64K read | 172K read | |---|---:|---:| | N | 29.62 / 29.99 s | 68.56 / 69.25 s | | W | 29.13 / 29.25 s | 67.41 / 67.81 s | Both W runs read faster than both N runs at both lengths. Exit counter: "ran 0 IQ4_XS and 20288 IQ4_NL products; declined ... MMQ would split K 128". Decode does not use this path; I saw 81.1 (N) and 83.2 (W) tok/s, which I count as noise between two binaries, not as a result. - Exactness in the engine (`STRATA_PREFILL_CPU_SHARE=0`, `--adapt-swaps 0`, `--pcie-frac 0.17`): three greedy 200-token answers after 2K / 20K / 70K-token prompts. N against N (the control) and W against N give the same texts. - SASS: `nvcc -arch=sm_86` and `-arch=sm_120 -cubin` of `moe_iq4_w4a8.cu` before and after, `cuobjdump -sass`: 8 of 8 kernels identical on both. **Failed:** - none observed. **Not run:** - Hardware runs on sm_80+ cards (none here). Their SASS is identical, so I expect the same behavior, but no run is reported. - The HIP build (the file's HIP branch is the stub, which this change does not touch), SYCL, Metal and Windows builds. - Other Turing cards (RTX 20xx, T4). Only the CMP 50HX was run. ## Limits - sm_75 only reaches the kernel through the same declines as other cards: shapes, types, and launches MMQ would split along K stay on MMQ. - The gain was measured on one box with a layer split over PCIe 2.0. Here only GPU 0's prompt kernels get faster, and other parts of the read (the CPU share, the second card's copies) stay the same. A single Turing card may see a different share. - One IQ4_XS gate/up layer in this model was left on MMQ (`=2`). `=1` passed the bit test but was not run in the engine. 🤖 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#5471
No description provided.