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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio diffusion: keep the CFG-parallel weight probe inside large inference weights (#14844)
Daniel Han89ae8fa19975
diff --git a/studio/backend/core/inference/diffusion_multigpu.py b/studio/backend/core/inference/diffusion_multigpu.pyindex cc76b436ca5..861e9f4a6ff 100644--- a/studio/backend/core/inference/diffusion_multigpu.py+++ b/studio/backend/core/inference/diffusion_multigpu.py@@ -1816,9 +1816,9 @@ def weights_probe(module: Any, index_cache: Optional[dict] = None) -> Optional[bkey = (n, flat.device)idx = cache.get(key)if idx is None:- idx = torch.linspace(- 0, n - 1, steps = min(n, _PROBE_SAMPLES), device = flat.device- ).long()+ # integer spacing: a float32 linspace rounds n - 1 up to n past 2**24 bytes and reads past the end+ k = min(n, _PROBE_SAMPLES)+ idx = torch.arange(k, device = flat.device) * (n - 1) // max(k - 1, 1)cache[key] = idxby_device.setdefault(flat.device, []).append(flat.index_select(0, idx))if not by_device:diff --git a/studio/backend/tests/test_diffusion_multigpu.py b/studio/backend/tests/test_diffusion_multigpu.pyindex 5e65112e3ae..98b22d1abfe 100644--- a/studio/backend/tests/test_diffusion_multigpu.py+++ b/studio/backend/tests/test_diffusion_multigpu.py@@ -2439,6 +2439,19 @@ def test_probe_sees_an_in_place_edit_of_an_inference_tensor():assert mg.weights_probe(_Dit()) is None+def test_probe_stays_inside_inference_weights_past_two_to_the_24_bytes():+ # 3072 x 3072 bf16 = 18,874,368 bytes: a float32 linspace puts its last sample at n, one past the end+ with torch.inference_mode():+ dit = torch.nn.Linear(3072, 3072, bias = False, dtype = torch.bfloat16)+ dit.weight.fill_(1.0)+ dit.weight.view(-1)[-1] = 2.0+ probe = mg.weights_probe(dit)+ assert probe is not None and len(probe) == mg._PROBE_SAMPLES+ with torch.inference_mode():+ dit.weight.view(-1)[-1] = -2.0 # flips the high (last) byte of the last element+ assert mg.weights_probe(dit) != probe # the last byte is sampled++def test_an_in_place_edit_of_inference_weights_rebuilds_the_replica_on_the_next_render():with torch.inference_mode():dit = _ScaleDit()