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

sycl engine: the device waits long enough for the host on an A-series card (first request after a start gave token 0 or crashed the CPU pool), STRATA_VERIFY_NO_HOST=0 means off, version follows the project, no CUDA-runtime warning, no FIXME placeholder in the verify lines; build.sh is executable and takes SPIN_MAX

Niko1221013015934a5e
diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt
index 37c5d0f6c..4d79be350 100644
--- a/sycl/CMakeLists.txt
+++ b/sycl/CMakeLists.txt
@@ -10,7 +10,15 @@
#
# Device code is JIT-compiled from SPIR-V unless STRATA_SYCL_AOT names a device (bmg-g31 for the Arc Pro B70).
cmake_minimum_required(VERSION 3.24)
-project(strata_sycl VERSION 0.1.40 LANGUAGES C CXX) # the upstream engine version this port tracks
+# the engine's version is the project's (../CMakeLists.txt): the log line and BUILD.json say 0.1.40.2, not a number of the port's own
+file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt _strata_proj REGEX "^project\\(strata VERSION [0-9.]+")
+string(REGEX MATCH "VERSION ([0-9.]+)" _m "${_strata_proj}")
+if(CMAKE_MATCH_1)
+ set(STRATA_SYCL_VERSION ${CMAKE_MATCH_1})
+else()
+ set(STRATA_SYCL_VERSION 0.1.40.2)
+endif()
+project(strata_sycl VERSION ${STRATA_SYCL_VERSION} LANGUAGES C CXX)
set(STRATA_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -18,9 +26,20 @@ set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
-add_compile_definitions(STRATA_VERSION="${PROJECT_VERSION}-sycl")
+add_compile_definitions(STRATA_VERSION="${PROJECT_VERSION}")
set(STRATA_SYCL_AOT "" CACHE STRING "AOT device for the GPU code, e.g. bmg-g31 (empty: SPIR-V, JIT at run time)")
+# The device spins on host flags are bounded (include/strata/sycl_doorbell.hpp). The B-series keeps 20,000 reads; any
+# other build - the A-series JIT build - waits up to 2,000,000, which the host's per-layer CPU expert work needs there.
+set(STRATA_SYCL_SPIN_MAX "" CACHE STRING "bound of the device's spins on host flags, in reads (empty: 20000 for a bmg AOT build, else 2000000)")
+if(NOT STRATA_SYCL_SPIN_MAX)
+ if(STRATA_SYCL_AOT MATCHES "^bmg")
+ set(STRATA_SYCL_SPIN_MAX 20000)
+ else()
+ set(STRATA_SYCL_SPIN_MAX 2000000)
+ endif()
+endif()
+add_compile_definitions(STRATA_SYCL_SPIN_MAX=${STRATA_SYCL_SPIN_MAX}u)
set(_sycl_flags -fsycl)
if(STRATA_SYCL_AOT)
list(APPEND _sycl_flags -fsycl-targets=spir64_gen)
diff --git a/sycl/include/dpct/dpct.hpp b/sycl/include/dpct/dpct.hpp
index 6318e88cb..3ebb11727 100644
--- a/sycl/include/dpct/dpct.hpp
+++ b/sycl/include/dpct/dpct.hpp
@@ -83,9 +83,7 @@ enum error_code { success = 0, default_error = 999 };
/// The migration tool user should replace it with a real error-handling function.
/// SYCL reports errors using exceptions and does not use error codes.
inline const char *get_error_string_dummy(int ec) {
- (void)ec;
- return "<FIXME: Placeholder>"; // Return the error string for the error code
- // ec.
+ return ec == 0 ? "no error" : "error"; // SYCL has no error codes: DPCT_CHECK_ERROR yields 0 on success
}
} // namespace dpct
diff --git a/sycl/include/strata/sycl_doorbell.hpp b/sycl/include/strata/sycl_doorbell.hpp
index 0690c7345..574e3017a 100644
--- a/sycl/include/strata/sycl_doorbell.hpp
+++ b/sycl/include/strata/sycl_doorbell.hpp
@@ -43,5 +43,14 @@ inline void sys_store(volatile uint32_t* p, uint32_t v) {
// xe driver times the queue out, resets the GT node by node (a window graph has 2,366 of them), and the card
// stays wedged until a reboot - measured twice. With a bound the failure is a wrong window instead, which the
// verifier's checks catch. ~2 M host-memory reads is a few seconds at PCIe latency.
-inline constexpr uint32_t kSpinMax = 20u * 1000u; // experiment: 100x smaller
+// The bound is the build's (CMake STRATA_SYCL_SPIN_MAX): 20,000 reads for the B-series (bmg) AOT builds, whose
+// device-plan windows only spin in a failure and where a longer spin is what makes the xe driver reset the GT; 2,000,000
+// (a few seconds) elsewhere. On an Arc A-series (i915) the CPU computes the experts the card does not hold and the GPU
+// waits for it at every layer: 20,000 reads is a few tens of milliseconds, the first request after a start (cold pages,
+// slow CPU layers) is slower than that, the GPU gave up, went on with the experts' outputs missing, and the answer was
+// token 0 ("!!!!!") or the engine crashed in the CPU pool on the garbage routing it read next.
+#ifndef STRATA_SYCL_SPIN_MAX
+#define STRATA_SYCL_SPIN_MAX 20000u
+#endif
+inline constexpr uint32_t kSpinMax = STRATA_SYCL_SPIN_MAX;
} // namespace strata
diff --git a/sycl/src/core/verify.cpp b/sycl/src/core/verify.cpp
index 9d26b8804..bae8ecb39 100644
--- a/sycl/src/core/verify.cpp
+++ b/sycl/src/core/verify.cpp
@@ -1938,7 +1938,7 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,
// memory are not reliably visible while the graph runs (measured: the ring is seen late or not at all),
// so waiting on them per layer fails. STRATA_VERIFY_NO_HOST=1 waits for the whole window instead. Only for
// an all-resident cache: a missed expert would leave the GPU waiting for a plan that never comes.
- static const bool no_host = std::getenv("STRATA_VERIFY_NO_HOST") != nullptr;
+ static const bool no_host = [] { const char* v = std::getenv("STRATA_VERIFY_NO_HOST"); return v && *v && std::strcmp(v, "0") != 0; }();
const int64_t steps = (le_ - lb_) * G;
const bool test_stall = g_test_stall > 0 && windows + 1 == g_test_stall; // #267 test hook (off: false)
if (ar_on() && !test_stall) {
diff --git a/sycl/src/program/generate.cpp b/sycl/src/program/generate.cpp
index 17cb29957..d714f8c91 100644
--- a/sycl/src/program/generate.cpp
+++ b/sycl/src/program/generate.cpp
@@ -4021,6 +4021,7 @@ int main(int argc, char **argv) try {
strata::emulated_cc()
? " (STRATA_EMULATE_CC: a test mode, the card is emulated)"
: "");
+#if 0 // the SYCL port has no CUDA runtime to mismatch (#542): dpct::get_major_version is the device version
#if !defined(STRATA_HIP_GFX906) // a CUDA toolkit mismatch; the gfx906 HIP build
// has no DPCT_COMPAT_RT_VERSION
{ // #542: a build whose libcudart is older than its headers (a CUDA 13 kit with a dangling libcudart.so that
@@ -4047,6 +4048,7 @@ int main(int argc, char **argv) try {
rt % 1000 / 10);
}
#endif
+#endif // #if 0
#endif
const std::string e = strata::core::device_code_error();
if (!e.empty()) {
@@ -4727,7 +4729,7 @@ int main(int argc, char **argv) try {
}
unmirrored_misses = (int64_t) miss.size() - (int64_t) (gguf_src.mirrored_bytes() ? std::count_if(miss.begin(), miss.end(),
[&](const std::pair<int64_t, int64_t>& pr) { return gguf_src.pinned(pr.first, pr.second); }) : 0);
- if (unmirrored_misses > 0 && std::getenv("STRATA_VERIFY_NO_HOST") != nullptr) {
+ if (unmirrored_misses > 0 && [] { const char* v = std::getenv("STRATA_VERIFY_NO_HOST"); return v && *v && std::strcmp(v, "0") != 0; }()) {
std::fprintf(stderr, "strata generate: REFUSED: %lld experts are neither in VRAM nor mirrored; with STRATA_VERIFY_NO_HOST "
"the device plan cannot run them and generation would lack a safe host fallback - raise "
"STRATA_MIRROR_MIB or the free RAM, or lower --max-context\n", (long long) unmirrored_misses);
diff --git a/sycl/tools/build.sh b/sycl/tools/build.sh
index ff6455610..5cb3cb58d 100644
--- a/sycl/tools/build.sh
+++ b/sycl/tools/build.sh
@@ -5,7 +5,7 @@ set +u; source /opt/intel/oneapi/setvars.sh >/dev/null 2>&1 || true; set -u
repo=${REPO:-$(git rev-parse --show-toplevel)}
b=${BUILD_DIR:-$repo/build-sycl}
[ -f $b/build.ninja ] || cmake -S $repo/sycl -B $b -G Ninja -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx \
- -DSTRATA_SYCL_AOT="${AOT:-}" 2>&1 | tail -15
+ -DSTRATA_SYCL_AOT="${AOT:-}" -DSTRATA_SYCL_SPIN_MAX="${SPIN_MAX:-}" 2>&1 | tail -15
cmake --build $b -j ${JOBS:-12} ${1:+--target "$@"} -- -k 0 2>&1 | tee $b/build.log | grep -E '^FAILED|error:|^ninja: build stopped|Linking|^\[[0-9]+/[0-9]+\] Linking' | tail -40
echo "BUILD EXIT ${PIPESTATUS[0]}"
grep -c 'error:' $b/build.log | sed 's/^/errors: /'