[PR #1659] [CLOSED] prefill gemm: recover the FP16 shapes cuBLAS 12's default algorithm fails on (issue #1650) #3589

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

📋 Pull Request Information

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

Base: main ← Head: codex/cublas-f16-algo-fallback


📝 Commits (1)

  • 7aa0201 prefill gemm: run a failing FP16 shape on a fixed cuBLAS algorithm; the default one fails once a second device's context exists (issue #1650)

📊 Changes

2 files changed (+29 additions, -0 deletions)

View changed files

📝 include/strata/prefill/gemm.hpp (+7 -0)
📝 src/prefill/gemm.cu (+22 -0)

📄 Description

Issue #1650: with more than one CUDA device initialized in the process, cuBLAS 12 answers the default
algorithm of a few FP16 GEMM shapes (CUDA_R_16F operands, CUBLAS_COMPUTE_32F) with
CUBLAS_STATUS_INTERNAL_ERROR (status 14), and the request aborts with
prefill gemm: cublasGemmEx f16: cuBLAS status 14.

Only initializing the other device's context is enough to set the state that does it: on this host,
cudaSetDevice(1); cudaFree(0); on the P100 makes the default-algorithm FP16 GEMM fail on the 2080 Ti
before any work has run there. The failing shapes depend on K as well as N (K = 10240: N a multiple
of 8 is safe; K = 2560: N = 8..32 fails too), so a "small N" guard is not enough.

The fixed algorithms (ALGO2 and up) run through that state, but they are markedly slower for the wide
shapes. So a Gemm moves only the shapes that failed: it remembers their (N, K) ((K << 32) | N, 32
slots) and runs them on CUBLAS_GEMM_ALGO2. The failing call is harmless and is paid once per shape
per process.

Measured on one Windows host (CUDA 12.4.131, RTX 2080 Ti sm_75 + Tesla P100 sm_60, driver 537.13), the
3-request fixture with STRATA_BF16_TC=1 (the abort is the stock engine, not a number):

FP16 algorithm 2K prompt 5.1K prompt
stock (CUBLAS_GEMM_DEFAULT) aborts aborts
every shape on ALGO2 7113 ms 11515 ms
this change 6261 ms 7499 ms

For reference, the same fixture with the tensor cores off is 6333 ms / 7899 ms: this change keeps the
STRATA_BF16_TC win and removes the abort.

Tested: the stock engine aborts on --short-read 0 (40-token prompt, STRATA_BF16_TC=1,
cublasGemmEx f16: cuBLAS status 14) and this change answers it ([3], valid, 3.1 s); the 2K / 5.1K /
warm fixture and the daily lend/source regression all pass with the same answers.


🔄 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/1659 **Author:** [@W1nge](https://github.com/W1nge) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/cublas-f16-algo-fallback` --- ### 📝 Commits (1) - [`7aa0201`](https://github.com/Niko1221/Strata/commit/7aa02012078a0d34bf407f777f72af85cb7fc4ce) prefill gemm: run a failing FP16 shape on a fixed cuBLAS algorithm; the default one fails once a second device's context exists (issue #1650) ### 📊 Changes **2 files changed** (+29 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/prefill/gemm.hpp` (+7 -0) 📝 `src/prefill/gemm.cu` (+22 -0) </details> ### 📄 Description Issue #1650: with more than one CUDA device initialized in the process, cuBLAS 12 answers the default algorithm of a few FP16 GEMM shapes (`CUDA_R_16F` operands, `CUBLAS_COMPUTE_32F`) with `CUBLAS_STATUS_INTERNAL_ERROR` (status 14), and the request aborts with `prefill gemm: cublasGemmEx f16: cuBLAS status 14`. Only initializing the other device's context is enough to set the state that does it: on this host, `cudaSetDevice(1); cudaFree(0);` on the P100 makes the default-algorithm FP16 GEMM fail on the 2080 Ti before any work has run there. The failing shapes depend on K as well as N (K = 10240: N a multiple of 8 is safe; K = 2560: N = 8..32 fails too), so a "small N" guard is not enough. The fixed algorithms (ALGO2 and up) run through that state, but they are markedly slower for the wide shapes. So a `Gemm` moves only the shapes that failed: it remembers their `(N, K)` ((K << 32) | N, 32 slots) and runs them on `CUBLAS_GEMM_ALGO2`. The failing call is harmless and is paid once per shape per process. Measured on one Windows host (CUDA 12.4.131, RTX 2080 Ti sm_75 + Tesla P100 sm_60, driver 537.13), the 3-request fixture with `STRATA_BF16_TC=1` (the abort is the stock engine, not a number): | FP16 algorithm | 2K prompt | 5.1K prompt | | --- | --- | --- | | stock (`CUBLAS_GEMM_DEFAULT`) | aborts | aborts | | every shape on ALGO2 | 7113 ms | 11515 ms | | this change | 6261 ms | 7499 ms | For reference, the same fixture with the tensor cores off is 6333 ms / 7899 ms: this change keeps the `STRATA_BF16_TC` win and removes the abort. Tested: the stock engine aborts on `--short-read 0` (40-token prompt, `STRATA_BF16_TC=1`, `cublasGemmEx f16: cuBLAS status 14`) and this change answers it (`[3]`, valid, 3.1 s); the 2K / 5.1K / warm fixture and the daily lend/source regression all pass with the same answers. --- <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:23 +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#3589
No description provided.