Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b24c827
Studio images: family batch adapters, measured batching race and per-…
danielhanchen Nov 26, 2026
28a9ecb
Studio images: no coalescing wait at a shape with no admitted size; r…
danielhanchen Nov 26, 2026
f437380
Studio images: a batch size that loses the race drops its CUDA graphs
danielhanchen Nov 26, 2026
58e0db6
Studio images: test that a measured win coalesces at the winning size…
danielhanchen Nov 26, 2026
6c55fd6
Studio images: members a fired batch could not take coalesce again be…
danielhanchen Nov 26, 2026
f5b1cec
Studio images: no shared call while FBCache can run; decode coalesced…
danielhanchen Nov 26, 2026
e8879fb
Studio images: FBCache coupling test holds with the length guard and …
danielhanchen Nov 26, 2026
731542d
Studio images: free the failed call before the halved retry; key race…
danielhanchen Nov 26, 2026
a8e5e17
Studio images: an edit at a new reference size never evicts a text-to…
danielhanchen Nov 26, 2026
9f0b357
Studio images: batch-size graphs get their own pool and graph budget;…
danielhanchen Nov 26, 2026
51c1217
Studio images: the race's batched-eager arm really runs with the grap…
danielhanchen Nov 26, 2026
bae160e
Studio images: key batching race verdicts by card topology
danielhanchen Nov 26, 2026
95de9ec
Studio images: price and scope batched CUDA graphs by what they hold
danielhanchen Nov 27, 2026
fe47b92
Studio images: seeded joins, eager wins and static compiles follow wh…
danielhanchen Nov 27, 2026
1a97100
Studio images: pin the Fast CFG interval in the batch key
danielhanchen Nov 27, 2026
53efa94
Studio images: the eager arm stays eager, graphed verdicts keep their…
danielhanchen Nov 27, 2026
8ca902e
Studio images: an aborted race size drops the batched graphs its warm…
danielhanchen Nov 27, 2026
3221b2c
Merge remote-tracking branch 'origin/main' into studio-batch-infra-main
danielhanchen Nov 27, 2026
92efbc1
Studio images: block graph handles never count a graphed race winner …
danielhanchen Nov 27, 2026
705da24
Studio images: a graphed race verdict holds only beside a live graph …
danielhanchen Nov 27, 2026
0d7d96d
Studio images: a measured batching win serves only with a passing G2c…
danielhanchen Nov 27, 2026
395de8b
Studio images: the race's replay check compares row 0 with its solo r…
danielhanchen Nov 27, 2026
e5b8e38
Studio images: the quality gate reads the path a race really ran, and…
danielhanchen Nov 27, 2026
71e85dc
Studio images: the race picks a qualifying arm first and refuses size…
danielhanchen Nov 27, 2026
67a7dcd
Studio images: a batched warm-up that runs out of memory keeps the si…
danielhanchen Nov 27, 2026
0dac8dd
Merge remote-tracking branch 'origin/main' into studio-batch-g2c-gate
danielhanchen Nov 27, 2026
7859edb
Studio images: the race never measures across a change in how the loa…
danielhanchen Nov 27, 2026
9173835
Studio images: the route leaves MOSS to the engine, and an eager win …
danielhanchen Nov 27, 2026
6e6b15b
Studio images: an adapted load never consumes the adapter-free batchi…
danielhanchen Nov 27, 2026
6332acb
Studio images: withhold an eager batching win once a same-size graph …
danielhanchen Nov 27, 2026
9993ecd
Merge remote-tracking branch 'origin/main' into studio-batch-g2c-gate
danielhanchen Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Studio images: block graph handles never count a graphed race winner …
…as missing

BlockGraphSet keeps no batch-size labels and records each new layout on
demand, user calls included, so its empty label set made every graphed
verdict on an offloaded or layer-split load fall back to the eager arm.
Only step-graph handles, which never record on a user's request, decide
whether a batch-size graph is missing.

[skip ci]
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit 92efbc14a030fb855d6b244f9bcbf29c50b31c9d
10 changes: 7 additions & 3 deletions studio/backend/core/inference/diffusion_batch_race.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,12 @@ def _neighbour_check(solo, batch, prompts: list, seeds: list, *, eager: bool) ->


