mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 14:21:06 -10:00
A request that continues an earlier leg (prompt + what it generated: solo -> batch slot, slot -> solo) names where its reply began (pen_from), so the penalty window keeps the earlier reply tokens
This commit is contained in:
1 parent
b509b2fef5
commit
62e861c995
2 files changed
+10
-3
No files matched your search
+5
-2
@@ -2038,6 +2038,7 @@ class StrataEngine:
|
||||
out: list[int] = []
|
||||
pending: list[int] = []
|
||||
prompt, left = list(ids), int(max_new)
|
||||
orig_len = len(prompt) # a leg that continues (prompt + what it generated) names where the reply began: pen_from, the penalty window's start
|
||||
reused0 = None # the first read's reused tokens: a continued leg's count includes this request's own output
|
||||
carry = {} # #1869: the figures of the legs that ended in a hand-back to the solo path (the final DONE adds to them)
|
||||
ok = yield from self._take_control(cancel, len(prompt), new=True,
|
||||
@@ -2065,7 +2066,8 @@ class StrataEngine:
|
||||
with self.slot_cv:
|
||||
alone = not any(self.slot_busy) and self.waiting == 0
|
||||
if alone and left > 1:
|
||||
head = f"GENI {left}{keys} {embeddings}" if embeddings else f"GEN {left}{keys}"
|
||||
pf = f" pen_from={orig_len - 1}" if len(prompt) > orig_len else ""
|
||||
head = f"GENI {left}{keys}{pf} {embeddings}" if embeddings else f"GEN {left}{keys}{pf}"
|
||||
self._last_done = None # (#879: this request's DONE decides below)
|
||||
deadline = getattr(cancel, "_strata_queue_deadline", None)
|
||||
if deadline is not None and time.monotonic() >= deadline:
|
||||
@@ -2193,7 +2195,8 @@ class StrataEngine:
|
||||
holding, born = True, self.gen # (the engine it now has the control lines of)
|
||||
while not self.slot_q[slot].empty():
|
||||
self.slot_q[slot].get_nowait()
|
||||
head = f"BGENI {slot} {left}{keys} {embeddings}" if embeddings else f"BGEN {slot} {left}{keys}"
|
||||
pf = f" pen_from={orig_len - 1}" if len(prompt) > orig_len else ""
|
||||
head = f"BGENI {slot} {left}{keys}{pf} {embeddings}" if embeddings else f"BGEN {slot} {left}{keys}{pf}"
|
||||
live = {"slot": slot, "request_id": getattr(cancel, "_strata_request_id", None),
|
||||
"state": "reading", "prompt_tokens": len(prompt), "prompt_read": 0, "generated": 0,
|
||||
"started": time.time(), "first_token": None}
|
||||
|
||||
@@ -14411,6 +14411,7 @@ int main(int argc, char** argv) {
|
||||
unsigned long long req_seed = 0;
|
||||
float req_min_p = 0.0f, req_penalty_repeat = 1.0f, req_penalty_freq = 0.0f, req_penalty_present = 0.0f;
|
||||
int req_penalty_last_n = 0;
|
||||
long long req_pen_from = -1; // pen_from=N: this request continues one that began at token N (the last token of the original prompt): the penalty window starts there
|
||||
std::string req_bias_text;
|
||||
bool req_bias_present = false;
|
||||
int req_cvec = 1; // cvec=0|1: a loaded control vector for this request (on when absent)
|
||||
@@ -14458,6 +14459,7 @@ int main(int argc, char** argv) {
|
||||
const std::string key = tok.substr(0, eq);
|
||||
const float fv = std::strtof(tok.c_str() + eq + 1, nullptr);
|
||||
if (key == "logit_bias") { req_bias_text = tok.substr(eq + 1); req_bias_present = true; }
|
||||
else if (key == "pen_from") req_pen_from = std::atoll(tok.c_str() + eq + 1);
|
||||
else if (key == "cvec") req_cvec = std::atoi(tok.c_str() + eq + 1);
|
||||
else if (key == "ckpt") req_ckpt = std::atoi(tok.c_str() + eq + 1) != 0;
|
||||
else if (key == "prefill") req_prefill_only = std::atoi(tok.c_str() + eq + 1) != 0;
|
||||
@@ -16743,7 +16745,8 @@ int main(int argc, char** argv) {
|
||||
for (int64_t i = 0; i < p; ++i) consumed.push_back((int32_t) ids[(size_t) i]);
|
||||
// #4590: where the penalty window may start in `consumed` (see pen_prompt above): the end of the prompt without its
|
||||
// last token, which joins the window as the fed-back head `x`.
|
||||
const size_t pen_gen0 = strata::kernels::penalty_window_from(consumed.size(), pen_prompt);
|
||||
size_t pen_gen0 = strata::kernels::penalty_window_from(consumed.size(), pen_prompt);
|
||||
if (req_pen_from >= 0 && !pen_prompt) pen_gen0 = std::min<size_t>(pen_gen0, (size_t) req_pen_from); // a continued request: its reply began earlier
|
||||
const char* finish = "length";
|
||||
const Clock::time_point d0 = Clock::now();
|
||||
// STRATA_DECODE_TIMING=1: where a request's decode time goes (one line per request)
|
||||
@@ -18192,6 +18195,7 @@ int main(int argc, char** argv) {
|
||||
const bool slot_pen = req_sp.penalty_last_n > 0 && (req_sp.penalty_repeat != 1.0f || req_sp.penalty_freq != 0.0f || req_sp.penalty_present != 0.0f);
|
||||
sl.pen_n = slot_pen ? std::min(req_sp.penalty_last_n, kPenaltyWindowCap) : 0;
|
||||
sl.reply0 = (int64_t) strata::kernels::penalty_window_from(live.size() > 0 ? live.size() - 1 : 0, pen_prompt);
|
||||
if (req_pen_from >= 0 && !pen_prompt) sl.reply0 = std::min<int64_t>(sl.reply0, req_pen_from); // a continued request (prompt + what it generated): the reply began earlier
|
||||
}
|
||||
if (batch_mtp) {
|
||||
int nd = 1; // (STRATA_PIPED_MTP: up to its proposals per window, as --spec-min-p allows)
|
||||
|
||||
Reference in new issue
Block a user