Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

#542: MMQ's device facts from cudaDeviceGetAttribute; warn when libcudart is older than the headers

Niko12219ae6dbd2ce81
diff --git a/src/prefill/ggml_cuda_host.cu b/src/prefill/ggml_cuda_host.cu
index c8f8284bf..1245c2b0b 100644
--- a/src/prefill/ggml_cuda_host.cu
+++ b/src/prefill/ggml_cuda_host.cu
@@ -80,17 +80,30 @@ const ggml_cuda_device_info & ggml_cuda_info() {
d.smpbo = prop.sharedMemPerBlock;
d.integrated = false;
d.supports_cooperative_launch = false;
-#else
- d.cc = 100 * strata::cc_major_of(prop.major) + 10 * strata::cc_minor_of(prop.minor); // STRATA_EMULATE_CC
- d.smpbo = strata::smem_optin_of((int) prop.sharedMemPerBlockOptin);
- d.integrated = prop.integrated != 0;
- d.supports_cooperative_launch = prop.cooperativeLaunch != 0;
-#endif
d.nsm = prop.multiProcessorCount;
d.smpb = prop.sharedMemPerBlock;
+ d.warp_size = prop.warpSize;
+#else
+ // #542: the fields MMQ's choices read come from cudaDeviceGetAttribute, which is ABI-stable: a
+ // cudaDeviceProp filled by an older libcudart than the headers (a CUDA 13 build that links a CUDA 12
+ // libcudart.so) is shifted - sharedMemPerBlockOptin read 1 there, and every i-quant lost MMQ (#420's
+ // fits()). In a matched build both give the same values.
+ auto attr = [id](cudaDeviceAttr a) {
+ int v = 0;
+ CUDA_CHECK(cudaDeviceGetAttribute(&v, a, id));
+ return v;
+ };
+ d.cc = 100 * strata::cc_major_of(attr(cudaDevAttrComputeCapabilityMajor)) +
+ 10 * strata::cc_minor_of(attr(cudaDevAttrComputeCapabilityMinor)); // STRATA_EMULATE_CC
+ d.smpbo = strata::smem_optin_of(attr(cudaDevAttrMaxSharedMemoryPerBlockOptin));
+ d.integrated = attr(cudaDevAttrIntegrated) != 0;
+ d.supports_cooperative_launch = attr(cudaDevAttrCooperativeLaunch) != 0;
+ d.nsm = attr(cudaDevAttrMultiProcessorCount);
+ d.smpb = (size_t) attr(cudaDevAttrMaxSharedMemoryPerBlock);
+ d.warp_size = attr(cudaDevAttrWarpSize);
+#endif
d.vmm = false;
d.total_vram = prop.totalGlobalMem;
- d.warp_size = prop.warpSize;
d.physical_device = id;
d.physical_share_count = 1;
d.virtual_index = 0;
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index a7de0614c..6088b323c 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -2703,6 +2703,16 @@ int main(int argc, char** argv) {
std::fprintf(stderr, "strata generate: GPU %d: %s, compute capability %d.%d%s\n", dev, name,
strata::cc_major_of(p.major), strata::cc_minor_of(p.minor),
strata::emulated_cc() ? " (STRATA_EMULATE_CC: a test mode, the card is emulated)" : "");
+ { // #542: a build whose libcudart is older than its headers (a CUDA 13 kit with a dangling libcudart.so that
+ // CMake resolved to the system's CUDA 12 one) reads cudaDeviceProp shifted - silently, and slowly
+ int rt = 0;
+ if (cudaRuntimeGetVersion(&rt) == cudaSuccess && rt / 1000 != CUDART_VERSION / 1000)
+ std::fprintf(stderr, "strata generate: WARNING: this engine was compiled with CUDA %d.%d headers but "
+ "loaded a CUDA %d.%d runtime (libcudart): GPU properties can read wrong and some "
+ "kernels go unused. Rebuild it against one toolkit (cmake -DCUDAToolkit_ROOT=<the "
+ "toolkit>, with its libcudart.so present) (#542)\n",
+ CUDART_VERSION / 1000, CUDART_VERSION % 1000 / 10, rt / 1000, rt % 1000 / 10);
+ }
#endif
const std::string e = strata::core::device_code_error();
if (!e.empty()) {