Repository navigation
Tests: start every diffusion_segment test with no GPU arbiter resident - #14271
Conversation
choose_device() runs SAM 3 on the CPU when another owner holds the card,
and the arbiter's owner state is module-global. A test elsewhere in the
same xdist worker that leaves a CHAT owner behind turned
test_choose_device_needs_room_on_the_card and
test_choose_device_reads_bf16_on_the_chosen_card into ('cpu', float32) in
the (Python 3.13, a-k) shard. An autouse fixture clears _owner and
_residents; tests that need an owner still set one.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adb5d87f48
ℹ️ 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".
| monkeypatch.setattr(gpu_arbiter, "_owner", None) | ||
| monkeypatch.setattr(gpu_arbiter, "_residents", {}) |
There was a problem hiding this comment.
Restore the arbiter's complete state
When a worker enters this module with an existing arbiter claim, this fixture saves and restores only _owner and _residents, while later tests in this file call the real acquire_for(), which mutates correlated globals such as _owner_account, _prior_account, _owner_epoch, _accounts, and _media_needs. Teardown can therefore reattach the saved owner/residents to mutated account metadata, so subsequent tests in the same xdist worker may observe the wrong owning account and remain order-dependent; isolate all correlated arbiter fields together or clear the state without partially restoring it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, fixed in the next commit. The fixture now swaps every correlated arbiter global together: _owner, _owner_account, _prior_account, _residents, _accounts and _media_needs are emptied, and _owner_epoch and _handovers are pinned to their current values, all through monkeypatch. Each test therefore starts unclaimed, and whatever acquire_for() changes is put back as one set afterwards.
Checked with a throwaway test before this file that leaves ("chat", "acct-x") claimed, and one after it that asserts the claim comes back unchanged (owner, account, prior account, residents, accounts, media needs): 66 passed. The file alone: 64 passed.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Two tests in
studio/backend/tests/test_diffusion_segment.pyfail in the(Python 3.13, a-k)shard on PRs with different bases (#14229, #14245):Both pass when the file runs on its own (64 passed).
Cause
choose_device()(from #14235, SAM 3 masks) puts SAM 3 on the CPU when another GPU arbiter owner holds the card (_other_owner_on->gpu_arbiter.residents()). The arbiter's_owner/_residentsare module globals. These two tests stub torch and the free-memory probe but not the arbiter. So when an earlier test in the same xdist worker leaves a CHAT owner behind, they see the card as taken and pick the CPU. The product is right to refuse a card another owner holds. The tests were order dependent.Change
Test-only: an autouse fixture in
test_diffusion_segment.pyclearsgpu_arbiter._ownerand_residentsbefore each test (withmonkeypatch, so they are restored). Tests that exercise ownership already set their own owner, and still do.Testing
test_diffusion_segment.py: 64 passed.gpu_arbiter._owner = gpu_arbiter.CHATand ran it first in the same process:test_choose_device_needs_room_on_the_cardandtest_choose_device_reads_bf16_on_the_chosen_cardfail. These are the two CI failures.