Skip to content

Studio video: keep the stream encode hook out of a compiled VAE decode graph - #14822

Merged
danielhanchen merged 1 commit into
mainfrom
dh/s3-diff-stream-encode-compiled-vae
Oct 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
dh/s3-diff-stream-encode-compiled-vae

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

With UNSLOTH_DIFFUSION_COMPILE_VAE=1, Studio compiles vae.decode, and the stream-encode forward hook on vae.decoder ran inside that graph. Its thread start, queue put and CUDA stream context each broke the graph: 6 breaks and 6 graphs on a tiny Wan VAE, under both the eager backend and inductor.

The hook is now registered through torch.compiler.disable, so it runs as one eager island: 2 breaks and 3 graphs. The decoder compute stays compiled, and the streamed mp4 still matches the exported frames and is still used. Skipping the stream session under a compiled decode would give 0 breaks but lose the overlapped encode, so streaming is kept.

Tests: a new test compiles the decode the way Studio does (fullgraph=False, dynamic=True) and checks the frames, the stream use and the break count on CPU and CUDA. On a B200: 2 failed / 11 passed on main, 13 passed here.

Not measured: the time cost of the 2 remaining breaks under compile.

…e graph

With UNSLOTH_DIFFUSION_COMPILE_VAE=1 the decoder forward hook ran inside
the compiled decode, and its thread start, queue put and CUDA stream
context each broke the graph (6 breaks, 6 graphs on the tiny Wan VAE).
Register the hook through torch.compiler.disable so it runs as one eager
island: 2 breaks, 3 graphs, and the streamed mp4 is still used.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T23:07:35.301282Z 2d9970f 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 2d9970fd5e

ℹ️ 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 8cbcf05 into main Oct 23, 2026
2 of 35 checks passed
@danielhanchen
danielhanchen deleted the dh/s3-diff-stream-encode-compiled-vae branch October 23, 2026 00:36
danielhanchen added a commit that referenced this pull request Oct 23, 2026
… in #14822 (#14852)

pre-commit.ci fails `ruff-format-with-kwargs` again on PRs queued after
00:36 UTC (#14834, #14835, #14836, #14842, #14845):
`studio/backend/tests/test_video_stream_encode.py` was merged in #14822
without the formatter, so every PR's all-files run rewrites it.

Same class as #14817. `python scripts/run_ruff_format.py` (the hook's
entry point, `ruff==0.6.9`) applied to that one file. The AST is
identical before and after, `ruff check` passes, and a full run of the
hook over every tracked Python file on this branch changes nothing else.
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