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++
conversation snapshot/checkpoint copies: private non-blocking stream instead of the legacy stream (HIP capture conflict)
Niko1221a6346cdceaef
diff --git a/src/core/conversation_copy.hpp b/src/core/conversation_copy.hppnew file mode 100644index 000000000..e15b1197b--- /dev/null+++ b/src/core/conversation_copy.hpp@@ -0,0 +1,32 @@+#pragma once++#include <cuda_runtime.h>++#include <cstddef>+#include <vector>++namespace strata::core::conversation_detail {++/// Conversation snapshot / checkpoint copies go through a private non-blocking stream of the current device+/// instead of the legacy (null) stream. A plain cudaMemcpy is ordered against every blocking stream of the+/// device, and while another thread captures a graph on one (a drafter or a stage worker), HIP refuses it with+/// "operation would make the legacy stream depend on a capturing blocking stream". The caller's contract is+/// unchanged: the device was synchronized before the copy (the copy itself is complete on return).+inline cudaError_t copy_nonblocking(void* dst, const void* src, size_t bytes) {+ int dev = 0;+ cudaError_t e = cudaGetDevice(&dev);+ if (e != cudaSuccess) return e;+ thread_local std::vector<cudaStream_t> streams;+ if (dev < 0) dev = 0;+ if ((size_t) dev >= streams.size()) streams.resize((size_t) dev + 1, nullptr); // never destroyed: process lifetime+ if (!streams[(size_t) dev]) {+ e = cudaStreamCreateWithFlags(&streams[(size_t) dev], cudaStreamNonBlocking);+ if (e != cudaSuccess) { streams[(size_t) dev] = nullptr; return e; }+ }+ cudaStream_t s = streams[(size_t) dev];+ e = cudaMemcpyAsync(dst, src, bytes, cudaMemcpyDefault, s);+ if (e != cudaSuccess) return e;+ return cudaStreamSynchronize(s);+}++} // namespace strata::core::conversation_detaildiff --git a/src/core/conversation_snapshot.cpp b/src/core/conversation_snapshot.cppindex 0ae736291..1468dc652 100644--- a/src/core/conversation_snapshot.cpp+++ b/src/core/conversation_snapshot.cpp@@ -1,6 +1,7 @@#include "strata/core/conversation_snapshot.hpp"#include "strata/kernels/kv_q4.hpp"#include "conversation_checked.hpp"+#include "conversation_copy.hpp"#include <cuda_runtime.h>#include <array>@@ -113,7 +114,7 @@ bool transfer(void* dst, const void* src, size_t n, std::string& error) {if (!n) return true;if (!src || !dst) { error = "conversation snapshot: missing state buffer"; return false; }// Default handles both device allocations and device-mapped host pool aliases.- const cudaError_t e = cudaMemcpy(dst, src, n, cudaMemcpyDefault);+ const cudaError_t e = conversation_detail::copy_nonblocking(dst, src, n);if (e == cudaSuccess) return true;error = std::string("conversation snapshot copy: ") + cudaGetErrorString(e);return false;diff --git a/src/core/conversation_state.cpp b/src/core/conversation_state.cppindex ae40f3ac8..9c2342f84 100644--- a/src/core/conversation_state.cpp+++ b/src/core/conversation_state.cpp@@ -1,5 +1,6 @@#include "strata/core/conversation_snapshot.hpp"#include "conversation_checked.hpp"+#include "conversation_copy.hpp"#include <algorithm>#include <array>@@ -32,7 +33,7 @@ bool sync(std::string& error) {bool copy(void* dst, const void* src, size_t bytes, std::string& error) {if (!bytes) return true;if (!dst || !src) return fail(error, "missing running-state buffer");- const auto status = cudaMemcpy(dst, src, bytes, cudaMemcpyDefault);+ const auto status = conversation_detail::copy_nonblocking(dst, src, bytes);if (status == cudaSuccess) return true;error = std::string("conversation snapshot running-state copy: ") + cudaGetErrorString(status);return false;@@ -174,6 +175,7 @@ bool conversation_checkpoint_restore(const ConversationCheckpoint& c, SessionStaif (!conversation_checkpoint_validate(c, ss, g, error)) return false;ConversationStateSizes z;if (!conversation_session_sizes(g, ss, z, error)) return false;+ if (!sync(error)) return false; // the copies below no longer ride the legacy stream's implicit orderingif (!copy(ss.gdn_state, c.gdn.data(), c.gdn.size(), error) ||!copy(ss.ple_hist, c.ple.data(), c.ple.size(), error)) return false;for (size_t j = 0; j < owned_qsa(ss); ++j) {