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

verify: the shared-expert stream fork starts off on HIP (#816)

pugolini7fd67ddd6dca
diff --git a/src/core/verify.cpp b/src/core/verify.cpp
index d6bd65d03..6a19b3d15 100644
--- a/src/core/verify.cpp
+++ b/src/core/verify.cpp
@@ -89,6 +89,21 @@ const bool g_doorbell_store = env_on("STRATA_DOORBELL_STORE");
#endif
const bool g_trace = env_on("STRATA_VERIFY_TRACE");
+// The shared expert runs on its own stream, forked off and joined back per layer (`sh_fork` in record_window). The
+// overlap pays off on CUDA, where it was added (cfd3b72). On HIP a cross-stream event dependency costs more than the
+// shared expert takes to run, so there the fork starts off: same binary, same 48,067-token prompt, three runs each on a
+// Radeon AI PRO R9700 (gfx1201, ROCm 6.4.3), the fork off decodes at 62.9 t/s against 43.4 t/s with it on. The
+// profiler turns the fork off to time the stages, so a profiled run never showed that. #816 reports the same fall on a
+// gfx1030 (RX 6800, Windows, 42.5 -> 56.4 t/s). STRATA_SH_STREAM overrides either default: `=1` forks, `=0` does not.
+const bool g_sh_stream = [] {
+ if (const char* v = std::getenv("STRATA_SH_STREAM")) return v[0] != '0';
+#if defined(STRATA_USE_HIP)
+ return false;
+#else
+ return true;
+#endif
+}();
+
bool mapped(size_t bytes, void** h, void** d) {
#if defined(STRATA_USE_HIP)
if (g_coherent) {
@@ -976,11 +991,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
}
stamp(l, 16, grp);
const bool q8_ffn = gr_read_group(1, true, inj_, inj2_); // true: nat_xq_ holds the MoE input's q8_1 (STRATA_QFUSE)
- static const bool sh_stream_env = [] {
- const char* e = std::getenv("STRATA_SH_STREAM");
- return !e || e[0] != '0';
- }();
- const bool sh_fork = sh_stream_env && !prof_on_ && sh_cs_ != nullptr && ev_fork_ != nullptr && ev_join_ != nullptr;
+ const bool sh_fork = g_sh_stream && !prof_on_ && sh_cs_ != nullptr && ev_fork_ != nullptr && ev_join_ != nullptr;
cudaStream_t sh_stream = sh_fork ? sh_cs_ : cs;
if (sh_fork) {
cudaEventRecord(ev_fork_, cs);
@@ -1172,7 +1183,9 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
}
moe_hit_add(parts_out, hit_out, p_dst, p_counts + 1, cap, N, cs);
}
- if (!prof_on_ && sh_cs_ != nullptr && ev_fork_ != nullptr && ev_join_ != nullptr) {
+ // Same condition as `sh_fork` above, which is per group and out of scope here: wait only when the fork
+ // actually ran (a wait on an event never recorded is a no-op, but saying it outright reads better).
+ if (g_sh_stream && !prof_on_ && sh_cs_ != nullptr && ev_fork_ != nullptr && ev_join_ != nullptr) {
cudaStreamWaitEvent(cs, ev_join_, 0);
}
if (sg_gated_[grp]) { // STRATA_LFUSE: the shared expert's gate was not applied: the combine applies it (all rows are hits)