Skip to content

Follow #11635's Diffusers prefetch and #11660's responsive classes in the tests - #11680

Merged
danielhanchen merged 6 commits into
mainfrom
fix/main-red-11635-11660
Sep 23, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
fix/main-red-11635-11660

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Repo tests (CPU, studio) is red on main with six failures from two PRs that merged today: five in tests/studio (on 318fcc97c the suite gives 5 failed, 14,578 passed) and one in tests/python.

#11635: test_every_installer_entry_point_invalidates

AssertionError: a new installer entry point appeared: ['_prefetch_diffusers_main', 'pip_install', 'pip_install_try'].
It has to drop the torch classification too, or it will answer for the build it replaced

The check treats any function that builds a pip or uv command as an installer, and requires every installer to drop the memoized torch classification. _prefetch_diffusers_main builds with ("--no-deps", "--target", scratch). That writes the pinned Diffusers into a scratch directory only to warm uv's cache, and installs nothing into the environment. It cannot change which torch is installed.

The product is right and the check was too broad.

  • Change: _prefetch_diffusers_main is exempted by name (SCRATCH_PREFETCHERS). Every other function that builds a command still has to invalidate, and the installer set is still read from the module rather than listed. Earlier revisions tried to prove the exemption from the source with ast, and review kept finding spellings it could not see through (a rebound name, a second --target), so the proof now runs the function instead.
  • New test, TestScratchPrefetch: runs the prefetch through both its git and archive paths, with the subprocess stubbed, and reads the command it actually issues. It requires exactly one --target (either spelling), naming a directory under the temp root with the prefetch prefix, and requires that directory to be gone afterwards.

#11635 again: test_pip_install_and_the_audits_share_it

AssertionError: a caller that filters its own way can disagree with the file that installs
assert 5 == 4

The ARM64 wheelhouse test counted _effective_requirements(req) in install_python_stack.py and expected four. The Diffusers prefetch is a fifth caller. It is the invariant holding, not loosening: the prefetch has to build from the same filtered file that _diffusers_main_step then installs from, or its cache entry misses.

The test now names each caller (pip_install, pip_install_try, _closure_record, _requirements_satisfied, _prefetch_diffusers_main) and the file it passes. A new caller fails with its own name, and a caller that stops filtering fails by going missing.

#11660: four test_desktop_reliability_frontend_contract.py tests

#11660 made these changes on purpose:

  • The Images, Audio and image-train rails get a 20px gutter on phones (max-sm:px-5, max-sm:pl-5).
  • The chat split moves from md:flex-row to lg:flex-row, so tablets stack.

The four contracts pinned the old class strings. They now pin the new ones, with a line saying which PR changed them.

Verification

  • tests/studio/install/test_torch_probe_memoization.py, tests/studio/test_desktop_reliability_frontend_contract.py and tests/python/test_windows_arm64_wheelhouse_tags.py all pass.
  • Sabotage, one at a time. Each of these fails only the test that covers it:
    • The prefetch built with a second --target, a target under sys.prefix, or no target at all: both TestScratchPrefetch cases fail.
    • The prefetch reading the raw requirements file instead of _effective_requirements(req), or another caller passing a different file: test_pip_install_and_the_audits_share_it.
    • The Images rail without max-sm:px-5: test_image_page_structural_panes_share_the_container_breakpoint.
    • The Audio rail without max-sm:px-5: test_audio_page_matches_the_image_rail_header_and_action_footer.
    • The chat split back to md:flex-row: test_mac_chat_header_controls_share_the_titlebar_row.

#11635's _prefetch_diffusers_main builds the pinned Diffusers into a scratch
--target directory to warm uv's cache, so it installs nothing into the
environment and cannot change which torch is there. The entry-point check
counted any caller of _build_uv_cmd as an installer and failed main.

A function whose every build command carries --target is now read as a
scratch prefetch. Anything else that builds a command still has to drop the
memoized torch classification.
#11660 gave the Images, Audio and image-train rails a 20px gutter on phones
(max-sm:px-5, max-sm:pl-5) and moved the chat split from md to lg, so
tablets stack. Four contracts still pinned the old class strings.
@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-23T14:57:57.151618Z 425254c 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 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: c240e27039

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

