[GH-ISSUE #1650] prefill: the batched prompt path aborts (cublasGemmEx f16, cuBLAS status 14) on chunks below about 32 tokens #666

Closed
opened 2026-11-04 01:44:54 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @W1nge on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1650

With very small --short-read values the prompt path cannot serve anything: the first request aborts the engine.

prefill gemm: cublasGemmEx f16: cuBLAS status 14

(the engine exits with code 1, the server restarts it, the same thing happens to the next request).

--short-read 0 sends every prompt segment to the batched path, including the last segment of a chat prompt – the role header the server appends, which is about 6 tokens. Chunks that small abort. Measured on one Windows host (CUDA 12.4.131, RTX 2080 Ti sm_75 + Tesla P100 sm_60, driver 537.13, native IQ3_XXS pack, 8192 context) with STRATA_TRACE=1, which prints the chunk before it runs:

prompt chunk result
6 tokens (the turn header, prompt chunk 0 of 6) aborts
21 tokens aborts
24 tokens aborts
33 tokens reads normally (2.30 s)
37 tokens reads normally
73 / 109 / 195 / 429 / 546 / 877 tokens read normally

So the boundary sits between 24 and 33 tokens of chunk. It is not the first request that fails: after a chunk that reads, the next small chunk still aborts, and a session that reads anything through the verify windows first (any --short-read of 32 or more on these prompts) never shows it.

Minimal reproduction, no patches, stock 0.1.41 (fb58e0d) on Windows:

strata.exe --serve --short-read 0 ...      # any full-size serve configuration

then send one ordinary chat request whose prompt ends with the role header, e.g. a message of about 40 tokens. STRATA_TRACE=1 makes the last lines

strata trace: request 40 0
strata trace: prompt chunk 0 of 33          <- reads normally
strata trace: prompt chunk 0 of 6           <- aborts here
prefill gemm: cublasGemmEx f16: cuBLAS status 14

The failing call is Gemm::f16 in src/prefill/gemm.cu (cublasGemmEx, CUDA_R_16F operands, CUBLAS_COMPUTE_32F), which is the fp16 expert GEMM of the chunk (the row count is the number of experts the chunk routes to, src/prefill/prefill.cpp around the dq_gu/dq_d calls). Small chunks therefore reach it with very few rows.

I first hit this while measuring whether the batched prompt path can replace the verify windows for medium prompts: it makes --short-read 0 unusable, and it means the minimum is implicitly about 32 tokens rather than the documented "0 = never use the windows". A guard (clamp the flag, or keep the windows for a segment the batched path cannot serve) or a fix in the small-chunk GEMM path would both be fine; the default --short-read 64 is unaffected.

Originally created by @W1nge on GitHub (Oct 9, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1650 With very small `--short-read` values the prompt path cannot serve anything: the first request aborts the engine. ``` prefill gemm: cublasGemmEx f16: cuBLAS status 14 ``` (the engine exits with code 1, the server restarts it, the same thing happens to the next request). `--short-read 0` sends every prompt segment to the batched path, including the last segment of a chat prompt – the role header the server appends, which is about 6 tokens. Chunks that small abort. Measured on one Windows host (CUDA 12.4.131, RTX 2080 Ti sm_75 + Tesla P100 sm_60, driver 537.13, native IQ3_XXS pack, 8192 context) with `STRATA_TRACE=1`, which prints the chunk before it runs: | prompt chunk | result | | --- | --- | | 6 tokens (the turn header, `prompt chunk 0 of 6`) | aborts | | 21 tokens | aborts | | 24 tokens | aborts | | 33 tokens | reads normally (2.30 s) | | 37 tokens | reads normally | | 73 / 109 / 195 / 429 / 546 / 877 tokens | read normally | So the boundary sits between 24 and 33 tokens of chunk. It is not the first request that fails: after a chunk that reads, the next small chunk still aborts, and a session that reads anything through the verify windows first (any `--short-read` of 32 or more on these prompts) never shows it. Minimal reproduction, no patches, stock 0.1.41 (`fb58e0d`) on Windows: ``` strata.exe --serve --short-read 0 ... # any full-size serve configuration ``` then send one ordinary chat request whose prompt ends with the role header, e.g. a message of about 40 tokens. `STRATA_TRACE=1` makes the last lines ``` strata trace: request 40 0 strata trace: prompt chunk 0 of 33 <- reads normally strata trace: prompt chunk 0 of 6 <- aborts here prefill gemm: cublasGemmEx f16: cuBLAS status 14 ``` The failing call is `Gemm::f16` in `src/prefill/gemm.cu` (`cublasGemmEx`, `CUDA_R_16F` operands, `CUBLAS_COMPUTE_32F`), which is the fp16 expert GEMM of the chunk (the row count is the number of experts the chunk routes to, `src/prefill/prefill.cpp` around the `dq_gu`/`dq_d` calls). Small chunks therefore reach it with very few rows. I first hit this while measuring whether the batched prompt path can replace the verify windows for medium prompts: it makes `--short-read 0` unusable, and it means the minimum is implicitly about 32 tokens rather than the documented "0 = never use the windows". A guard (clamp the flag, or keep the windows for a segment the batched path cannot serve) or a fix in the small-chunk GEMM path would both be fine; the default `--short-read 64` is unaffected.
Author
Owner

@W1nge commented on GitHub (Oct 9, 2026):

Root cause found: it is not the chunk size itself, but a cuBLAS 12 state that a second CUDA device in the process creates.

With another device's context initialized, cudaGemmEx - the call Gemm::f16 makes (CUDA_R_16F operands, CUBLAS_COMPUTE_32F) - answers CUBLAS_STATUS_INTERNAL_ERROR (14) for a few shapes when asked for CUBLAS_GEMM_DEFAULT. Minimal reproduction, no strata: on the machine that runs the GEMM on device 0, this is enough to break it for the rest of the process:

cudaSetDevice(1);
cudaFree(0);          // only the context exists; no work, no allocation

In-process controls (RTX 2080 Ti sm_75 + Tesla P100 sm_60, Windows, driver 537.13, CUDA 12.4.131, a probe around the same call): 96/96 calls return 14 when the P100 takes part in the run, 0/96 with the P100 idle, 0/96 single-card - the pattern follows "was the second device's context created", not the shapes of the run.

The set of failing shapes moves with K as well as N, which is why a "small N" guard is not enough: K = 10240 is safe for N a multiple of 8 (N = 4, the expert gate/up pair, fails), while K = 2560 fails for N = 8..32 as well and is safe from 48 up. The small-chunk boundary in this report is a consequence of which shapes the small chunks reach.

An algorithm scan shows the fixed algorithms are immune: CUBLAS_GEMM_ALGO2 .. ALGO11 all return success under that state (ALGO0/1/12..15 are not-supported, CUBLAS_GEMM_TENSOR_OP and DEFAULT return 14), and ALGO2 measures the same as DEFAULT where DEFAULT works.

#1659 falls back per shape: a Gemm remembers the (N, K) of the shapes whose default call failed and runs only those on ALGO2, so the abort is gone and the wide shapes keep their default kernel (running everything on ALGO2 cost 11515 ms on a 5.1K prompt versus 7499 ms with this change; 7899 ms with the tensor cores off).

Verified against the stock engine on this host: stock aborts on --short-read 0 with STRATA_BF16_TC=1 (the exact prefill gemm: cublasGemmEx f16: cuBLAS status 14 from this report, exit code 1), and the patch answers the same 40-token request ([3], valid, 3.1 s).

<!-- gh-comment-id:6074654543 --> @W1nge commented on GitHub (Oct 9, 2026): Root cause found: it is not the chunk size itself, but a cuBLAS 12 state that a second CUDA device in the process creates. With another device's context initialized, `cudaGemmEx` - the call `Gemm::f16` makes (`CUDA_R_16F` operands, `CUBLAS_COMPUTE_32F`) - answers `CUBLAS_STATUS_INTERNAL_ERROR` (14) for a few shapes when asked for `CUBLAS_GEMM_DEFAULT`. Minimal reproduction, no strata: on the machine that runs the GEMM on device 0, this is enough to break it for the rest of the process: cudaSetDevice(1); cudaFree(0); // only the context exists; no work, no allocation In-process controls (RTX 2080 Ti sm_75 + Tesla P100 sm_60, Windows, driver 537.13, CUDA 12.4.131, a probe around the same call): 96/96 calls return 14 when the P100 takes part in the run, 0/96 with the P100 idle, 0/96 single-card - the pattern follows "was the second device's context created", not the shapes of the run. The set of failing shapes moves with K as well as N, which is why a "small N" guard is not enough: K = 10240 is safe for N a multiple of 8 (N = 4, the expert gate/up pair, fails), while K = 2560 fails for N = 8..32 as well and is safe from 48 up. The small-chunk boundary in this report is a consequence of which shapes the small chunks reach. An algorithm scan shows the fixed algorithms are immune: `CUBLAS_GEMM_ALGO2` .. `ALGO11` all return success under that state (ALGO0/1/12..15 are not-supported, `CUBLAS_GEMM_TENSOR_OP` and `DEFAULT` return 14), and ALGO2 measures the same as DEFAULT where DEFAULT works. #1659 falls back per shape: a `Gemm` remembers the `(N, K)` of the shapes whose default call failed and runs only those on ALGO2, so the abort is gone and the wide shapes keep their default kernel (running everything on ALGO2 cost 11515 ms on a 5.1K prompt versus 7499 ms with this change; 7899 ms with the tensor cores off). Verified against the stock engine on this host: stock aborts on `--short-read 0` with `STRATA_BF16_TC=1` (the exact `prefill gemm: cublasGemmEx f16: cuBLAS status 14` from this report, exit code 1), and the patch answers the same 40-token request (`[3]`, valid, 3.1 s).
Author
Owner

@Niko1221 commented on GitHub (Oct 10, 2026):

Thanks for the root cause. We checked it: on two RTX A4000 with CUDA 12.9 a probe (cublasGemmEx f16, default vs ALGO2, 99 shapes with K 2560/10240) does not fail even with the second device's context created, so the state needs the mixed Turing+Pascal pair or cuBLAS 12.4 you used. We ported #1659 as it is (authorship kept) and it builds on CUDA 12.9 and 13.4; our identity gate on a 3060 is unchanged.

<!-- gh-comment-id:6099659707 --> @Niko1221 commented on GitHub (Oct 10, 2026): Thanks for the root cause. We checked it: on two RTX A4000 with CUDA 12.9 a probe (cublasGemmEx f16, default vs ALGO2, 99 shapes with K 2560/10240) does not fail even with the second device's context created, so the state needs the mixed Turing+Pascal pair or cuBLAS 12.4 you used. We ported #1659 as it is (authorship kept) and it builds on CUDA 12.9 and 13.4; our identity gate on a 3060 is unchanged.
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6156174142 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
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#666
No description provided.