Repository navigation
Studio Qwen-Image-2.1: encode a condition image again after load_state_dict(assign=True) on its VAE - #17197
Merged
Conversation
…e_dict(assign=True) on its VAE
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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: Didn't find any major issues. Already looking forward to the next diff. 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". |
danielhanchen
added a commit
that referenced
this pull request
Nov 9, 2026
…uff-unsloth wheel (#17211) ## Summary The Backend CI step that installs the pinned `ruff-unsloth` wheel retries 3 times with 5 s and 10 s gaps. Between 05:19 and 05:40 UTC today, GitHub served intermittent 504s for the release asset, and every attempt of an unlucky job landed inside one burst. That turned `Repo tests (CPU, fsdp2 / gloo-cp / gloo-pp / gloo-tp / rest / studio-install)` red on #17188, #17191, #17197, #17201 and #17202, while sibling jobs in the same runs installed the wheel fine a minute later. This raises the loop to 6 attempts with exponential backoff (10, 20, 40, 80, 160 s, about 5 minutes total). A healthy download still never sleeps, and a lasting outage still fails the job with the same `::error::` line, so the fixed-point formatter guard keeps failing loudly in CI when the wheel is truly unavailable. ## Changes - `.github/workflows/studio-backend-ci.yml`: 6 attempts, `sleep $((10 << (attempt - 1)))`. - `tests/test_ruff_unsloth_install_retries.py`: runs the step's own `run:` script under bash with `pip` and `sleep` faked on `PATH`, and checks that - 5 failed downloads in a row still install, after at least 300 s of backoff, - a download that never recovers still fails the job, in under 10 minutes, - a healthy download does not wait at all. ## Testing - `pytest tests/test_ruff_unsloth_install_retries.py`: 3 passed. - Against the old step from `main`, the burst test fails with `ruff-unsloth install failed after 3 attempts`. - The other tests that read `studio-backend-ci.yml` pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #17092, which reuses a condition image's VAE latents across Qwen-Image-2.1 / Turbo renders.
What happened
The cache key tells a weight change apart by
_weights_revision, the tensor count plus the sum of the tensors' version counters. An in-placeload_state_dictbumps those counters, so it encodes again.load_state_dict(..., assign=True)does not write in place: it swaps in the incoming tensors, whose counters can equal the old ones. The VAE object, config, dtype and method overrides are also unchanged, so the next render with the same pixels hit the old entry and returned latents encoded with the previous weights.With the tiny
AutoencoderKLQwenImage21and the real_encode_vae_image, assigning a differently seeded state dict left the revision unchanged and the cached result differed from a fresh encode.No default Studio flow does this today: every
assign=Trueload builds the VAE before the pipeline installs the cache. It is still a silent wrong-output path for any later reload, so it is closed here.Fix
When the cache first sees a VAE it registers a
load_state_dictpost hook on each of the VAE's modules. Any load on the VAE or one of its submodules (in place orassign=True) clears the entries and bumps a generation number that is part of the key, so an encode that was in flight during the load cannot be served afterwards. Offload moves that swap.datado not run the hook and keep their hits, as before. A VAE that refuses the hook is never cached. The per-render cost is one attribute read; the hooks are registered once per VAE.UNSLOTH_REFERENCE_VAE_CACHE=0still turns the cache off.Tests
studio/backend/tests/test_diffusion_reference_cache.py:test_assigned_weights_encode_again:assign=Trueon the whole VAE and onvae.decoderboth encode again and equal a fresh encode. Fails on main (stale latents), passes here.test_a_vae_that_takes_no_hooks_is_never_cached: a VAE that refuses the hook bypasses the cache.CPU, diffusers 0.42.1 / torch 2.10 and diffusers 0.41.0 / torch 2.10 (cpu): main 2 failed / 8 passed, this branch 10 passed on both.