From bb628ce12fe44aa98044e56747ce396484dfebd0 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 30 Sep 2026 13:29:18 +0200 Subject: [PATCH] A fatal CUDA fault in the prompt path exits at once instead of hanging until the watchdog (#224); CMake warns when sm_120 is built with CUDA < 13.0 (#220, #224); iq_pack writes native_experts.txt under a temporary name, so a stop part-way leaves no partial pack (#172) --- CMakeLists.txt | 5 +++++ src/program/generate.cpp | 7 +++++++ tools/iq_pack.py | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83682627d1..e74f6bfcd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,11 @@ if(STRATA_ENABLE_CUDA) "Strata needs an NVIDIA GPU of compute capability 7.5 or newer (RTX 20 / 30 / 40 / 50 series), but " "CMAKE_CUDA_ARCHITECTURES is '${CMAKE_CUDA_ARCHITECTURES}'.") endif() + # #220 / #224: RTX 50 engines built with CUDA 12.8 crashed in the prompt path on Linux (13.0 and newer did not) + if(_base GREATER_EQUAL 120 AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0) + message(WARNING "Building for sm_${_base} (RTX 50) with CUDA ${CMAKE_CUDA_COMPILER_VERSION}: engines built with " + "CUDA 12.8 crashed on long prompts on these cards (issues #220, #224). Use CUDA 13.0 or newer.") + endif() endforeach() message(STATUS "Strata: CUDA enabled, arch ${CMAKE_CUDA_ARCHITECTURES}") set(_strata_gpu_runtime_target CUDA::cudart) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 5d7894c714..6070087069 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -4044,6 +4044,13 @@ int main(int argc, char** argv) { if (!stop_req.load()) { std::fprintf(stderr, "strata serve: %s\n", err.c_str()); std::printf("ERR %s\n", err.c_str()); + // #224: a CUDA fault (an illegal address) poisons the context for the whole process, and + // unwinding the destructors on it could hang until the 60 s watchdog: leave at once + if (cudaPeekAtLastError() != cudaSuccess) { + std::fflush(stdout); + std::fflush(stderr); + std::_Exit(1); + } return 1; } cancelled = true; // stopped while reading the prompt: refill the lent slots below, then DONE cancel diff --git a/tools/iq_pack.py b/tools/iq_pack.py index d86f53c4a1..f0ff890b30 100644 --- a/tools/iq_pack.py +++ b/tools/iq_pack.py @@ -308,7 +308,10 @@ def main() -> int: blob = per[0] + per[1] + per[2] layout.append((l, ts[0].type_id, ts[2].type_id, offset, blob, ts)) offset += blob * n_expert - with open(out / "native_experts.txt", "w", encoding="utf-8", newline="\n") as fo: + # written to a temporary name and renamed only when every layer is in: a stop part-way (a layer split across + # shards, #171) left a partial native_experts.txt that the next setup run took as a finished pack (#172) + tmp = out / "native_experts.txt.tmp" + with open(tmp, "w", encoding="utf-8", newline="\n") as fo: fo.write("# strata native experts v3: layer gu_type d_type offset blob_bytes gate_off up_off down_off [shard] " "(n_expert %d, total %d; absolute offsets in %s, or in the named shard beside it)\n" % (n_expert, offset, src.name)) @@ -316,10 +319,13 @@ def main() -> int: ws = [model.where[t.name] for t in ts] if len({w[3] for w in ws}) != 1: print("layer %d: its gate/up/down tensors are in different shards" % l) + fo.close() + tmp.unlink() return 1 gg, shard = ws[0][0], ws[0][3] line = "%d %d %d %d %d %d %d %d" % (l, gt, dt, off, blob, *[gg.data_start + t.offset for t in ts]) fo.write(line + ("" if shard == src else " " + shard.name) + "\n") + tmp.replace(out / "native_experts.txt") if a.skip_experts or not a.experts_bin: if (out / "experts.bin").exists() and not a.experts_bin: print("note: %s/experts.bin exists; the engine reads it instead of the GGUF" % out)