[GH-ISSUE #2682] [Engine] fail the test build when a release-engine CUDA kernel spills or uses local memory #1067

Closed
opened 2026-11-04 01:48:12 +07:00 by bsakaguchi · 8 comments
Owner

Originally created by @Avicennasis on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2682

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Re-filing #1758, which the 2026-10-13 sweep closed as older than three days. The ask is unchanged; the difference is that the PR is filed right behind this issue and names it (Resolves #…), so both exist inside the three-day window.

A build-time check that fails STRATA_BUILD_TESTS when a CUDA kernel in the release engine spills registers to local memory or keeps a per-thread array there, per architecture in CMAKE_CUDA_ARCHITECTURES.

Why. Strata carries per-architecture kernel tables and has found two defects that were compiler-output facts rather than source facts: #1522 (gdn_l2_kernel compiles without the fma the fused kernel spells out on CUDA 13.3 / sm_120) and #1469 (Pascal decode regression). A register spill is the same kind of fact: it shows up in the compiler's resource report and nowhere in the source, it varies by toolkit and sm_, and it costs decode throughput silently. Nothing in the tree reads that report today.

Shape (what the PR does). tools/check_cuda_spills.py reads the built kernel libraries with cuobjdump --dump-resource-usage and fails when a kernel's STACK or LOCAL bytes exceed what an exceptions table in the script allows for that (kernel, sm_) pair; the message names the kernel, the sm_ and the two numbers. It is registered as the CTest cuda_spill_guard under STRATA_ENABLE_CUDA AND STRATA_BUILD_TESTS (not under HIP, where there is no cuobjdump), skips with 77 where cuobjdump or Python is missing, and mirrors tools/check_isa_guard.py in shape. No build-flag change: it reads the objects that were built anyway, and it needs no GPU at test time. The vendored llama.cpp ggml kernels (mul_mat_q, quantize_*) are skipped — they are the only kernels with no namespace, and they are llama.cpp's to gate. This is how DeepGEMM gates its kernels (DG_JIT_CHECK_NO_SPILLS / DG_JIT_CHECK_NO_LOCAL_MEMORY).

Measured on 296b59d2 with CUDA 13.1 (nvcc V13.1.80), Release, sm_86 and sm_120: 1351 Strata kernels (359 once template instantiations are collapsed) across the eight kernel libraries; 150 (kernel, sm_) entries carry a stack frame — 61 are register spills in 21 distinct kernels (the largest block_topk_reg_kernel, 196 B of spill stores / 284 B of loads on sm_120 at the 64-register cap of its launch bounds; then native_mmvq_il_kernel 60/60 B and native_gu_multi_kernel 56/64 B) and 89 are spill-free per-thread arrays (attn_chunk_kernel's 384-byte score tile the largest). LOCAL is 0 everywhere: on CUDA 13.1 both arrays and spills land in STACK. The exceptions table carries exactly those numbers — 37 entries, 53 (kernel, sm_) allowances, one line each saying what the array is or what spilled — so the first run documents the current state rather than failing on it; a later change that adds a spill or grows a local array is a red test naming the kernel. The spills themselves are findings, not fixed in the PR.

Not measured: sm_75 and sm_89 (the table is per-sm_; entries for them come from the first build on such a box), HIP and Windows, any timing or GPU behaviour, and why ptxas settles on different register counts per arch (e.g. gr_down_q8_kernel<7>: 128 registers + spills on sm_86, 206 registers and clean on sm_120).

If you would rather have the capture elsewhere (a CMake option, a CI step over the build log), say so on the PR and I will move it.

Originally created by @Avicennasis on GitHub (Oct 15, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2682 ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? Re-filing #1758, which the 2026-10-13 sweep closed as older than three days. The ask is unchanged; the difference is that the PR is filed right behind this issue and names it (`Resolves #…`), so both exist inside the three-day window. A build-time check that fails `STRATA_BUILD_TESTS` when a CUDA kernel in the release engine spills registers to local memory or keeps a per-thread array there, per architecture in `CMAKE_CUDA_ARCHITECTURES`. **Why.** Strata carries per-architecture kernel tables and has found two defects that were compiler-output facts rather than source facts: #1522 (`gdn_l2_kernel` compiles without the fma the fused kernel spells out on CUDA 13.3 / sm_120) and #1469 (Pascal decode regression). A register spill is the same kind of fact: it shows up in the compiler's resource report and nowhere in the source, it varies by toolkit and `sm_`, and it costs decode throughput silently. Nothing in the tree reads that report today. **Shape (what the PR does).** `tools/check_cuda_spills.py` reads the built kernel libraries with `cuobjdump --dump-resource-usage` and fails when a kernel's STACK or LOCAL bytes exceed what an exceptions table in the script allows for that (kernel, `sm_`) pair; the message names the kernel, the `sm_` and the two numbers. It is registered as the CTest `cuda_spill_guard` under `STRATA_ENABLE_CUDA AND STRATA_BUILD_TESTS` (not under HIP, where there is no `cuobjdump`), skips with 77 where `cuobjdump` or Python is missing, and mirrors `tools/check_isa_guard.py` in shape. No build-flag change: it reads the objects that were built anyway, and it needs no GPU at test time. The vendored llama.cpp ggml kernels (`mul_mat_q`, `quantize_*`) are skipped — they are the only kernels with no namespace, and they are llama.cpp's to gate. This is how DeepGEMM gates its kernels (`DG_JIT_CHECK_NO_SPILLS` / `DG_JIT_CHECK_NO_LOCAL_MEMORY`). **Measured on `296b59d2` with CUDA 13.1 (nvcc V13.1.80), Release, `sm_86` and `sm_120`:** 1351 Strata kernels (359 once template instantiations are collapsed) across the eight kernel libraries; 150 (kernel, `sm_`) entries carry a stack frame — 61 are register spills in 21 distinct kernels (the largest `block_topk_reg_kernel`, 196 B of spill stores / 284 B of loads on sm_120 at the 64-register cap of its launch bounds; then `native_mmvq_il_kernel` 60/60 B and `native_gu_multi_kernel` 56/64 B) and 89 are spill-free per-thread arrays (`attn_chunk_kernel`'s 384-byte score tile the largest). LOCAL is 0 everywhere: on CUDA 13.1 both arrays and spills land in STACK. The exceptions table carries exactly those numbers — 37 entries, 53 (kernel, `sm_`) allowances, one line each saying what the array is or what spilled — so the first run documents the current state rather than failing on it; a later change that adds a spill or grows a local array is a red test naming the kernel. The spills themselves are findings, not fixed in the PR. **Not measured:** sm_75 and sm_89 (the table is per-`sm_`; entries for them come from the first build on such a box), HIP and Windows, any timing or GPU behaviour, and why ptxas settles on different register counts per arch (e.g. `gr_down_q8_kernel<7>`: 128 registers + spills on sm_86, 206 registers and clean on sm_120). If you would rather have the capture elsewhere (a CMake option, a CI step over the build log), say so on the PR and I will move it.
Author
Owner

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

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271167427 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@Avicennasis commented on GitHub (Oct 20, 2026):

Re-tested on cbfd5b92 (main, v0.2.1 + 55) — not fixed; the tree still reads none of the compiler's resource report, and the state has moved since the first measurement.

What I see. Building the eight CUDA kernel libraries for sm_86 + sm_120 (CUDA 13.1, nvcc/cuobjdump V13.1.80, cmake 3.28.3 + ninja 1.11.1, Release) and reading them with cuobjdump --dump-resource-usage: 1804 Strata kernels (412 once template instantiations collapse), 3608 (kernel, sm_) entries, 270 with a stack frame — 136 register spills in 30 distinct kernels and 134 spill-free per-thread arrays. At 296b59d2 it was 150 framed entries, 61 spills in 21 kernels. 13 kernels with a frame are new since then (expdec_down_kernel is now the largest spill in the tree: 428 B of spill stores / 600 B of loads on sm_86 at the 64-register cap of __launch_bounds__(256, STRATA_EXPDEC_MINB = 4)), 3 moved (block_topk_reg_kernel, gr_down_staged_kernel, dequant_kernel's Q6_K vectorised instantiation), 1 lost its sm_120 frame (gdn_step_norm_multi_kernel). LOCAL is 0 everywhere on this toolkit; spills and local arrays both land in STACK.

Strata version: cbfd5b92 (main, 55 commits past v0.2.1). Graphics card / memory: none used — this is a compiler-output measurement in an Ubuntu 24.04.3 CUDA 13.1 devel container with no GPU, so no throughput claim is made here. System: Ubuntu 24.04.3 container on a Linux host, 16 cores.

The PR (#2683) is rebased on this revision with the allowance table re-measured and the gate green on it; its validation section carries the commands and the output.

<!-- gh-comment-id:6301793584 --> @Avicennasis commented on GitHub (Oct 20, 2026): Re-tested on `cbfd5b92` (main, v0.2.1 + 55) — not fixed; the tree still reads none of the compiler's resource report, and the state has moved since the first measurement. **What I see.** Building the eight CUDA kernel libraries for sm_86 + sm_120 (CUDA 13.1, nvcc/cuobjdump V13.1.80, cmake 3.28.3 + ninja 1.11.1, Release) and reading them with `cuobjdump --dump-resource-usage`: 1804 Strata kernels (412 once template instantiations collapse), 3608 (kernel, `sm_`) entries, 270 with a stack frame — 136 register spills in 30 distinct kernels and 134 spill-free per-thread arrays. At `296b59d2` it was 150 framed entries, 61 spills in 21 kernels. 13 kernels with a frame are new since then (`expdec_down_kernel` is now the largest spill in the tree: 428 B of spill stores / 600 B of loads on sm_86 at the 64-register cap of `__launch_bounds__(256, STRATA_EXPDEC_MINB = 4)`), 3 moved (`block_topk_reg_kernel`, `gr_down_staged_kernel`, `dequant_kernel`'s Q6_K vectorised instantiation), 1 lost its sm_120 frame (`gdn_step_norm_multi_kernel`). LOCAL is 0 everywhere on this toolkit; spills and local arrays both land in STACK. **Strata version:** `cbfd5b92` (main, 55 commits past v0.2.1). **Graphics card / memory:** none used — this is a compiler-output measurement in an Ubuntu 24.04.3 CUDA 13.1 devel container with no GPU, so no throughput claim is made here. **System:** Ubuntu 24.04.3 container on a Linux host, 16 cores. The PR (#2683) is rebased on this revision with the allowance table re-measured and the gate green on it; its validation section carries the commands and the output.
Author
Owner

@Avicennasis commented on GitHub (Oct 20, 2026):

/reopen

<!-- gh-comment-id:6301797525 --> @Avicennasis commented on GitHub (Oct 20, 2026): /reopen
Author
Owner

@github-actions[bot] commented on GitHub (Oct 20, 2026):

Not reopened yet. Still missing:

  • Fill in "Area".

Edit the issue and comment /reopen again. Details: CONTRIBUTING.md

<!-- gh-comment-id:6301800039 --> @github-actions[bot] commented on GitHub (Oct 20, 2026): Not reopened yet. Still missing: - [ ] Fill in "Area". Edit the issue and comment `/reopen` again. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@Avicennasis commented on GitHub (Oct 20, 2026):

/reopen

<!-- gh-comment-id:6301817078 --> @Avicennasis commented on GitHub (Oct 20, 2026): /reopen
Author
Owner

@github-actions[bot] commented on GitHub (Oct 20, 2026):

Reopened, thank you. A maintainer will pick it up from here.

<!-- gh-comment-id:6301819712 --> @github-actions[bot] commented on GitHub (Oct 20, 2026): Reopened, thank you. A maintainer will pick it up from here.
Author
Owner

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

This is the tracking issue for #2683, which implements it (cuda_spill_guard with an exceptions table). We will handle both together on that pull request; the allowance table will need re-measuring on the current tree and the CUDA toolkit we ship, and a CMake option or CI step is fine if you prefer. Please follow #2683.

<!-- gh-comment-id:6423265201 --> @Niko1221 commented on GitHub (Oct 26, 2026): This is the tracking issue for #2683, which implements it (cuda_spill_guard with an exceptions table). We will handle both together on that pull request; the allowance table will need re-measuring on the current tree and the CUDA toolkit we ship, and a CMake option or CI step is fine if you prefer. Please follow #2683.
Author
Owner

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

Thank you. Fixed in 0.2.7: Cuda_spill_guard fails the CUDA test build when a Strata kernel spills or keeps a per-thread array in local memory (#2683, #2682). Your name is on the commit.

Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7

<!-- gh-comment-id:6446015720 --> @Niko1221 commented on GitHub (Oct 27, 2026): Thank you. Fixed in 0.2.7: Cuda_spill_guard fails the CUDA test build when a Strata kernel spills or keeps a per-thread array in local memory (#2683, #2682). Your name is on the commit. Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7
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#1067
No description provided.