perf: EXL3 performance tuning on GeForce Blackwell#1652
Conversation
Signed-off-by: AlpinDale <alpindale@gmail.com>
Signed-off-by: AlpinDale <alpindale@gmail.com>
Signed-off-by: AlpinDale <alpindale@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a878380265
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (K == 4 && size_k == 1024 && size_n == 256) { | ||
| *shape_idx = 4; | ||
| *num_sms = 32; |
There was a problem hiding this comment.
Do not select shape 4 for n=256 Blackwell override
select_blackwell_gemm_override forces shape_idx = 4 when K == 4, size_k == 1024, and size_n == 256, but shape 4 is a 512-wide N tile (EXL3_GEMM_TILESIZE_N), so exl3_gemm_kernel_inner computes tiles_n = size_n / TILESIZE_N = 0 and exits without producing output tiles. On Blackwell, this override can return incorrect/empty GEMM results for that projection shape instead of just changing performance.
Useful? React with 👍 / 👎.
| get_mgemm_kernel_ptr(K, override_shape_idx, c_fp32, cb), | ||
| override_shape_idx, override_num_sms, | ||
| exl3_gemm_blockdim[override_shape_idx]}; | ||
| _tuning_cache[key] = tr; |
There was a problem hiding this comment.
Include size_m when caching Blackwell-specific overrides
This override path is explicitly conditioned on size_m == 1, but the cached entry it writes is keyed only by size_k/size_n/cc/K/c_fp32, so later calls with size_m > 1 can incorrectly reuse single-token tuning results. That bypasses the intended size_m guard and can regress non-decode workloads after the cache is warmed by decode shapes.
Useful? React with 👍 / 👎.
Signed-off-by: AlpinDale <alpindale@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af26558dfd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if (cc == CC_BLACKWELL && K == 4 && size_m == 1 && size_k == 1024 && | ||
| size_n == 256 && bszm_out <= 32) { | ||
| shape_idx = 4; |
There was a problem hiding this comment.
Stop forcing shape 4 when it yields zero tiles
For the Blackwell override path (K==4, size_m==1, size_k==1024, size_n==256), hard-coding shape_idx = 4 selects a kernel with TILESIZE_N=512, so this shape has zero N tiles. In select_exl3_mgemm_kernel, that drives max_slices to 0 and sets num_sms to 0, and exl3_mgemm_gr then computes total_sms / num_sms, which is a divide-by-zero on this decode shape rather than a pure performance tweak.
Useful? React with 👍 / 👎.
Signed-off-by: AlpinDale <alpindale@gmail.com>
Signed-off-by: AlpinDale <alpindale@gmail.com>
Signed-off-by: AlpinDale <alpindale@gmail.com>
Some shape adjustments and kernel work for sm_120, results:
Trinity-Nano-Preview-4.0bpw:
Qwen3-0.6B-4.0bpw: