Start: name the GPU and stop at once when the build has no code for it; STRATA_EMULATE_CC for tests

- generate.cpp: before the expert arena loads, the engine names the card and its compute capability and checks that
  the build has code for it (device_code_error: cudaFuncGetAttributes on a kernel). A binary built for other GPUs
  used to fail at the first kernel, after the whole arena had loaded; now it stops in ~0.3 s and says why.
- include/strata/core/emulate.hpp: STRATA_EMULATE_CC=75|80|86|89 makes the host's device queries (compute
  capability, shared memory per block) answer as that generation, for a PTX build of it JIT-compiled on a newer
  card - ggml's MMQ config, the QSA kernels' choice, fused_gr's shared memory. Tests only.
- STRATA_QSA_WARP=1|select|attn: the pre-sm_80 QSA kernels on any card (A/B).
This commit is contained in:
sergiywith authored and Niko1221 committed 2026-10-01 08:11:23 +02:00
1 parent aea6e45c64
commit a606e3a966
9 files changed
+85 -4

No files matched your search

+17
View File
@@ -55,6 +55,8 @@
#include "strata/spec/suffix_drafter.hpp"
#include "strata/kernels/cvec.hpp"
#include "strata/core/progress.hpp"
#include "strata/core/device.hpp"
#include "strata/core/emulate.hpp"
#ifndef NOMINMAX
#define NOMINMAX // gguf_reader.hpp includes windows.h
#endif
@@ -2391,6 +2393,21 @@ int main(int argc, char** argv) {
// CUDA error left set by the failed `cudaHostRegister` and read later by `gr_read`'s launch check. See the
// note in `pinned.cu`.
strata::core::FileExpertSource src;
{ // the card, and whether this build has code for it (a binary built for other GPUs fails at its first kernel
// otherwise, after the whole expert arena has loaded) - before the arena starts loading
int dev = 0;
cudaDeviceProp p{};
if (cudaGetDevice(&dev) == cudaSuccess && cudaGetDeviceProperties(&p, dev) == cudaSuccess)
std::fprintf(stderr, "strata generate: GPU %d: %s, compute capability %d.%d%s\n", dev, p.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)" : "");
const std::string e = strata::core::device_code_error();
if (!e.empty()) {
std::fprintf(stderr, "strata generate: this engine has no code for %s (sm_%d%d): %s - rebuild it for this "
"card (setup does: START-HERE.bat --setup)\n", p.name, p.major, p.minor, e.c_str());
return 1;
}
}
strata::core::ArenaExpertSource arena_src;
strata::core::ExpertSource* srcp = nullptr;
if (o.mmap_experts) {