Comment on lines +363 to +365
return any(
(isinstance(item, ast.Constant) and item.value == "--target") or carries(item)
for item in node.elts

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 Require a scratch destination before exempting target installs

When a helper passes the active environment's site-packages directory to --target, this predicate returns true solely because the flag occurs in the tuple, so test_every_installer_entry_point_invalidates excludes a real environment-mutating installer and no longer detects a missing torch-probe invalidation. Both pip install --help ("Install packages into

") and uv pip install --help ("specified directory") confirm that the destination is arbitrary; verify that it is actually a disposable scratch path, or narrowly exempt _prefetch_diffusers_main, rather than treating every --target command as harmless.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in af280f2: --target only counts when the next argument is a directory the same function made with tempfile.mkdtemp, as s or str(s). Pointing _prefetch_diffusers_main at site.getsitepackages()[0] now fails the entry-point test, and the parametrised cases cover a caller-supplied directory and site-packages.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 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: af280f22f5

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

Comment on lines +378 to +384
if any(
isinstance(sub, ast.Call)
and isinstance(sub.func, ast.Attribute)
and sub.func.attr == "mkdtemp"
for sub in ast.walk(node.value)
):
scratch.add(target.id)

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 Invalidate scratch names when they are rebound

The new mkdtemp check still produces a false exemption when a function later reassigns the same variable: for example, target = tempfile.mkdtemp(); target = site.getsitepackages()[0]; _build_uv_cmd(("--target", target)). Because scratch only accumulates names and never accounts for the later binding, this environment-mutating helper is classified as scratch-only and omitted from the invalidation check. Track the value reaching each command call, or at least remove a name from scratch when a subsequent assignment is not derived from mkdtemp.

Useful? React with 👍 / 👎.

@danielhanchen danielhanchen Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 22eab66: a scratch directory or argument tuple now counts only when its name is bound exactly once in the function (any assignment, loop target or parameter counts as a binding). The parametrised cases add a rebind after mkdtemp, a rebound args tuple, and a loop that rebinds the name; all three read as installers. Dropping the single-binding rule fails the mkdtemp rebind and the loop cases (the rebound tuple was already caught, since the later tuple carries no --target).

@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: 22eab66568

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

return carries(node.value)
if isinstance(node, ast.Tuple):
items = node.elts
return any(

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 Reject later non-scratch targets before exempting the command

When a helper builds ("--target", scratch, "--target", site.getsitepackages()[0], "torch"), this any(...) succeeds on the first pair and causes the invalidation test to omit the helper. This is environment-mutating under pip: pip install --help describes --target <dir> as “Install packages into

,” and with pip 26.1 an install containing the option twice populated only the final directory. Require the scratch target to be the sole effective --target rather than accepting any matching pair.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 8c9e04a, by dropping the source classifier rather than growing it. _prefetch_diffusers_main is now exempted by name, and a new TestScratchPrefetch runs it through both the git and archive paths with the subprocess stubbed and checks the command it actually issues: exactly one --target (either spelling), naming a directory under the temp root with the prefetch prefix, removed afterwards. A second --target, a target under sys.prefix, and no target each fail both cases. Any other builder of a command still has to invalidate.

…ts source

The AST classifier kept meeting spellings it could not see through: a
rebound name, a second --target. Exempt _prefetch_diffusers_main by name
instead, and prove the exemption by running it with the subprocess stubbed,
through both the git and the archive source: exactly one --target, naming a
directory it made under the temp root, gone afterwards.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 8c9e04a632

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

…s prefetch

The ARM64 wheelhouse test counted _effective_requirements(req) and expected
four. #11635's Diffusers prefetch is a fifth, and it has to filter the same
way, since it builds the cache entry the install then reads. Name each caller
and the file it passes instead, so a new caller fails with its own name.
@danielhanchen danielhanchen changed the title Follow #11635's scratch prefetch and #11660's responsive classes in the studio tests Follow #11635's Diffusers prefetch and #11660's responsive classes in the tests Sep 23, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 425254cbbf

ℹ️ 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 66febc7 into main Sep 23, 2026
7 of 28 checks passed
@danielhanchen
danielhanchen deleted the fix/main-red-11635-11660 branch September 23, 2026 15:08
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ponsive classes in the tests (unslothai#11680)

* Let a scratch --target prefetch through the torch-probe installer check

unslothai#11635's _prefetch_diffusers_main builds the pinned Diffusers into a scratch
--target directory to warm uv's cache, so it installs nothing into the
environment and cannot change which torch is there. The entry-point check
counted any caller of _build_uv_cmd as an installer and failed main.

A function whose every build command carries --target is now read as a
scratch prefetch. Anything else that builds a command still has to drop the
memoized torch classification.

* Follow unslothai#11660's phone gutters and lg chat split in the desktop contract

unslothai#11660 gave the Images, Audio and image-train rails a 20px gutter on phones
(max-sm:px-5, max-sm:pl-5) and moved the chat split from md to lg, so
tablets stack. Four contracts still pinned the old class strings.

* Exempt only a --target into a directory the function just made with mkdtemp

* Only a name bound once can prove its --target is the mkdtemp scratch

* Hold the prefetch to a scratch target by running it, not by reading its source

The AST classifier kept meeting spellings it could not see through: a
rebound name, a second --target. Exempt _prefetch_diffusers_main by name
instead, and prove the exemption by running it with the subprocess stubbed,
through both the git and the archive source: exactly one --target, naming a
directory it made under the temp root, gone afterwards.

* Name the callers of the shared requirements filter, including unslothai#11635's prefetch

The ARM64 wheelhouse test counted _effective_requirements(req) and expected
four. unslothai#11635's Diffusers prefetch is a fifth, and it has to filter the same
way, since it builds the cache entry the install then reads. Name each caller
and the file it passes instead, so a new caller fails with its own name.
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