Skip to content

Give every GGUF cancel-drain test the loaded-runner budget - #11662

Merged
danielhanchen merged 1 commit into
mainfrom
fix/gguf-cancel-start-budget
Sep 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/gguf-cancel-start-budget

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

What failed

(Python 3.13, l-r) on #11644 (job). #11644 touches the hub inventory, not inference.

tests/test_openai_tool_passthrough.py:6330: in _run
    assert await asyncio.to_thread(started.wait, 1.0)
E   assert False
FAILED tests/test_openai_tool_passthrough.py::TestGgufVisionToolRouting::test_non_streaming_gguf_cancel_drains_worker

Why

The route is right. The stub worker runs on a thread-pool thread, so a 1.0s start wait measures how quickly a loaded runner schedules that thread. The shard took 528s against its usual ~400s.

This failure was already fixed once. #10008 ("Give the cancel drain a budget sized for a loaded runner") names this exact failure, test_non_streaming_gguf_cancel_drains_worker - assert False. Its hunk, however, landed on the test's tool twin, test_gguf_tool_non_streaming_cancel_drains_worker_before_releasing_slot. The two are near-identical, and the twin is the only test that uses _DRAIN_BUDGET_S. The test #10008 named, and three others shaped like it, kept started.wait, 1.0 and wait_for(..., timeout = 1.0).

Fix

studio/backend/tests/test_openai_tool_passthrough.py only:

  • _DRAIN_BUDGET_S = 30.0 moves to module level, and all five cancel-drain tests use it: the two streaming ones, both non-streaming ones, and the monitor stream one. It is only reached when something is stuck.
  • The stub workers now linger _WORKER_LINGER_S = 0.3 after seeing the cancel flag and before setting released. A route that drains its worker waits that out before raising. One that skips the drain raises first, and assert released.is_set() fails deterministically, instead of depending on the assertion beating the worker's 5 ms poll.

Verification

  • tests/test_openai_tool_passthrough.py: 443 passed.
  • Sabotage: I removed await _drain_cancelled_gguf_task() from the non-streaming GGUF except asyncio.CancelledError in routes/inference.py. test_non_streaming_gguf_cancel_drains_worker fails with assert False where False = is_set(), both with this branch's test file and with main's. On main that catch relied on the 5 ms race, which it won 5 of 5 times locally.

…the drain check deterministic

test_non_streaming_gguf_cancel_drains_worker failed again with assert False on its
1.0s start wait (Backend CI on #11644). #10008 sized this for a loaded runner, but its
hunk landed on the tool twin of the test it named, so that test and three others
shaped like it kept waiting 1.0s for a thread-pool worker to be scheduled.

All of them now use one module-level _DRAIN_BUDGET_S (30s, only reached when
something is stuck). The stub workers also linger 0.3s after seeing the cancel flag,
so a route that skips its drain is caught by released.is_set() every time rather
than whenever the assertion beats the worker's 5 ms poll.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T07:43:01.606934Z 64c5730 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 64c5730c29

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@danielhanchen
danielhanchen merged commit e64fd8f into main Sep 23, 2026
34 of 35 checks passed
@danielhanchen
danielhanchen deleted the fix/gguf-cancel-start-budget branch September 23, 2026 09:05
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…the drain check deterministic (unslothai#11662)

test_non_streaming_gguf_cancel_drains_worker failed again with assert False on its
1.0s start wait (Backend CI on unslothai#11644). unslothai#10008 sized this for a loaded runner, but its
hunk landed on the tool twin of the test it named, so that test and three others
shaped like it kept waiting 1.0s for a thread-pool worker to be scheduled.

All of them now use one module-level _DRAIN_BUDGET_S (30s, only reached when
something is stuck). The stub workers also linger 0.3s after seeing the cancel flag,
so a route that skips its drain is caught by released.is_set() every time rather
than whenever the assertion beats the worker's 5 ms poll.
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