def batched_graph_sizes(state: Any) -> Optional[set]:
"""Batch sizes every recording graph handle of this load holds a graph for now; None when the load has no graphs."""
handles = list(getattr(state, "cuda_graphs", ()) or ())
"""Batch sizes every step-graph handle of this load holds a graph for now; None when no handle constrains it.

Only handles that label their batch-size graphs (GraphedForward ``_batched``) count: they never record one on a
user's request. Block / segment graphs (BlockGraphSet, offloaded and layer-split loads) record each new layout on
demand, user calls included, so a size they raced graphed is never missing for them."""
handles = [h for h in (getattr(state, "cuda_graphs", ()) or ()) if hasattr(h, "_batched")]
if not handles:
return None
held = None
Expand Down Expand Up @@ -691,7 +695,7 @@ def effective_verdict(
return verdict
Comment on lines +858 to +859

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 Revalidate eager winners when later races install matching graphs

If a size wins on the eager arm at canvas A, then a later race wins on the graph arm at canvas B with the same tensor shapes (for example, the same dimensions and guidance but a different step count), this early return still admits A as eager. The second race has installed a graph that GraphedForward will replay for A, and the request route does not force eager execution. Having drop_batched() only enforces the winner immediately after its race; it does not prevent later captures from changing that path. Consequently, an eager-only quality PASS and eager reproducibility checks can authorize graph-backed requests. Force the recorded eager path per request, or withhold its verdict whenever matching graphs have subsequently appeared.

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.

Fixed in 6332acb. effective_verdict now withholds any promoted eager-path verdict (an eager-arm win, or a graphed win falling back to its eager arm) while a step-graph handle holds a batch-size graph of that size. Graphs key on tensor shapes, and a later race at another canvas or step count can record one with the same shapes, so the eager path could no longer be guaranteed. Withheld sizes fall back to serial, and seeded joins are refused with them. A graphed win at its own canvas and layout still holds, and other sizes are unaffected. New test test_an_eager_win_is_withheld_once_a_later_race_records_a_graph_of_that_size fails before the change; 338 batching and graph tests pass.

held = batched_graph_sizes(state)
if held is None:
return verdict # no graphs on this load: the graphed arm ran eager too
return verdict # no step graphs: the graphed arm ran eager, or on block graphs that record on demand
same_layout = verdict.get("layout") is not None and layout_token(layout) == verdict.get(
"layout"
)
Expand Down
27 changes: 27 additions & 0 deletions studio/backend/tests/test_image_batch_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,3 +1166,30 @@ def test_an_aborted_size_drops_the_batched_graphs_its_warm_up_recorded(monkeypat
)
assert calls == [1, 4] and report["aborted"] is True
assert dropped == [4] and report["sizes"]["4"]["batched_graphs_dropped"] == 1


def test_block_graph_handles_never_count_a_graphed_winner_as_missing():
"""BlockGraphSet (offloaded / layer-split loads) records each layout on demand, user calls included, and keeps no
per-batch-size labels: only handles that refuse to record on a user's request (GraphedForward) decide."""
import inspect

from core.inference.diffusion_block_graph import BlockGraphSet

assert "_batched" not in inspect.getsource(BlockGraphSet)
graphed_win = {
"promoted": True,
"arm": "batched",
"layout": race.layout_token(()),
"arms": {"batched": {"promoted": True}, "batched_eager": {"promoted": False}},
}
blocks = types.SimpleNamespace(cache = {(0, "k4"): object()})
assert (
race.effective_verdict(
graphed_win, 4, types.SimpleNamespace(cuda_graphs = (blocks,)), layout = ()
)["promoted"]
is True
)
# Beside a step-graph handle, that handle still decides.
step = types.SimpleNamespace(cache = {"k1": object()}, _batched = {})
mixed = types.SimpleNamespace(cuda_graphs = (blocks, step))
assert race.effective_verdict(graphed_win, 4, mixed, layout = ())["promoted"] is False