mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
serve: the #4677 stop bound on every backend, not only HIP
serve_stop_bound() caps the accepted rows a decode window commits at the rows the request can still emit (max_new) and at the first EOS, so the conversation the session keeps is exactly what the client got and the next continuation reuses it instead of falling back to the older checkpoint. It was compiled for HIP only, where it was measured (4 x R9700: 4 of 16 continuations fell back without it, 0 of 16 with it). It changes no emitted token; on CUDA it now applies too. STRATA_SERVE_STOP_BOUND=0 still turns it off (serve_stop_bound_on(), tested in serve_stop_bound_test). Host code only (generate.cpp is compiled as C++). The register entry's backend is now cuda-hip. Part of lane AGENT-TURN (P1); the thinking-budget hold (P2) needs the bound on every backend.
This commit is contained in:
1 parent
9bef5255df
commit
7d4f78242c
4 files changed
+20
-17
No files matched your search
@@ -35468,13 +35468,13 @@
|
||||
{
|
||||
"name": "STRATA_SERVE_STOP_BOUND",
|
||||
"backends": [
|
||||
"hip"
|
||||
"cuda-hip"
|
||||
],
|
||||
"reads": [
|
||||
{
|
||||
"file": "src/program/generate.cpp",
|
||||
"line": 18141,
|
||||
"backend": "hip",
|
||||
"line": 18199,
|
||||
"backend": "cuda-hip",
|
||||
"fn": "getenv"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace strata::core {
|
||||
// A committed input row must correspond to an output the caller can expose.
|
||||
@@ -12,4 +13,11 @@ int serve_stop_bound(int accepted, int64_t remaining, const Token* outputs, IsEo
|
||||
if (is_eos(outputs[i])) return i + 1;
|
||||
return count;
|
||||
}
|
||||
|
||||
// #4677: the bound is on by default on every backend; STRATA_SERVE_STOP_BOUND=0 (the variable's value, passed in)
|
||||
// turns it off. It only limits which accepted rows enter the cached conversation: the tokens a request emits are the
|
||||
// same either way.
|
||||
inline bool serve_stop_bound_on(const char* env_value) {
|
||||
return env_value == nullptr || std::strcmp(env_value, "0") != 0;
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,7 @@
|
||||
#include "strata/core/expert_nibble.hpp"
|
||||
#include "strata/core/conversation_snapshot.hpp"
|
||||
#include "strata/core/lookup_default.hpp"
|
||||
#if defined(STRATA_USE_HIP)
|
||||
#include "strata/core/serve_stop_bound.hpp"
|
||||
#endif
|
||||
#include "strata/core/conversation_file.hpp"
|
||||
#include "strata/core/session_save_reclaim.hpp"
|
||||
#include "strata/core/conversation_memory.hpp"
|
||||
@@ -18195,14 +18193,10 @@ int main(int argc, char** argv) {
|
||||
if (fol_next < fol_sets.size() && !fol_sets[fol_next].empty()) fol = &fol_sets[fol_next];
|
||||
++fol_next;
|
||||
}
|
||||
#if defined(STRATA_USE_HIP)
|
||||
// on by default (HIP, where it was measured: 4 x R9700, Qwen3.8-Flash-Next IQ3_S, 0 of 16 continuations fell back to the older
|
||||
// checkpoint against 4 of 16 without it, #4677); STRATA_SERVE_STOP_BOUND=0 turns it off
|
||||
static const bool stop_bound = [] {
|
||||
const char* v = std::getenv("STRATA_SERVE_STOP_BOUND");
|
||||
return v == nullptr || std::strcmp(v, "0") != 0;
|
||||
}();
|
||||
#endif
|
||||
// on by default on every backend (measured on HIP: 4 x R9700, Qwen3.8-Flash-Next IQ3_S, 0 of 16 continuations fell back to
|
||||
// the older checkpoint against 4 of 16 without it, #4677; it changes no emitted token, only which accepted rows the
|
||||
// session keeps); STRATA_SERVE_STOP_BOUND=0 turns it off
|
||||
static const bool stop_bound = strata::core::serve_stop_bound_on(std::getenv("STRATA_SERVE_STOP_BOUND"));
|
||||
int64_t chain_windows = 0, chain_drafts = 0, chain_ok = 0; // --lookup-chain's own counts
|
||||
int64_t t2_rej[8] = {}, t2_hit[8] = {}; // STRATA_MTP_TOP2: rejections inside the MTP drafts by depth, runner-up hits
|
||||
int64_t dp_tested[8] = {}, dp_ok[8] = {}; // STRATA_SPEC_DEPTH=1: MTP drafts tested / accepted by depth
|
||||
@@ -18758,12 +18752,10 @@ int main(int argc, char** argv) {
|
||||
chain_kind = 0;
|
||||
int a = 0;
|
||||
while (a < A.T - 1 && A.tok[a + 1] == outp[(size_t) a]) ++a;
|
||||
#if defined(STRATA_USE_HIP)
|
||||
if (stop_bound)
|
||||
a = strata::core::serve_stop_bound(a + 1, max_new - produced_n, outp.data(), [&](int32_t y) {
|
||||
return std::find(o.eos_ids.begin(), o.eos_ids.end(), (int64_t) y) != o.eos_ids.end();
|
||||
}) - 1;
|
||||
#endif
|
||||
if (!V1(A).pl_commit_async(a + 1, err)) return die(err);
|
||||
for (int i = 0; i <= a; ++i) consumed.push_back(A.tok[i]);
|
||||
draft_offered += A.T - 1;
|
||||
@@ -19300,14 +19292,12 @@ int main(int argc, char** argv) {
|
||||
if (!ver.window_logprobs(fol_tg.data(), a + 1, p, 248046, fol_lp, fe))
|
||||
std::fprintf(stderr, "strata serve: STRATA_FOLLOW_LOGPOS: %s\n", fe.c_str());
|
||||
}
|
||||
#if defined(STRATA_USE_HIP)
|
||||
// A merged window contains prompt rows: every one must still be committed.
|
||||
// Otherwise do not cache accepted rows whose outputs this request cannot emit.
|
||||
if (stop_bound && !merged)
|
||||
a = strata::core::serve_stop_bound(a + 1, max_new - produced_n, outv.data(), [&](int32_t y) {
|
||||
return std::find(o.eos_ids.begin(), o.eos_ids.end(), (int64_t) y) != o.eos_ids.end();
|
||||
}) - 1;
|
||||
#endif
|
||||
if (from_sfx) { ++sfx_windows; sfx_drafts += T - 1; sfx_ok += a; }
|
||||
if (chain_n > 0) { ++chain_windows; chain_drafts += chain_n; chain_ok += std::max(0, a - (T_mtp - 1)); }
|
||||
if (!from_sfx && !first_window)
|
||||
|
||||
@@ -27,5 +27,10 @@ int main() {
|
||||
++cases;
|
||||
}
|
||||
assert(strata::core::serve_stop_bound(4, 0, static_cast<const int*>(nullptr), [](int) { return false; }) == 0);
|
||||
// on unless the variable is exactly "0" (every backend, since the bound left HIP-only)
|
||||
assert(strata::core::serve_stop_bound_on(nullptr));
|
||||
assert(strata::core::serve_stop_bound_on("1"));
|
||||
assert(strata::core::serve_stop_bound_on(""));
|
||||
assert(!strata::core::serve_stop_bound_on("0"));
|
||||
std::cout << "SUMMARY stop_bound cases=" << cases << " passed\n";
|
||||
}
|
||||
Reference in new issue
Block a user