Repository navigation
Studio: stop the max speed tier recompiling on every new prompt length - #11731
Conversation
dynamic=False recompiled the regional blocks on every new prompt length for DiTs whose blocks see the text tokens (Qwen-Image-2.1 paid 4-6 s on about half of new prompts). Automatic dynamic (None) keeps the first shape static and autotuned and generalises a dimension once it changes. U-Net whole-module compile stays static; the compile-cache fingerprint keys the new mode apart.
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86f43cdca5
ℹ️ 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".
| # max compiles DiTs with automatic dynamic (None); keyed apart from the old static | ||
| # bundles. | ||
| "dynamic": None if effective_speed == SPEED_MAX else True, |
There was a problem hiding this comment.
Persist the auto-dynamic generalized graph
For a max-tier DiT rendered at the same width, height, and batch size with different prompt token lengths, this initially saves only the first static artifact. When the second prompt triggers automatic generalization, the cache is not dirtied again: the generation path registers only (width, height, batch), and compiled_shapes_are_static() still classifies max as static, so register_shape() sees the existing tuple and save_async() remains a no-op. Consequently, each process restart reloads the static-only bundle and pays the prompt-length generalizing compile again; the cache lifecycle needs to re-save after automatic dynamic generalization or defer its initial save.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. The max tier now marks its DiTs as automatic dynamic, generate counts dynamo's compiled graphs across the render, and compile_cache.mark_recompiled re-dirties the context when an automatic-dynamic DiT compiled new graphs at an already-registered shape, so save_async rewrites the bundle with the generalised graph. Fixed in b27c8fb, tests added.
…mension Automatic dynamic recompiles on the first new text length at a (width, height, batch) the bundle already covers, which register_shape cannot see. Count dynamo's compiled graphs across the render and re-dirty the cache context when an automatic-dynamic DiT compiled new ones, so a fresh process loads the generalised graph instead of recompiling it.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b27c8fbf7d
ℹ️ 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".
| if auto_dynamic_active(state.pipe) and dynamo_graph_count() > graphs_before: | ||
| # Automatic dynamic recompiles on the first new text length at an already-registered | ||
| # (width, height, batch): persist those graphs too, or every fresh process pays them again. | ||
| compile_cache.mark_recompiled(state.compile_cache_ctx) |
There was a problem hiding this comment.
Persist recompiles from cancelled renders
When a max-tier render is cancelled or raises after Dynamo has generalized the prompt-length graph, control exits before this success-only check. A later successful render can reuse that generalized in-memory graph, so unique_graphs does not increase, while register_shape() also stays clean because width, height, and batch were already recorded; the on-disk bundle therefore remains static-only and recompiles after restart. Fresh evidence beyond the prior comment is the cancellation/error path skipping this bookkeeping entirely, so the context should be dirtied when compilation occurred even if the render does not return successfully.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 45116b7. The render loop now has an exception path that compares the Dynamo graph count against the pre-render value and calls mark_recompiled before re-raising, so a later successful render's save_async rewrites the bundle even though it compiles nothing new.
… already generalised a graph
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45116b7f2b
ℹ️ 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".
| ``max`` compiles regional blocks with automatic dynamic (static until a dimension changes) and | ||
| U-Net whole-module is always static; | ||
| ``default`` DiT compiles dynamic=True (one artifact across shapes). The compile-cache layer | ||
| keys on this to re-save its bundle when a session hits an uncovered shape.""" |
There was a problem hiding this comment.
Avoid treating auto-dynamic DiTs as fully static
After a max-tier DiT has generalized a changed width, height, or batch dimension, later unseen values of that dimension reuse the symbolic graph without compiling. However, compiled_shapes_are_static() still returns true for every max-tier pipeline, so the generation path calls register_shape() for every new tuple and unnecessarily reserializes and rewrites the entire compile-cache bundle. This can also delay unloads, which wait for background saves. Keep static shape tracking for the U-Net path, but for auto-dynamic DiTs rely on the new Dynamo graph-count delta to dirty the cache only when a graph was actually compiled.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a69aa4a. compiled_shapes_are_static now returns False on the max tier when a DiT compiled auto-dynamic (U-Net whole-module compiles stay static), so register_shape no longer rewrites the bundle for every new tuple; the graph-count delta in generate is what dirties it.
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
…k fail (unslothai#11749) * Chat UI driver: wait for the Recents thread to load, and let the check fail The Recents step clicked the first sidebar row, slept 500 ms and read the turns once. Opening a chat runs a history loader that awaits the thread, its active runs, its messages and its research state in sequence before anything renders. On the Windows lane, which runs two Studios and two browsers on one runner, that took longer than 500 ms in 15 of 57 Windows runs on 2026-09-23, so the read found turns_text=''. The server logs of those runs show the messages request returning 200 at or after the moment the driver navigated away; the thread was loading, not empty. It never failed a job because the soft_fail sat inside the try whose except Exception was meant for click errors. In STRICT mode the AssertionError was caught, logged as "recent-thread click 0 failed", and the step passed. The FAIL line that shows up in failing runs of unslothai#11706 and unslothai#11731 is this swallowed message; those jobs failed on other steps. The step now: - picks the Recents row whose title is a prompt this run sent, falling back to the listed order, since the most recent row need not be ours - waits up to 20 s for the URL to name that thread and for a user turn to contain one of our prompts, instead of reading once after 500 ms - raises outside the click retry, so a thread that opens without our turns fails the run in STRICT mode tests/studio/test_chat_ui_recents_step.py runs the helper in Chromium against a page whose thread renders after 1.5 s (passes), one that never shows our prompts (fails), and one with an unrelated chat above ours (checks ours), plus source checks for the sleep and the swallowing except. * Chat UI driver: keep looking for this run's chat when Recents titles are generated With auto-titling no Recents title equals a prompt this run sent, so the fallback tried the newest row, stopped there, and failed after 20 s when that row was someone else's chat, even with ours next in the list. A row titled with our prompt is ours and must still show our turns. A row reached only by the fallback is now judged when it loads: our prompt passes, someone else's turns or none moves on to the next row, within a 60 s budget. * Chat UI driver: do not judge a Recents row from the previous thread's turns The chat keeps one runtime while the next thread loads, so the previous thread's turns stay on screen for a while after the URL changes. Judging a fallback row on those could reject our chat as someone else's, or, with our thread already open, pass a different chat on our stale turns. Snapshot the user turns and open thread before each click, and count turns identical to that snapshot as not loaded yet unless the clicked row is the thread that was already open. The fixture can now keep stale turns on screen until the next thread loads, as the app does. * Chat UI driver: reopen this run's chat by id in the Recents step The prompts are fixed, so on a reused Studio home an earlier run's chat can carry the same title and turns, and the title match would open it and pass without ever reopening this run's chat. Read this run's chat id while it is open, from ?thread= or the active Recents row, and have the Recents step open exactly that row and require our turns in it. The title search stays as the fallback when no id is on the page. A test evaluates the driver's capture expression itself, since it only runs there. * Chat UI driver: find this run's chat by id anywhere in the sidebar Pinned and project chats use the same row testid as Recents, so on a reused home this run's chat can sit past the first 20 rows the title search reads. Locate the captured id directly across every row, and walk candidate rows rather than indices so a strict row, known to be ours by id or title, still has to show our turns. * Recents step tests: skip when another file left a Playwright stand-in Backend CI's CPU studio shard has no Playwright, and test_heavy_thread_measurement_integrity.py installs a stand-in playwright.sync_api whose every name raises RuntimeError. importorskip then succeeds, and all 12 browser tests errored in that job. A stand-in that raises now skips, like a missing package.
…k fail (unslothai#11749) * Chat UI driver: wait for the Recents thread to load, and let the check fail The Recents step clicked the first sidebar row, slept 500 ms and read the turns once. Opening a chat runs a history loader that awaits the thread, its active runs, its messages and its research state in sequence before anything renders. On the Windows lane, which runs two Studios and two browsers on one runner, that took longer than 500 ms in 15 of 57 Windows runs on 2026-09-23, so the read found turns_text=''. The server logs of those runs show the messages request returning 200 at or after the moment the driver navigated away; the thread was loading, not empty. It never failed a job because the soft_fail sat inside the try whose except Exception was meant for click errors. In STRICT mode the AssertionError was caught, logged as "recent-thread click 0 failed", and the step passed. The FAIL line that shows up in failing runs of unslothai#11706 and unslothai#11731 is this swallowed message; those jobs failed on other steps. The step now: - picks the Recents row whose title is a prompt this run sent, falling back to the listed order, since the most recent row need not be ours - waits up to 20 s for the URL to name that thread and for a user turn to contain one of our prompts, instead of reading once after 500 ms - raises outside the click retry, so a thread that opens without our turns fails the run in STRICT mode tests/studio/test_chat_ui_recents_step.py runs the helper in Chromium against a page whose thread renders after 1.5 s (passes), one that never shows our prompts (fails), and one with an unrelated chat above ours (checks ours), plus source checks for the sleep and the swallowing except. * Chat UI driver: keep looking for this run's chat when Recents titles are generated With auto-titling no Recents title equals a prompt this run sent, so the fallback tried the newest row, stopped there, and failed after 20 s when that row was someone else's chat, even with ours next in the list. A row titled with our prompt is ours and must still show our turns. A row reached only by the fallback is now judged when it loads: our prompt passes, someone else's turns or none moves on to the next row, within a 60 s budget. * Chat UI driver: do not judge a Recents row from the previous thread's turns The chat keeps one runtime while the next thread loads, so the previous thread's turns stay on screen for a while after the URL changes. Judging a fallback row on those could reject our chat as someone else's, or, with our thread already open, pass a different chat on our stale turns. Snapshot the user turns and open thread before each click, and count turns identical to that snapshot as not loaded yet unless the clicked row is the thread that was already open. The fixture can now keep stale turns on screen until the next thread loads, as the app does. * Chat UI driver: reopen this run's chat by id in the Recents step The prompts are fixed, so on a reused Studio home an earlier run's chat can carry the same title and turns, and the title match would open it and pass without ever reopening this run's chat. Read this run's chat id while it is open, from ?thread= or the active Recents row, and have the Recents step open exactly that row and require our turns in it. The title search stays as the fallback when no id is on the page. A test evaluates the driver's capture expression itself, since it only runs there. * Chat UI driver: find this run's chat by id anywhere in the sidebar Pinned and project chats use the same row testid as Recents, so on a reused home this run's chat can sit past the first 20 rows the title search reads. Locate the captured id directly across every row, and walk candidate rows rather than indices so a strict row, known to be ours by id or title, still has to show our turns. * Recents step tests: skip when another file left a Playwright stand-in Backend CI's CPU studio shard has no Playwright, and test_heavy_thread_measurement_integrity.py installs a stand-in playwright.sync_api whose every name raises RuntimeError. importorskip then succeeds, and all 12 browser tests errored in that job. A stand-in that raises now skips, like a missing package.
unslothai#11731) * Studio: compile the max tier's DiT blocks with automatic dynamic dynamic=False recompiled the regional blocks on every new prompt length for DiTs whose blocks see the text tokens (Qwen-Image-2.1 paid 4-6 s on about half of new prompts). Automatic dynamic (None) keeps the first shape static and autotuned and generalises a dimension once it changes. U-Net whole-module compile stays static; the compile-cache fingerprint keys the new mode apart. * Studio: keep the video max-tier comments accurate under automatic dynamic * Studio: re-save the compile cache after the max tier generalises a dimension Automatic dynamic recompiles on the first new text length at a (width, height, batch) the bundle already covers, which register_shape cannot see. Count dynamo's compiled graphs across the render and re-dirty the cache context when an automatic-dynamic DiT compiled new ones, so a fresh process loads the generalised graph instead of recompiling it. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: dirty the compile cache when a cancelled or failed max render already generalised a graph * Studio: track max-tier auto-dynamic DiT bundles by graph count, not per shape * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Problem
The
maxspeed tier compiles every DiT's regional blocks withdynamic=False. On a DiT whose blocks see the text tokens, the sequence length changes with every new prompt, so each new prompt length forces a fresh max-autotune compile. Qwen-Image-2.1 is such a model: its blocks run over prompt + image tokens. On it,maxpaid an extra 3 to 7 s on about half of all new prompts. That cost more than the tier's few-percent steady-state gain.Fix
maxtier now compiles DiT blocks with automatic dynamic (dynamic=None). The first shape still compiles static and autotuned. When a dimension changes, dynamo generalises that dimension once, and later prompt lengths reuse the graph.maxondynamic: null, so the old static bundles are never reused for the new mode.video.pythat describedmaxasdynamic=Falseare reworded. The MiniMax-H3 demotion and the HunyuanVideo attention-trim hold-off are unchanged.Measurements
Qwen-Image-2.1 bf16, 1024x1024, 25 steps, CFG 1, B200, 12 new prompts in a row after one warm-up. Other tenants loaded the GPU during parts of this run (utilisation 40 to 86 percent at the start of some arms), so absolute seconds are noisy. The recompile count is not affected by that.
The static arm's slow renders are 4.8 to 9.6 s; with automatic dynamic, every prompt after the second stays between 1.8 and 2.8 s. Steady-state medians on a repeated prompt were 2.82 s (static) and 2.71 s (automatic dynamic), within the noise of this run. A paired, alternated rerun follows.
Paired rerun (static and automatic dynamic alternated twice)
Same model and settings, 12 new prompts per arm after a warm-up, then 5 repeats of already-seen prompts for the steady state. The GPU was idle when the first arm started (utilisation 0%). Another tenant then loaded it (38% and 44% at the start of the next two arms, 89% at the last), so the second pair is heavily contended.
speed_optimsis identical in every arm (compiled, cuda_graph, tf32, fused_qkv).Tests
test_speed_max_enables_tf32_and_fused_qkvnow assertsdynamic is Noneformax. The U-Net tests still assertdynamic=False.tests/test_diffusion*.py tests/test_video*.py: 3826 passed. The failures are the same environment-only ones as onmain: 15 intest_diffusion_dataset_api.pyand one GGUF Q8_0 registry case.