Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: same diffusion pixels on every B200 server for FLUX.2 Klein and Z-Image (#14483)

Daniel Han5fdcfe585110
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index f04e4eee464..c18af6701de 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -258,7 +258,7 @@ class DiffusionFamily:
# Fresh servers rendered 2-4 variants of one seed here (FLUX.1, Z-Image, Qwen-Image; the edit siblings share their DiT):
-# near-tied norm-reduction configs, benchmarked per process, sum in different orders. B200 measured deterministic.
+# near-tied norm-reduction configs, benchmarked per process, sum in different orders. B200: FLUX.1 measured deterministic.
_REDUCTION_RACE_ARCHS: tuple[tuple[int, int], ...] = ((8, 0), (8, 9), (12, 0))
# Qwen-Image races on B200 too (torch 2.14): fresh processes rendered one seed 26 dB apart; with the filter 6/6 matched bitwise.
_QWEN_REDUCTION_RACE_ARCHS: tuple[tuple[int, int], ...] = _REDUCTION_RACE_ARCHS + ((10, 0),)
@@ -434,6 +434,8 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (
),
),
pipeline_class = "Flux2KleinPipeline",
+ # B200: a per-process XBLOCK pick for the q/k RMSNorm reduction changed the latent and stuck to the compile home.
+ filter_reduction_configs_archs = ((10, 0),),
uses_negative_prompt = False,
transformer_class = "Flux2Transformer2DModel",
base_repo = "black-forest-labs/FLUX.2-klein-4B",
@@ -1031,7 +1033,8 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (
auto_prefer = _GATED_AUTO_PREFER,
preview_factors = "zimage",
),
- filter_reduction_configs_archs = _REDUCTION_RACE_ARCHS,
+ # B200 too: 1 of 4 fresh servers picked R0_BLOCK 1024 (others 4096) and rendered other latents.
+ filter_reduction_configs_archs = _REDUCTION_RACE_ARCHS + ((10, 0),),
cudnn_benchmark = False,
comfy_flow_shift = 3.0, # ComfyUI shift 3 for Turbo and base (Turbo already ships 3.0)
pipeline_class = "ZImagePipeline",
diff --git a/studio/backend/tests/fixtures/diffusion_family_data_freeze.json b/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
index 1280e2062d8..1bff063580b 100644
--- a/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
+++ b/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
@@ -313,7 +313,12 @@
"flux.2-klein": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [
+ [
+ 10,
+ 0
+ ]
+ ]
},
"flux.3-klein": {
"cudnn_benchmark": true,
@@ -486,6 +491,10 @@
[
12,
0
+ ],
+ [
+ 10,
+ 0
]
]
}
diff --git a/studio/backend/tests/test_diffusion_reduction_filter_arch.py b/studio/backend/tests/test_diffusion_reduction_filter_arch.py
index 1142b6b4962..079b830a713 100644
--- a/studio/backend/tests/test_diffusion_reduction_filter_arch.py
+++ b/studio/backend/tests/test_diffusion_reduction_filter_arch.py
@@ -6,7 +6,7 @@ one image in every fresh server there.
A few of their norm reductions get several configs that sum in different orders, and a cold-cache server benchmarks
them in its own process on near-equal timings: fresh servers rendered 2-4 variants per seed on an RTX PRO 6000, A100
-and L4. B200 servers were deterministic for FLUX.1 and Z-Image but not Qwen-Image, so the opt-in is per (family,
+and L4. B200 servers were deterministic for FLUX.1 but not Qwen-Image or Z-Image, so the opt-in is per (family,
compute capability)."""
from __future__ import annotations
@@ -24,6 +24,7 @@ _SM120 = (12, 0)
_MEASURED_ARCHS = ((8, 0), (8, 9), (12, 0))
_IMAGE_FAMILIES = ("flux.1", "z-image", "qwen-image", "flux.1-kontext", "qwen-image-edit")
_QWEN_FAMILIES = ("qwen-image", "qwen-image-edit", "qwen-image-layered")
+_B200_PINNED = (*_QWEN_FAMILIES, "z-image")
def _family(name):
@@ -70,15 +71,15 @@ def test_the_race_families_share_one_arch_list():
for name in _IMAGE_FAMILIES:
expected = (
diffusion_families._QWEN_REDUCTION_RACE_ARCHS
- if name in _QWEN_FAMILIES
+ if name in _B200_PINNED
else diffusion_families._REDUCTION_RACE_ARCHS
)
- assert _family(name).filter_reduction_configs_archs == expected
+ assert tuple(_family(name).filter_reduction_configs_archs) == tuple(expected)
assert set(diffusion_families._REDUCTION_RACE_ARCHS) == set(_MEASURED_ARCHS)
assert set(diffusion_families._QWEN_REDUCTION_RACE_ARCHS) == {*_MEASURED_ARCHS, (10, 0)}
[email protected]("name", _QWEN_FAMILIES)
[email protected]("name", _B200_PINNED)
def test_qwen_image_also_pins_on_b200(monkeypatch, name):
_on(monkeypatch, (10, 0))
fam = _family(name)
@@ -89,8 +90,8 @@ def test_qwen_image_also_pins_on_b200(monkeypatch, name):
@pytest.mark.parametrize("cap", [(10, 0), (10, 3), (9, 0), (7, 5), (12, 1), None])
@pytest.mark.parametrize("name", _IMAGE_FAMILIES)
def test_image_family_keeps_inductor_pick_elsewhere(monkeypatch, name, cap):
- if cap == (10, 0) and name in _QWEN_FAMILIES:
- pytest.skip("Qwen-Image pins on B200 (test_qwen_image_also_pins_on_b200)")
+ if cap == (10, 0) and name in _B200_PINNED:
+ pytest.skip("Qwen-Image and Z-Image pin on B200 (test_qwen_image_also_pins_on_b200)")
_on(monkeypatch, cap)
fam = _family(name)
assert cc.family_filters_reductions(fam) is False
diff --git a/studio/backend/tests/test_diffusion_speed.py b/studio/backend/tests/test_diffusion_speed.py
index 16eeaac4e14..ee04666cb0d 100644
--- a/studio/backend/tests/test_diffusion_speed.py
+++ b/studio/backend/tests/test_diffusion_speed.py
@@ -678,6 +678,26 @@ def test_cudnn_benchmark_opt_out_image_families():
assert off == {"qwen-image", "flux.1", "flux.2-dev", "z-image", "sdxl"}
+ "repo, cap, pinned",
+ [
+ ("Tongyi-MAI/Z-Image-Turbo", (10, 0), True),
+ ("Tongyi-MAI/Z-Image-Turbo", (8, 9), True),
+ ("Tongyi-MAI/Z-Image-Turbo", (9, 0), False),
+ ("black-forest-labs/FLUX.2-klein-4B", (10, 0), True),
+ ("black-forest-labs/FLUX.2-klein-base-4B", (10, 0), True),
+ ("black-forest-labs/FLUX.2-klein-4B", (8, 9), False),
+ ("black-forest-labs/FLUX.1-schnell", (10, 0), False),
+ ],
+)
+def test_reduction_filter_archs(monkeypatch, repo, cap, pinned):
+ from core.inference import diffusion_compile_config as cc
+ from core.inference.diffusion_families import detect_family
+
+ monkeypatch.setattr(cc, "_device_capability", lambda: cap)
+ assert cc.family_filters_reductions(detect_family(repo)) is pinned
+
+
def test_speed_max_enables_tf32_and_fused_qkv(monkeypatch):
torch = _stub_torch(monkeypatch)
pipe = _Pipe(with_compile = True, with_fuse = True)