fix : handle zero-token batch generation

- return empty results without running inference for non-positive limits
- keep scheduler batch outputs aligned with requested max_tokens
- add engine and scheduler regression coverage
This commit is contained in:
2026-08-06 12:31:09 +08:00
parent 6f09b1d2ee
commit 5c180cfa90
4 changed files with 44 additions and 7 deletions
+8
View File
@@ -261,6 +261,14 @@ def test_run_batch_respects_max_tokens(device):
scheduler.stop()
def test_run_batch_zero_max_tokens_returns_empty(device):
scheduler, _tok, _model = _make_real_scheduler(device)
try:
assert scheduler.run_batch([[10, 20, 30]], max_tokens=0) == [[]]
finally:
scheduler.stop()
def test_run_batch_stop_id_terminates(device):
"""A token matching stop_ids terminates generation for that prompt."""
scheduler, _tok, _model = _make_real_scheduler(device)