[PR #485] [CLOSED] EXL3 prompt on V100 / T4 / RTX 20: the light experts on the tensor cores (wmma) - prompt +5-11% on a V100 #557

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/485
Author: @merbanan
Created: 10/25/2026
Status: ❌ Closed

Base: main ← Head: pr/exl3-v70-prompt


📝 Commits (1)

  • 8c006b1 EXL3 prompt on Volta / Turing: the light experts on the tensor cores (MAYA_EXL3_WMMA, on by default on sm_7x)

📊 Changes

4 files changed (+119 additions, -9 deletions)

View changed files

📝 docs/SETTINGS.md (+2 -1)
📝 include/strata/kernels/exl3.hpp (+3 -0)
📝 src/core/glm_prefill.cu (+2 -2)
📝 src/kernels/cuda/exl3.cu (+112 -6)

📄 Description

What

On NVIDIA GPUs before the RTX 30 (sm_7x: V100, T4, RTX 20), every EXL3 expert in a prompt was decoded to FP16 and multiplied by cuBLAS, even an expert routed one or two tokens of the chunk. x3_run_set sends light experts (MAYA_GLM_EXL3_MMA_ROWS, 64) to the tensor-core kernels only where mma_supported() holds, which is sm_80+ (mma.m16n8k16).

This PR runs the matrix-core prompt kernel there:

  • Which kernel: wmma_set_kernel, which RDNA 3 already uses.
  • How: on nvcuda::wmma's 16×16×16 FP16 product with F32 sums.
    • A is the warp's decoded tile, through shared memory at a 12-word pitch; ldm must be a multiple of 8 halves.
    • B is 16 activations' slice of xb, read column-major.
    • D is stored column-major into out.
  • Rows per block: each weight tile is decoded once for 16 rows. 32 rows' gate/up block goes over sm_7x's 48 KB of static shared memory, so CUDA instantiates only 16.
  • Routing: exl3::prompt_tc() (mma_supported() || wmma_now()) is what x3_run_set asks now.
  • Setting: MAYA_EXL3_WMMA is on by default on sm_7x; =0 gives cuBLAS for every expert, as before. It has a row in docs/SETTINGS.md, and the MAYA_GLM_EXL3_MMA_ROWS row now names these GPUs.
  • Elsewhere nothing changes. sm_80+ keeps its kernels. HIP keeps its own EXL3_WMMA / EXL3_WMMA_ROWS and does not take prompt_tc (tools/check_hip_compat.py passes).

Correctness

exl3_test's set tests on the V100: every K, 3 experts and 107 rows, against the reference.

Every set test passes, rel 6e-5 to 1.1e-4, about what the CUDA-core kernels give (7e-5 to 9e-5); 0 failures, 0 launch errors.

KL against BF16: malaiwah's fidelity suite, 15 contexts × 511 positions, teacher-forced, so this measures the prompt path itself. CPU lane off, fixed RAM tier.

mean KL top-1 agree NLL
MAYA_EXL3_WMMA=0 (cuBLAS) 0.2523 81.94 % 1.7120
this PR 0.2532 81.92 % 1.7105

(BF16's NLL is 1.5421.) The difference is within run-to-run noise.

Speed

Measured on a Tesla V100-PCIE-32GB at 250 W with a Ryzen 9 7950X and turboderp's EXL3 2.05bpw.

Prompt, default settings (2 alternating rounds, tok/s):

prompt =0 this PR
2K 587 653 +11 %
8K 804 882 +10 %
27K 901 947 +5 %

On upstream main v1.1.27; each round with the change was faster.

The gain is largest on short prompts, where most experts are light. Decode is unchanged.

MAYA_GLM_EXL3_MMA_ROWS on this card (1 round, prompt tok/s at 2K / 8K / 27K):

rows 2K 8K 27K
16 627 851 934
32 650 871 944
64 (default) 659 888 951
128 673 895 951
256 666 887 948

128 may be about 1 % better here, but that's one round, so the default stays.

Not run on a T4 or RTX 20.


🔄 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/485 **Author:** [@merbanan](https://github.com/merbanan) **Created:** 10/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/exl3-v70-prompt` --- ### 📝 Commits (1) - [`8c006b1`](https://github.com/mw00/project-maya/commit/8c006b1a1f084d94ef395cd2c609da1cdf0bb2b1) EXL3 prompt on Volta / Turing: the light experts on the tensor cores (MAYA_EXL3_WMMA, on by default on sm_7x) ### 📊 Changes **4 files changed** (+119 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+2 -1) 📝 `include/strata/kernels/exl3.hpp` (+3 -0) 📝 `src/core/glm_prefill.cu` (+2 -2) 📝 `src/kernels/cuda/exl3.cu` (+112 -6) </details> ### 📄 Description ## What On NVIDIA GPUs before the RTX 30 (sm_7x: V100, T4, RTX 20), every EXL3 expert in a prompt was decoded to FP16 and multiplied by cuBLAS, even an expert routed one or two tokens of the chunk. `x3_run_set` sends light experts (`MAYA_GLM_EXL3_MMA_ROWS`, 64) to the tensor-core kernels only where `mma_supported()` holds, which is sm_80+ (`mma.m16n8k16`). This PR runs the matrix-core prompt kernel there: - **Which kernel:** `wmma_set_kernel`, which RDNA 3 already uses. - **How:** on `nvcuda::wmma`'s 16×16×16 FP16 product with F32 sums. - A is the warp's decoded tile, through shared memory at a 12-word pitch; `ldm` must be a multiple of 8 halves. - B is 16 activations' slice of `xb`, read column-major. - D is stored column-major into `out`. - **Rows per block:** each weight tile is decoded once for 16 rows. 32 rows' gate/up block goes over sm_7x's 48 KB of static shared memory, so CUDA instantiates only 16. - **Routing:** `exl3::prompt_tc()` (`mma_supported() || wmma_now()`) is what `x3_run_set` asks now. - **Setting:** `MAYA_EXL3_WMMA` is on by default on sm_7x; `=0` gives cuBLAS for every expert, as before. It has a row in `docs/SETTINGS.md`, and the `MAYA_GLM_EXL3_MMA_ROWS` row now names these GPUs. - **Elsewhere nothing changes.** sm_80+ keeps its kernels. HIP keeps its own `EXL3_WMMA` / `EXL3_WMMA_ROWS` and does not take `prompt_tc` (`tools/check_hip_compat.py` passes). ## Correctness **`exl3_test`'s set tests on the V100:** every K, 3 experts and 107 rows, against the reference. Every set test passes, rel 6e-5 to 1.1e-4, about what the CUDA-core kernels give (7e-5 to 9e-5); 0 failures, 0 launch errors. **KL against BF16:** malaiwah's fidelity suite, 15 contexts × 511 positions, teacher-forced, so this measures the prompt path itself. CPU lane off, fixed RAM tier. | | mean KL | top-1 agree | NLL | |---|---:|---:|---:| | `MAYA_EXL3_WMMA=0` (cuBLAS) | 0.2523 | 81.94 % | 1.7120 | | this PR | 0.2532 | 81.92 % | 1.7105 | (BF16's NLL is 1.5421.) The difference is within run-to-run noise. ## Speed Measured on a Tesla V100-PCIE-32GB at 250 W with a Ryzen 9 7950X and turboderp's EXL3 2.05bpw. **Prompt, default settings** (2 alternating rounds, tok/s): | prompt | `=0` | this PR | | |---|---:|---:|---:| | 2K | 587 | 653 | +11 % | | 8K | 804 | 882 | +10 % | | 27K | 901 | 947 | +5 % | On upstream main v1.1.27; each round with the change was faster. The gain is largest on short prompts, where most experts are light. Decode is unchanged. **`MAYA_GLM_EXL3_MMA_ROWS` on this card** (1 round, prompt tok/s at 2K / 8K / 27K): | rows | 2K | 8K | 27K | |---:|---:|---:|---:| | 16 | 627 | 851 | 934 | | 32 | 650 | 871 | 944 | | 64 (default) | 659 | 888 | 951 | | 128 | 673 | 895 | 951 | | 256 | 666 | 887 | 948 | 128 may be about 1 % better here, but that's one round, so the default stays. Not run on a T4 or RTX 20. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:48 +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#557
No description provided.