Repository navigation
Studio: CI guard that fails when any family's VAE decodes in tiles below the seam floor - #12766
Conversation
Builds each image / video family's VAE from its real vae/config.json on the meta device, applies what a Studio load applies (enable_tiling plus every tile override module), and reads the tile grid the real decode takes over every canvas side Studio offers. Fails a tile under 32 latents, an overlap under 16, or an edge tile under 16, naming the VAE and its grid. SMALLER_GEOMETRY_OK and KNOWN_SEAMS (strict xfail) carry the measured exceptions. Runs in its own CPU workflow with the diffusers Studio installs.
…AEs allow-listed from the video audit The default floor is diffusion_vae_tiling's own TILE_LATENTS / OVERLAP_LATENTS (every tile, the edge one included, at least TILE_LATENTS), LTX-2's from video_ltx2_vae_tiles, and classes in KEEP_STOCK are reported, not failed. HunyuanVideo-1.5 and the Wan2.2 16x VAE keep their stock tiles: the video seam audit measured them line-free (PSNR >= 49.3 dB).
…iled decode meets the floor
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 security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 754cf0651d
ℹ️ 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".
| shape = (1, c, length, other) if frames is None else (1, c, frames, length, other) | ||
| rec = _TileRecorder(shape[-2:]) |
There was a problem hiding this comment.
Every probe places the swept length in the height dimension and keeps width fixed at the minimum, and the recorder subsequently returns only the height-axis slices. Flattening both members of each resolution preset into _sides() does not fix this because even values originating as preset widths are still probed as heights. A regression confined to tile_sample_stride_width, width tile starts, or width slicing can therefore ship while every portrait and landscape case in this guard passes; run the sweep in both tensor axes and validate both recorded grids.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: diffusers' tiled_decode and diffusion_vae_tiling compute both axes with the same tile/stride per side (stock_tiles takes the min over height and width), so a width-only grid needs an asymmetric override that does not exist.
| if side % ratio: | ||
| continue |
There was a problem hiding this comment.
Exercise valid sides not divisible by the VAE ratio
Skipping every side that is not divisible by the VAE compression ratio omits dimensions that Studio accepts. For example, hunyuanimage-2.1 inherits the 16-pixel family dimension_multiple while its fixture declares a 32x VAE, so valid sizes such as 272 or 304 pixels are never probed. Those requests still reach the production pipeline and its rounding/padding determines a real latent edge layout, which may expose a short terminal tile; derive the production latent extent instead of dropping these canvas sizes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: the pipelines round the canvas to the VAE's latent grid before decode, so a decode only ever sees whole latents; the swept latent lengths already cover every reachable extent.
| try: | ||
| with rec, torch.no_grad(): | ||
| vae.decode(torch.zeros(shape), return_dict = False) | ||
| return sorted(rec.axes[0]) |
There was a problem hiding this comment.
Probe production-length video latents
The probe returns after the first decodable frame count, which for these VAEs is generally the one-frame case, so it never exercises the temporal chunking used by Studio's real 81-, 121-, or 124-frame videos. For example, a 121-frame HunyuanVideo clip produces far more than the probed one latent frame and can enter use_framewise_decoding, where temporal boundaries and the spatial decode calls inside each chunk are different. The attribute-only overlap check later cannot detect incorrect slice starts, short terminal chunks, or a long-input-only decode regression; probe latent frame counts derived from the family's production durations and record temporal slices as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: the spatial grid does not depend on frame count. Probing 1, 2, 21 and 31 latent frames on Wan2.1 and HunyuanVideo-1.5 gives the same height tiles every time; temporal overlap is checked separately from the tile attributes.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 326b411a7f
ℹ️ 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".
| def test_every_family_has_a_vae_config(): | ||
| missing = [f.name for f in (*DF._FAMILIES, *VF._FAMILIES) if f.name not in _fixture()] | ||
| assert not missing, ( | ||
| f"families without a VAE config in {FIXTURE.name}: {missing}. Add each one's vae/config.json " | ||
| "(base repo, pinned revision) so the seam guard checks the tile geometry Studio decodes it with." |
There was a problem hiding this comment.
Tie fixture coverage to each family's VAE source
This only verifies that a fixture key matches the family name. If an existing family's base_repo changes while its name remains stable, the workflow is triggered but _family_configs() continues constructing the old embedded VAE config, so a new production VAE geometry can ship without being probed. Validate each fixture's recorded repository against the registry's effective VAE source (accounting for intentional mirrors), so such changes force the config and revision to be refreshed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: a family moving to a different VAE repo under the same name is a hypothetical future edit, and that PR would also touch the family entry and its loader, which re-runs this guard. Fixture keys already fail on any new or renamed family.
…erage in Backend CI (#12843) #12766 added the VAE seam guard and #12775 / #12777 added the qwen-image-layered family right after it, with no entry in vae_tile_configs.json. The seam guard fails on main: test_every_family_has_a_vae_config, then a KeyError in the geometry check. Add Qwen/Qwen-Image-Layered's vae/config.json at revision 8f0ca708df (the 4-channel RGBA AutoencoderKLQwenImage). With it the full seam guard passes: 27 passed. The coverage check lives in a module that importorskips torch and diffusers, so it only ran in the path-filtered seam-guard job. A dependency-free copy now runs in Backend CI, plus a shape check on each entry.
Problem
Two VAE tile seam bugs shipped and were found by users, not by CI:
AutoencoderKLQwenImage21, a 16x VAE, the Wan VAE's 8x pixel tile geometry. That is 16-latent tiles, a 4-latent blend and 4-latent sliver tiles at the right / bottom edge, so every low-VRAM tier drew thin lines one tile long.HunyuanImage-2.1, Qwen-Image and the 1600 px sliver on AutoencoderKL / FLUX.2 had the same class of bug, fixed in #12736.
Nothing in the test suite looks at the tile grid a VAE is actually decoded with, so a new family, a diffusers upgrade that changes a default, or a Studio override with a too-small tile can bring the lines back without any test failing.
Change
New
studio/backend/tests/test_vae_tile_geometry.py, a CPU-only guard over every family in the image and video registries, plus LTX-2.3's single-file VAE:vae/config.json(base repo, pinned revision, intests/fixtures/vae_tile_configs.json) on the meta device, so no weights are needed.enable_tiling(), then every tile override module undercore/inference(any module that rebindstiled_decodewithtypes.MethodTypeand hasinstall(vae), found by scanning: todaydiffusion_vae_tiling(Studio: seam-free VAE tiles for Qwen-Image-2.1 on low-VRAM tiers (fixes thin horizontal / vertical lines) #12696, Studio: seam-free tiled decode for every image VAE whose stock tiles fall under the floor (HunyuanImage-2.1 grid, Qwen-Image, slivers) #12736) andvideo_ltx2_vae_tiles(Studio: seam-free LTX-2.3 video decode (untiled when it fits, VRAM-sized tiles otherwise) #12698)).vae.decodethen runs over every canvas side Studio offers the family (image: 256 px tomax_output_sideindimension_multiplesteps; video: the resolution presets). The decoder is replaced by a stand-in that only produces the right output shape, and the tile grid is read from the latent slices the decode actually takes. That covers diffusers' defaults, a diffusers upgrade that changes them, and Studio's overrides, without reimplementing any tiling code. Off CUDA the overrides size their tiles for zero free VRAM, which is the tightest low-VRAM tier.diffusion_vae_tilingitself (TILE_LATENTS,OVERLAP_LATENTS: 32 and 16 latents, the overlap ComfyUI's tiled decode uses), so the guard and the fix cannot drift apart. On every tiled axis it requires tiles of at leastTILE_LATENTS, a neighbour overlap of at leastOVERLAP_LATENTS, and no tile, edge tile included, shorter thanTILE_LATENTS. LTX's floor comes fromvideo_ltx2_vae_tiles(16 and 8) when that module is present. A class indiffusion_vae_tiling.KEEP_STOCKis reported with the module's reason instead of failing. Where temporal tiling is on, neighbouring temporal tiles must share at least one latent frame.SMALLER_GEOMETRY_OKholds VAEs measured seam-free at a smaller geometry, each with its own floor and the measurement:KNOWN_SEAMSis for a family whose geometry is measured below the floor and not yet fixed, as a strict xfail, so the PR that widens its tiles, or allow-lists it with a measurement, has to delete the entry. It is empty: on main every family meets the floor.tiled_decodein some other way must be listed as geometry-preserving (today only the fused batched decode), and every registry family must have a VAE config in the fixture.New
.github/workflows/studio-vae-seam-guard.ymlruns the guard on CPU. Backend CI does not install diffusers, so there the test would only skip. This workflow installs the diffusers Studio installs: the release pin, then the pinned main commit on top, which is the one that has Qwen-Image-2.1. It triggers oncore/inference/**, the diffusers pins and the test. About 20 s on 4 threads.Results
Guard (with
KNOWN_SEAMSempty) on main at three points, CPU torch 2.12, the diffusers main pin:df4eb29579)The failures name the VAE and its grid. For example, on the main before #12696:
With the fixes, Qwen-Image-2.1 decodes 1024 px in
[(0, 32), (16, 48), (32, 64)], and LTX in 16-latent tiles with overlaps of 8 latents or more. With #12736 every image family decodes at or above the floor.The geometry rule was checked against real decodes. Each family's real VAE (bf16, B200) encodes a natural photo untiled. The latent is then decoded untiled, and tiled the way the tree tiles it on its tightest tier. The table gives the worst 64 px window mean of |tiled - untiled| in 8-bit levels (#12696's line metric) and the PSNR of tiled against untiled. A boundary-step score did not separate lines from photo content, so it is not used.
Before #12736 the 13 image families failed on geometry below the floor:
Tests
python -m pytest studio/backend/tests/test_vae_tile_geometry.pywith the diffusers main pin: 25 passed on main (torch 2.12.1); the earlier trees above were run on CPU torch 2.10 and torch 2.6.0, with the same failures on both. It takes about 20 s on 4 threads.AutoencoderKLQwenImage21as missing. That is why the workflow also installs the main pin, as Studio does.tests/test_diffusion_vae_tiling.pystill passes alongside the guard (590 passed).workflow-trigger-lint.ymlruns pass with the new workflow: 2197 passed, 43 skipped. The three security tests that needunsloth_zoowere not run here.scripts/lint_workflow_triggers.pyis clean.Not covered