Official Inference Code of EAGLE-4
fix(core): reject a stop_check workload shorter than concurrency x waves
kevin9327573cb7cfa673
diff --git a/tests/test_stop_check.py b/tests/test_stop_check.pynew file mode 100644index 0000000..6c037e8--- /dev/null+++ b/tests/test_stop_check.py@@ -0,0 +1,43 @@+# Copyright 2026 Eagle AI Corp.+# SPDX-License-Identifier: LicenseRef-Eagle-4-Source-Available++"""tools/stop_check.py refuses a workload file too short for the requested batches before sending anything."""++import importlib.util+import json+from pathlib import Path+import sys+import types++import pytest+++class Tokenizer:+ eos_token_id = 2++ def encode(self, text, add_special_tokens=False):+ return [10] if text == "\n\n" else [ord(c) for c in text]++ def apply_chat_template(self, messages, **kwargs):+ return messages[0]["content"]+++def load(monkeypatch):+ transformers = types.ModuleType("transformers")+ transformers.AutoTokenizer = types.SimpleNamespace(from_pretrained=lambda path: Tokenizer())+ monkeypatch.setitem(sys.modules, "transformers", transformers)+ monkeypatch.setitem(sys.modules, "requests", types.ModuleType("requests"))+ spec = importlib.util.spec_from_file_location("stop_check", Path(__file__).parents[1] / "tools/stop_check.py")+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ return module+++def test_short_data_is_a_usage_error(tmp_path, monkeypatch):+ module = load(monkeypatch)+ data = tmp_path / "question_multiturn.jsonl"+ data.write_text("".join(json.dumps({"turns": [f"question {i}"]}) + "\n" for i in range(3)))+ argv = ["--api", "sglang", "--port", "1", "--data", str(data), "--tokenizer", str(tmp_path)]+ with pytest.raises(SystemExit, match="has 3 conversations.*needs 32"):+ module.main([*argv, "--out", str(tmp_path / "out.json")])+ assert not (tmp_path / "out.json").exists()diff --git a/tools/stop_check.py b/tools/stop_check.pyindex bf269f1..a9c7764 100644--- a/tools/stop_check.py+++ b/tools/stop_check.py@@ -164,6 +164,11 @@ def main(argv: Optional[Sequence[str]] = None) -> int:base = f"http://127.0.0.1:{args.port}"model = requests.get(f"{base}/v1/models", timeout=60).json()["data"][0]["id"] if args.api != "sglang" else Noneturns = first_turns(args.data, args.concurrency * args.waves)+ if len(turns) < args.concurrency * args.waves:+ raise SystemExit(+ f"{args.data} has {len(turns)} conversations; --concurrency {args.concurrency} x --waves {args.waves} "+ f"needs {args.concurrency * args.waves}"+ )prompts = [tokenizer.encode(tokenizer.apply_chat_template(