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++

dsv41: one runtime header for the tests on both backends (HIP or CUDA), so a CUDA box needs no shim on -I

Niko122152543768c70c
diff --git a/include/strata/dsv41/hip_or_cuda.h b/include/strata/dsv41/hip_or_cuda.h
new file mode 100644
index 000000000..c839ce882
--- /dev/null
+++ b/include/strata/dsv41/hip_or_cuda.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2026 Peasant Smith and the Project Maya contributors (MIT; https://github.com/mw00/project-maya, v1.1.17).
+// Ported into Strata (third_party/project-maya/NOTICE.md, LICENSE); changes are in the git history of this file.
+// include/strata/dsv41/hip_or_cuda.h - the runtime the dsv41 *tests* need, whichever backend the build has.
+//
+// The engine's own sources take their runtime from the backend's headers (ds4_*.cu compile as HIP or as CUDA). The tests
+// are plain .cpp files that launch kernels and copy buffers, and they used to include <hip/hip_runtime.h> unconditionally,
+// which no CUDA toolkit ships: every CUDA box had to pass a shim on -I to build them (found on l620 and z440, 2026-10-23).
+// This header is that shim, in the tree: HIP names on a HIP build, mapped onto the CUDA runtime otherwise.
+#pragma once
+
+#if defined(__HIP_PLATFORM_AMD__) || defined(__HIPCC__)
+#include <hip/hip_runtime.h>
+#else
+#include <cuda_runtime.h>
+
+using hipError_t = cudaError_t;
+using hipEvent_t = cudaEvent_t;
+using hipStream_t = cudaStream_t;
+constexpr hipError_t hipSuccess = cudaSuccess;
+constexpr int hipMemcpyHostToDevice = cudaMemcpyHostToDevice;
+constexpr int hipMemcpyDeviceToHost = cudaMemcpyDeviceToHost;
+
+inline hipError_t hipMalloc(void** p, size_t n) { return cudaMalloc(p, n); }
+inline hipError_t hipFree(void* p) { return cudaFree(p); }
+inline hipError_t hipMemcpy(void* dst, const void* src, size_t n, int kind) {
+ return cudaMemcpy(dst, src, n, static_cast<cudaMemcpyKind>(kind));
+}
+inline hipError_t hipDeviceSynchronize() { return cudaDeviceSynchronize(); }
+inline const char* hipGetErrorString(hipError_t e) { return cudaGetErrorString(e); }
+inline hipError_t hipEventCreate(hipEvent_t* e) { return cudaEventCreate(e); }
+inline hipError_t hipEventRecord(hipEvent_t e, hipStream_t s = nullptr) { return cudaEventRecord(e, s); }
+inline hipError_t hipEventSynchronize(hipEvent_t e) { return cudaEventSynchronize(e); }
+inline hipError_t hipEventElapsedTime(float* ms, hipEvent_t a, hipEvent_t b) { return cudaEventElapsedTime(ms, a, b); }
+#endif
diff --git a/tests/dsv41/iq_expert_test.cpp b/tests/dsv41/iq_expert_test.cpp
index 8804d30d2..7b8246e84 100644
--- a/tests/dsv41/iq_expert_test.cpp
+++ b/tests/dsv41/iq_expert_test.cpp
@@ -7,7 +7,7 @@
#include "../../src/dsv41/ds4_gguf_cpu.hpp"
#include "../../src/dsv41/ds4_iq.cuh"
-#include <hip/hip_runtime.h>
+#include "strata/dsv41/hip_or_cuda.h" // HIP names on a HIP build, the CUDA runtime otherwise
#include "ggml.h" // ggml_get_type_traits(type)->to_float: ggml's decode of the same blocks
diff --git a/tests/dsv41/tq_expert_test.cpp b/tests/dsv41/tq_expert_test.cpp
index eb8ccb718..b19ac5e04 100644
--- a/tests/dsv41/tq_expert_test.cpp
+++ b/tests/dsv41/tq_expert_test.cpp
@@ -7,7 +7,7 @@
#include "../../src/dsv41/ds4_iq.cuh"
#include "../../tools/trellis/tqenc.hpp"
-#include <hip/hip_runtime.h>
+#include "strata/dsv41/hip_or_cuda.h" // HIP names on a HIP build, the CUDA runtime otherwise
#include <algorithm>
#include <cmath>
diff --git a/tools/dsv41/engram_fold.py b/tools/dsv41/engram_fold.py
index 765a5580d..a647e7ed5 100644
--- a/tools/dsv41/engram_fold.py
+++ b/tools/dsv41/engram_fold.py
@@ -84,7 +84,8 @@ def dequant(g, t) -> np.ndarray:
name, typ, dims, off = t
tname = pack_gguf.TYPES[typ][0]
nb = nbytes(typ, dims)
- raw = np.fromfile(g.path, dtype=np.uint8, count=nb, offset=off)
+ # Gguf's tensor offsets are relative to the shard's data section; pack_gguf adds data_start when it writes a pack
+ raw = np.fromfile(g.path, dtype=np.uint8, count=nb, offset=g.data_start + off)
if tname == "Q5_K":
return dequant_q5k(raw, nb // 176).astype(np.float64)
if tname == "Q4_K":