Skip to content

Studio tests: a frozen background compile may be thawed more than once for one waiting compile - #16364

Merged
danielhanchen merged 1 commit into
mainfrom
fix-bg-compile-thaw-count
Nov 1, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-bg-compile-thaw-count

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

studio/backend/tests/test_diffusion_bg_compile_idle.py::test_a_compile_elsewhere_thaws_a_frozen_compile_instead_of_deadlocking, added in #16312, failed in (Python 3.13, a-f) on #16353, which only changes a training route:

tests/test_diffusion_bg_compile_idle.py:270
    assert job.thaws == 1
E   assert 2 == 1

The deadlock check right above it passed: the render's compile finished, and the output was correct. Only the exact thaw count was off.

A second thaw is legitimate. _thaw_for_lock lets the frozen compile run to the end of the frame that holds dynamo's compile_lock, where it releases the lock. _maybe_freeze declines to refreeze only while the lock is owned and a thread is waiting on it. So if the background compile reaches its next safe call after that release, but before the waiting thread's next 50 ms acquire(True, 0.05) poll, it freezes again without holding the lock. The waiter's poll then thaws it once more and takes the lock. No deadlock and no lost progress, but thaws reads 2. That depends only on scheduling, which is why it shows up on a loaded runner.

Change

assert job.thaws == 1 becomes assert job.thaws >= 1, with a comment saying why. The guard this test exists for, assert not worker.is_alive(), which catches a render compile waiting forever on the frozen trace, is unchanged. So is the later freezes >= 2 check.

Verification

  • Reproduced on main: 1 of 96 runs failed with assert 2 == 1 under -n 12 --count 96 pinned to 2 CPUs.
  • This branch: 192/192 pass under -n 12 --count 192 on 2 CPUs. The whole file passes 16/16.
  • Sabotage: with _thaw_for_lock turned into a no-op, so a frozen compile is never thawed for a waiter, the test does not pass. The waiting compile deadlocks and the run hung until it was killed. The assertion still guards what it was written for.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T02:47:59.125153Z 567ecfc 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. What shall we delve into next?

Reviewed commit: 567ecfc9ca

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

@danielhanchen
danielhanchen merged commit 1c6789c into main Nov 1, 2026
@danielhanchen
danielhanchen deleted the fix-bg-compile-thaw-count branch November 1, 2026 02:53
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