Repository navigation
Studio video: decode Wan VAE tiles on both cards when the decode is tiled and the second card has room - #18829
Conversation
…iled and the second card has room
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 153a7dd2dc
ℹ️ 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".
…ase the copy when the load card fails [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25dcc545c1
ℹ️ 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".
… before re-raising [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3850574793
ℹ️ 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".
…odules, refuse leftover captures [skip ci]
…n ulp of the one-card fused decode
…e same model Automatic (no gpu_ids) selections hold every visible card, and the split took the first secondary whenever torch reported room, opening a CUDA context on it and decoding beside whatever another process runs there. Pick the partner the way the automatic CFG copy does (automatic_partner over nvidia-smi probes: idle, same model, room for the copy); explicit multi-card picks are unchanged and UNSLOTH_VIDEO_VAE_MULTIGPU=force keeps the old behaviour under Automatic.
…skip a non-mirrored diffusers body [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5a7050c83
ℹ️ 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".
…its causal caches [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4d8d6829f
ℹ️ 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".
… falls back without decoding [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
…r the two-card Wan decode with the VAE seam guard (main reds) (#18945) ## Summary Two checks are red on `main` and fail on every PR that runs them, for example the staging run for #18941: | Failing check | Introduced by | Which side was wrong | Fix | |---|---|---|---| | `tests/test_python39_compatibility.py::test_studio_evaluated_unions_do_not_grow` (`Core`, all three combos): "36 studio files now evaluate PEP 604 unions on the floor, against 35 recorded" | #18917 added `core/inference/diffusion_lanczos_triton.py` | Code. Its public entry point declares `crop`, `mean` and `std` as `tuple[...] \| None`, which is evaluated when the function is defined and raises `TypeError` on Python 3.9. | Those three parameters become `Optional[tuple[...]]`. No `from __future__ import annotations`: the module's Triton kernels read their `tl.constexpr` annotations, which that import would turn into strings. | | `studio/backend/tests/test_vae_tile_geometry.py::test_every_tiled_decode_patch_is_probed` (`seam-guard`): "['video_vae_multigpu'] rebind a VAE's tiled_decode but expose no install(vae) this guard applies" | #18829 added `core/inference/video_vae_multigpu.py` | Test registry. The module mirrors the stock `AutoencoderKLWan.tiled_decode` body (checked by AST fingerprint) and only shares its tiles between two cards. It keeps the stock tile grid, and `test_video_vae_multigpu.py::test_split_tiles_match_the_stock_tiled_decode_bitwise` proves it. Its `install(pipe, partner)` takes a pipeline, not a VAE, so the guard cannot apply it. | Listed in `GEOMETRY_PRESERVING` with that reason, which is the remedy the guard's message names for a module that keeps the stock tiles. | Neither fix changes behaviour. ## Testing - `tests/test_python39_compatibility.py`: fails on `main` with the message above, 8 passed with this change. - `tests/test_vae_tile_geometry.py` and `tests/test_video_vae_multigpu.py`: `test_every_tiled_decode_patch_is_probed` fails on `main`. With this change, 55 passed, 2 skipped, 2 xfailed (the recorded known seams). - `tests/test_diffusion_ref_preprocess.py` and `tests/test_diffusion_ref_preprocess_gate.py`, the suites that exercise the Lanczos module: 33 passed. - `ruff check --select F` on the Lanczos module: clean.
On a multi-GPU selection, Studio's tiled Wan VAE decode now shares its spatial tiles with the second card: the load card decodes every other tile while a short-lived copy of the VAE decodes the rest on the partner card, and the tiles are blended on the load card exactly as diffusers does. The output is bitwise identical to the one-card tiled decode.
Each spatial tile of
AutoencoderKLWan.tiled_decodeis an independent causal decode over every frame (its own feature cache), so the split changes where a tile runs, not what it computes. Temporal chunks are not split (the causal cache makes them dependent).When it engages
tiled_decodeis only reached when the decode is tiled: speed tieroff, or a default-tier decode whose untiled peak does not fit).AutoencoderKLWan, and only when the installedtiled_decodebody matches the mirrored diffusers body (checked by anast.unparsefingerprint; diffusers 0.42.1 and 0.43.0). Anything else keeps the stock decode.UNSLOTH_VIDEO_VAE_MULTIGPU=0turns it off.Stream discipline
The copy is built and its tiles decoded on a dedicated partner stream that first waits for the caller's stream. Copies from the load card run with the caller's stream current for that card, and the decoded tiles come back on the caller's stream after it waits for the partner stream. Nothing on the partner card is freed before that stream finishes. The copy is collected (it sits in reference cycles) and the partner cache emptied after each decode, so the next render finds the memory free again.
An earlier version that built the copy on the caller thread and relied on implicit cross-card copies on the default streams aborted inside Studio's render with
CUDA error: unspecified launch failure(it ran clean underCUDA_LAUNCH_BLOCKING=1). This version has not faulted in any run below.Results (Kaggle 2x T4, Wan 2.2 TI2V 5B, fp32 VAE)
Standalone VAE decode, random latents, median of 3, bitwise vs the stock tiled decode in every case:
Inside Studio, Automatic placement (CFG replica on the second card), speed tier
off, 480x320x17, 6 steps, 2 renders per load, fresh Studio home per load, three kernels, main as base in the same kernel (main's Automatic decode stays on one card: 20.5 - 25.0 s):Default tier at 1280x704x17: the decode uses wide tiles that need about 9 GB on the partner card, which the CFG replica leaves only about 5 GB of, so the split correctly stays on one card (no change in output or speed).
Tests
tests/test_video_vae_multigpu.py(CPU): split equals the stock tiled decode bitwise with and withoutpatch_size, with a supplied copy and with the copy the split builds itself; a changedtiled_decodebody or another VAE class is refused; install / uninstall routing and the one-card fallback; forward hooks stay on the source; the partner free-memory read counts reusable blocks and the working set scales with the tile size; a copy holding tensors on another card is detected.test_split_tiles_keep_the_callers_autocast_on_two_cards(two CUDA cards, fp16 autocast, bitwise against the stock tiled decode under the same autocast) andtest_a_failing_load_card_still_releases_the_copyboth fail with the previous module and pass with this one. Kaggle 2x T4, same kernel: previous module 2 failed / 8 passed, this branch 10 passed with no skips.Speed paths and Automatic placement
UNSLOTH_VIDEO_VAE_MULTIGPU=forcerestores it under Automatic.