Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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: MOSS batch key renders alone when its module cannot im…
…port

coalesce_prompt_key imported diffusion_moss_image (which needs diffusers at import) outside the
try, so a backend without diffusers raised from the key instead of rendering alone.

[skip ci]
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit fbd251cda80626cd29e4b704fe8f7c8f9c31aa35
6 changes: 4 additions & 2 deletions studio/backend/core/inference/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5127,8 +5127,10 @@ def coalesce_prompt_key(family: Any, pipe: Any, prompt: str) -> Optional[tuple]:

name = getattr(family, "name", None)
if name == MOSS_IMAGE_FAMILY_NAME:
from .diffusion_moss_image import coalesce_key
try:
if getattr(pipe, "transformer", None) is None:
return None
try: # the MOSS module needs diffusers at import; a missing or broken one renders alone
from .diffusion_moss_image import coalesce_key
return coalesce_key(pipe)
except Exception: # noqa: BLE001 - an unreadable load renders alone
return None
Expand Down
13 changes: 13 additions & 0 deletions studio/backend/tests/test_image_concurrency_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ def test_moss_image_never_batches():
assert coalesce_prompt_key(family, None, "a fox") is None


def test_moss_image_renders_alone_when_its_module_cannot_import(monkeypatch):
"""coalesce_prompt_key never raises when the MOSS module (diffusers at import) is unavailable."""
import sys

from core.inference.diffusion import coalesce_prompt_key

monkeypatch.delitem(sys.modules, "core.inference.diffusion_moss_image", raising = False)
monkeypatch.setitem(sys.modules, "diffusers.configuration_utils", None)
family = types.SimpleNamespace(name = "moss-image")
pipe = types.SimpleNamespace(transformer = object())
assert coalesce_prompt_key(family, pipe, "a fox") is None


def test_qwen_image_21_never_batches():
"""A batch gains about 3% (A100, INT8) while a member lands about 35 dB from its solo render."""
from core.inference.diffusion import coalesce_prompt_key
Expand Down