serve: an engine option written as one entry of the config's args is split, a JSON slip is said with its place (#2267)

"--ple-io mmap" as ONE element of "args" (or "--ple-io=mmap") reached the engine as a single
argument, which it stops on ("unknown argument: --ple-io mmap"); the usual form is two entries.
The server now splits such an element into the flag and its value and says so at startup
(never one in a flag's value place). A config with a JSON mistake (a missing comma between two
args) gave a traceback; it now names the file, line and column. The slow-PLE-probe warning says
how the two entries are written in a config. --ple-io mmap, ram and direct themselves parse
correctly in the engine (checked on the 0.1.45 build).

Reported by lama7 on #2267.
This commit is contained in:
Niko1221 committed 2026-10-15 15:04:33 +02:00
1 parent 36381540f9
commit 8101a8903b
4 files changed
+81 -3

No files matched your search

+39 -1
View File
@@ -6485,6 +6485,43 @@ def clean_shared_defaults(d) -> dict:
return out
def split_joined_args(cfg: dict) -> None:
"""#2267: an engine option written as ONE element of the config's "args" - "--ple-io mmap" or "--ple-io=mmap" - reaches
the engine as a single argument ("unknown argument: --ple-io mmap"; the usual form is two elements, "--ple-io",
"mmap"). Recommend, never force: such an element is split into the flag and its value, and said at startup. Only an
element that starts with a flag name (--letters-digits-dashes) followed by a space or "=" is touched, and never one
that sits in the value place of the flag before it."""
args = cfg.get("args")
if not isinstance(args, list):
return
out, changed = [], []
for a in args:
m = re.match(r"^(--[A-Za-z0-9][A-Za-z0-9-]*)(?:\s+|=)(\S.*)$", a) if isinstance(a, str) else None
prev = out[-1] if out else None
in_value_place = isinstance(prev, str) and re.match(r"^--[A-Za-z0-9][A-Za-z0-9-]*$", prev) is not None
if m is None or in_value_place:
out.append(a)
continue
out += [m.group(1), m.group(2).strip()]
changed.append(a)
if changed:
cfg["args"] = out
print("[strata] the config's args hold " + ", ".join(repr(c) for c in changed) + " as one element each: split into the "
'flag and its value (write them as two elements, e.g. "--ple-io", "mmap")', flush=True)
def read_config(path) -> dict:
"""The run config's JSON. A mistake in it (a missing comma between two args, a trailing comma) is said with its
place in the file instead of a traceback (#2267: editing "args" by hand is where it happens)."""
text = Path(path).read_text(encoding="utf-8-sig") # Notepad adds a BOM
try:
return json.loads(text)
except json.JSONDecodeError as e:
raise SystemExit(f"[strata] {path} is not valid JSON: {e.msg} at line {e.lineno}, column {e.colno}. Check the commas "
'between the entries of "args" (each option and each value is its own quoted entry, e.g. '
'"--ple-io", "mmap",) and that no entry is followed by a comma at the end of a list.') from None
def lift_reasoning_effort_arg(cfg: dict) -> None:
"""#1641: "--reasoning-effort high" in a config's "args" is meant for the thinking level, which is not an engine
option (the engine stopped at the unknown flag). It is the config's "reasoning_effort" (none, low, medium or high:
@@ -6719,7 +6756,8 @@ def main() -> int:
"each, requests spread over them (also \"replicas\" in the config: a number, or "
"[{\"gpus\": [0, 1]}, {\"gpus\": [2, 3]}])")
a = ap.parse_args()
cfg = json.loads(Path(a.config).read_text(encoding="utf-8-sig")) if a.config else {} # Notepad adds a BOM
cfg = read_config(a.config) if a.config else {}
split_joined_args(cfg)
lift_reasoning_effort_arg(cfg)
if a.replicas is not None:
cfg["replicas"] = a.replicas
+40
View File
@@ -2855,6 +2855,46 @@ class ConfigReasoningEffort(unittest.TestCase):
self.assertEqual(cfg, {"args": ["--ctx", "4096"]})
class JoinedEngineArgs(unittest.TestCase):
"""#2267: "--ple-io mmap" written as one element of the config's args reached the engine as one argument."""
def split(self, args):
from serve.server import split_joined_args
cfg = {"args": list(args)}
with mock.patch("builtins.print") as pr:
split_joined_args(cfg)
return cfg["args"], pr.called
def test_one_element_becomes_flag_and_value(self):
self.assertEqual(self.split(["--spec", "4", "--ple-io mmap"]), (["--spec", "4", "--ple-io", "mmap"], True))
self.assertEqual(self.split(["--ple-io=mmap", "--kv int8"]), (["--ple-io", "mmap", "--kv", "int8"], True))
def test_proper_args_are_untouched(self):
args = ["--ple-io", "mmap", "--native", "/data/My Models/a b.gguf", "--max-context", "131072", "--vision"]
self.assertEqual(self.split(args), (args, False))
# a value in a flag's value place stays whole, whatever it looks like
args = ["--system-prompt", "--be brief please"]
self.assertEqual(self.split(args), (args, False))
def test_no_args(self):
from serve.server import split_joined_args
cfg = {}
split_joined_args(cfg)
self.assertEqual(cfg, {})
def test_bad_json_names_the_place(self):
import tempfile
from serve.server import read_config
with tempfile.TemporaryDirectory() as d:
p = Path(d) / "c.json"
p.write_text('{"args": ["--ple-io" "mmap"]}', encoding="utf-8")
with self.assertRaises(SystemExit) as cm:
read_config(p)
self.assertIn("line 1", str(cm.exception))
p.write_text('{"args": ["--ple-io", "mmap"]}', encoding="utf-8")
self.assertEqual(read_config(p), {"args": ["--ple-io", "mmap"]})
class SharedSettings(unittest.TestCase):
"""The web app's "Use for other apps too": POST /settings makes its Chat settings every client's defaults."""
+1 -1
View File
@@ -3546,7 +3546,7 @@ int main(int argc, char** argv) {
"MB/s of random 4 KiB reads): a prompt can spend minutes reading layer 1 and trip the "
"stall watchdog (#1425, #1629). --ple-io mmap was 40-100x faster on some DRAM-less NVMe drives but 7x slower on a SATA SSD (#2040), so it is not chosen for you; "
"--ple-io ram needs the RAM for the table%s\n", rps, rps * 4096.0 / 1e6,
o.ple_io_explicit ? "" : " (kept direct: pass --ple-io mmap or --ple-io ram to change it)");
o.ple_io_explicit ? "" : " (kept direct: pass --ple-io mmap or --ple-io ram to change it; in a config file's \"args\" they are two entries: \"--ple-io\", \"mmap\")");
}
}
}
+1 -1
View File
@@ -3093,7 +3093,7 @@ int main(int argc, char **argv) try {
"MB/s of random 4 KiB reads): a prompt can spend minutes reading layer 1 and trip the "
"stall watchdog (#1425, #1629). --ple-io mmap was 40-100x faster on some DRAM-less NVMe drives but 7x slower on a SATA SSD (#2040), so it is not chosen for you; "
"--ple-io ram needs the RAM for the table%s\n", rps, rps * 4096.0 / 1e6,
o.ple_io_explicit ? "" : " (kept direct: pass --ple-io mmap or --ple-io ram to change it)");
o.ple_io_explicit ? "" : " (kept direct: pass --ple-io mmap or --ple-io ram to change it; in a config file's \"args\" they are two entries: \"--ple-io\", \"mmap\")");
}
}
}