[PR #4811] [Engine] stage mode-8 expert weight tiles on sm_121 #5192

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4811
Author: @InB4DevOps
Created: 10/31/2026
Status: 🔄 Open

Base: main ← Head: perf/sm121-weight-tiles


📝 Commits (1)

  • fed5ec8 CUDA: stage mode-8 weight tiles on sm_121

📊 Changes

1 file changed (+52 additions, -12 deletions)

View changed files

📝 src/kernels/cuda/iq_kernels.cu (+52 -12)

📄 Description

Problem and result

The mode-8 fused routed-expert gate/up kernel reads the same 16 contiguous weight rows again for every entry in an active group chunk. On a GB10 this is a measurable part of the fixed-work verify window.

This change has the block copy each 16-row gate/up tile to shared memory once per up-to-four-entry chunk, then reuse it across the entries. The submitted path is selected automatically only on compute capability 12.1. It adds no setting and leaves the CUDA/HIP fallback specialization in place.

On one NVIDIA DGX Spark, a 16-run fixed-work alternating gate measured:

  • paired median: +14.2270%
  • geometric mean: +12.6524%
  • AB median: +7.0229%
  • BA median: +17.8884%

The machine was noisy: individual pair gains ranged from -24.97% to +50.18%. The aggregate passes the gate, but 14.23% should not be read as a stable point estimate.

I searched open and closed issues and pull requests before the change. The closest prior work was #242, #646, #1418, and #2058. None stages these mode-8 gate/up weight rows once per chunk pass.

Approach

  • Add staged and fallback specializations of native_gu_fused_kernel.
  • In each of four passes, cooperatively copy 16 contiguous rows with int4, compute from the shared tile, and synchronize before reusing it.
  • Allocate the extra 16-row dynamic shared-memory region and select the staged specialization only on sm_121.
  • Keep HIP and every other CUDA architecture on the fallback specialization.

For TG16, TG18, TG21, TG22, and TG23, the submitted staged PTX matches the measured candidate after symbol/label normalization. The five fallback PTX instruction bodies match the clean baseline after normalizing only the template labels and dynamic-shared-memory symbol name.

Performance evidence

Environment: commit c62d5e3a plus this focused change, Ubuntu 24.04 aarch64, NVIDIA GB10 (compute capability 12.1), driver 580.178.04, CUDA 13.0.88, Qwen3.8-Flash-Next IQ3_S. The retained stack was STRATA_EXP_MODE=8, STRATA_SIDE_MIXER=2, STRATA_SPEC_COST=0, STRATA_SH_FORK_LATE=0, and --suffix-draft 0.

The balanced order was ABBABAABBAABABBA. A was baseline binary SHA-256 7a907ec5aaa7576ba57eb120ada478c6469d810e58b0e30cd77785cefdf7df04; B was candidate binary SHA-256 61e1e7f893aca25aca5224f306f980c67537bfdd80d2945de1fee46e4b95f8d6.

Pair Order Baseline ms Candidate ms Gain
1 AB 8506.4 9249.0 -8.0290%
2 BA 9423.5 6595.6 +42.8756%
3 BA 8302.7 7964.3 +4.2490%
4 AB 9870.6 8085.7 +22.0748%
5 BA 8686.2 6712.8 +29.3976%
6 AB 9865.2 6569.1 +50.1758%
7 AB 6991.6 9318.4 -24.9700%
8 BA 9660.4 9081.1 +6.3792%

The T4-window aggregates were +13.8345% paired median, +12.6907% geometric mean, +6.5973% AB median, and +18.8246% BA median. An earlier four-run ABBA screen measured +5.7336% paired median, +5.7294% geometric mean, +4.7957% AB, and +6.6715% BA.

All 16 gate runs:

  • returned normally with no OOM;
  • performed identical work: T1:1 T2:0 T3:0 T4:149;
  • reported the same speculation counts: 150 rounds, 363/447 drafts accepted, 0:12 1:16 2:19 3:103;
  • produced output SHA-256 95d9d5e1aa6f14c1b3d570c03b3b998dafb2d9e05f974fd83ce7aa8a91e2b86a;
  • reported 0 of 512 emitted tokens differ from the argmax.

A same-source kernel screen at 40 groups and 4 tokens measured these gate/up medians:

Format Baseline Staged
IQ3_XXS 305.55 us 224.90 us
IQ3_S 315.10 us 251.80 us
IQ2_S 250.75 us 245.40 us
IQ4_XS 294.10 us 306.20 us

Applying that mix to graph 23 projected a 1.667 ms saving, or 3.61% of its 46.130 ms kernel window.

Validation

Revision/environment tested: fb1a4dc6495740b70ad8cb0e6b66f748e5aa527a; Ubuntu 24.04 aarch64, NVIDIA GB10 (compute capability 12.1), driver 580.178.04, CUDA 13.0.88, Qwen3.8-Flash-Next IQ3_S.

Passed:

  • GitHub Actions HIP compile checked out and verified exact revision fb1a4dc6495740b70ad8cb0e6b66f748e5aa527a in rocm/dev-ubuntu-24.04:10.1.0-full. cmake -S . -B build-hip -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=OFF -DCMAKE_HIP_ARCHITECTURES=gfx1100 configured successfully, and cmake --build build-hip --target strata -j2 built and linked the HIP strata executable.
  • cmake --build build-sm121 --target native_expert_bench native_expert_parity strata -j2: built all three focused targets at the revision above.
  • ctest --test-dir build-sm121 --output-on-failure -R '^native_expert_parity_.*$': 11/11 passed at the revision above.
  • ctest --test-dir build-sm121 --output-on-failure -R '^check_cuda_spills_unit$': 1/1 passed.
  • CUDA_VISIBLE_DEVICES=0 build-sm121/native_expert_bench /home/admin/.local/share/strata/Strata-data/models/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf 1,7,17,47 40 4 0 8 100: zero differences. The four layer hashes were 476ae862f4a8b64f, 45f75025c61e9599, af8a9aa1a03ece30, and cc2ec90789bf3865.
  • The following final-source end-to-end smoke returned normally with fixed work T1:1 T2:0 T3:0 T4:149, output SHA-256 95d9d5e1aa6f14c1b3d570c03b3b998dafb2d9e05f974fd83ce7aa8a91e2b86a, zero argmax differences, and no OOM. The exact binary SHA-256 was 2845c7e2f66c9e6268a091a8c65d3593e17ebef6ba300c806c520933c3c6b648.
STRATA_SM121_PERF=1 STRATA_EXP_MODE=8 STRATA_SIDE_MIXER=2 STRATA_SPEC_T_CYCLE=4 STRATA_SPEC_COST=0 \
STRATA_GRAPH_PRIO=0 STRATA_DF_PDL=0 STRATA_DF_PLE=0 STRATA_SH_STREAM=1 STRATA_FUSE_WAIT=0 \
STRATA_QIL=0 STRATA_GDN_TC=0 STRATA_FUSE_HEAD_GR=0 STRATA_MTP_SHARED_BRANCH=1 STRATA_MTP_PRIORITY=1 \
STRATA_SH_FORK_LATE=0 build-sm121/strata \
  --pack /home/admin/.local/share/strata/Strata-data/packs/iq3_s --tokens 1,2,3,4,5,6,7,8 \
  --native /home/admin/.local/share/strata/Strata-data/models/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf \
  --ple-gguf /home/admin/.local/share/strata/Strata-data/models/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf \
  --expert-profile /home/admin/.local/share/strata/terminal/0.1.54/data/expert-profile.bin --expert-cache auto \
  --prefill auto:32768 --spec 4 --spec-min-p 0.5 --mtp /home/admin/.local/share/strata/Strata-data/mtp/rt \
  --max-context 65536 --kv int8 --mmap-experts --mtp-q4 all --mtp-hnorm stream --ple-io ram \
  --kv-resident 32768 --max-new 512 --greedy --adapt-every 0 --suffix-draft 0 \
  --spec-follow /tmp/opencode/iq3s_follow_512.txt --spec-oracle /tmp/opencode/iq3s_follow_512.txt
  • cuobjdump: all five staged specializations use zero stack and zero local memory.
  • git diff --check.

Failed:

  • ctest --test-dir build-sm121 --output-on-failure -R '^cuda_spill_guard$' fails on existing unallowlisted kernels across the build. It also names fallback TG21, whose 8-byte stack use matches the clean baseline. The five staged specializations use zero stack/local memory.
  • cmake --build build-sm121 -j2 reaches an unrelated ARM configuration failure where mmq_nvfp4_parity receives unsupported -mf16c. The focused targets above build.

Not run:

  • HIP hardware execution: no AMD GPU was available on the GitHub-hosted runner. The successful HIP compile is listed above; it does not establish hardware correctness.
  • Non-sm_121 hardware execution. The fallback PTX comparison above is static validation, not a hardware test.
  • Nsight Compute counters: the machine returns ERR_NVGPUCTRPERM without administrator access.

Limits

This was measured only on one DGX Spark and one fixed IQ3_S decode workload. It changes only mode 8 on sm_121. The isolated IQ4_XS gate/up microbenchmark regressed, while the measured graph mix and fixed-work end-to-end aggregate improved. Other models, group distributions, and hardware remain unmeasured.


🔄 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/4811 **Author:** [@InB4DevOps](https://github.com/InB4DevOps) **Created:** 10/31/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/sm121-weight-tiles` --- ### 📝 Commits (1) - [`fed5ec8`](https://github.com/Niko1221/Strata/commit/fed5ec87e71d3c140d1a5577a7ea8350679a6067) CUDA: stage mode-8 weight tiles on sm_121 ### 📊 Changes **1 file changed** (+52 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src/kernels/cuda/iq_kernels.cu` (+52 -12) </details> ### 📄 Description ## Problem and result The mode-8 fused routed-expert gate/up kernel reads the same 16 contiguous weight rows again for every entry in an active group chunk. On a GB10 this is a measurable part of the fixed-work verify window. This change has the block copy each 16-row gate/up tile to shared memory once per up-to-four-entry chunk, then reuse it across the entries. The submitted path is selected automatically only on compute capability 12.1. It adds no setting and leaves the CUDA/HIP fallback specialization in place. On one NVIDIA DGX Spark, a 16-run fixed-work alternating gate measured: - paired median: **+14.2270%** - geometric mean: **+12.6524%** - AB median: **+7.0229%** - BA median: **+17.8884%** The machine was noisy: individual pair gains ranged from -24.97% to +50.18%. The aggregate passes the gate, but 14.23% should not be read as a stable point estimate. ## Related discussion I searched open and closed issues and pull requests before the change. The closest prior work was #242, #646, #1418, and #2058. None stages these mode-8 gate/up weight rows once per chunk pass. ## Approach - Add staged and fallback specializations of `native_gu_fused_kernel`. - In each of four passes, cooperatively copy 16 contiguous rows with `int4`, compute from the shared tile, and synchronize before reusing it. - Allocate the extra 16-row dynamic shared-memory region and select the staged specialization only on sm_121. - Keep HIP and every other CUDA architecture on the fallback specialization. For TG16, TG18, TG21, TG22, and TG23, the submitted staged PTX matches the measured candidate after symbol/label normalization. The five fallback PTX instruction bodies match the clean baseline after normalizing only the template labels and dynamic-shared-memory symbol name. ## Performance evidence Environment: commit `c62d5e3a` plus this focused change, Ubuntu 24.04 aarch64, NVIDIA GB10 (compute capability 12.1), driver 580.178.04, CUDA 13.0.88, Qwen3.8-Flash-Next IQ3_S. The retained stack was `STRATA_EXP_MODE=8`, `STRATA_SIDE_MIXER=2`, `STRATA_SPEC_COST=0`, `STRATA_SH_FORK_LATE=0`, and `--suffix-draft 0`. The balanced order was `ABBABAABBAABABBA`. A was baseline binary SHA-256 `7a907ec5aaa7576ba57eb120ada478c6469d810e58b0e30cd77785cefdf7df04`; B was candidate binary SHA-256 `61e1e7f893aca25aca5224f306f980c67537bfdd80d2945de1fee46e4b95f8d6`. | Pair | Order | Baseline ms | Candidate ms | Gain | |---:|:---:|---:|---:|---:| | 1 | AB | 8506.4 | 9249.0 | -8.0290% | | 2 | BA | 9423.5 | 6595.6 | +42.8756% | | 3 | BA | 8302.7 | 7964.3 | +4.2490% | | 4 | AB | 9870.6 | 8085.7 | +22.0748% | | 5 | BA | 8686.2 | 6712.8 | +29.3976% | | 6 | AB | 9865.2 | 6569.1 | +50.1758% | | 7 | AB | 6991.6 | 9318.4 | -24.9700% | | 8 | BA | 9660.4 | 9081.1 | +6.3792% | The T4-window aggregates were +13.8345% paired median, +12.6907% geometric mean, +6.5973% AB median, and +18.8246% BA median. An earlier four-run ABBA screen measured +5.7336% paired median, +5.7294% geometric mean, +4.7957% AB, and +6.6715% BA. All 16 gate runs: - returned normally with no OOM; - performed identical work: `T1:1 T2:0 T3:0 T4:149`; - reported the same speculation counts: 150 rounds, 363/447 drafts accepted, `0:12 1:16 2:19 3:103`; - produced output SHA-256 `95d9d5e1aa6f14c1b3d570c03b3b998dafb2d9e05f974fd83ce7aa8a91e2b86a`; - reported `0 of 512 emitted tokens differ from the argmax`. A same-source kernel screen at 40 groups and 4 tokens measured these gate/up medians: | Format | Baseline | Staged | |:---|---:|---:| | IQ3_XXS | 305.55 us | 224.90 us | | IQ3_S | 315.10 us | 251.80 us | | IQ2_S | 250.75 us | 245.40 us | | IQ4_XS | 294.10 us | 306.20 us | Applying that mix to graph 23 projected a 1.667 ms saving, or 3.61% of its 46.130 ms kernel window. ## Validation Revision/environment tested: `fb1a4dc6495740b70ad8cb0e6b66f748e5aa527a`; Ubuntu 24.04 aarch64, NVIDIA GB10 (compute capability 12.1), driver 580.178.04, CUDA 13.0.88, Qwen3.8-Flash-Next IQ3_S. **Passed:** - [GitHub Actions HIP compile](https://github.com/InB4DevOps/Strata/actions/runs/41271642349) checked out and verified exact revision `fb1a4dc6495740b70ad8cb0e6b66f748e5aa527a` in `rocm/dev-ubuntu-24.04:10.1.0-full`. `cmake -S . -B build-hip -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=OFF -DCMAKE_HIP_ARCHITECTURES=gfx1100` configured successfully, and `cmake --build build-hip --target strata -j2` built and linked the HIP `strata` executable. - `cmake --build build-sm121 --target native_expert_bench native_expert_parity strata -j2`: built all three focused targets at the revision above. - `ctest --test-dir build-sm121 --output-on-failure -R '^native_expert_parity_.*$'`: 11/11 passed at the revision above. - `ctest --test-dir build-sm121 --output-on-failure -R '^check_cuda_spills_unit$'`: 1/1 passed. - `CUDA_VISIBLE_DEVICES=0 build-sm121/native_expert_bench /home/admin/.local/share/strata/Strata-data/models/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf 1,7,17,47 40 4 0 8 100`: zero differences. The four layer hashes were `476ae862f4a8b64f`, `45f75025c61e9599`, `af8a9aa1a03ece30`, and `cc2ec90789bf3865`. - The following final-source end-to-end smoke returned normally with fixed work `T1:1 T2:0 T3:0 T4:149`, output SHA-256 `95d9d5e1aa6f14c1b3d570c03b3b998dafb2d9e05f974fd83ce7aa8a91e2b86a`, zero argmax differences, and no OOM. The exact binary SHA-256 was `2845c7e2f66c9e6268a091a8c65d3593e17ebef6ba300c806c520933c3c6b648`. ```sh STRATA_SM121_PERF=1 STRATA_EXP_MODE=8 STRATA_SIDE_MIXER=2 STRATA_SPEC_T_CYCLE=4 STRATA_SPEC_COST=0 \ STRATA_GRAPH_PRIO=0 STRATA_DF_PDL=0 STRATA_DF_PLE=0 STRATA_SH_STREAM=1 STRATA_FUSE_WAIT=0 \ STRATA_QIL=0 STRATA_GDN_TC=0 STRATA_FUSE_HEAD_GR=0 STRATA_MTP_SHARED_BRANCH=1 STRATA_MTP_PRIORITY=1 \ STRATA_SH_FORK_LATE=0 build-sm121/strata \ --pack /home/admin/.local/share/strata/Strata-data/packs/iq3_s --tokens 1,2,3,4,5,6,7,8 \ --native /home/admin/.local/share/strata/Strata-data/models/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf \ --ple-gguf /home/admin/.local/share/strata/Strata-data/models/IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf \ --expert-profile /home/admin/.local/share/strata/terminal/0.1.54/data/expert-profile.bin --expert-cache auto \ --prefill auto:32768 --spec 4 --spec-min-p 0.5 --mtp /home/admin/.local/share/strata/Strata-data/mtp/rt \ --max-context 65536 --kv int8 --mmap-experts --mtp-q4 all --mtp-hnorm stream --ple-io ram \ --kv-resident 32768 --max-new 512 --greedy --adapt-every 0 --suffix-draft 0 \ --spec-follow /tmp/opencode/iq3s_follow_512.txt --spec-oracle /tmp/opencode/iq3s_follow_512.txt ``` - `cuobjdump`: all five staged specializations use zero stack and zero local memory. - `git diff --check`. **Failed:** - `ctest --test-dir build-sm121 --output-on-failure -R '^cuda_spill_guard$'` fails on existing unallowlisted kernels across the build. It also names fallback TG21, whose 8-byte stack use matches the clean baseline. The five staged specializations use zero stack/local memory. - `cmake --build build-sm121 -j2` reaches an unrelated ARM configuration failure where `mmq_nvfp4_parity` receives unsupported `-mf16c`. The focused targets above build. **Not run:** - HIP hardware execution: no AMD GPU was available on the GitHub-hosted runner. The successful HIP compile is listed above; it does not establish hardware correctness. - Non-sm_121 hardware execution. The fallback PTX comparison above is static validation, not a hardware test. - Nsight Compute counters: the machine returns `ERR_NVGPUCTRPERM` without administrator access. ## Limits This was measured only on one DGX Spark and one fixed IQ3_S decode workload. It changes only mode 8 on sm_121. The isolated IQ4_XS gate/up microbenchmark regressed, while the measured graph mix and fixed-work end-to-end aggregate improved. Other models, group distributions, and hardware remain unmeasured. --- <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#5192
No description provided.