Skip to content

Studio: CI guard that fails when any family's VAE decodes in tiles below the seam floor - #12766

Merged
danielhanchen merged 12 commits into
mainfrom
studio/vae-seam-guard
Oct 6, 2026
Merged

danielhanchen merged 12 commits into
mainfrom
studio/vae-seam-guard

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Two VAE tile seam bugs shipped and were found by users, not by CI:

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:

  • Each family's VAE is built from its real vae/config.json (base repo, pinned revision, in tests/fixtures/vae_tile_configs.json) on the meta device, so no weights are needed.
  • It gets what a Studio load gives it: enable_tiling(), then every tile override module under core/inference (any module that rebinds tiled_decode with types.MethodType and has install(vae), found by scanning: today diffusion_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) and video_ltx2_vae_tiles (Studio: seam-free LTX-2.3 video decode (untiled when it fits, VRAM-sized tiles otherwise) #12698)).
  • The real vae.decode then runs over every canvas side Studio offers the family (image: 256 px to max_output_side in dimension_multiple steps; 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.
  • The floor is read from diffusion_vae_tiling itself (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 least TILE_LATENTS, a neighbour overlap of at least OVERLAP_LATENTS, and no tile, edge tile included, shorter than TILE_LATENTS. LTX's floor comes from video_ltx2_vae_tiles (16 and 8) when that module is present. A class in diffusion_vae_tiling.KEEP_STOCK is reported with the module's reason instead of failing. Where temporal tiling is on, neighbouring temporal tiles must share at least one latent frame.
  • The failure message names the family, the VAE class and ratio, the overrides applied, the tile grid at the canvas nearest 1024 px, and every canvas side that fails.
  • SMALLER_GEOMETRY_OK holds VAEs measured seam-free at a smaller geometry, each with its own floor and the measurement:
    • LTX-2 / 2.3 (32x): Studio: seam-free LTX-2.3 video decode (untiled when it fits, VRAM-sized tiles otherwise) #12698's 16-latent tiles with 8-latent overlaps.
    • Wan2.1 VAE (8x): its stock 32-latent tiles with 8-latent overlaps.
    • HunyuanVideo-1.5 and the Wan2.2-TI2V-5B VAE (16x): their stock 16-latent tiles. A video seam audit on a real clip measured PSNR 49.3 to 52.5 dB against the untiled decode, with no line at the boundaries.
    • MiniMax-H3: its decoder works at its own 256 px tile. Its untiled decode is not a reference: 20 dB PSNR against the input photo, against 30 dB for the tiled decode. Studio always decodes it tiled.
  • KNOWN_SEAMS is 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.
  • Two more tests: a module that rebinds tiled_decode in 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.yml runs 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 on core/inference/**, the diffusers pins and the test. About 20 s on 4 threads.

Results

Guard (with KNOWN_SEAMS empty) on main at three points, CPU torch 2.12, the diffusers main pin:

tree passed failed
main before #12696 (df4eb29579) 9 16: qwen-image-2.1, ltx-2, ltx-2.3 and the 13 image families below
main before #12736 (with #12696 and #12698) 12 13: flux.1, flux.1-kontext, z-image, lumina-2, hidream-i1, sdxl, flux.2-klein, flux.2-dev, ideogram-4, qwen-image, qwen-image-edit, krea-2, hunyuanimage-2.1
main now (with #12736) 25 0

The failures name the VAE and its grid. For example, on the main before #12696:

qwen-image-2.1: AutoencoderKLQwenImage21 (16x, overrides none) decodes a 1024 px side in tiles [(0, 16), (12, 28), (24, 40), (36, 52), (48, 64), (60, 64)] (latents): 16-latent tiles < 32, 4-latent overlap < 16, a 4-latent edge tile < 32; 78 of 79 canvas sides fail
ltx-2.3: AutoencoderKLLTX2Video (32x, overrides none) decodes a 1216 px side in tiles [(0, 16), (14, 30), (28, 38)] (latents): 2-latent overlap < 8; 3 of 4 canvas sides fail ([704, 768, 1216])

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.

family tree worst 64 px window PSNR dB
Qwen-Image-2.1, 1024 / 1600 px, 2 photos main before #12696 3.4 to 9.2 40.9 to 46.2
Qwen-Image-2.1, same, 0 / 8 GiB free with #12696 0.27 to 1.56 55.8 to 64.5
LTX-2 / 2.3, 4 presets, 9-frame pan main before #12698 2.3 to 7.7 39.7 to 49.3
LTX-2 / 2.3, same + #12698 0.47 to 1.88 53.2 to 61.2
HunyuanImage-2.1 (12 / 3-latent tiles) main before #12736 30 to 61 24.0 to 29.1
HunyuanImage-2.1 with #12736 8.3 to 20.4 35.0 to 39.1

Before #12736 the 13 image families failed on geometry below the floor:

  • The 8x AutoencoderKL and FLUX.2 VAEs end in a 2 to 10 latent sliver at 1552 to 1648 px.
  • The 8x Qwen-Image VAE has 8-latent overlaps.
  • HunyuanImage-2.1 has 12-latent tiles with 3-latent overlaps.

Tests

  • python -m pytest studio/backend/tests/test_vae_tile_geometry.py with 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.
  • With only the diffusers 0.40.0 release installed, the same file reports AutoencoderKLQwenImage21 as missing. That is why the workflow also installs the main pin, as Studio does.
  • Self-tests in the file cover the threshold checker (on Qwen-Image-2.1's stock grid and on an 8x sliver) and the probe (reading diffusers' stock Wan grid).
  • tests/test_diffusion_vae_tiling.py still passes alongside the guard (590 passed).
  • The workflow guard suites that workflow-trigger-lint.yml runs pass with the new workflow: 2197 passed, 43 skipped. The three security tests that need unsloth_zoo were not run here. scripts/lint_workflow_triggers.py is clean.

Not covered

  • The CI guard checks geometry only. Whether a geometry that passes is actually seam-free still needs a real decode. The numbers above come from a GPU bench that runs outside this repo.
  • Tile geometry of the tiled encode (img2img and edit inputs) is not checked.
  • The fused batched tile decode is treated as geometry-preserving based on its source, not probed. It reuses the stock tile attributes.
  • The GPU numbers come from one host (B200), bf16, two photos and a 9-frame pan, at the tightest tier. Generated latents and other cards were not measured here.

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).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 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-10-06T03:21:46.947295Z 326b411 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

Repo tests (CPU, rest) fails on this PR's new test: tests/test_source_read_encoding.py flags studio/backend/tests/test_vae_tile_geometry.py:265, a read_text() of a checked-in file without encoding = "utf-8". The other red checks here are runs from before the fixes for them reached main (zoo requests, the Core zoo 4.57.6 compiler test and the latest GRPO torchcodec stub) and should clear on a full re-run.

@danielhanchen danielhanchen self-assigned this Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security 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: 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".

Comment on lines +293 to +294
shape = (1, c, length, other) if frames is None else (1, c, frames, length, other)
rec = _TileRecorder(shape[-2:])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Probe both spatial axes

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 👍 / 👎.

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.

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.

Comment on lines +363 to +364
if side % ratio:
continue

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 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 👍 / 👎.

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.

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])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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.

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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 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: 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".

Comment on lines +391 to +395
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."

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 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 👍 / 👎.

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.

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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@danielhanchen
danielhanchen merged commit b8b7525 into main Oct 6, 2026
@danielhanchen
danielhanchen deleted the studio/vae-seam-guard branch October 6, 2026 05:16
danielhanchen added a commit that referenced this pull request Oct 6, 2026
…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.
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