[PR #262] [MERGED] Volta grouped-WMMA prompt experts for the MoE prefill (STRATA_PF_WMMA, off by default) #433

Closed
opened 2026-10-29 21:25:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/262
Author: @chenyb999-zhcn
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @mw00

Base: main ← Head: wmma-volta-prefill


📝 Commits (1)

  • f538a87 Volta grouped-WMMA prompt experts for the MoE prefill (MAYA_PF_WMMA, off by default)

📊 Changes

11 files changed (+1007 additions, -25 deletions)

View changed files

📝 CMakeLists.txt (+9 -0)
📝 docs/SETTINGS.md (+1 -0)
📝 include/strata/kernels/glm_batch.hpp (+2 -0)
📝 include/strata/kernels/iq_kernels.hpp (+25 -0)
📝 include/strata/prefill/kernels.hpp (+2 -0)
📝 src/core/glm_prefill.cu (+78 -3)
📝 src/kernels/cuda/glm_batch.cu (+19 -0)
📝 src/kernels/cuda/iq_kernels.cu (+442 -16)
➕ src/kernels/pf_wmma_parity.cpp (+348 -0)
📝 src/prefill/kernels.cu (+12 -0)
📝 src/prefill/prefill.cpp (+69 -6)

📄 Description

Volta grouped-WMMA prompt experts for the MoE prefill (STRATA_PF_WMMA)

One topic: the prompt path's routed-expert GEMMs (MMQ dp4a on the CUDA cores) gain a grouped WMMA kernel for Volta (sm_70) and newer. Each expert's IQ weights are dequantized to FP16 in shared memory and fed to 16x16x16 FP16 tensor-core tiles with FP32 accumulators. Decode is unchanged.

What it covers and how it stays safe

  • Formats: the native packs' IQ3_XXS / IQ3_S / IQ2_S gate-up and IQ4_NL / Q2_0 down products, with K a whole 256 values (Maya-M's 4096/2048 geometry qualifies; unsupported shapes return false and stay on MMQ).
  • A per-device caps probe (gemm_iq_f16_grouped_caps) attributes every tile shape's dynamic shared-memory size before any launch; a device that refuses one attribute keeps that shape on MMQ. STRATA_PF_WMMA is off by default; when it is on and the launcher rejects the first shape, the whole path stays on MMQ for the rest of the run (wmma_fell_back), so unsupported devices and formats cost nothing.
  • Works for both model packs (the Qwen pack's prefill path and the GLM path); HIP builds are untouched (the support probe returns false there, and tools/check_hip_compat.py passes).

Performance measurements (required by CONTRIBUTING)

2x Tesla V100-32GB, Maya-M (--glm-pack), identical harness both sides: OpenAI /v1/chat/completions streaming TTFT to the first content delta, fresh prompts (deterministic per-round shuffles defeat the prefix cache), median of 3 rounds, max_tokens=24. Same binary, STRATA_PF_WMMA=1 on vs 0 off:

prompt tokens MMQ (off) WMMA (on) prompt speed
~2,621 8.18 s (320 tok/s) 7.30 s (359 tok/s) +11.6%
~7,769 12.63 s (615 tok/s) 11.90 s (653 tok/s) +5.8%
~20,030 26.14 s (766 tok/s) 24.3 s (~825 tok/s) +6.8–7.3%

Decode is unchanged (~50 ms/token both sides), as expected for a prefill-only path. The relative gain shrinks on long prompts because streaming the expert weights over PCIe/RAM takes a larger share of the time, and short prompts are diluted by the fixed server-side overhead (tokenization etc.).

Output changes

The WMMA path rounds weights to FP16 and accumulates in FP32 tensor-core sums, so outputs differ from MMQ's within that rounding, checked against a double reference over the same FP16 weights by the new pf_wmma_parity ctest (max error <= 2e-5 of the matrix's max magnitude; guards, strides, sparse id gathers and an out-of-order weight table are exercised, so a launch reading the wrong half of the table mismatches instead of passing).

Notes for reviewers

  • New setting STRATA_PF_WMMA (default off): documented in docs/SETTINGS.md next to STRATA_GLM_PREFILL_FUSED (its AMD counterpart). I kept the Strata-side name rather than a STRATA_GLM_* prefix because it switches both packs' prefill path — happy to rename if you prefer.
  • pf_wmma_parity needs a GPU with FP16 tensor cores (sm_70+); on machines without one, ctest reports it skipped (SKIP_RETURN_CODE 77). --bench times the launch as a captured graph over 8 launches / 7 windows.
  • Known issue seen once on my hardware, not reproduced after a restart: on the very first request after a cold start (a 108K-token conversation restore), the nan guard retried 16 routes in one prompt layer; the retry succeeded and every later request has been clean. I am watching for a recurrence but could not root-cause it yet.

python tools/check_hip_compat.py passes locally (exit 0).


