[PR #1744] [CLOSED] CUDA SM86: opt-in IQ3 two-stage prefill build #3647

Closed
opened 2026-11-07 15:29:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1744
Author: @InB4DevOps
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: perf/cuda-prefill-iq3-two-stage


📝 Commits (3)

  • 29a442a CUDA prefill: opt-in two-stage buffering for IQ3 pairs
  • 19bcd91 CUDA prefill: isolate IQ3 stage tuning in an SM86 build
  • 0701e61 setup: offer opt-in SM86 IQ3 prefill builds

📊 Changes

16 files changed (+5660 additions, -16 deletions)

View changed files

📝 .gitignore (+4 -0)
📝 CMakeLists.txt (+14 -1)
📝 docs/DETAILS.md (+9 -0)
📝 docs/INSTALL.md (+5 -0)
➕ docs/INSTALL_SM86_PREFILL.md (+102 -0)
➕ docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/README.md (+128 -0)
➕ docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/cuda-only-evidence.json (+2016 -0)
➕ docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/cuda-only-parity.log (+369 -0)
➕ docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/evidence.json (+2014 -0)
➕ docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/isolated-parity.log (+227 -0)
➕ docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/prompts.json (+14 -0)
📝 setup.py (+166 -15)
➕ src/prefill/cuda/moe_fused_iq_stage2_sm86.cu (+72 -0)
➕ src/prefill/cuda/native_fused_iq_sm86.cuh (+244 -0)
➕ tools/test_cuda_prefill_variant.py (+47 -0)
➕ tools/test_setup_sm86_prefill.py (+229 -0)

📄 Description

Summary

Add the off-by-default STRATA_CUDA_SM86_IQ3_STAGE2 CMake option, requiring an
explicit CUDA architecture 86 target. It builds a CUDA-only specialization; runtime
opt-in remains STRATA_PF_FUSED=1 STRATA_PF_IQ3_STAGE2=1. Only IQ3_S/IQ4_NL and IQ3_XXS/IQ4_NL
gate/up–down pairs use two activation stages. Every other pair and the default
retain four stages.

Updated scope: the shared kernel and C++ test edits from the initial draft have
been fully reverted. The specialization is selected only in the CUDA CMake branch
and only executes on runtime SM86. HIP's source/build branch and SYCL's build are
unchanged, so the original missing-ROCm gate no longer applies to this patch.
Other CUDA devices use the original implementation. SM86 includes other Ampere
cards, but only the RTX 3060 was measured. Windows/other hardware remain untested.

What changed

Installer integration (separate commit 0701e617)

Eligible NVIDIA users now get an off-by-default setup question, or can use:

./setup.sh --setup --model IQ3_XXS --sm86-prefill iq3-stage2
# Windows: START-HERE.bat --setup --model IQ3_XXS --sm86-prefill iq3-stage2

Setup uses the detected architecture, selects the build option, bypasses plain
prebuilt engines, and writes the fused/runtime settings. It remembers the model's
choice for starts and updates, with separate engine/build caches and variant-aware
metadata. --sm86-prefill off returns to normal engine selection and restores the
previous fused setting. --yes alone leaves a new install off. The normal engine
and other models' variants are not overwritten. See docs/INSTALL_SM86_PREFILL.md.

98 relevant setup tests pass, including default-config goldens and simulated
Windows/Linux policy. Cache reuse/invalidation, disabling, config preservation,
starts and updates are covered without GPU/model downloads. Two checksum-caller
failures found by full discovery on the sibling integration also reproduce on the
untouched base (unmocked HTTP HEAD/404); the affected code is unchanged here.

Kernel and measurement commits

  • CUDA-only stage specialization with matching shared-memory sizing, copy-wait
    depth and launch attributes; conversion/routing helpers and the fallback are
    reused from the unchanged original implementation. The specialized kernel body
    must keep its arithmetic in sync with the original.
  • Instantiate the two-stage family only for the eligible kernel types; select it
    only when both formats of the layer match the measured pairs.
  • Fresh-process off/on numerical parity checks and scoped measurement evidence.

The blanket two-stage experiment is not included: it regressed IQ2_S by
4.8–5.8% at some sizes. Those kernels retain four stages. Weight prefetch distance,
tile/grid selection, residency, decode, setup defaults and HIP policy are unchanged.
This branch is independently based on fb58e0db, with no prefetch/head experiments.

Measured evidence

RTX 3060 12 GB / 100 W, i7-12700KF AVX2, Linux, CUDA 13.4.92, native IQ3_XXS,
explicit 4096-token prefill and static residency. Six balanced pairs per realistic
prompt, 128 generated tokens:

Prompt Input tokens Median paired prompt-speed gain Faster pairs
Parser/test review 12,247 +0.199% 5/6
Runtime documentation 20,324 +0.304% 5/6
C++ prefill review 30,757 +0.239% 5/6

All 18 pairs had identical output IDs and draft counts and were repeatable.
The clearer effect is in the IQ3 expert-layer workload: +2.65–17.02% across
six format/size combinations, all 18 process-level shape pairs faster. Untouched
IQ2 kernels stayed near baseline, rather than showing the global policy's regressions.

These are prototype measurements of the same selective policy. Final isolated
validation is separately recorded, not pooled into that series. The whole-engine
effect is modest; A/A controls include roughly +/-1.5% individual outliers. This
is a targeted kernel-tuning proposal, not a substantial general inference speedup.
No occupancy increase was measured, and no combined-prefetch claim is made.

Validation

  • CUDA SM86 Release: default-off reference build and this enabled build of strata and prefill_fused_iq_test.
  • Architecture-86 requirement and mutually exclusive build options checked.
  • Shared kernel/test bytes, HIP build branch and SYCL build file verified unchanged from upstream.
  • Six formats × both tiles: isolated off/on fingerprints and prior disabled-build
    comparison against the default-off build, retaining the existing FP64/MMQ checks.
  • Isolated two-pair checks on all three realistic prompts for token IDs, drafts
    and repeatability.
  • git diff --check.
  • Non-SM86 predicate checked at compile time; Windows/other GPU hardware runtime untested.

Details: docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/README.md. Current validation
is in cuda-only-evidence.json/cuda-only-parity.log; earlier evidence remains
separately recorded, with the exact public-source prompts.

The separate one-superblock prefetch proposal (#1742) touches the same kernel but is not
a dependency. Combining or merging both policies needs additional validation.


🔄 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/1744 **Author:** [@InB4DevOps](https://github.com/InB4DevOps) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `perf/cuda-prefill-iq3-two-stage` --- ### 📝 Commits (3) - [`29a442a`](https://github.com/Niko1221/Strata/commit/29a442ab86dea8d0f7b107d195c032a5d62c4e6c) CUDA prefill: opt-in two-stage buffering for IQ3 pairs - [`19bcd91`](https://github.com/Niko1221/Strata/commit/19bcd91892dbab33d00aef1e48f1b542884d3eee) CUDA prefill: isolate IQ3 stage tuning in an SM86 build - [`0701e61`](https://github.com/Niko1221/Strata/commit/0701e617b93c8ea37984d2121ce3b1447f0c4e81) setup: offer opt-in SM86 IQ3 prefill builds ### 📊 Changes **16 files changed** (+5660 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+4 -0) 📝 `CMakeLists.txt` (+14 -1) 📝 `docs/DETAILS.md` (+9 -0) 📝 `docs/INSTALL.md` (+5 -0) ➕ `docs/INSTALL_SM86_PREFILL.md` (+102 -0) ➕ `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/README.md` (+128 -0) ➕ `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/cuda-only-evidence.json` (+2016 -0) ➕ `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/cuda-only-parity.log` (+369 -0) ➕ `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/evidence.json` (+2014 -0) ➕ `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/isolated-parity.log` (+227 -0) ➕ `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/prompts.json` (+14 -0) 📝 `setup.py` (+166 -15) ➕ `src/prefill/cuda/moe_fused_iq_stage2_sm86.cu` (+72 -0) ➕ `src/prefill/cuda/native_fused_iq_sm86.cuh` (+244 -0) ➕ `tools/test_cuda_prefill_variant.py` (+47 -0) ➕ `tools/test_setup_sm86_prefill.py` (+229 -0) </details> ### 📄 Description ## Summary Add the off-by-default **`STRATA_CUDA_SM86_IQ3_STAGE2` CMake option**, requiring an explicit CUDA architecture 86 target. It builds a CUDA-only specialization; runtime opt-in remains `STRATA_PF_FUSED=1 STRATA_PF_IQ3_STAGE2=1`. Only **IQ3_S/IQ4_NL and IQ3_XXS/IQ4_NL** gate/up–down pairs use two activation stages. Every other pair and the default retain four stages. **Updated scope:** the shared kernel and C++ test edits from the initial draft have been fully reverted. The specialization is selected only in the CUDA CMake branch and only executes on runtime SM86. HIP's source/build branch and SYCL's build are unchanged, so the original missing-ROCm gate no longer applies to this patch. Other CUDA devices use the original implementation. SM86 includes other Ampere cards, but only the RTX 3060 was measured. Windows/other hardware remain untested. ## What changed ### Installer integration (separate commit `0701e617`) Eligible NVIDIA users now get an off-by-default setup question, or can use: ```sh ./setup.sh --setup --model IQ3_XXS --sm86-prefill iq3-stage2 # Windows: START-HERE.bat --setup --model IQ3_XXS --sm86-prefill iq3-stage2 ``` Setup uses the detected architecture, selects the build option, bypasses plain prebuilt engines, and writes the fused/runtime settings. It remembers the model's choice for starts and updates, with separate engine/build caches and variant-aware metadata. `--sm86-prefill off` returns to normal engine selection and restores the previous fused setting. `--yes` alone leaves a new install off. The normal engine and other models' variants are not overwritten. See `docs/INSTALL_SM86_PREFILL.md`. **98 relevant setup tests pass**, including default-config goldens and simulated Windows/Linux policy. Cache reuse/invalidation, disabling, config preservation, starts and updates are covered without GPU/model downloads. Two checksum-caller failures found by full discovery on the sibling integration also reproduce on the untouched base (unmocked HTTP HEAD/404); the affected code is unchanged here. ### Kernel and measurement commits - CUDA-only stage specialization with matching shared-memory sizing, copy-wait depth and launch attributes; conversion/routing helpers and the fallback are reused from the unchanged original implementation. The specialized kernel body must keep its arithmetic in sync with the original. - Instantiate the two-stage family only for the eligible kernel types; select it only when both formats of the layer match the measured pairs. - Fresh-process off/on numerical parity checks and scoped measurement evidence. The blanket two-stage experiment is **not** included: it regressed IQ2_S by 4.8–5.8% at some sizes. Those kernels retain four stages. Weight prefetch distance, tile/grid selection, residency, decode, setup defaults and HIP policy are unchanged. This branch is independently based on `fb58e0db`, with no prefetch/head experiments. ## Measured evidence RTX 3060 **12 GB / 100 W**, i7-12700KF AVX2, Linux, CUDA 13.4.92, native IQ3_XXS, explicit 4096-token prefill and static residency. Six balanced pairs per realistic prompt, 128 generated tokens: | Prompt | Input tokens | Median paired prompt-speed gain | Faster pairs | |---|---:|---:|---:| | Parser/test review | 12,247 | +0.199% | 5/6 | | Runtime documentation | 20,324 | +0.304% | 5/6 | | C++ prefill review | 30,757 | +0.239% | 5/6 | All 18 pairs had identical output IDs and draft counts and were repeatable. The clearer effect is in the IQ3 expert-layer workload: **+2.65–17.02%** across six format/size combinations, all 18 process-level shape pairs faster. Untouched IQ2 kernels stayed near baseline, rather than showing the global policy's regressions. These are **prototype measurements of the same selective policy**. Final isolated validation is separately recorded, not pooled into that series. The whole-engine effect is modest; A/A controls include roughly +/-1.5% individual outliers. This is a targeted kernel-tuning proposal, not a substantial general inference speedup. No occupancy increase was measured, and no combined-prefetch claim is made. ## Validation - CUDA SM86 Release: default-off reference build and this enabled build of `strata` and `prefill_fused_iq_test`. - Architecture-86 requirement and mutually exclusive build options checked. - Shared kernel/test bytes, HIP build branch and SYCL build file verified unchanged from upstream. - Six formats × both tiles: isolated off/on fingerprints and prior disabled-build comparison against the default-off build, retaining the existing FP64/MMQ checks. - Isolated two-pair checks on all three realistic prompts for token IDs, drafts and repeatability. - `git diff --check`. - Non-SM86 predicate checked at compile time; Windows/other GPU hardware runtime untested. Details: `docs/benchmarks/2026-10-09-rtx3060-iq3-stage2/README.md`. Current validation is in `cuda-only-evidence.json`/`cuda-only-parity.log`; earlier evidence remains separately recorded, with the exact public-source prompts. The separate one-superblock prefetch proposal (#1742) touches the same kernel but is not a dependency. Combining or merging both policies needs additional validation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29:47 +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#3647
No description provided.