mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
serve: the loop GEN keys (loop_passes, loop_cd_omega, loop_cd_thinking) are not sent to the all-cards split engine; test_split_gen_keys classifies them as dropped
This commit is contained in:
1 parent
b0c4b5deb9
commit
15e457cd83
2 files changed
+21
-10
No files matched your search
@@ -1503,7 +1503,7 @@ class StrataEngine:
|
||||
return f" pen_from={orig_len - 1}"
|
||||
|
||||
@staticmethod
|
||||
def sampling_keys(sampling: dict, *, hy4: bool = False, inkling: bool = False, ling32: bool = False) -> str:
|
||||
def sampling_keys(sampling: dict, *, hy4: bool = False, inkling: bool = False, ling32: bool = False, split: bool = False) -> str:
|
||||
if ling32:
|
||||
# Ling-3.2-Air (serve/ling32_kind.py): the GEN keys it takes are temperature, top_p, top_k and seed; anything else is `ERR unsupported key` (a request that asks for min_p
|
||||
# or a penalty is refused with a 400 before this: ling32_kind.refuse)
|
||||
@@ -1604,16 +1604,17 @@ class StrataEngine:
|
||||
# extends: no conversation checkpoint for it (#830). It still reuses a cached prefix. Absent = as before.
|
||||
if sampling.get("strata_checkpoint") is False:
|
||||
keys += " ckpt=0"
|
||||
# Looped Qwen3.8-Flash-Next per-request overrides (opt-in; absent = engine start-up defaults).
|
||||
# Unknown GEN keys are ignored by older engines.
|
||||
# Looped-core per-request overrides (opt-in; absent = engine start-up defaults).
|
||||
# Unknown GEN keys are ignored by older engines, but NOT by the all-cards split engine (sFNX): its parse_gen ends the request with "GEN: unknown key", so the loop
|
||||
# keys are not sent to it (it has no loop: a request's loop_passes=1, the only value an engine without --loop-adapter accepts, is already what it runs).
|
||||
lp = sampling.get("loop_passes")
|
||||
if isinstance(lp, int) and not isinstance(lp, bool) and lp >= 1:
|
||||
if not split and isinstance(lp, int) and not isinstance(lp, bool) and lp >= 1:
|
||||
keys += f" loop_passes={lp}"
|
||||
lco = sampling.get("loop_cd_omega")
|
||||
if isinstance(lco, (int, float)) and not isinstance(lco, bool) and math.isfinite(float(lco)):
|
||||
if not split and isinstance(lco, (int, float)) and not isinstance(lco, bool) and math.isfinite(float(lco)):
|
||||
keys += f" loop_cd_omega={float(lco)!r}"
|
||||
lct = sampling.get("loop_cd_thinking")
|
||||
if isinstance(lct, bool):
|
||||
if not split and isinstance(lct, bool):
|
||||
keys += f" loop_cd_thinking={1 if lct else 0}"
|
||||
# Hy4-Flash (serve/hy4_kind.py): its pictures are files the engine reads and encodes itself, one `image=<path>` key each, in prompt order (spaces and % in a path as %20 and %25)
|
||||
for p in sampling.get("strata_hy4_images") or []:
|
||||
@@ -2261,7 +2262,8 @@ class StrataEngine:
|
||||
keys0 = self.sampling_keys({k: v for k, v in (sampling or {}).items() if k != HOLD_KEY},
|
||||
hy4=getattr(self, "hy4_engine", False),
|
||||
inkling=getattr(self, "inkling_engine", False),
|
||||
ling32=getattr(self, "ling32_engine", False)) # (the hold's key goes on per leg: leg_keys below)
|
||||
ling32=getattr(self, "ling32_engine", False),
|
||||
split=getattr(self, "split_engine", False)) # (the hold's key goes on per leg: leg_keys below)
|
||||
# logprobs: only an admission's token can have an LP line here (the slot's "BT" lines carry none), so the
|
||||
# server refuses these requests unless max_tokens is 1. The lines go to the request itself, through its
|
||||
# cancel Event: several requests read control lines at once, and the engine's lp_lines is one attribute.
|
||||
@@ -2880,8 +2882,8 @@ class StrataEngine:
|
||||
self.lp_lines = LPLines(cancel)
|
||||
carry = NO_LINE # a line read for a token's LP line, held until it is used
|
||||
# an image request takes the same sampling keys as text (#75: it used to decode greedily whatever was asked)
|
||||
head = f"GENI {int(max_new)}{self.sampling_keys(sampling or {}, hy4=getattr(self, 'hy4_engine', False), inkling=getattr(self, 'inkling_engine', False), ling32=getattr(self, 'ling32_engine', False))} {embeddings}" if embeddings else \
|
||||
f"GEN {int(max_new)}{self.sampling_keys(sampling or {}, hy4=getattr(self, 'hy4_engine', False), inkling=getattr(self, 'inkling_engine', False), ling32=getattr(self, 'ling32_engine', False))}"
|
||||
head = f"GENI {int(max_new)}{self.sampling_keys(sampling or {}, hy4=getattr(self, 'hy4_engine', False), inkling=getattr(self, 'inkling_engine', False), ling32=getattr(self, 'ling32_engine', False), split=getattr(self, 'split_engine', False))} {embeddings}" if embeddings else \
|
||||
f"GEN {int(max_new)}{self.sampling_keys(sampling or {}, hy4=getattr(self, 'hy4_engine', False), inkling=getattr(self, 'inkling_engine', False), ling32=getattr(self, 'ling32_engine', False), split=getattr(self, 'split_engine', False))}"
|
||||
if prefill_only: # split serving (serve/split.py): read the prompt, make no token
|
||||
if embeddings or int(max_new) != 0:
|
||||
raise ValueError("prefill_only is a text prompt and max_new 0")
|
||||
|
||||
@@ -16,7 +16,7 @@ ACCEPTED = {"temperature", "top_p", "top_k", "min_p", "penalty_repeat", "penalty
|
||||
"pcie_frac", "spec_min_p", "pipe", "aux_cpus", "cvec", "img_keys"}
|
||||
# keys the server does not send to a split engine: pen_from is dropped (StrataEngine.pen_from_key), logprobs / allowed / logit_bias are refused with a 400 first
|
||||
# (refuse_for_split, logit_bias.validate_request)
|
||||
DROPPED = {"pen_from"}
|
||||
DROPPED = {"pen_from", "loop_passes", "loop_cd_omega", "loop_cd_thinking"} # the loop keys: StrataEngine.sampling_keys(split=True) leaves them out (the split engine has no loop)
|
||||
REFUSED = {"logprobs", "allowed", "logit_bias"}
|
||||
# keys only other engines are sent: the prefill-only request of serve/split.py,
|
||||
# and hold (the thinking budget's GEN hold=N:ID): the server sends it only to an engine whose READY line says "hold" (a --batch engine: "holdb" too), which is the
|
||||
@@ -55,6 +55,15 @@ class SplitGenKeys(unittest.TestCase):
|
||||
for must in ("pen_from", "logprobs", "allowed", "temperature", "penalty_last_n", "seed"):
|
||||
self.assertIn(must, sent, f"{must}: the parse of serve/server.py no longer finds it (update this test)")
|
||||
|
||||
def test_the_loop_keys_are_not_sent_to_a_split_engine_and_are_to_the_others(self):
|
||||
from serve import server
|
||||
|
||||
req = {"loop_passes": 1, "loop_cd_omega": 0.5, "loop_cd_thinking": True}
|
||||
self.assertEqual(server.StrataEngine.sampling_keys(req, split=True), "")
|
||||
sent = server.StrataEngine.sampling_keys(req)
|
||||
for key in ("loop_passes=1", "loop_cd_omega=0.5", "loop_cd_thinking=1"):
|
||||
self.assertIn(key, sent)
|
||||
|
||||
def test_hold_is_only_for_an_engine_that_says_hold_and_the_split_engine_never_does(self):
|
||||
"""The server sends `hold` only to an engine whose READY line says "hold" (the --batch slots: "holdb"); the split engine's READY line says neither, and
|
||||
its parser does not know the key (it would end the request: "GEN: unknown key hold")."""
|
||||
|
||||
Reference in new issue
Block a user