tests: batch_test --dump (an A/B of two engine builds) and the parallel-above-8 message with --batch-mtp

This commit is contained in:
Niko1221 committed 2026-10-05 13:19:39 +02:00
1 parent 3216d27118
commit d90028c755
2 files changed
+27

No files matched your search

+24
View File
@@ -149,6 +149,30 @@ class ParallelArgs(unittest.TestCase):
self.assertEqual(parallel_args({"parallel": "4"}, []), []) # said and ignored
self.assertEqual(parallel_args({"parallel": True}, []), [])
self.assertEqual(parallel_args({"parallel": 12}, []), ["--batch", "12"]) # the engine warns and caps
def test_parallel_above_the_window_says_so_unless_batch_mtp(self):
import contextlib, io, os
def said(args, env):
buf = io.StringIO()
old = os.environ.get("STRATA_BATCH_MTP")
if env is None:
os.environ.pop("STRATA_BATCH_MTP", None)
else:
os.environ["STRATA_BATCH_MTP"] = env
try:
with contextlib.redirect_stdout(buf):
r = parallel_args({"parallel": 12}, args)
finally:
if old is None:
os.environ.pop("STRATA_BATCH_MTP", None)
else:
os.environ["STRATA_BATCH_MTP"] = old
self.assertEqual(r, ["--batch", "12"])
return "at most" in buf.getvalue()
self.assertTrue(said([], None)) # 0.1.39: the window holds 8 rows
self.assertTrue(said([], "0"))
self.assertFalse(said(["--batch-mtp"], None)) # --batch-mtp waves more through the window
self.assertFalse(said([], "1"))
args = engine_args({"args": ["--pack", "p"], "parallel": 2})
self.assertEqual(args[-2:], ["--batch", "2"])
+3
View File
@@ -74,6 +74,7 @@ def main():
ap.add_argument("--skip-solo", action="store_true")
ap.add_argument("--keys", default="", help='sampling keys for every request, e.g. "temperature=0.7 top_k=20"')
ap.add_argument("--extra", default="", help='more engine arguments in one string, e.g. "--adapt-every 1000000"')
ap.add_argument("--dump", default="", help="write every slot's tokens (solo and batch) as JSON: an A/B of two engine builds")
ap.add_argument("--mt-min", default="1", help="STRATA_IQ_MT_MIN for the engine (1: exact; empty: the default)")
a = ap.parse_args()
cfg = json.loads(Path(a.config).read_text())
@@ -152,6 +153,8 @@ def main():
first_diff = next((k for k in range(min(len(b), len(solo[i]))) if b[k] != solo[i][k]), None)
print(f"slot {i}: {len(b)} tokens, solo {len(solo[i])}: {'IDENTICAL' if same else f'DIFFERS at {first_diff}'}")
print(" ", ascii(tok.decode(b)[:160]))
if a.dump:
Path(a.dump).write_text(json.dumps({"solo": solo, "batch": [got[i] for i in range(len(prompts))]}), encoding="utf-8")
eng.send("QUIT")
eng.p.wait(timeout=180) # the next run needs the GPUs back
return 0 if ok else 2