Skip to content

Tests: stop a GPU-selection route test leaking a CHAT owner into the upsampler tests - #14169

Merged
danielhanchen merged 1 commit into
mainfrom
fix/arbiter-state-leak-upsampler-tests
Oct 19, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/arbiter-state-leak-upsampler-tests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

(Python 3.13, a-k) failed three of #14137's new FLUX.3 prompt upsampler tests on #14151's run (base def3451e), on two different xdist workers:

tests/test_flux3_prompt_upsampler.py::test_generated_only_penalties_follow_the_server[True]
tests/test_flux3_prompt_upsampler.py::test_generated_only_penalties_follow_the_server[False]
tests/test_flux3_prompt_upsampler.py::test_stop_during_server_start_cancels_the_start
core.inference.flux3_prompt_upsampler.UpsamplerUnavailableError: The image model no longer holds the GPU.

On their own the tests pass on main (93 passed, serially and with -n 4). They fail only after another test has run in the same process. #14151 does not touch either file, so any PR whose worker draws this order will hit it.

Cause

FluxPromptUpsampler.generate starts the sidecar only while _image_model_owns_gpu(), which reads gpu_arbiter.current_owner() (image model or nobody). That arbiter is process-wide, and the upsampler tests never pinned it.

I ran each tests/test_[a-k]* file that touches the arbiter in front of test_flux3_prompt_upsampler.py in one process. Only test_gpu_selection.py reproduces the failures, and it gives the same three IDs. Tracing gpu_arbiter._owner around each test points at one test: TestRouteErrors::test_inference_route_returns_400_for_invalid_gpu_ids (None -> 'chat'). It drives the real /load route, which claims the GPU for CHAT through acquire_for_request before the stubbed backend refuses gpu_ids = [99]. Nothing puts the arbiter back afterwards.

So the tests are what is wrong here: one leaks global state, the other depends on it.

A failed chat load leaving CHAT claimed with nothing loaded is a separate product question, which this PR does not change. I could not find a failure path in routes/inference.py that calls release_chat_gpu_claim(). It may be worth a look on its own.

Change

Test only:

  • test_gpu_selection.py: TestRouteErrors.setUp saves the arbiter's module state (_owner, _owner_epoch, _owner_account, _prior_account) and restores it with addCleanup. The route tests therefore leave the arbiter as they found it.
  • test_flux3_prompt_upsampler.py: the autouse _clean fixture pins gpu_arbiter._owner to None, the fresh-start state those tests assume. The tests about a different owner already set it themselves and still do.

Testing

tests/test_gpu_selection.py tests/test_flux3_prompt_upsampler.py in one process, in that order:

change result
neither (main) 3 failed, 194 passed: the three IDs above
only the upsampler pin 197 passed
only the TestRouteErrors restore 197 passed
both (this PR) 197 passed

test_gpu_selection.py, test_flux3_prompt_upsampler.py and test_gpu_arbiter.py together with -n 4 give 218 passed.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-10-19T00:04:24.286960Z f1fd01e Manual request
🔒 Security Review ⚠️ Failed 2026-10-19T00:02:28.663339Z f1fd01e PR opened
ℹ️ 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. Another round soon, please!

Reviewed commit: f1fd01e16a

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

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