DeepSeek-V4.1: slot keep and auto-pin default off (switches STRATA_DS4_SLOT_KEEP=1, STRATA_DS4_AUTO_PIN=1)

This commit is contained in:
Niko1221 committed 2026-10-24 01:39:15 +02:00
1 parent be26cb7995
commit e2361d80d2
3 files changed
+25 -19

No files matched your search

+5 -5
View File
@@ -70,11 +70,11 @@ The server speaks to the engine as it does for the other models, so `/v1/chat/co
server turns them into OpenAI `tool_calls` and Anthropic `tool_use`, including `tool_choice`, streamed arguments and calls written inside the thinking.
A value marked `string="true"` stays a string.
- Defaults when a request names none: temperature 1.0, top_p 1.0.
- Agents and sub-agents that take turns do not read their prompts again. When another request takes the model, the engine sets the
conversation aside (about 17 MB per 6.5K tokens) and takes it back when the next prompt continues it; the system prompt and tools shared by
an agent and its sub-agents are kept as a checkpoint too. Slots survive a restart, live in `ds4-slots` next to the run log, are capped at
2 GB and are removed after a week. `STRATA_DS4_SLOT_KEEP=0` turns it off, `STRATA_DS4_SLOT_GB` changes the cap, `STRATA_DS4_AUTO_PIN=0`
turns off the shared-start checkpoint. The answers are the same as a fresh read of the prompt.
- Agents and sub-agents that take turns can skip reading their prompts again (off in this version, a switch for testing). With
`STRATA_DS4_SLOT_KEEP=1` the engine sets a conversation aside when another request takes the model (about 17 MB per 6.5K tokens) and takes it
back when the next prompt continues it, also after a restart. Slots live in `ds4-slots` next to the run log, are capped at 2 GB
(`STRATA_DS4_SLOT_GB`) and are removed after a week. `STRATA_DS4_AUTO_PIN=1` also keeps the system prompt and tools shared by an agent
and its sub-agents as a checkpoint.
Pictures and the DSpark drafter are in the engine (strata-dsv41 reads them from the unsloth mmproj and dspark files beside the model; the server side is not wired yet). Not in this version: several requests at once (`--parallel` is ignored with a note), tuning
(`--tune` is skipped with a note).
+4 -4
View File
@@ -3477,7 +3477,7 @@ def hip_auto_devices(cfg: dict, env: dict) -> list[int] | None:
return visible
DS41_SLOT_KEEP_DEFAULT = "1" # the engine keeps a displaced conversation in RAM and in the slot folder (see below)
DS41_SLOT_KEEP_DEFAULT = "0" # the engine keeps a displaced conversation in RAM and in the slot folder (see below)
DS41_SLOT_GB_DEFAULT = "2" # the folder's cap in GB (a 6.5K-token conversation is about 17 MB)
@@ -3486,7 +3486,7 @@ def deepseek_slot_env(env: dict, cfg: dict) -> None:
at its checkpoints (agents and sub-agents that take turns do not read their prompts again). STRATA_DS4_SLOT_KEEP
switches it (the default above; a config's env or the shell wins); the folder is `ds4-slots` next to the run log, in
Strata's data folder (STRATA_DS4_SLOT_DIR names another), and the engine caps it (STRATA_DS4_SLOT_GB, 2 here, 16 in the engine) and
removes what is older than a week or not this model's. On by default; STRATA_DS4_SLOT_KEEP=0 turns it off."""
removes what is older than a week or not this model's. Off by default (0.2.4); STRATA_DS4_SLOT_KEEP=1 turns it on."""
env.setdefault("STRATA_DS4_SLOT_KEEP", DS41_SLOT_KEEP_DEFAULT)
env.setdefault("STRATA_DS4_SLOT_GB", DS41_SLOT_GB_DEFAULT)
log = cfg.get("log")
@@ -4926,8 +4926,8 @@ class Service:
"""DeepSeek-V4.1 only: how many leading messages are the system prompt (its tools are rendered with them). An
agent and its sub-agents that work behind the same system prompt and tools share exactly this start, so the
engine keeps a checkpoint of its state there (pin=N): the next agent behind the same start goes back to it
instead of reading it again. 0: none (STRATA_DS4_AUTO_PIN=0, no system message, or nothing after it)."""
if os.environ.get("STRATA_DS4_AUTO_PIN", "1") == "0":
instead of reading it again. 0: none (off unless STRATA_DS4_AUTO_PIN=1, no system message, or nothing after it)."""
if os.environ.get("STRATA_DS4_AUTO_PIN", "0") != "1":
return 0
n = 0
for m in messages:
+16 -10
View File
@@ -530,6 +530,7 @@ class Api(unittest.TestCase):
# -- the shared start of an agent's and its sub-agents' prompts (the engine keeps its state there) ------------
def test_the_system_prompt_and_tools_are_the_shared_start(self):
self.start("ok")
self.auto_pin("1")
sysmsg = {"role": "system", "content": "You are an agent. " * 20}
body = {"messages": [sysmsg, {"role": "user", "content": "task one"}], "tools": [WEATHER], "max_tokens": 40}
self.assertEqual(self.post("/v1/chat/completions", body)[0], 200)
@@ -544,24 +545,29 @@ class Api(unittest.TestCase):
self.assertEqual(self.engine.last_sampling["strata_prefix"]["tokens"], n)
self.assertEqual(self.engine.last_prompt[:n], ids[:n])
def auto_pin(self, value):
old = os.environ.get("STRATA_DS4_AUTO_PIN")
if value is None:
os.environ.pop("STRATA_DS4_AUTO_PIN", None)
else:
os.environ["STRATA_DS4_AUTO_PIN"] = value
self.addCleanup(lambda: os.environ.pop("STRATA_DS4_AUTO_PIN", None) if old is None
else os.environ.__setitem__("STRATA_DS4_AUTO_PIN", old))
def test_no_shared_start_without_a_system_prompt_or_when_switched_off(self):
self.start("ok")
self.auto_pin("1")
self.chat()
self.assertNotIn("strata_prefix", self.engine.last_sampling)
self.assertNotIn("strata_prefix", self.engine.last_sampling) # no system message
body = {"messages": [{"role": "system", "content": "s"}, {"role": "user", "content": "u"}], "max_tokens": 40}
old = os.environ.get("STRATA_DS4_AUTO_PIN")
os.environ["STRATA_DS4_AUTO_PIN"] = "0"
try:
for off in (None, "0"): # off by default, and when switched off
self.auto_pin(off)
self.post("/v1/chat/completions", body)
self.assertNotIn("strata_prefix", self.engine.last_sampling)
finally:
if old is None:
os.environ.pop("STRATA_DS4_AUTO_PIN", None)
else:
os.environ["STRATA_DS4_AUTO_PIN"] = old
def test_a_clients_own_prefix_wins(self):
self.start("ok")
self.auto_pin("1")
body = {"messages": [{"role": "system", "content": "s " * 30}, {"role": "user", "content": "u"}],
"max_tokens": 40, "strata_prefix": {"tokens": 7}}
self.post("/v1/chat/completions", body)
@@ -592,7 +598,7 @@ class SlotEnv(unittest.TestCase):
def test_deepseek_gets_a_folder_in_the_data_folder_and_the_default_switch(self):
env = self.env({"arch": "deepseek41", "log": str(Path("data") / "strata-deepseek.log"), "args": []})
self.assertEqual(Path(env["STRATA_DS4_SLOT_DIR"]), Path("data") / "ds4-slots")
self.assertEqual(env["STRATA_DS4_SLOT_KEEP"], "1")
self.assertEqual(env["STRATA_DS4_SLOT_KEEP"], "0")
self.assertEqual(env["STRATA_DS4_SLOT_GB"], "2")
def test_the_configs_own_settings_win(self):