🔄 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/mw00/project-maya/pull/262 **Author:** [@chenyb999-zhcn](https://github.com/chenyb999-zhcn) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/20/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `wmma-volta-prefill` --- ### 📝 Commits (1) - [`f538a87`](https://github.com/mw00/project-maya/commit/f538a87f6ff40b76df471e876dcc0f234196f35f) Volta grouped-WMMA prompt experts for the MoE prefill (MAYA_PF_WMMA, off by default) ### 📊 Changes **11 files changed** (+1007 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+9 -0) 📝 `docs/SETTINGS.md` (+1 -0) 📝 `include/strata/kernels/glm_batch.hpp` (+2 -0) 📝 `include/strata/kernels/iq_kernels.hpp` (+25 -0) 📝 `include/strata/prefill/kernels.hpp` (+2 -0) 📝 `src/core/glm_prefill.cu` (+78 -3) 📝 `src/kernels/cuda/glm_batch.cu` (+19 -0) 📝 `src/kernels/cuda/iq_kernels.cu` (+442 -16) ➕ `src/kernels/pf_wmma_parity.cpp` (+348 -0) 📝 `src/prefill/kernels.cu` (+12 -0) 📝 `src/prefill/prefill.cpp` (+69 -6) </details> ### 📄 Description # Volta grouped-WMMA prompt experts for the MoE prefill (`STRATA_PF_WMMA`) One topic: the prompt path's routed-expert GEMMs (MMQ dp4a on the CUDA cores) gain a grouped WMMA kernel for Volta (sm_70) and newer. Each expert's IQ weights are dequantized to FP16 in shared memory and fed to 16x16x16 FP16 tensor-core tiles with FP32 accumulators. Decode is unchanged. ## What it covers and how it stays safe - Formats: the native packs' IQ3_XXS / IQ3_S / IQ2_S gate-up and IQ4_NL / Q2_0 down products, with K a whole 256 values (Maya-M's 4096/2048 geometry qualifies; unsupported shapes return false and stay on MMQ). - A per-device caps probe (`gemm_iq_f16_grouped_caps`) attributes every tile shape's dynamic shared-memory size before any launch; a device that refuses one attribute keeps that shape on MMQ. `STRATA_PF_WMMA` is off by default; when it is on and the launcher rejects the first shape, the whole path stays on MMQ for the rest of the run (`wmma_fell_back`), so unsupported devices and formats cost nothing. - Works for both model packs (the Qwen pack's prefill path and the GLM path); HIP builds are untouched (the support probe returns false there, and `tools/check_hip_compat.py` passes). ## Performance measurements (required by CONTRIBUTING) 2x Tesla V100-32GB, Maya-M (`--glm-pack`), identical harness both sides: OpenAI `/v1/chat/completions` streaming TTFT to the first content delta, fresh prompts (deterministic per-round shuffles defeat the prefix cache), median of 3 rounds, `max_tokens=24`. Same binary, `STRATA_PF_WMMA=1` on vs `0` off: | prompt tokens | MMQ (off) | WMMA (on) | prompt speed | |---|---|---|---| | ~2,621 | 8.18 s (320 tok/s) | 7.30 s (359 tok/s) | **+11.6%** | | ~7,769 | 12.63 s (615 tok/s) | 11.90 s (653 tok/s) | **+5.8%** | | ~20,030 | 26.14 s (766 tok/s) | 24.3 s (~825 tok/s) | **+6.8–7.3%** | Decode is unchanged (~50 ms/token both sides), as expected for a prefill-only path. The relative gain shrinks on long prompts because streaming the expert weights over PCIe/RAM takes a larger share of the time, and short prompts are diluted by the fixed server-side overhead (tokenization etc.). ## Output changes The WMMA path rounds weights to FP16 and accumulates in FP32 tensor-core sums, so outputs differ from MMQ's within that rounding, checked against a double reference over the same FP16 weights by the new `pf_wmma_parity` ctest (max error <= 2e-5 of the matrix's max magnitude; guards, strides, sparse id gathers and an out-of-order weight table are exercised, so a launch reading the wrong half of the table mismatches instead of passing). ## Notes for reviewers - New setting `STRATA_PF_WMMA` (default off): documented in docs/SETTINGS.md next to `STRATA_GLM_PREFILL_FUSED` (its AMD counterpart). I kept the Strata-side name rather than a `STRATA_GLM_*` prefix because it switches both packs' prefill path — happy to rename if you prefer. - `pf_wmma_parity` needs a GPU with FP16 tensor cores (sm_70+); on machines without one, ctest reports it skipped (SKIP_RETURN_CODE 77). `--bench` times the launch as a captured graph over 8 launches / 7 windows. - Known issue seen once on my hardware, not reproduced after a restart: on the very first request after a cold start (a 108K-token conversation restore), the nan guard retried 16 routes in one prompt layer; the retry succeeded and every later request has been clean. I am watching for a recurrence but could not root-cause it yet. `python tools/check_hip_compat.py` passes locally (exit 0). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:25:23 +07:00
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#433
No description provided.