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 copy engine: the stager's issued-flag is a copy, not a fill kernel (a copy-only command list runs no kernel: the driver aborted the lent-slot prompt of the 128K config)

Niko1221cd5660593e50
diff --git a/sycl/include/strata/copy_queue.hpp b/sycl/include/strata/copy_queue.hpp
index 9223053b0..138298b87 100644
--- a/sycl/include/strata/copy_queue.hpp
+++ b/sycl/include/strata/copy_queue.hpp
@@ -21,4 +21,6 @@ namespace strata {
sycl::queue* make_copy_engine_queue(const char* what);
/// true once a copy-engine queue has been made in this process
bool copy_engine_active();
+/// true for the queue make_copy_engine_queue() returned: it runs copies and barriers only, no kernel (not even queue::fill)
+bool is_copy_engine_queue(const sycl::queue* q);
} // namespace strata
diff --git a/sycl/src/core/copy_queue.cpp b/sycl/src/core/copy_queue.cpp
index e292996da..4416ca16d 100644
--- a/sycl/src/core/copy_queue.cpp
+++ b/sycl/src/core/copy_queue.cpp
@@ -55,6 +55,9 @@ bool load_ze(ZeFns& f) {
bool copy_engine_active() { return g_active.load(); }
+namespace { std::atomic<const sycl::queue*> g_copy_q{nullptr}; }
+bool is_copy_engine_queue(const sycl::queue* q) { return q != nullptr && q == g_copy_q.load(); }
+
sycl::queue* make_copy_engine_queue(const char* what) {
static const bool off = [] { const char* v = std::getenv("STRATA_COPY_ENGINE"); return v && v[0] == '0'; }();
if (off) return nullptr;
@@ -105,6 +108,7 @@ sycl::queue* make_copy_engine_queue(const char* what) {
sycl::property_list{sycl::property::queue::in_order{}});
auto* q = new sycl::queue(sycl::make_queue<sycl::backend::ext_oneapi_level_zero>(in, ctx));
made = q;
+ g_copy_q.store(q);
g_active.store(true);
static std::atomic<bool> said{false};
if (!said.exchange(true))
diff --git a/sycl/src/prefill/prefill.cpp b/sycl/src/prefill/prefill.cpp
index a34f8b931..93bde7dd2 100644
--- a/sycl/src/prefill/prefill.cpp
+++ b/sycl/src/prefill/prefill.cpp
@@ -362,6 +362,7 @@ struct Stager {
std::vector<std::vector<uint8_t>> pageable; // the fallback when no more RAM can be pinned
std::vector<dpct::event_ptr> dma_done;
uint64_t* done_seq = nullptr; // page-locked: the copy queue's last finished DMA per buffer
+ uint64_t* src_seq = nullptr; // page-locked: the values a copy-engine queue copies into done_seq (it cannot run a fill kernel)
std::vector<uint64_t> want; // the sequence number each buffer's last DMA writes
uint64_t issue_seq = 0;
std::vector<Job> jobs;
@@ -387,6 +388,9 @@ struct Stager {
done_seq = sycl::malloc_host<uint64_t>((size_t) kRing, dpct::get_in_order_queue());
if (done_seq == nullptr) return false;
for (int i = 0; i < kRing; ++i) done_seq[i] = 0;
+ src_seq = sycl::malloc_host<uint64_t>((size_t) 4 * kRing, dpct::get_in_order_queue());
+ if (src_seq == nullptr) return false;
+ for (int i = 0; i < 4 * kRing; ++i) src_seq[i] = 0;
pageable.resize(kRing);
for (int i = 0; i < kRing; ++i) {
/*
@@ -419,6 +423,7 @@ struct Stager {
cv.notify_all();
for (auto& t : threads) t.join();
if (done_seq) sycl::free(done_seq, dpct::get_in_order_queue());
+ if (src_seq) sycl::free(src_seq, dpct::get_in_order_queue());
for (int i = 0; i < kRing; ++i) {
if (dma_done[i]) dpct::destroy_event(dma_done[i]);
if (buf[i] && pinned[i])
@@ -505,7 +510,13 @@ struct Stager {
void issued_one(int j, dpct::queue_ptr copy) {
const uint64_t s = ++issue_seq;
want[(size_t) (j % kRing)] = s;
- copy->fill<uint64_t>(done_seq + j % kRing, s, 1);
+ if (strata::is_copy_engine_queue(copy)) { // a copy-only command list runs no kernels (a fill is one): a copy of the value
+ uint64_t* v = src_seq + (size_t) (s % (uint64_t) (4 * kRing));
+ *v = s;
+ copy->memcpy(done_seq + j % kRing, v, sizeof(uint64_t));
+ } else {
+ copy->fill<uint64_t>(done_seq + j % kRing, s, 1);
+ }
issued.store(j + 1, std::memory_order_release);
}
bool buffer_free(int b) const {