Skip to content

Commit d14f07b

Browse files
committed
tests : make the failed-save park a matter of lengths rather than of two requests overlapping
1 parent 9aabc85 commit d14f07b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

tools/server/tests/unit/test_preempt.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,24 @@ def test_a_resident_cycling_through_context_shifts_is_rotated_out_for_a_parked_h
327327
def test_a_park_whose_host_allocation_fails_is_parked_by_recompute():
328328
# the budget grants permission to allocate, not a successful allocation: a failed save used to stop the planner and leave the pool to overflow, although the same victim could be parked by dropping its cells
329329
os.environ["LLAMA_SERVER_PREEMPT_FAIL_SAVE"] = "1"
330-
_start(n_ctx=256)
330+
_start(n_ctx=1024, n_slots=2)
331331

332-
n_predict = 160
333-
results = _complete_all(n_predict)
332+
# lengths decide the overlap, not the host's speed: two 171-cell requests fired together did not overlap on a Windows runner, so nothing was parked. The leader ends at 960 of 1024 cells, so the second is parked whatever the client's lag
333+
leader = _prompt_of(500, _PROMPT_A)
334+
other = _prompt_of(200, _PROMPT_B)
335+
with ThreadPoolExecutor(1) as pool:
336+
first = pool.submit(_complete, 460, leader, 0)
337+
_wait_processing([0])
338+
second = _complete(400, other, 1)
339+
results = [first.result(), second]
334340

335341
text = _log()
336342
assert "could not take the host memory" in text, "the injected allocation failure never fired"
337343
assert "tokens to re-prefill" in text, "the failed save did not fall back to recompute"
338344
assert "Context size has been exceeded" not in text
339-
_assert_completed(results, n_predict)
345+
for res, n_predict in zip(results, (460, 400)):
346+
assert res.status_code == 200, res.body
347+
assert res.body["timings"]["predicted_n"] == n_predict
340348

341349

342350
def test_a_resident_that_cannot_be_swapped_out_is_rotated_by_recompute():

0 commit comments

Comments
 (0)