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: STRATA_BATCH_SELF_COMMIT=1 lets a one-row-per-slot batch window keep its rows itself
havok2-htwo69a05bfb591d
diff --git a/src/core/verify.cpp b/src/core/verify.cppindex f45bf8267..a4a8f3529 100644--- a/src/core/verify.cpp+++ b/src/core/verify.cpp@@ -200,6 +200,21 @@ const bool g_doorbell_store = env_on("STRATA_DOORBELL_STORE");const bool g_trace = env_on("STRATA_VERIFY_TRACE");const bool g_no_multi_gr = env_on("STRATA_NO_MULTI_GR"); // #783 PR-g: per-token GR reads/writes and generic-T kernels againconst bool g_no_batch_kv = env_on("STRATA_NO_BATCH_KV_STEP"); // #783 PR-d: per-token K/V and indexer appends again+// STRATA_BATCH_SELF_COMMIT=1 (opt-in): a batch window whose rows are each another slot's one token keeps them itself,+// as a one-token window does (record_window): the GDN conv histories and states advance inside the window graph, and+// no commit graph runs after it. Such a window's commit is unconditional (each slot keeps its one row), and the rest+// of the commit graph only repeats what the window wrote: the indexer tails are put back and appended again from the+// same rows, the PLE histories are put back to the window's own snapshot.+const bool g_batch_self_commit = env_on("STRATA_BATCH_SELF_COMMIT");++// every row of a batch window is another slot's (no slot has proposal rows)+bool one_row_per_slot(const int* rows, int S) {+ for (int i = 0; i < S; ++i)+ for (int j = i + 1; j < S; ++j)+ if (rows[i] == rows[j]) return false;+ return S >= 1;+}+bool batch_self_commits(const int* rows, int S) { return g_batch_self_commit && one_row_per_slot(rows, S); }// 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@@ -916,6 +931,8 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {// a batch window: row t is slot t, whose state lives in its own sessionauto slot_ss = [&](int t) -> SessionState& { return batch_rec_ ? *slots_[(size_t) brow_[t]] : ss; };const int hrow0 = batch_rec_ ? row_base_ : 0; // a slot group's own hand-off rows+ // STRATA_BATCH_SELF_COMMIT: the window keeps its rows (no commit graph, nothing to snapshot for one)+ const bool keep_rows = batch_rec_ && batch_self_commits(brow_, T);// ---- the window's inputs, from mapped staging. With branches the steps and positions (first read by the first// layer's mixer) cross PCIe on side 1 beside the embedding and the first hyper-connection read.@@ -1081,7 +1098,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {err = std::string("verify PLE: ") + e.what();return false;}- copy_from_mapped(hist_snap_ + (size_t) t * HS, hist, HS, cs);+ if (!keep_rows) copy_from_mapped(hist_snap_ + (size_t) t * HS, hist, HS, cs);}pending = false;}@@ -1169,7 +1186,8 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {const float* cx = sx.gdn_state + (size_t) (gi - sx.gdn_ord0) * gdn_floats +(uint64_t) g.ssm_state_size * g.ssm_v_heads * g.ssm_state_size;gdn_conv_l2_multi(cx, qkv + (size_t) first * C, (const float*) wc->data,- hb + (size_t) first * C, (int) C, (int) (2 * HK), EPS, t - first, cs, 0);+ hb + (size_t) first * C, (int) C, (int) (2 * HK), EPS, t - first, cs, 0,+ keep_rows);}} else// a one-token window keeps its token: it advances the conv history and the state itself (commit)@@ -1204,7 +1222,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {gdn_step_norm_multi(stx, hb + (size_t) first * C, (int) C, gate + (size_t) first * HV,beta + (size_t) first * HV, z_ + (size_t) first * ZV,(const float*) wnm->data, EPS, y_ + (size_t) first * ZV,- (int) HK, (int) HV, t - first, nullptr, cs, 0);+ (int) HK, (int) HV, t - first, keep_rows ? one_ : nullptr, cs, 0);}} elsegdn_step_norm_multi(state, hb, (int) C, gate, beta, z_, (const float*) wnm->data, EPS, y_, (int) HK,@@ -1289,7 +1307,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {}stamp(l, 8, grp);if (batch_rec_) { // snapshot each slot's indexer tail before its first proposed row- for (int t = tb; t < te; ++t)+ for (int t = tb; t < te && !keep_rows; ++t)if (t == tb || brow_[t] != brow_[t - 1])copy_from_mapped(tail_snap_b_ + ((size_t) brow_[t] * nQall + qi) * TS,slot_ss(t).qsa_states[qi].idx_tail, TS, cs);@@ -2750,8 +2768,8 @@ bool Verifier::init_slots(const std::vector<SessionState*>& slots, std::string&tail_snap_b_ = (float*) ((uint8_t*) d + a);slots_ = slots;slot_sp_.assign(slots.size(), sampling_); // greedy until set_slot_sampling- std::fprintf(stderr, "strata verify: batch windows of up to %lld sequences (layers [%lld, %lld))\n", (long long) S,- (long long) lb_, (long long) le_);+ std::fprintf(stderr, "strata verify: batch windows of up to %lld sequences (layers [%lld, %lld))%s\n", (long long) S,+ (long long) lb_, (long long) le_, g_batch_self_commit ? ", one-row windows keep their rows" : "");return true;}@@ -2788,6 +2806,7 @@ bool Verifier::capture_batch(const int* rows, int S, int hbase, std::string& err}bool Verifier::capture_commit_batch(const int* rows, int S, int hbase, std::string& err) {+ if (batch_self_commits(rows, S)) return true; // the window keeps its rows: no commit graphcudaGraphExec_t& cex = commit_bm_[bkey(rows, S, hbase)];if (cex != nullptr) return true;using namespace strata::kernels;@@ -3148,10 +3167,12 @@ bool Verifier::commit_slot_prefixes(const int* keep, std::string& err) {c[2 + j] = j < n ? (int32_t) last_pos_b_[first + j] : -1;}std::atomic_thread_fence(std::memory_order_seq_cst);- const cudaError_t le = cudaGraphLaunch(commit_bm_[bkey(last_rows_, S, row_base_)], cs_);- if (le != cudaSuccess) { err = std::string("verify: batch commit launch: ") + cudaGetErrorString(le); return false; }- const cudaError_t se = cudaStreamSynchronize(cs_);- if (se != cudaSuccess) { err = std::string("verify: batch commit: ") + cudaGetErrorString(se); return false; }+ if (!batch_self_commits(last_rows_, S)) { // (else the window has kept its rows)+ const cudaError_t le = cudaGraphLaunch(commit_bm_[bkey(last_rows_, S, row_base_)], cs_);+ if (le != cudaSuccess) { err = std::string("verify: batch commit launch: ") + cudaGetErrorString(le); return false; }+ const cudaError_t se = cudaStreamSynchronize(cs_);+ if (se != cudaSuccess) { err = std::string("verify: batch commit: ") + cudaGetErrorString(se); return false; }+ }if (ple_stage())for (int t = 0; t < S;) {const int first = t;@@ -3188,7 +3209,8 @@ bool Verifier::batch_launch(int base, int S, const int32_t* tokens, const int64_for (int t = 0; t < S && t < 8; ++t) rows[t] = base + t;if (!stage_batch(rows, S, base, tokens, pos, err)) return false;cudaError_t le = cudaGraphLaunch(exec_bm_[bkey(rows, S, base)], cs_);- if (le == cudaSuccess) le = cudaGraphLaunch(commit_bm_[bkey(rows, S, base)], cs_); // right behind it: every row is kept+ if (le == cudaSuccess && !batch_self_commits(rows, S)) // (else the window has kept its rows itself)+ le = cudaGraphLaunch(commit_bm_[bkey(rows, S, base)], cs_); // right behind it: every row is keptif (le != cudaSuccess) { err = std::string("verify: batch launch: ") + cudaGetErrorString(le); return false; }(void) cudaStreamQuery(cs_);if (ple_stage()) // the host's side of the commit (the hash's last two tokens)