diff --git a/docs/DETAILS.md b/docs/DETAILS.md index 65e486db..22b30ef3 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -635,6 +635,10 @@ reading after it instead of from token 0. A prompt read from the start is also c prompt when that is 2,048 tokens or more (engine 0.1.20; PR #62 + #65), so that root exists for agent clients with long system prompts and tool lists. Engine options: `--prompt-cache N` (0 = off), `--prompt-cache-every N`, `--prompt-cache-root N` (0 = no system-prompt checkpoint), `--turn-token ID`. +A one-shot request that no later request continues (a classification call, a probe) can send +`"strata_checkpoint": false` in its body: it then saves no checkpoint at its last turn and reads its prompt in one +part, which skips work nothing would reuse. It still starts from a checkpoint it matches, and the system-prompt root +is still taken. Without the field (or with `true`) nothing changes. **Multiple conversations (opt-in).** Add `--conversation-cache-mib 8192 --conversation-cache-slots 4` to the engine arguments to park up to four conversations diff --git a/serve/server.py b/serve/server.py index 1cdafd82..00841fcf 100644 --- a/serve/server.py +++ b/serve/server.py @@ -716,6 +716,10 @@ class StrataEngine: v = tune.get(k) if isinstance(v, (int, float)) and not isinstance(v, bool) and 0.0 <= float(v) <= 1.0: keys += f" {k}={float(v)!r}" + # "strata_checkpoint": false - a one-shot call (a classification, a probe) whose turn no later request + # extends: no conversation checkpoint at its end (#830). It still reuses a cached prefix. Absent = today's. + if sampling.get("strata_checkpoint") is False: + keys += " ckpt=0" return keys + StrataEngine.projection_key(sampling) @staticmethod diff --git a/serve/test_server.py b/serve/test_server.py index c868d2bd..133db7d3 100644 --- a/serve/test_server.py +++ b/serve/test_server.py @@ -1070,6 +1070,11 @@ class SamplingKeys(unittest.TestCase): bad = self.keys(strata_tune={"pcie_frac": 3, "spec_min_p": True, "pool_workers": 2}) self.assertFalse([x for x in bad if x.split("=")[0] in ("pcie_frac", "spec_min_p", "pool_workers")]) + def test_checkpoint_key(self): + self.assertIn("ckpt=0", self.keys(temperature=0, strata_checkpoint=False)) + for absent in ({}, {"strata_checkpoint": True}, {"strata_checkpoint": 0}, {"cache_prompt": False}): + self.assertNotIn("ckpt=0", self.keys(**absent), absent) + def test_penalty_window(self): self.assertIn("penalty_last_n=64", self.keys(presence_penalty=1.5)) self.assertIn("penalty_last_n=4096", self.keys(repetition_penalty=1.1, penalty_last_n=4096)) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index c30713cf..e013cefa 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -6316,6 +6316,10 @@ int main(int argc, char** argv) { 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; int req_cvec = 1; // cvec=0|1: a loaded control vector for this request (on when absent) + // ckpt=0: a one-shot call whose turn no later request extends. It reads its prompt in one part and saves + // no checkpoint at the last turn boundary (nor the periodic ones of a long prompt); it still resumes from + // a checkpoint it matches, and still saves the root of a long enough system prompt. Absent = today's. + int req_ckpt = 1; // tuning keys (setup's calibration measures settings without restarting the engine): the PCIe share of // the missed experts and the draft-probability floor, for this request only double req_pcie_frac = o.pcie_frac, req_spec_min_p = o.spec_min_p; @@ -6332,6 +6336,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 == "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 == "temperature") req_temperature = fv; else if (key == "top_p") req_top_p = fv; else if (key == "top_k") req_top_k = std::atoi(tok.c_str() + eq + 1); @@ -6720,7 +6725,7 @@ int main(int argc, char** argv) { pp_from = read_from; pp_reached = read_from; pp_t0 = r0; - pp_next_check = reread_to > 0 ? INT64_MAX : resume + o.prompt_cache_every; + pp_next_check = reread_to > 0 || !req_ckpt ? INT64_MAX : resume + o.prompt_cache_every; // ckpt=0: none { std::lock_guard lk(part_mu); part_at.clear(); @@ -7047,9 +7052,11 @@ int main(int argc, char** argv) { // which the retention policy pins (conv_cache.hpp), so the next new chat reads only what comes after it. // (PR #65, code-martin.) Only for a system prompt of --prompt-cache-root tokens or more: a small one // is cheaper to read again than the extra part costs (~0.3 s). + const int64_t last_turn = turn_at; // ckpt=0 drops the split there, the root is still looked for before it + if (!req_ckpt) turn_at = -1; int64_t root_at = -1; if (o.prompt_cache > 0 && o.turn_token >= 0 && o.prompt_cache_root > 0 && (read_from == 0 || resumed_from0)) - for (int64_t i = 1; i < turn_at; ++i) + for (int64_t i = 1; i < last_turn; ++i) if (ids[(size_t) i] == o.turn_token) { if (i >= o.prompt_cache_root) root_at = i; break;