Skip to content

Stop the idle-unload TTL test racing a loaded runner - #8175

Merged
danielhanchen merged 2 commits into
mainfrom
fix-8050-test-drift
Aug 9, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix-8050-test-drift

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

test_idle_loop_unloads_after_ttl_and_stashes_for_reload drives the idle-unload loop for a fixed 0.2 s of wall clock and then asserts one unload happened. That is plenty locally and not always enough on a loaded runner, where the loop's first poll can land outside the window.

The failure it produces is assert [] == [1], which reads as "auto-unload is broken" rather than "the sleep was short". That is how it got blamed on #8051, whose change has nothing to do with the idle loop.

It now waits on the condition with a 15 s deadline, the same shape the keep-KV test directly below it already uses for the same reason (its comment names the cause: Windows rounds a 10 ms sleep to its ~15.6 ms tick). After the first unload it keeps polling briefly, so a loop that frees repeatedly is still caught rather than passing because we stopped watching.

Verified the "freed once" assertion still fails when the unload stops clearing the slot.

This PR originally also carried fixes for the five tests left red on main by #8050. Those landed in #8182 and #8183 while this was queued, so the branch is now rebased onto them and only the timing fix remains.

studio/backend/tests/test_openai_auto_switch.py
337 passed

@danielhanchen danielhanchen changed the title Fix the five tests left red on main by the Vulkan CPU fallback Fix the tests left red and flaky on main Aug 8, 2026
test_idle_loop_unloads_after_ttl_and_stashes_for_reload drives the idle
loop for a fixed 0.2s of wall clock and then asserts one unload
happened. That is plenty locally and not always enough on a busy runner,
where the loop's first poll can land outside the window. The failure it
produces, `assert [] == [1]`, reads as "auto-unload is broken" rather
than "the sleep was short", which is how it got blamed on PR 8051.

Wait on the condition with a 15s deadline, the same shape the keep-KV
test right below already uses for the same reason, then keep polling
briefly afterwards so a loop that frees repeatedly is still caught rather
than passing because we stopped watching. Verified the "freed once"
assertion still fails when the unload stops clearing the slot.
@danielhanchen danielhanchen changed the title Fix the tests left red and flaky on main Stop the idle-unload TTL test racing a loaded runner Aug 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83f2b1786e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

break
# Keep polling briefly after the first unload so a loop that frees repeatedly
# is still caught, rather than passing because we stopped watching.
await asyncio.sleep(0.15)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Observe follow-up iterations before asserting one unload

On the loaded runners this change targets, the fixed 150 ms observation window can expire before the idle loop completes the two subsequent iterations needed to reveal a repeated-unload regression: after a faulty unload leaves backend.is_loaded true, the first iteration resets activity when seen_model changes and only the following iteration unloads again. Cancelling here can therefore leave unloads == [1] and let the regression pass; coordinate with completed loop iterations or another deterministic signal instead of another short fixed sleep.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen merged commit 1a23d56 into main Aug 9, 2026
35 of 42 checks passed
@danielhanchen
danielhanchen deleted the fix-8050-test-drift branch August 9, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant