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: an aborted race size drops the batched graphs its warm…
…-up recorded

A request arriving after the batched warm-up aborted the size before the
drop, so the graph it recorded kept its static buffers and pool until a
reset or unload, though no verdict could ever admit it.

[skip ci]
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit 8ca902ef0c647202b8d051eed8dc69ffe66d18fc
29 changes: 19 additions & 10 deletions studio/backend/core/inference/diffusion_batch_race.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ def batch(
_neighbour_check(solo, batch, prompts, seeds, eager = best == "batched_eager")
)
except _Aborted:
report["sizes"][str(size)] = {"aborted": "a request started waiting for the slot"}
# No verdict for this size, so no request can use what its warm-up recorded: drop it before returning.
report["sizes"][str(size)] = {
"aborted": "a request started waiting for the slot",
"batched_graphs_dropped": _drop_batched(handles, size),
}
report["aborted"] = True
break
except Exception as exc: # noqa: BLE001 - only a capacity failure is a verdict; anything else raises
Expand All @@ -564,22 +568,27 @@ def batch(
# A losing size never runs batched here, and an eager-won size must not replay the graphs the race
# recorded (dispatch never bypasses them; user calls never record new ones): drop that size's graphs (their
# own pool returns to the card; under BATCH_POOL_ENV=shared they stay in the one pool).
dropped = 0
for handle in handles:
drop = getattr(handle, "drop_batched", None)
if callable(drop):
try:
dropped += int(drop(size) or 0)
except Exception: # noqa: BLE001
pass
verdict["batched_graphs_dropped"] = dropped
verdict["batched_graphs_dropped"] = _drop_batched(handles, size)
Comment on lines +620 to +624

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 Enforce eager race winners for block-graph loads

On a load using BlockGraphSet, an eager-arm win does not actually switch subsequent coalesced requests to eager execution: _drop_batched() skips these handles because they have no drop_batched() method, and generate() re-enables them through cuda_graph.set_bypass() before each chunk. effective_verdict() nevertheless accepts the eager winner unchanged. With an eager G2c PASS, this admits requests using the graph path that lost the race and may lack a graph quality PASS; the seeded reproducibility checks also describe a different execution path. Apply a per-call bypass for eager-winning sizes, or withhold their promotion when the handle cannot enforce that path.

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 3e8503c312 by withholding promotion: an eager-arm win now stands only when every graph handle can drop its batched graphs (drop_batched). The race records why it withheld one, and effective_verdict() applies the same rule to saved verdicts, including a graphed win that falls back to its eager arm. New test: a fast eager win on block-graph-style handles is not promoted by the race or from a saved verdict (fails before the fix); a control with drop_batched still promotes.

if verdict.get("failed"):
_release_cached() # after the drop, so the batched pool's blocks go back too
if persist:
verdict["persisted"] = record(state, width, height, guidance, size, verdict, steps)
return report


def _drop_batched(handles: Sequence[Any], size: int) -> int:
"""Drop every handle's batched graphs of ``size``; how many went."""
dropped = 0
for handle in handles:
drop = getattr(handle, "drop_batched", None)
if callable(drop):
try:
dropped += int(drop(size) or 0)
except Exception: # noqa: BLE001
pass
return dropped


def _capacity_failure(exc: BaseException) -> bool:
"""CUDA / MPS out of memory or a unified-memory refusal: the size does not fit this card, a verdict, not a bug."""
try:
Expand Down
24 changes: 24 additions & 0 deletions studio/backend/tests/test_image_batch_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,3 +1142,27 @@ def broken(**kw):
repeats = 3,
accuracy = False,
)


def test_an_aborted_size_drops_the_batched_graphs_its_warm_up_recorded(monkeypatch):
"""A request arriving after the batched warm-up (calls [1, 4]) aborts the size with no verdict: an otherwise serial
load can never use the graph that warm-up recorded, so it goes before the aborted report returns."""
monkeypatch.setattr(race, "record", lambda *a, **k: True)
dropped = []
handle = types.SimpleNamespace(
set_bypass = lambda on: None, drop_batched = lambda size: dropped.append(size) or 1
)
generate, clock, calls = _fake_generate(lambda rows: 1.0)
report = race.run_race(
generate,
types.SimpleNamespace(cuda_graphs = (handle,)),
idle = lambda: len(calls) < 2,
width = 512,
height = 512,
sizes = (4,),
repeats = 3,
accuracy = False,
clock = lambda: clock["t"],
)
assert calls == [1, 4] and report["aborted"] is True
assert dropped == [4] and report["sizes"]["4"]["batched_graphs_dropped"] == 1