Files
Strata/engine/tests/core/arch_probe_test.cpp
Niko1221 a8371d27fa fix(inkling2, hy4): say plainly when the binary has no GPU code for the card, before anything loads (#6759)
A CUDA engine binary is built for a list of architectures (the CUDA 13 packages: sm_75 and newer; the CUDA 12 ones also
sm_60/61/70). On a card it holds no code for, the weights load and the first kernel fails; strata-inkling then ended with a
misleading "CUDA error 2 (out of memory)" in the loader, and a binary that gets past that (lazy module loading, as under
volta-forever) leaves the logits at 0 and answers token id 0 forever, with no error.

strata/core/arch_probe.hpp builds the message; strata-inkling (ink_cuda_backend.cu) and strata-hy4 (hy4_main.hip.cpp, CUDA
builds, serve and CLI, every GPU named) ask CUDA for the attributes of a probe kernel (cudaFuncGetAttributes), which answers
for the whole binary, and end with: "this strata-inkling has no GPU code for <card> (compute capability X.Y): <cuda error>.
<way out>" (a Pascal / Volta card: the CUDA 12 engine package or a CUDA 12.x build with -DSTRATA_EXPERIMENTAL_SM60=ON; else
the package made for the card or a rebuild for that architecture). strata (generate.cpp, the Qwen engine) already did this
(device_code_error()).

Test arch_probe_test (no GPU): the message names engine, card, compute capability, CUDA error and the way out; the Volta
text appears only below 7.5.

Measured on an RTX 4090 (sm_89) with binaries built for sm_120 only (no SASS for the card, PTX compute_120 cannot run on it):
- strata-inkling, origin/main: "strata-inkling CUDA error 2 at ink_runner.cuh:322: out of memory", exit 1.
- strata-inkling, this change: "init: this strata-inkling has no GPU code for NVIDIA GeForce RTX 4090 (compute capability 8.9):
  invalid resource handle. Use the engine package made for this card ... -DCMAKE_CUDA_ARCHITECTURES=89", exit 1, nothing loaded.
- strata-hy4, origin/main: no mention of the card (it goes on to read the model); this change: the same message, as an
  "ERR ..." line in --serve and on stderr in the CLI, exit 1.
2026-11-23 12:20:56 +01:00

43 lines
1.9 KiB
C++

// The message an engine gives when its binary has no GPU code for the card (strata/core/arch_probe.hpp, #6759): it names the engine,
// the card and its compute capability, the CUDA error, and the way out (the CUDA 12 package for Pascal / Volta, else the right package or a rebuild).
#include "strata/core/arch_probe.hpp"
#include <cstdio>
#include <string>
using strata::core::no_gpu_code_message;
namespace {
int failed = 0;
#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)
bool has(const std::string& s, const char* part) { return s.find(part) != std::string::npos; }
} // namespace
int main() {
const std::string v100 = no_gpu_code_message("strata-inkling", "Tesla V100-PCIE-32GB", 7, 0, "no kernel image is available for execution on the device");
CHECK(has(v100, "strata-inkling"));
CHECK(has(v100, "Tesla V100-PCIE-32GB"));
CHECK(has(v100, "compute capability 7.0"));
CHECK(has(v100, "no kernel image is available"));
CHECK(has(v100, "CUDA 12 engine package"));
CHECK(has(v100, "-DCMAKE_CUDA_ARCHITECTURES=70"));
CHECK(has(v100, "STRATA_EXPERIMENTAL_SM60=ON"));
const std::string p61 = no_gpu_code_message("strata-hy4", "GeForce GTX 1080 Ti", 6, 1, "no kernel image");
CHECK(has(p61, "strata-hy4") && has(p61, "6.1") && has(p61, "CMAKE_CUDA_ARCHITECTURES=61"));
// a newer card the binary was not built for: no word about CUDA 12 / Volta
const std::string ada = no_gpu_code_message("strata-hy4", "NVIDIA GeForce RTX 3060", 8, 6, "no kernel image is available for execution on the device");
CHECK(has(ada, "compute capability 8.6"));
CHECK(!has(ada, "Volta"));
CHECK(has(ada, "-DCMAKE_CUDA_ARCHITECTURES=86"));
CHECK(has(ada, "strata update"));
if (failed) {
std::fprintf(stderr, "arch_probe_test: %d failed\n", failed);
return 1;
}
std::printf("arch_probe_test: ok\n");
return 0;
}