[GH-ISSUE #2027] [Bug]: CMake: four native-expert tests are registered only from the second configure (STRATA_NATIVE_EXPERTS is read before its option()) #805

Closed
opened 2026-11-04 01:46:04 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @KarlGrier on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2027

What happened

In a GPU build, CMakeLists.txt reads STRATA_NATIVE_EXPERTS at line 538 (if(STRATA_BUILD_TESTS AND STRATA_NATIVE_EXPERTS), inside the if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP) block from line 292) before option(STRATA_NATIVE_EXPERTS "Native (IQ) expert support through ggml-cpu" ON) defines it at line 1210 (v0.1.43, 7695859a). On a fresh build directory the variable is still unset at line 538, so that block registers nothing. The option() then writes it to the cache, and only the next configure registers the four tests: expert_layout_test, native_dense_ple_key_test, expert_cache_per_layer_test and expert_cache_segmented_test. A build directory configured once (as in CI or a first build) runs four tests fewer than one configured twice.

Steps (configure only, nothing built):

cmake -S . -B build -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=120
ctest --test-dir build -N | tail -1      # Total Tests: 109
cmake -S . -B build
ctest --test-dir build -N | tail -1      # Total Tests: 113

(I also passed -DSTRATA_GGML_DIR pointing at a llama.cpp checkout and -DCMAKE_CUDA_COMPILER.) A CPU-only configure is not affected: it registers 39 tests both times, since the block is in the GPU section. v0.1.42 had it at lines 538 / 1199 (108 → 112) and v0.1.41 at 488 / 1131 (95 → 99); the four passed there once registered.

Suggested fix: move option(STRATA_NATIVE_EXPERTS ...) from line 1210 up to the other option()s (lines 14–101), so it is defined before line 538 reads it.

Not tested: HIP builds (the same block), other CMake versions.

Strata version, GPU, OS

v0.1.43 (7695859a) source, CMake 3.28.3, CUDA 13.3 · configure only, so the GPU does not matter (RTX 5080 + RTX 4060 Ti here) · Linux 7.0 (Ubuntu 24.04-based)

Engine log

Not applicable (configure time).

Measured and drafted with Claude Code.

Originally created by @KarlGrier on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2027 ### What happened In a GPU build, `CMakeLists.txt` reads `STRATA_NATIVE_EXPERTS` at line 538 (`if(STRATA_BUILD_TESTS AND STRATA_NATIVE_EXPERTS)`, inside the `if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)` block from line 292) before `option(STRATA_NATIVE_EXPERTS "Native (IQ) expert support through ggml-cpu" ON)` defines it at line 1210 (v0.1.43, `7695859a`). On a fresh build directory the variable is still unset at line 538, so that block registers nothing. The `option()` then writes it to the cache, and only the next configure registers the four tests: `expert_layout_test`, `native_dense_ple_key_test`, `expert_cache_per_layer_test` and `expert_cache_segmented_test`. A build directory configured once (as in CI or a first build) runs four tests fewer than one configured twice. Steps (configure only, nothing built): ``` cmake -S . -B build -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=120 ctest --test-dir build -N | tail -1 # Total Tests: 109 cmake -S . -B build ctest --test-dir build -N | tail -1 # Total Tests: 113 ``` (I also passed `-DSTRATA_GGML_DIR` pointing at a llama.cpp checkout and `-DCMAKE_CUDA_COMPILER`.) A CPU-only configure is not affected: it registers 39 tests both times, since the block is in the GPU section. v0.1.42 had it at lines 538 / 1199 (108 → 112) and v0.1.41 at 488 / 1131 (95 → 99); the four passed there once registered. Suggested fix: move `option(STRATA_NATIVE_EXPERTS ...)` from line 1210 up to the other `option()`s (lines 14–101), so it is defined before line 538 reads it. Not tested: HIP builds (the same block), other CMake versions. ### Strata version, GPU, OS v0.1.43 (`7695859a`) source, CMake 3.28.3, CUDA 13.3 · configure only, so the GPU does not matter (RTX 5080 + RTX 4060 Ti here) · Linux 7.0 (Ubuntu 24.04-based) ### Engine log Not applicable (configure time). Measured and drafted with Claude Code.
Author
Owner

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

Confirmed by reading the file: line 538 reads STRATA_NATIVE_EXPERTS before the option() at line 1210 defines it, so a fresh build directory registers four tests fewer than the second configure. Fixed as you suggested: the option(STRATA_NATIVE_EXPERTS ...) now sits with the other options near the top, ahead of the GPU section, and the old line is removed (the default stays ON, and -DSTRATA_NATIVE_EXPERTS=OFF still works because option() keeps a value given on the command line). I could not run a CUDA configure on this machine, so a first configure should now show Total Tests: 113; if it does not on your side, please tell us. Closing when the fix ships in 0.1.43.1 (out now).

<!-- gh-comment-id:6129328443 --> @Niko1221 commented on GitHub (Oct 12, 2026): Confirmed by reading the file: line 538 reads `STRATA_NATIVE_EXPERTS` before the `option()` at line 1210 defines it, so a fresh build directory registers four tests fewer than the second configure. Fixed as you suggested: the `option(STRATA_NATIVE_EXPERTS ...)` now sits with the other options near the top, ahead of the GPU section, and the old line is removed (the default stays ON, and `-DSTRATA_NATIVE_EXPERTS=OFF` still works because `option()` keeps a value given on the command line). I could not run a CUDA configure on this machine, so a first configure should now show `Total Tests: 113`; if it does not on your side, please tell us. Closing when the fix ships in 0.1.43.1 (out now).
Author
Owner

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

Checked on v0.1.43.1 (a0116b27): a fresh build directory with CUDA and tests on shows Total Tests: 113 on the first configure. Thanks for the quick fix.

Measured and drafted with Claude Code.

<!-- gh-comment-id:6136775614 --> @KarlGrier commented on GitHub (Oct 13, 2026): Checked on v0.1.43.1 (`a0116b27`): a fresh build directory with CUDA and tests on shows `Total Tests: 113` on the first configure. Thanks for the quick fix. Measured and drafted with Claude Code.
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#805
No description provided.