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: "Denoising please wait..." status with step count, and a live denoising preview at no speed cost (#12692)

Daniel Han96864bbd4b3e
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py
index 36a40ebbacc..566aaeadebc 100644
--- a/studio/backend/core/inference/diffusion.py
+++ b/studio/backend/core/inference/diffusion.py
@@ -163,7 +163,7 @@ from .diffusion_memory import (
from .diffusion_torchao_patches import install_torchao_int_mm_patch
from .image_orientation import exif_upright
from .mcp_images import flattened_rgb
-from .media_decode_phase import decode_phase
+from .media_decode_phase import decode_phase, denoise_phase
from .diffusion_speed import (
SPEED_DEFAULT,
SPEED_EAGER,
@@ -1173,8 +1173,10 @@ class _GenState:
first_step_at: float = 0.0
# Computed once per step (in the callback) so it's stable between polls.
eta_seconds: Optional[float] = None
- # "decode" once pipe() enters its decoder, which runs after the last step callback.
- phase: str = "denoise"
+ # encode -> denoise (pipe() entered its loop) -> decode (pipe() entered its decoder).
+ phase: str = "encode"
+ preview: Optional[str] = None
+ preview_seq: int = 0
def _estimate_eta(total_steps: int, step: int, first_step_at: float, now: float) -> Optional[float]:
@@ -9368,6 +9370,8 @@ class DiffusionBackend:
# load_identity() of the caller's status() read; refuse rather than run a different load (#9448)
expected_load: Optional[LoadIdentity] = None,
allow_oversized: bool = False,
+ # None = on unless UNSLOTH_DIFFUSION_PREVIEW=0.
+ live_preview: Optional[bool] = None,
) -> dict[str, Any]:
import torch
from PIL import Image
@@ -9838,17 +9842,96 @@ class DiffusionBackend:
static_skip = state.transformer_cache == TC_STATIC
static_chunks_run = 0
- def _on_step(pipe, step_index, timestep, callback_kwargs):
- if static_skip:
- mark_step_end(state.pipe)
+ def _publish_preview(
+ url: str,
+ seq: int,
+ gen = gen,
+ ) -> None:
+ gen.preview = url
+ gen.preview_seq = seq
+
+ # Started inside the try below, whose exits finish() it: its worker thread polls until then.
+ previewer = None
+
+ def _start_previewer():
+ if "callback_on_step_end" not in call_params:
+ return None
+ from .diffusion_preview import LatentPreviewer
+
+ try:
+ preview_w, preview_h = _compile_shape_dims(
+ workflow, init_pil, width, height, fam
+ )
+ except Exception: # noqa: BLE001 - no size, no preview
+ preview_w = preview_h = None
+ return LatentPreviewer.create(
+ family = state.family.name,
+ requested = live_preview,
+ height = preview_h,
+ width = preview_w,
+ device = state.device,
+ publish = _publish_preview,
+ total_steps = steps,
+ )
+
+ # Count steps the GPU FINISHED (per-step CUDA events, as the video path): under CUDA graphs the host
+ # enqueues all steps early, and a host count read N/N "decode" mid-denoise.
+ from .video import (
+ _BOUNDARY_MARK_ATTEMPTS,
+ _BOUNDARY_MARK_RETRY_SECONDS,
+ _CompletedStepTicker,
+ _completed_step_poller,
+ _hold_off_cuda_graph_capture,
+ )
+
+ # Replaced per chunk: a finished chunk's boundary must not end the next one's denoise.
+ chunk_ticker = [_CompletedStepTicker(steps)]
+
+ def _report(done_in_chunk: int) -> None:
+ if gen.phase not in ("encode", "denoise"):
+ return
+ done = steps_done[0] + max(0, min(int(done_in_chunk), steps))
+ if done <= gen.step:
+ return
+ gen.phase = "denoise"
# Monotonic: a wall-clock adjustment (NTP) mid-denoise would skew the ETA.
now = time.monotonic()
- gen.step = steps_done[0] + step_index + 1
+ gen.step = done
if gen.first_step_at == 0.0:
gen.first_step_at = now
gen.eta_seconds = _estimate_eta(
gen.total_steps, gen.step, gen.first_step_at, now
)
+
+ def _flip_to_decode(gen = gen) -> None:
+ # The chunk's denoise is provably over: complete it even if a skipped event left the count short.
+ _report(steps)
+ gen.phase = "decode"
+ gen.eta_seconds = None
+
+ def _pump() -> None:
+ if gen.phase not in ("encode", "denoise"):
+ return
+ ticker = chunk_ticker[0]
+ if ticker.boundary_marked and ticker.boundary_reached():
+ _flip_to_decode()
+ return
+ _report(ticker.completed())
+
+ def _on_step(pipe, step_index, timestep, callback_kwargs):
+ if static_skip:
+ mark_step_end(state.pipe)
+ if gen.phase == "encode":
+ gen.phase = "denoise"
+ if previewer is not None:
+ previewer.on_step(
+ callback_kwargs.get("latents"), getattr(pipe, "scheduler", None)
+ )
+ # Runs after scheduler.step, so this step's update is already enqueued.
+ with _hold_off_cuda_graph_capture() as clear:
+ if clear:
+ chunk_ticker[0].record(step_index + 1)
+ _report(chunk_ticker[0].completed())
if cancel.is_set():
pipe._interrupt = True
return callback_kwargs
@@ -9893,6 +9976,7 @@ class DiffusionBackend:
graphs_before = fresh_compile_count()
compile_cache.note_use(state.compile_cache_ctx)
try:
+ previewer = _start_previewer()
pending = list(chunks)
while pending:
chunk = pending.pop(0)
@@ -9948,12 +10032,28 @@ class DiffusionBackend:
# diffusers resets FBCache only after a SUCCESSFUL __call__; a raised call leaves a stale residual.
self._reset_step_cache(state.pipe)
protect_ctx = protect_generation(pipe, denoise_steps, logger = logger)
- # Per chunk: a later chunk denoises again after an earlier one decoded.
- gen.phase = "denoise"
-
- def _enter_decode_phase(gen = gen) -> None:
- gen.phase = "decode"
- gen.eta_seconds = None
+ # Per chunk: a later chunk encodes again after an earlier one decoded.
+ gen.phase = "encode"
+
+ def _enter_denoise_phase(gen = gen) -> None:
+ if gen.phase == "encode":
+ gen.phase = "denoise"
+
+ chunk_ticker[0] = _CompletedStepTicker(steps)
+
+ def _enter_decode_phase() -> None:
+ """The decoder was entered: a HOST position, possibly far ahead of the GPU. Mark the
+ boundary in the stream and let the poller flip once the GPU reaches it; with no event
+ to wait on (CPU, MPS) there is no queue to be ahead of, so flip now."""
+ marked = False
+ for _ in range(_BOUNDARY_MARK_ATTEMPTS):
+ with _hold_off_cuda_graph_capture() as clear:
+ if clear:
+ marked = chunk_ticker[0].mark_boundary()
+ break
+ time.sleep(_BOUNDARY_MARK_RETRY_SECONDS)
+ if not marked:
+ _flip_to_decode()
try:
# torchao aten.to fails torch's aliasing check under inference_mode once offloaded.
@@ -9964,11 +10064,15 @@ class DiffusionBackend:
else torch.inference_mode()
),
protect_ctx,
+ denoise_phase(pipe, _enter_denoise_phase),
decode_phase(pipe, _enter_decode_phase),
+ _completed_step_poller(_pump),
):
out = render_thread.run(
"diffusion", lambda: pipe(**chunk_kwargs).images
)
+ if gen.phase in ("encode", "denoise"):
+ _flip_to_decode()
except Exception as exc: # noqa: BLE001 - reraised unless a splittable OOM
oom = is_oom_error(exc)
if oom:
@@ -10007,6 +10111,8 @@ class DiffusionBackend:
chunk_shapes.append(len(chunk))
steps_done[0] += steps
except BaseException:
+ if previewer is not None:
+ previewer.finish()
# A cancelled or failed render may already have generalised a graph that the next render reuses
# without compiling, so the success path below would never see the count grow: dirty it now.
try:
@@ -10018,6 +10124,8 @@ class DiffusionBackend:
except Exception: # noqa: BLE001 - bookkeeping must not mask the render's own error
pass
raise
+ if previewer is not None:
+ previewer.finish()
if static_skip:
logger.debug("diffusion.step_skip: %s", static_skip_stats(state.pipe))
# Keep progress ACTIVE through the post-denoise work: the route persists the image after this returns,
@@ -10156,6 +10264,8 @@ class DiffusionBackend:
"fraction": gen.step / gen.total_steps, # step is 1..total, never over 1.0
"eta_seconds": gen.eta_seconds,
"phase": gen.phase,
+ "preview": gen.preview,
+ "preview_seq": gen.preview_seq,
}
def cancel_generate(self, expected_account: Optional[str] = None) -> bool:
diff --git a/studio/backend/core/inference/diffusion_preview.py b/studio/backend/core/inference/diffusion_preview.py
new file mode 100644
index 00000000000..4f1a8537be0
--- /dev/null
+++ b/studio/backend/core/inference/diffusion_preview.py
@@ -0,0 +1,479 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Live latent previews for the image and video denoise loops.
+
+Each snapshot projects the latent to a small RGB picture with a fitted per-family linear map
+(``diffusion_preview_factors``), copies it into a pinned slot with ``non_blocking=True`` plus a CUDA
+event, and a worker thread JPEG-encodes it once ``Event.query()`` says it landed. The denoise thread
+never syncs or reads host memory the GPU is writing, every CUDA call sits inside the CUDA-graph capture
+hold-off, and the latent is only read, so the final image is identical with previews on or off.
+
+Snapshots are planned by STEP, not host time: under CUDA graphs the host enqueues every step long
+before the GPU runs it. Kill switch: ``UNSLOTH_DIFFUSION_PREVIEW=0``.
+"""
+
+from __future__ import annotations
+
+import base64
+import contextlib
+import functools
+import io
+import logging
+import math
+import os
+import threading
+import time
+from dataclasses import dataclass
+from typing import Any, Callable, Optional
+
+logger = logging.getLogger(__name__)
+
+PREVIEW_ENV = "UNSLOTH_DIFFUSION_PREVIEW"
+MAX_SIDE = 256
+MIN_INTERVAL_S = 0.25
+MAX_SNAPSHOTS = 24
+JPEG_QUALITY = 80
+
+
+@dataclass(frozen = True)
+class LatentRGB:
+ """layout: "tokens" (B, N, D) | "bchw" | "bcthw"; down: output px per grid cell; patch: RGB px per
+ cell side (2 for 2x2 packed tokens); weight: D rows of 3*patch*patch outputs ordered (dy, dx, rgb)."""
+
+ layout: str
+ down: int
+ patch: int
+ weight: tuple
+ bias: tuple
+
+ @property
+ def channels(self) -> int:
+ return len(self.weight)
+
+
+def env_enabled() -> bool:
+ return os.environ.get(PREVIEW_ENV, "").strip().lower() not in ("0", "false", "off", "no")
+
+
+def preview_wanted(requested: Optional[bool]) -> bool:
+ if not env_enabled():
+ return False
+ return True if requested is None else bool(requested)
+
+
[email protected]_cache(maxsize = 64)
+def factors_for(family: Optional[str]) -> Optional[LatentRGB]:
+ """Cached so a family keeps one object, and its device copy is uploaded once per process."""
+ if not family:
+ return None
+ from .diffusion_preview_factors import FACTORS, FAMILY_FACTORS
+
+ key = FAMILY_FACTORS.get(str(family).strip().lower())
+ entry = FACTORS.get(key) if key else None
+ if not entry:
+ return None
+ return LatentRGB(
+ layout = entry["layout"],
+ down = int(entry["down"]),
+ patch = int(entry["patch"]),
+ weight = tuple(tuple(float(v) for v in row) for row in entry["weight"]),
+ bias = tuple(float(v) for v in entry["bias"]),
+ )
+
+
+def latent_grid(latents: Any, spec: LatentRGB, height: int, width: int) -> Any:
+ """First image / frame as a (gh, gw, D) view, or None. Packed tokens take their grid from the render
+ size, which must tile the sequence exactly."""
+ if spec.layout == "tokens":
+ gh, gw = int(height) // spec.down, int(width) // spec.down
+ if latents.ndim != 3 or latents.shape[-1] != spec.channels or gh <= 0 or gw <= 0:
+ return None
+ n = int(latents.shape[1])
+ if n < gh * gw or n % (gh * gw):
+ return None
+ # Frame-major then row-major (diffusers _pack_latents).
+ return latents[0, : gh * gw].reshape(gh, gw, spec.channels)
+ if spec.layout == "bchw":
+ if latents.ndim != 4 or latents.shape[1] != spec.channels:
+ return None
+ return latents[0].permute(1, 2, 0)
+ if spec.layout == "bcthw":
+ if latents.ndim != 5 or latents.shape[1] != spec.channels:
+ return None
+ return latents[0, :, 0].permute(1, 2, 0)
+ return None
+
+
+def project(grid: Any, weight: Any, bias: Any, patch: int) -> Any:
+ gh, gw, d = grid.shape
+ rgb = grid.reshape(gh * gw, d).float() @ weight + bias
+ if patch == 1:
+ return rgb.reshape(gh, gw, 3)
+ rgb = rgb.reshape(gh, gw, patch, patch, 3).permute(0, 2, 1, 3, 4)
+ return rgb.reshape(gh * patch, gw * patch, 3)
+
+
+def smooth_patch_grid(rgb: Any) -> Any:
+ """[1, 2, 1]^2 / 16 blur: zero response at Nyquist, so it removes the period-2 grid that per-pixel
+ row mismatches of a 2x2 packed-token map print, and barely softens the rest."""
+ import torch
+ import torch.nn.functional as F
+
+ chw = rgb.permute(2, 0, 1).unsqueeze(1)
+ # Built on the device from scalars: a host tensor would be a pageable copy, which synchronises.
+ kernel = torch.full((1, 1, 3, 3), 1.0 / 16.0, device = rgb.device, dtype = rgb.dtype)
+ kernel[..., 1, :] *= 2.0
+ kernel[..., :, 1] *= 2.0
+ out = F.conv2d(F.pad(chw, (1, 1, 1, 1), mode = "replicate"), kernel)
+ return out.squeeze(1).permute(1, 2, 0)
+
+
+def to_uint8(rgb: Any, max_side: int = MAX_SIDE) -> Any:
+ import torch
+ import torch.nn.functional as F
+
+ h, w, _ = rgb.shape
+ k = max(1, math.ceil(max(h, w) / max(1, int(max_side))))
+ if k > 1:
+ chw = rgb.permute(2, 0, 1).unsqueeze(0)
+ chw = F.avg_pool2d(chw, kernel_size = k, stride = k)
+ rgb = chw.squeeze(0).permute(1, 2, 0)
+ return (rgb.clamp(0.0, 1.0) * 255.0).round().to(torch.uint8).contiguous()
+
+
+_DEVICE_MAPS: dict = {}
+_DEVICE_MAPS_LOCK = threading.Lock()
+
+
+def _device_map(spec: LatentRGB, device: Any) -> tuple:
+ """Uploaded from pinned memory: a pageable host-to-device copy would synchronise."""
+ import torch
+
+ key = (id(spec.weight), str(device))
+ with _DEVICE_MAPS_LOCK:
+ hit = _DEVICE_MAPS.get(key)
+ if hit is not None and hit[0] is spec.weight:
+ return hit[1], hit[2]
+ w = torch.tensor(spec.weight, dtype = torch.float32).pin_memory().to(device, non_blocking = True)
+ b = torch.tensor(spec.bias, dtype = torch.float32).pin_memory().to(device, non_blocking = True)
+ with _DEVICE_MAPS_LOCK:
+ _DEVICE_MAPS[key] = (spec.weight, w, b)
+ return w, b
+
+
+def x0_estimate(prev: Any, cur: Any, pair: Optional[tuple]) -> Any:
+ """Euler x0 of the previous step: ``prev * (1 + c) - cur * c``, ``c = s_prev / (s_cur - s_prev)``.
+ Weights sum to 1, so it commutes with the affine map. ``pair`` may be 0-dim device tensors (never read back)."""
+ if prev is None or pair is None:
+ return cur
+ s_prev, s_cur = pair
+ delta = s_cur - s_prev
+ if isinstance(delta, float):
+ if abs(delta) <= 1e-6:
+ return cur
+ c = s_prev / delta
+ return prev * (1.0 + c) - cur * c
+ import torch
+
+ ok = delta.abs() > 1e-6
+ c = torch.where(
+ ok, s_prev / torch.where(ok, delta, torch.ones_like(delta)), torch.zeros_like(delta)
+ )
+ return prev * (1.0 + c) - cur * c
+
+
+def _hold_off():
+ try:
+ from .diffusion_cuda_graph import hold_off_capture
+ return hold_off_capture()
+ except Exception: # noqa: BLE001 - no graph layer means no capture to collide with
+ return contextlib.nullcontext(True)
+
+
+def _sigma_pair(scheduler: Any) -> Optional[tuple]:
+ """(s_prev, s_cur) for the step that just ran; a device sigmas tensor is indexed, never read."""
+ sigmas = getattr(scheduler, "sigmas", None)
+ idx = getattr(scheduler, "_step_index", None)
+ if sigmas is None or not isinstance(idx, int) or idx < 1:
+ return None
+ try:
+ if idx >= int(sigmas.shape[0]):
+ return None
+ if sigmas.device.type == "cpu":
+ return float(sigmas[idx - 1]), float(sigmas[idx])
+ return sigmas[idx - 1].float(), sigmas[idx].float()
+ except Exception: # noqa: BLE001 - an odd scheduler just gets the raw-latent preview
+ return None
+
+
+class LatentPreviewer:
+ """``on_step`` runs on the denoise thread after each scheduler step; it never raises or blocks."""
+
+ def __init__(
+ self,
+ spec: LatentRGB,
+ *,
+ height: int,
+ width: int,
+ device: Any,
+ publish: Callable[[str, int], None],
+ total_steps: int = MAX_SNAPSHOTS,
+ max_side: int = MAX_SIDE,
+ min_interval_s: float = MIN_INTERVAL_S,
+ max_snapshots: int = MAX_SNAPSHOTS,
+ clock: Callable[[], float] = time.monotonic,
+ ) -> None:
+ import torch
+
+ self.spec = spec
+ self.height, self.width = int(height), int(width)
+ self.device = torch.device(device)
+ self.max_side = int(max_side)
+ self.min_interval_s = float(min_interval_s)
+ self._clock = clock
+ self._publish = publish
+ self._weight, self._bias = _device_map(spec, self.device)
+ # Pre-sized (with a margin for pipelines that round the size up): nothing is allocated in the loop.
+ side_h = (self.height // spec.down + 2) * spec.patch
+ side_w = (self.width // spec.down + 2) * spec.patch
+ # to_uint8 output never exceeds the input or max_side on either side, whatever divisor it picks.
+ cap = min(side_h, self.max_side) * min(side_w, self.max_side) * 3
+ total = max(1, int(total_steps or 1))
+ # One slot per planned snapshot: with the host far ahead every one can be in flight at once.
+ self.stride = max(1, math.ceil(total / max(1, int(max_snapshots))))
+ n_slots = total // self.stride + 2
+ pinned = torch.empty(n_slots * cap, dtype = torch.uint8, pin_memory = True)
+ self._slots = [
+ {
+ "host": pinned[i * cap : (i + 1) * cap],
+ "event": torch.cuda.Event(),
+ "state": "free", # free -> copying -> encoding -> free
+ "shape": None,
+ "step": 0,
+ }
+ for i in range(n_slots)
+ ]
+ self._slot_lock = threading.Lock()
+ self._prev: Any = None
+ self._prev_index: Optional[int] = None
+ self._steps_seen = 0
+ self._last_publish = -1e30
+ self._seq = 0
+ self.emitted = 0
+ self.published = 0
+ self.skipped_capture = 0
+ self.failed = False
+ self._stop = threading.Event()
+ self._wake = threading.Event()
+ self._worker = threading.Thread(target = self._run, name = "diffusion-preview", daemon = True)
+ self._worker.start()
+
+ @classmethod
+ def create(
+ cls,
+ *,
+ family: Optional[str],
+ requested: Optional[bool],
+ height: Optional[int],
+ width: Optional[int],
+ device: Any,
+ publish: Callable[[str, int], None],
+ **kwargs: Any,
+ ) -> Optional["LatentPreviewer"]:
+ if not preview_wanted(requested):
+ return None
+ spec = factors_for(family)
+ if spec is None or not height or not width:
+ return None
+ try:
+ import torch
+
+ dev = torch.device(device)
+ if dev.type != "cuda" or not torch.cuda.is_available():
+ # No event to poll off CUDA, so a preview would block.
+ return None
+ with _hold_off() as clear:
+ if not clear:
+ return None
+ return cls(spec, height = height, width = width, device = dev, publish = publish, **kwargs)
+ except Exception as exc: # noqa: BLE001 - previews are optional
+ logger.debug("diffusion.preview: disabled for this render (%s)", exc)
+ return None
+
+ def on_step(
+ self,
+ latents: Any,
+ scheduler: Any = None,
+ final: bool = False,
+ ) -> None:
+ if self.failed or latents is None:
+ return
+ try:
+ self._on_step(latents, scheduler, final)
+ except Exception as exc: # noqa: BLE001 - a preview must never fail a render
+ self.failed = True
+ logger.debug("diffusion.preview: stopped after an error (%s)", exc)
+
+ def _on_step(self, latents: Any, scheduler: Any, final: bool) -> None:
+ import torch
+ if getattr(latents, "device", None) is None or latents.device.type != "cuda":
+ return
+ with _hold_off() as clear:
+ if not clear:
+ self.skipped_capture += 1
+ self._prev = None
+ return
+ grid = latent_grid(latents, self.spec, self.height, self.width)
+ if grid is None:
+ self.failed = True
+ return
+ with torch.no_grad():
+ cur = project(grid, self._weight, self._bias, self.spec.patch)
+ index = getattr(scheduler, "_step_index", None)
+ prev, prev_index = self._prev, self._prev_index
+ self._prev, self._prev_index = cur, index
+ if not isinstance(index, int) or prev_index != index - 1:
+ prev = None
+ if prev is None and not final and _sigma_pair(scheduler) is not None:
+ # No partner yet: skip rather than open on the raw noisy latent.
+ return
+ self._steps_seen += 1
+ if not final and (self._steps_seen - 1) % self.stride:
+ return
+ slot = self._free_slot()
+ if slot is None:
+ return
+ pair = _sigma_pair(scheduler) if prev is not None else None
+ shown = x0_estimate(prev, cur, pair)
+ if self.spec.patch > 1:
+ shown = smooth_patch_grid(shown)
+ img = to_uint8(shown, self.max_side)
+ n = img.numel()
+ if n > slot["host"].numel():
+ return
+ slot["host"][:n].copy_(img.view(-1), non_blocking = True)
+ slot["event"].record(torch.cuda.current_stream(self.device))
+ slot["shape"] = tuple(img.shape)
+ slot["step"] = self._seq = self._seq + 1
+ slot["state"] = "copying"
+ self.emitted += 1
+
+ def _free_slot(self) -> Optional[dict]:
+ with self._slot_lock:
+ for slot in self._slots:
+ if slot["state"] == "free":
+ return slot
+ return None
+
+ def _harvest(self) -> list:
+ ready = []
+ with _hold_off() as clear:
+ if not clear:
+ return ready
+ for slot in self._slots:
+ with self._slot_lock:
+ if slot["state"] != "copying":
+ continue
+ if slot["event"].query():
+ with self._slot_lock:
+ slot["state"] = "encoding"
+ ready.append(slot)
+ return ready
+
+ def finish(self, timeout: float = 1.0) -> None:
+ """One last pass for landed copies, then stop the worker; an in-flight copy is dropped."""
+ self._prev = None
+ self._stop.set()
+ self._wake.set()
+ if self._worker is not threading.current_thread():
+ self._worker.join(timeout = timeout)
+
+ def _run(self, poll_s: float = 0.05) -> None:
+ """Publish the newest landed snapshot at most every ``min_interval_s``; drop older ones unencoded."""
+ while True:
+ stopping = self._stop.is_set()
+ try:
+ ready = sorted(self._harvest(), key = lambda slot: slot["step"])
+ if ready:
+ newest = ready[-1]
+ for slot in ready[:-1]:
+ self._release(slot)
+ if stopping or self._clock() - self._last_publish >= self.min_interval_s:
+ self._encode(newest)
+ self._last_publish = self._clock()
+ else:
+ self._release(newest, back_to = "copying")
+ except Exception as exc: # noqa: BLE001 - a preview must never fail a render
+ logger.debug("diffusion.preview: harvest failed (%s)", exc)
+ if stopping:
+ return
+ self._wake.wait(poll_s)
+ self._wake.clear()
+
+ def _release(
+ self,
+ slot: dict,
+ back_to: str = "free",
+ ) -> None:
+ with self._slot_lock:
+ slot["state"] = back_to
+
+ def _encode(self, slot: dict) -> None:
+ try:
+ h, w, _ = slot["shape"]
+ raw = slot["host"][: h * w * 3].numpy().tobytes()
+ url = encode_jpeg(raw, w, h)
+ self._publish(url, int(slot["step"]))
+ self.published += 1
+ except Exception as exc: # noqa: BLE001
+ logger.debug("diffusion.preview: encode failed (%s)", exc)
+ finally:
+ with self._slot_lock:
+ slot["state"] = "free"
+
+
+def encode_jpeg(
+ raw: bytes,
+ width: int,
+ height: int,
+ quality: int = JPEG_QUALITY,
+) -> str:
+ from PIL import Image
+
+ img = Image.frombytes("RGB", (int(width), int(height)), raw)
+ buf = io.BytesIO()
+ img.save(buf, format = "JPEG", quality = int(quality))
+ return "data:image/jpeg;base64," + base64.b64encode(buf.getvalue()).decode("ascii")
+
+
+def scheduler_step_preview(pipe: Any, previewer: Optional[LatentPreviewer]):
+ """Feed ``previewer`` from ``scheduler.step`` for pipelines without a step callback (HunyuanVideo-1.5)."""
+ scheduler = getattr(pipe, "scheduler", None)
+ original = getattr(scheduler, "step", None)
+ if previewer is None or scheduler is None or not callable(original):
+ yield
+ return
+ had_own = "step" in getattr(scheduler, "__dict__", {})
+
+ def _step(*args: Any, **kwargs: Any) -> Any:
+ out = original(*args, **kwargs)
+ try:
+ sample = out[0] if isinstance(out, tuple) else getattr(out, "prev_sample", None)
+ previewer.on_step(sample, scheduler)
+ except Exception: # noqa: BLE001
+ pass
+ return out
+
+ scheduler.step = _step
+ try:
+ yield
+ finally:
+ try:
+ if had_own:
+ scheduler.step = original
+ else:
+ del scheduler.step
+ except Exception: # noqa: BLE001
+ pass
diff --git a/studio/backend/core/inference/diffusion_preview_factors.py b/studio/backend/core/inference/diffusion_preview_factors.py
new file mode 100644
index 00000000000..15bafe57952
--- /dev/null
+++ b/studio/backend/core/inference/diffusion_preview_factors.py
@@ -0,0 +1,4859 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Latent -> RGB maps for the live denoise preview (diffusion_preview). GENERATED, do not edit by hand.
+
+Each map was fitted by least squares from the final denoised latent of real renders to the same renders' VAE
+decode, box-averaged onto the latent grid. Families without an entry get no preview."""
+
+# family name or alias (lower case) -> map key
+FAMILY_FACTORS = {
+ "flux.1": "flux1",
+ "flux.1-kontext": "flux1",
+ "flux.2-klein": "flux2",
+ "flux.2-dev": "flux2",
+ "qwen-image": "qwen_image",
+ "qwen-image-edit": "qwen_image",
+ "qwen-image-2.1": "qwen_image_21",
+ "z-image": "zimage",
+ "sdxl": "sdxl",
+ "wan2.2-ti2v-5b": "wan22_5b",
+ "hunyuanvideo-1.5": "hv15",
+ "hunyuanvideo-1.5-720p": "hv15",
+ "ltx-2": "ltx2",
+}
+
+FACTORS: dict = {
+ "flux1": {
+ "layout": "tokens",
+ "down": 16,
+ "patch": 2,
+ "weight": [
+ [
+ -0.00548,
+ 0.01459,
+ 0.02901,
+ -0.00013,
+ -0.00178,
+ 0.00042,
+ -0.0035,
+ 2e-05,
+ 0.00459,
+ 0.00417,
+ -0.00127,
+ -0.00118,
+ ],
+ [
+ -0.00553,
+ 0.00131,
+ 0.00765,
+ -0.01021,
+ 0.01248,
+ 0.02834,
+ 0.00409,
+ 0.00057,
+ -0.00043,
+ -0.00595,
+ -0.00133,
+ 0.00344,
+ ],
+ [
+ -0.00496,
+ -0.00231,
+ -0.00239,
+ 0.00162,
+ -0.0011,
+ -0.00237,
+ -0.00466,
+ 0.0156,
+ 0.02647,
+ -0.00122,
+ -0.00131,
+ 0.00025,
+ ],
+ [
+ 0.00187,
+ -0.00057,
+ -0.00339,
+ -0.00352,
+ -0.00099,
+ -0.00077,
+ -0.00484,
+ 0.00228,
+ 0.00657,
+ -0.00707,
+ 0.01563,
+ 0.02924,
+ ],
+ [
+ 0.0156,
+ 0.02349,
+ 0.03691,
+ 0.0076,
+ 0.00387,
+ 0.00677,
+ -0.00176,
+ 0.00282,
+ 0.01054,
+ 0.00315,
+ 0.00125,
+ 0.00138,
+ ],
+ [
+ 0.00421,
+ 0.00382,
+ 0.004,
+ 0.01398,
+ 0.02296,
+ 0.03532,
+ 0.00258,
+ 0.00156,
+ -0.001,
+ -0.00115,
+ 0.00182,
+ 0.00759,
+ ],
+ [
+ 0.00266,
+ 0.00427,
+ 0.00723,
+ 0.00233,
+ 0.00059,
+ 0.00053,
+ 0.01724,
+ 0.02495,
+ 0.03682,
+ 0.00762,
+ 0.00439,
+ 0.0067,
+ ],
+ [
+ 0.0014,
+ -0.00035,
+ -0.00271,
+ 0.00044,
+ 0.0014,
+ 0.00177,
+ 0.00161,
+ 0.00215,
+ 0.0028,
+ 0.01192,
+ 0.02126,
+ 0.03184,
+ ],
+ [
+ 0.01273,
+ -0.01446,
+ -0.01349,
+ 0.00543,
+ -0.00381,
+ 0.00033,
+ 0.00291,
+ -0.00271,
+ -0.00077,
+ -0.00212,
+ -0.0005,
+ 0.00217,
+ ],
+ [
+ 0.00635,
+ -0.00364,
+ -0.00082,
+ 0.01063,
+ -0.01884,
+ -0.01822,
+ -0.00295,
+ -0.0013,
+ 0.00117,
+ 0.00143,
+ -0.00437,
+ -0.00159,
+ ],
+ [
+ 0.00616,
+ -0.00291,
+ -0.00418,
+ -0.00315,
+ -0.00048,
+ 0.00132,
+ 0.01328,
+ -0.01533,
+ -0.01409,
+ 0.00343,
+ -0.00449,
+ 0.00072,
+ ],
+ [
+ -0.00367,
+ -0.00311,
+ 0.00077,
+ 0.00488,
+ -0.00513,
+ -0.00203,
+ 0.00624,
+ -0.00398,
+ 0.00038,
+ 0.00993,
+ -0.02101,
+ -0.01746,
+ ],
+ [
+ -0.00603,
+ 0.00357,
+ 0.0164,
+ 0.00515,
+ -0.0004,
+ 0.00205,
+ -0.00244,
+ -0.00432,
+ 0.00192,
+ 0.00243,
+ -0.00223,
+ -0.00124,
+ ],
+ [
+ -0.00818,
+ -0.00189,
+ -7e-05,
+ -0.00777,
+ 0.00805,
+ 0.02002,
+ -0.00079,
+ -0.0029,
+ -0.00327,
+ -0.00194,
+ -0.00306,
+ 0.003,
+ ],
+ [
+ -0.00222,
+ -0.00084,
+ -0.00441,
+ 0.00377,
+ -0.00021,
+ -0.00407,
+ -0.00226,
+ 0.00995,
+ 0.01859,
+ 0.00731,
+ 0.00144,
+ 0.0007,
+ ],
+ [
+ 0.00254,
+ 8e-05,
+ -0.00451,
+ -0.0009,
+ -0.00059,
+ -0.00345,
+ -0.00588,
+ -0.00058,
+ 0.0012,
+ -0.00204,
+ 0.01342,
+ 0.02314,
+ ],
+ [
+ 0.02298,
+ 0.01723,
+ 0.01029,
+ -0.00273,
+ 0.00034,
+ 0.00296,
+ 0.00212,
+ 0.00194,
+ 2e-05,
+ -0.00396,
+ -0.00323,
+ -0.00256,
+ ],
+ [
+ 0.00269,
+ -0.00021,
+ -0.0016,
+ 0.02993,
+ 0.02056,
+ 0.00959,
+ -0.00295,
+ -0.00231,
+ -0.00026,
+ 0.00279,
+ 0.00334,
+ 0.00187,
+ ],
+ [
+ -0.00734,
+ -0.00964,
+ -0.01049,
+ -0.00581,
+ -0.0039,
+ -0.00321,
+ 0.02897,
+ 0.02217,
+ 0.0152,
+ -0.00142,
+ 0.00209,
+ 0.00234,
+ ],
+ [
+ -0.00531,
+ -0.00183,
+ -0.00171,
+ -0.00564,
+ -0.00641,
+ -0.00814,
+ 0.00267,
+ 0.00188,
+ -0.00226,
+ 0.03113,
+ 0.02386,
+ 0.01453,
+ ],
+ [
+ -0.00263,
+ 0.00719,
+ 0.00191,
+ -0.00583,
+ 0.00435,
+ 0.00825,
+ 0.00427,
+ 0.00866,
+ 0.00316,
+ 0.00042,
+ 0.00325,
+ 0.00141,
+ ],
+ [
+ 0.00408,
+ 0.00588,
+ -0.00188,
+ -0.00121,
+ 0.00665,
+ -0.0024,
+ 0.00407,
+ 0.00488,
+ 0.00202,
+ 0.00421,
+ 0.00908,
+ 0.00495,
+ ],
+ [
+ 0.0012,
+ 0.00458,
+ 0.00579,
+ 0.00136,
+ 0.00147,
+ 0.00148,
+ -0.00909,
+ 0.00361,
+ 0.00227,
+ -0.00958,
+ 0.00079,
+ 0.00616,
+ ],
+ [
+ 0.00178,
+ 0.00255,
+ 0.00038,
+ -0.00022,
+ 0.00653,
+ 0.00701,
+ 0.00249,
+ 0.00586,
+ -0.0015,
+ -0.00414,
+ 0.0047,
+ -0.00304,
+ ],
+ [
+ 0.02044,
+ 0.03273,
+ 0.03946,
+ -0.00612,
+ -0.00465,
+ -0.00148,
+ 0.00282,
+ 0.00065,
+ 0.00036,
+ -0.00178,
+ -0.00306,
+ -0.00414,
+ ],
+ [
+ -0.00496,
+ -0.00099,
+ 0.00222,
+ 0.02018,
+ 0.03537,
+ 0.04151,
+ -0.00444,
+ -0.00547,
+ -0.00317,
+ 0.00267,
+ -0.00035,
+ -0.00113,
+ ],
+ [
+ 0.004,
+ 0.0082,
+ 0.00357,
+ -0.0025,
+ 0.00275,
+ -0.00045,
+ 0.02346,
+ 0.03636,
+ 0.04019,
+ -0.00499,
+ 0.00023,
+ 0.00125,
+ ],
+ [
+ -0.00642,
+ -0.00524,
+ -0.00461,
+ -0.00013,
+ 0.0029,
+ 0.00118,
+ -0.00422,
+ -0.00105,
+ -0.00087,
+ 0.01831,
+ 0.03355,
+ 0.03648,
+ ],
+ [
+ -0.0208,
+ -0.02416,
+ -0.02783,
+ -0.00221,
+ -0.00697,
+ -0.00918,
+ 0.00237,
+ -0.00612,
+ -0.01137,
+ -0.0008,
+ -0.00127,
+ -0.00259,
+ ],
+ [
+ 0.00173,
+ 0.00014,
+ -0.00208,
+ -0.01536,
+ -0.01741,
+ -0.02075,
+ -6e-05,
+ -0.00031,
+ 0.00307,
+ 0.00737,
+ -0.00351,
+ -0.00683,
+ ],
+ [
+ -0.00499,
+ -0.00274,
+ -0.00201,
+ 0.00026,
+ -0.00155,
+ -0.00177,
+ -0.01866,
+ -0.0187,
+ -0.02051,
+ 2e-05,
+ -0.00488,
+ -0.00855,
+ ],
+ [
+ 0.00123,
+ 0.00145,
+ -0.00293,
+ -0.0006,
+ -4e-05,
+ -0.00534,
+ 0.00245,
+ 0.0003,
+ -0.00545,
+ -0.0161,
+ -0.01624,
+ -0.02187,
+ ],
+ [
+ -0.01714,
+ 0.00291,
+ 0.03349,
+ -0.00755,
+ -0.00882,
+ 0.00295,
+ -0.01147,
+ -0.00429,
+ 0.00662,
+ 0.00154,
+ -0.00253,
+ -0.00363,
+ ],
+ [
+ -0.00142,
+ -0.00383,
+ -0.00074,
+ -0.01263,
+ 0.00561,
+ 0.03342,
+ 0.00176,
+ -0.00152,
+ -0.00669,
+ -0.00801,
+ -0.00136,
+ 0.00879,
+ ],
+ [
+ -0.00388,
+ -0.00407,
+ 0.00296,
+ 0.00269,
+ -0.00192,
+ -0.00345,
+ -0.01076,
+ 0.00677,
+ 0.03541,
+ -0.00525,
+ -0.00577,
+ 0.0044,
+ ],
+ [
+ 0.00136,
+ -0.00183,
+ -0.00707,
+ -0.00625,
+ -0.0053,
+ -0.00138,
+ -0.00521,
+ -0.00568,
+ -0.0014,
+ -0.01373,
+ 0.00412,
+ 0.03017,
+ ],
+ [
+ 0.0455,
+ 0.02624,
+ -0.00893,
+ 0.01507,
+ 0.00531,
+ -0.01054,
+ 0.0083,
+ 0.00801,
+ -0.00285,
+ 0.00092,
+ 0.00043,
+ 0.00029,
+ ],
+ [
+ 0.01346,
+ 0.00884,
+ -0.01185,
+ 0.04543,
+ 0.02834,
+ -0.01039,
+ -0.00255,
+ 0.00267,
+ 0.00082,
+ 0.00739,
+ 0.01047,
+ 3e-05,
+ ],
+ [
+ 0.00955,
+ 0.0083,
+ -0.00629,
+ -0.00261,
+ 0.00177,
+ 0.00107,
+ 0.04059,
+ 0.0247,
+ -0.01082,
+ 0.01054,
+ 0.00594,
+ -0.00749,
+ ],
+ [
+ -0.00462,
+ 0.00246,
+ 0.00286,
+ 0.00604,
+ 0.00721,
+ -0.00094,
+ 0.0089,
+ 0.00754,
+ -0.00863,
+ 0.04118,
+ 0.0253,
+ -0.00786,
+ ],
+ [
+ 0.0052,
+ 0.02549,
+ 0.01801,
+ 0.00274,
+ 0.00581,
+ -0.00673,
+ -0.00111,
+ 0.00155,
+ -0.00127,
+ 0.00137,
+ 0.00012,
+ -0.00327,
+ ],
+ [
+ -0.00267,
+ -0.0015,
+ -0.00375,
+ 8e-05,
+ 0.01844,
+ 0.01659,
+ 0.0015,
+ -0.00275,
+ -0.00113,
+ -0.00077,
+ -0.00158,
+ -0.00239,
+ ],
+ [
+ -0.00011,
+ 0.0044,
+ 0.00331,
+ 0.00126,
+ -0.00025,
+ -0.00095,
+ 0.00619,
+ 0.02462,
+ 0.01833,
+ 0.00334,
+ 0.00481,
+ -0.00433,
+ ],
+ [
+ 0.00091,
+ -0.00135,
+ -0.00586,
+ 0.00014,
+ 0.00452,
+ 0.00014,
+ 8e-05,
+ -3e-05,
+ -0.00492,
+ 0.00339,
+ 0.02057,
+ 0.01592,
+ ],
+ [
+ 0.03305,
+ 0.02109,
+ 0.01978,
+ -0.00315,
+ 0.0019,
+ 0.00607,
+ -0.00129,
+ -0.00353,
+ 0.00117,
+ -0.00663,
+ -0.00231,
+ 0.00075,
+ ],
+ [
+ -0.00649,
+ -0.0071,
+ -0.00015,
+ 0.03089,
+ 0.01423,
+ 0.0127,
+ -0.00495,
+ -0.00312,
+ -0.00046,
+ -0.00186,
+ -0.0066,
+ -0.00413,
+ ],
+ [
+ 0.00132,
+ -0.00057,
+ 0.00517,
+ -0.00138,
+ -0.00415,
+ -0.00345,
+ 0.0323,
+ 0.01841,
+ 0.0184,
+ -0.00109,
+ -0.00075,
+ 0.00267,
+ ],
+ [
+ -0.00129,
+ -0.00189,
+ -0.00121,
+ -3e-05,
+ -1e-05,
+ 0.00434,
+ 4e-05,
+ -0.00357,
+ 7e-05,
+ 0.03254,
+ 0.01608,
+ 0.01397,
+ ],
+ [
+ 0.02353,
+ 0.02484,
+ 0.02357,
+ -0.00372,
+ 0.00338,
+ 0.007,
+ 0.00026,
+ 0.00292,
+ 0.00087,
+ -0.00334,
+ 0.00019,
+ -0.00013,
+ ],
+ [
+ 0.00116,
+ -0.00286,
+ -0.00769,
+ 0.02169,
+ 0.02221,
+ 0.02019,
+ -0.00743,
+ -0.00337,
+ -0.00429,
+ -0.00423,
+ 0.00043,
+ -0.00019,
+ ],
+ [
+ -1e-05,
+ 0.00156,
+ 0.00849,
+ -0.00141,
+ -0.00276,
+ 0.00046,
+ 0.02268,
+ 0.02493,
+ 0.02624,
+ -0.0019,
+ 0.00192,
+ 0.00569,
+ ],
+ [
+ -0.00239,
+ -0.00328,
+ -0.00175,
+ -0.00122,
+ -0.00113,
+ 0.00405,
+ 0.0028,
+ -0.002,
+ -0.00349,
+ 0.02232,
+ 0.02086,
+ 0.02113,
+ ],
+ [
+ -0.04316,
+ -0.02055,
+ -0.03378,
+ -0.01019,
+ -0.00128,
+ -0.01085,
+ -0.01341,
+ -0.00221,
+ -0.00418,
+ -0.00462,
+ -0.00181,
+ -0.00243,
+ ],
+ [
+ 0.00208,
+ 0.00738,
+ -0.00767,
+ -0.03891,
+ -0.01458,
+ -0.02805,
+ -0.00191,
+ 0.00052,
+ -0.00023,
+ -0.0095,
+ 0.00118,
+ 0.00031,
+ ],
+ [
+ -0.0132,
+ -0.00371,
+ -0.0069,
+ -0.00342,
+ -0.0051,
+ -0.00262,
+ -0.04126,
+ -0.01917,
+ -0.0331,
+ -0.00931,
+ -0.00346,
+ -0.01131,
+ ],
+ [
+ -0.00117,
+ -0.00291,
+ -0.00293,
+ -0.00642,
+ -0.00102,
+ -0.00705,
+ -0.00293,
+ 0.00293,
+ -0.01031,
+ -0.04025,
+ -0.01843,
+ -0.03429,
+ ],
+ [
+ -0.01135,
+ -0.02424,
+ -0.01501,
+ -0.0061,
+ -0.00611,
+ 0.00247,
+ -0.00095,
+ -0.00199,
+ 0.00177,
+ -0.0003,
+ 0.00074,
+ 0.00199,
+ ],
+ [
+ -0.00258,
+ -0.0077,
+ -7e-05,
+ -0.01248,
+ -0.02598,
+ -0.01575,
+ -0.00421,
+ -0.00144,
+ -0.00036,
+ -0.00349,
+ -0.00388,
+ -0.00055,
+ ],
+ [
+ -0.00039,
+ -0.00565,
+ -0.00641,
+ -0.00184,
+ 0.00232,
+ 0.00133,
+ -0.01103,
+ -0.02531,
+ -0.01899,
+ -0.00607,
+ -0.00496,
+ 0.00119,
+ ],
+ [
+ 0.0006,
+ -0.00182,
+ 0.00056,
+ -0.00158,
+ -0.00756,
+ -0.00133,
+ 0.00214,
+ -0.00742,
+ -1e-05,
+ -0.00995,
+ -0.02821,
+ -0.01713,
+ ],
+ [
+ -0.04065,
+ -0.03056,
+ -0.01891,
+ -0.00137,
+ -0.00057,
+ 0.00249,
+ -0.00577,
+ -0.00116,
+ 0.00468,
+ 0.00173,
+ 0.00036,
+ 0.00039,
+ ],
+ [
+ 0.00029,
+ -0.00067,
+ 0.00029,
+ -0.03854,
+ -0.02896,
+ -0.02016,
+ 0.00332,
+ 0.00235,
+ 0.00288,
+ -0.00483,
+ -0.00092,
+ 0.00509,
+ ],
+ [
+ 0.00187,
+ 0.00375,
+ 0.00308,
+ 0.00594,
+ 0.00378,
+ 0.00171,
+ -0.04375,
+ -0.03416,
+ -0.02568,
+ -0.00088,
+ 0.0001,
+ 0.00339,
+ ],
+ [
+ 0.00575,
+ 0.00426,
+ 0.00274,
+ -0.00145,
+ 0.00246,
+ 0.00467,
+ 0.00044,
+ -0.00154,
+ -0.00197,
+ -0.04163,
+ -0.03248,
+ -0.02584,
+ ],
+ ],
+ "bias": [
+ 0.49872,
+ 0.47423,
+ 0.46307,
+ 0.49639,
+ 0.47697,
+ 0.46796,
+ 0.49638,
+ 0.47397,
+ 0.46403,
+ 0.49488,
+ 0.47547,
+ 0.46588,
+ ],
+ },
+ "flux2": {
+ "layout": "tokens",
+ "down": 16,
+ "patch": 2,
+ "weight": [
+ [
+ 0.00496,
+ 0.00311,
+ 0.00019,
+ 0.00485,
+ 0.00214,
+ 0.00088,
+ 0.00773,
+ 0.00365,
+ 0.0028,
+ 0.0067,
+ 0.00206,
+ 0.00124,
+ ],
+ [
+ 0.00433,
+ 0.00152,
+ 0.0024,
+ 0.00369,
+ 0.00122,
+ -0.00019,
+ 0.00383,
+ 0.00057,
+ 0.00367,
+ 0.00546,
+ 0.00216,
+ 0.00387,
+ ],
+ [
+ 0.0041,
+ 0.0005,
+ 0.00296,
+ 0.00189,
+ -0.00091,
+ 0.00274,
+ 0.00179,
+ 0.00107,
+ 0.00165,
+ 0.00123,
+ 0.00018,
+ 0.00343,
+ ],
+ [
+ 0.00049,
+ -0.0003,
+ 0.00116,
+ 0.00339,
+ 0.00235,
+ 0.00409,
+ -5e-05,
+ 0.00028,
+ 0.00116,
+ 0.00061,
+ 0.00164,
+ 0.00132,
+ ],
+ [
+ -0.00061,
+ 0.00063,
+ 0.0077,
+ 0.00014,
+ 0.001,
+ 0.00714,
+ 0.00017,
+ 0.00136,
+ 0.00732,
+ -0.00049,
+ 0.00081,
+ 0.00549,
+ ],
+ [
+ -0.00437,
+ -0.00275,
+ 0.00068,
+ -0.00592,
+ -0.00474,
+ 0.00014,
+ -0.00361,
+ -0.00234,
+ 0.0002,
+ -0.00201,
+ -0.00125,
+ 0.00226,
+ ],
+ [
+ -0.00102,
+ -0.00066,
+ 0.00506,
+ -0.00065,
+ -0.00016,
+ 0.00607,
+ -0.00215,
+ -0.00283,
+ 0.00387,
+ -0.00019,
+ -0.00126,
+ 0.00557,
+ ],
+ [
+ -0.00373,
+ -0.0008,
+ 0.00559,
+ -0.00513,
+ -0.00243,
+ 0.0041,
+ -0.00302,
+ -0.00012,
+ 0.00666,
+ -0.0069,
+ -0.00411,
+ 0.00326,
+ ],
+ [
+ -0.0049,
+ 0.00288,
+ 0.01474,
+ 0.00024,
+ 0.00233,
+ 0.00841,
+ -0.0025,
+ 0.00037,
+ 0.00725,
+ 0.00099,
+ 0.00173,
+ 0.00636,
+ ],
+ [
+ 0.00227,
+ 0.00298,
+ 0.00777,
+ -0.00157,
+ 0.00493,
+ 0.01534,
+ 0.00118,
+ 0.00014,
+ 0.00335,
+ 0.00068,
+ 0.0014,
+ 0.0071,
+ ],
+ [
+ 0.00359,
+ 0.00413,
+ 0.00687,
+ 0.0044,
+ 0.00346,
+ 0.00421,
+ -0.00043,
+ 0.00557,
+ 0.01422,
+ 0.00373,
+ 0.00362,
+ 0.00616,
+ ],
+ [
+ 0.00319,
+ 0.00022,
+ 0.00123,
+ 0.00205,
+ -0.0002,
+ 0.00212,
+ 0.00522,
+ 0.00462,
+ 0.00762,
+ -0.00079,
+ 0.00344,
+ 0.0114,
+ ],
+ [
+ 0.03658,
+ 0.06616,
+ 0.09445,
+ 0.00088,
+ 0.02765,
+ 0.05363,
+ 0.00026,
+ 0.02397,
+ 0.04872,
+ -0.00936,
+ 0.01385,
+ 0.03715,
+ ],
+ [
+ 0.01075,
+ 0.03127,
+ 0.05148,
+ 0.0518,
+ 0.07571,
+ 0.09827,
+ 0.00644,
+ 0.02524,
+ 0.04414,
+ 0.01489,
+ 0.03457,
+ 0.05474,
+ ],
+ [
+ 0.01689,
+ 0.03242,
+ 0.04867,
+ 0.01343,
+ 0.02874,
+ 0.04525,
+ 0.06217,
+ 0.08341,
+ 0.10258,
+ 0.02468,
+ 0.04346,
+ 0.06182,
+ ],
+ [
+ 0.02335,
+ 0.03298,
+ 0.04282,
+ 0.02704,
+ 0.03732,
+ 0.04648,
+ 0.02907,
+ 0.04017,
+ 0.05145,
+ 0.07345,
+ 0.08773,
+ 0.09932,
+ ],
+ [
+ -0.00054,
+ -0.00504,
+ -0.00123,
+ -6e-05,
+ -0.00469,
+ -0.00113,
+ -0.00169,
+ -0.00494,
+ -0.00201,
+ -0.00129,
+ -0.00556,
+ -0.00223,
+ ],
+ [
+ -0.00172,
+ -0.00622,
+ -0.00412,
+ -0.00078,
+ -0.00611,
+ -0.00315,
+ -0.00131,
+ -0.00674,
+ -0.00405,
+ -0.00191,
+ -0.00623,
+ -0.00321,
+ ],
+ [
+ -0.00261,
+ -0.00765,
+ -0.00245,
+ -0.0007,
+ -0.00479,
+ -0.00051,
+ -0.00232,
+ -0.00646,
+ -0.00085,
+ -0.00065,
+ -0.00464,
+ 0.00052,
+ ],
+ [
+ 0.00168,
+ -0.00427,
+ -0.00229,
+ 0.0006,
+ -0.00484,
+ -0.00108,
+ -0.00013,
+ -0.00585,
+ -0.00399,
+ 0.00067,
+ -0.00506,
+ -0.00212,
+ ],
+ [
+ -0.00195,
+ -0.00435,
+ -0.01036,
+ 0.00182,
+ -0.00322,
+ -0.01016,
+ -0.00026,
+ -0.00345,
+ -0.00776,
+ 0.00034,
+ -0.00445,
+ -0.00929,
+ ],
+ [
+ 0.00193,
+ -0.00191,
+ -0.00812,
+ 0.00227,
+ -0.00048,
+ -0.00676,
+ 0.0028,
+ -0.00268,
+ -0.00789,
+ 0.00468,
+ -0.00057,
+ -0.00552,
+ ],
+ [
+ -0.00091,
+ -0.00567,
+ -0.01074,
+ -6e-05,
+ -0.00555,
+ -0.01103,
+ -0.00064,
+ -0.0035,
+ -0.00939,
+ 0.00175,
+ -0.00283,
+ -0.0094,
+ ],
+ [
+ 0.00334,
+ -0.0027,
+ -0.00891,
+ 0.00349,
+ -0.00226,
+ -0.00845,
+ 0.00178,
+ -0.00337,
+ -0.01041,
+ 0.00121,
+ -0.00272,
+ -0.00992,
+ ],
+ [
+ -0.00737,
+ 0.00927,
+ -0.00927,
+ -0.00248,
+ 0.00617,
+ -0.00447,
+ 0.00012,
+ 0.00552,
+ -0.00362,
+ 0.0017,
+ 0.00488,
+ -0.00091,
+ ],
+ [
+ -0.00865,
+ -1e-05,
+ -0.00723,
+ -0.01478,
+ 0.00336,
+ -0.01118,
+ -0.0029,
+ -0.00185,
+ -0.00435,
+ -0.00614,
+ -0.00094,
+ -0.00659,
+ ],
+ [
+ -0.00059,
+ 0.00402,
+ -0.00316,
+ 0.00239,
+ 0.00333,
+ -0.00062,
+ -0.00958,
+ 0.00782,
+ -0.00812,
+ -0.0014,
+ 0.00687,
+ -0.00222,
+ ],
+ [
+ 0.00367,
+ 0.00734,
+ 0.00328,
+ 0.00088,
+ 0.00692,
+ -0.00048,
+ -0.00032,
+ 0.0101,
+ 0.0007,
+ -0.00722,
+ 0.01121,
+ -0.00507,
+ ],
+ [
+ -0.00368,
+ -0.00209,
+ -0.00429,
+ -0.00396,
+ -0.00199,
+ -0.00494,
+ -0.00303,
+ -0.00136,
+ -0.00463,
+ -0.00197,
+ -0.00077,
+ -0.00369,
+ ],
+ [
+ -0.00031,
+ 0.00104,
+ -0.00411,
+ 0.00066,
+ 0.00102,
+ -0.00386,
+ -0.00251,
+ -0.0022,
+ -0.00687,
+ -0.00185,
+ -0.00153,
+ -0.00672,
+ ],
+ [
+ -0.00342,
+ -0.001,
+ -0.00516,
+ -0.00322,
+ -0.00051,
+ -0.00506,
+ -0.00338,
+ -0.00063,
+ -0.00306,
+ -0.00261,
+ 0.00032,
+ -0.00342,
+ ],
+ [
+ -0.0025,
+ -0.00101,
+ -0.00527,
+ -0.00098,
+ 0.00041,
+ -0.00436,
+ -0.00023,
+ -0.00024,
+ -0.00467,
+ -0.00145,
+ -0.00084,
+ -0.00413,
+ ],
+ [
+ -0.09704,
+ -0.08562,
+ -0.07038,
+ -0.05147,
+ -0.0383,
+ -0.02306,
+ -0.04976,
+ -0.03659,
+ -0.02124,
+ -0.04335,
+ -0.02985,
+ -0.015,
+ ],
+ [
+ -0.04981,
+ -0.03161,
+ -0.01319,
+ -0.0899,
+ -0.07291,
+ -0.05361,
+ -0.04025,
+ -0.0236,
+ -0.00645,
+ -0.04552,
+ -0.02835,
+ -0.01017,
+ ],
+ [
+ -0.05221,
+ -0.03139,
+ -0.00683,
+ -0.03951,
+ -0.01804,
+ 0.00626,
+ -0.0893,
+ -0.06941,
+ -0.04532,
+ -0.04313,
+ -0.02214,
+ 0.0015,
+ ],
+ [
+ -0.02296,
+ 0.00197,
+ 0.02662,
+ -0.03556,
+ -0.01035,
+ 0.01477,
+ -0.03045,
+ -0.00571,
+ 0.0194,
+ -0.07095,
+ -0.04664,
+ -0.02112,
+ ],
+ [
+ 0.00057,
+ -0.00216,
+ -0.00204,
+ -0.00149,
+ -0.00327,
+ -0.00308,
+ -0.00331,
+ -0.00444,
+ -0.00497,
+ -0.00186,
+ -0.00266,
+ -0.00343,
+ ],
+ [
+ -0.00396,
+ -0.00507,
+ -0.00363,
+ -0.00133,
+ -0.00293,
+ -0.00213,
+ -0.00297,
+ -0.00365,
+ -0.00306,
+ -0.00328,
+ -0.00391,
+ -0.00336,
+ ],
+ [
+ -0.00336,
+ -0.00411,
+ -0.00412,
+ -0.00232,
+ -0.00263,
+ -0.00297,
+ -0.00311,
+ -0.00527,
+ -0.0048,
+ -0.00424,
+ -0.00559,
+ -0.00493,
+ ],
+ [
+ -0.00077,
+ -0.00646,
+ -0.00833,
+ 4e-05,
+ -0.00473,
+ -0.00633,
+ -0.00346,
+ -0.00965,
+ -0.01016,
+ -0.00241,
+ -0.00781,
+ -0.00865,
+ ],
+ [
+ 0.00259,
+ 0.00214,
+ 0.0016,
+ 0.002,
+ 0.00169,
+ 0.00229,
+ 0.00161,
+ 0.00105,
+ 0.00178,
+ 0.00066,
+ 0.00054,
+ 0.00121,
+ ],
+ [
+ 0.00411,
+ 0.00263,
+ 0.00378,
+ 0.00174,
+ 0.00128,
+ 0.00232,
+ 0.00155,
+ 0.00099,
+ 0.00261,
+ 0.00217,
+ 0.00117,
+ 0.00301,
+ ],
+ [
+ -0.0019,
+ -0.00334,
+ -0.0027,
+ 0.00032,
+ -0.00114,
+ -0.00077,
+ -0.00154,
+ -0.00269,
+ -0.00262,
+ 0.00048,
+ -0.00126,
+ -0.00077,
+ ],
+ [
+ 0.00118,
+ -4e-05,
+ 0.00141,
+ -0.00175,
+ -0.00373,
+ -0.00251,
+ 0.00311,
+ 0.00122,
+ 0.00185,
+ -0.00188,
+ -0.0027,
+ -0.00191,
+ ],
+ [
+ 0.01383,
+ -0.0029,
+ -0.02529,
+ 0.00184,
+ -0.00021,
+ -0.00589,
+ 0.0041,
+ 0.0023,
+ -0.00338,
+ 0.00123,
+ 0.00172,
+ 0.00045,
+ ],
+ [
+ 0.00407,
+ 0.00377,
+ -0.00093,
+ 0.01747,
+ 0.00205,
+ -0.0197,
+ -0.00033,
+ 0.00222,
+ 0.00187,
+ 0.00428,
+ 0.0041,
+ -0.00116,
+ ],
+ [
+ 0.00266,
+ 0.00219,
+ -0.00351,
+ 0.0009,
+ 0.0027,
+ 0.00098,
+ 0.01579,
+ -0.00057,
+ -0.02329,
+ 0.00345,
+ 0.00192,
+ -0.00409,
+ ],
+ [
+ -0.00037,
+ 0.00338,
+ 0.0033,
+ 0.00312,
+ 0.00486,
+ 0.0009,
+ 0.00516,
+ 0.00664,
+ 0.00279,
+ 0.01868,
+ 0.0046,
+ -0.01622,
+ ],
+ [
+ 0.00313,
+ 0.00278,
+ 0.00718,
+ 0.00094,
+ 0.00149,
+ 0.004,
+ 0.00118,
+ 0.002,
+ 0.00397,
+ 0.00199,
+ 0.00256,
+ 0.00521,
+ ],
+ [
+ 0.00171,
+ 0.00313,
+ 0.00802,
+ 0.00327,
+ 0.00451,
+ 0.01183,
+ 0.00136,
+ 0.00287,
+ 0.00775,
+ 0.00013,
+ 0.00206,
+ 0.00733,
+ ],
+ [
+ 0.00094,
+ 0.00134,
+ 0.00559,
+ -0.00092,
+ -3e-05,
+ 0.00384,
+ 0.00289,
+ 0.00257,
+ 0.01058,
+ 4e-05,
+ 0.00116,
+ 0.00622,
+ ],
+ [
+ 0.00095,
+ -0.00029,
+ 0.0035,
+ 0.00211,
+ 0.00128,
+ 0.00509,
+ 0.00081,
+ 0.00082,
+ 0.00548,
+ 0.00303,
+ 0.00254,
+ 0.0089,
+ ],
+ [
+ -0.00563,
+ -0.00284,
+ -0.00155,
+ -0.00097,
+ 0.0013,
+ 0.00089,
+ 0.00241,
+ 0.00246,
+ 0.00209,
+ 0.00432,
+ 0.00534,
+ 0.00497,
+ ],
+ [
+ 2e-05,
+ -0.0023,
+ -0.00179,
+ -0.00521,
+ -0.00591,
+ -0.00388,
+ 0.00183,
+ 6e-05,
+ 0.00208,
+ 7e-05,
+ -0.00183,
+ -0.00058,
+ ],
+ [
+ 0.00128,
+ -0.00254,
+ -0.0024,
+ 0.00357,
+ -0.00022,
+ 0.00119,
+ -0.00487,
+ -0.006,
+ -0.00496,
+ 0.0008,
+ -0.00131,
+ -0.00014,
+ ],
+ [
+ -0.00269,
+ -0.00239,
+ -0.00156,
+ -0.00406,
+ -0.00401,
+ -0.00315,
+ -0.00292,
+ -0.00186,
+ -0.00133,
+ -0.00929,
+ -0.00755,
+ -0.00623,
+ ],
+ [
+ -0.00374,
+ 0.00111,
+ 0.00052,
+ -0.00334,
+ 0.00059,
+ 0.0017,
+ -0.00274,
+ 0.00067,
+ 0.00227,
+ -0.00331,
+ -0.00036,
+ 0.00164,
+ ],
+ [
+ -0.00218,
+ 0.00098,
+ 0.00313,
+ -0.00082,
+ 0.00315,
+ 0.00287,
+ -0.00281,
+ 0.00089,
+ 0.00412,
+ 0.00021,
+ 0.00357,
+ 0.00569,
+ ],
+ [
+ -0.00061,
+ 0.0028,
+ 0.00533,
+ -0.00323,
+ 0.00032,
+ 0.00441,
+ -0.00123,
+ 0.00329,
+ 0.00316,
+ -0.00264,
+ 0.00146,
+ 0.00377,
+ ],
+ [
+ -0.00137,
+ 0.00063,
+ 0.0038,
+ -0.00234,
+ -0.00061,
+ 0.00202,
+ -0.0004,
+ 0.0023,
+ 0.00521,
+ -0.00179,
+ 0.00085,
+ 0.00136,
+ ],
+ [
+ -0.01512,
+ -0.00459,
+ -0.00074,
+ -0.01093,
+ -0.00213,
+ 0.00088,
+ -0.00924,
+ -0.00279,
+ -0.0012,
+ -0.0074,
+ -0.0022,
+ -0.0009,
+ ],
+ [
+ -0.00918,
+ 0.0047,
+ 0.00725,
+ -0.01311,
+ 0.00165,
+ 0.00552,
+ -0.00891,
+ 0.00141,
+ 0.00285,
+ -0.0104,
+ 0.00041,
+ 0.0019,
+ ],
+ [
+ -0.00957,
+ -0.0042,
+ -0.00316,
+ -0.00812,
+ -0.00316,
+ -0.00288,
+ -0.01838,
+ -0.00793,
+ -0.00531,
+ -0.01453,
+ -0.00589,
+ -0.00447,
+ ],
+ [
+ -0.00729,
+ -0.00229,
+ -0.00167,
+ -0.00738,
+ -0.0024,
+ -0.0008,
+ -0.00868,
+ -7e-05,
+ 0.00093,
+ -0.01323,
+ -0.00312,
+ -0.00036,
+ ],
+ [
+ -0.00253,
+ -0.00183,
+ -0.00404,
+ -0.00332,
+ -0.00291,
+ -0.00391,
+ -0.00198,
+ -0.00197,
+ -0.00322,
+ -0.00406,
+ -0.00419,
+ -0.00446,
+ ],
+ [
+ -0.00576,
+ -0.00458,
+ -0.00349,
+ -0.00544,
+ -0.00398,
+ -0.00403,
+ -0.00325,
+ -0.00332,
+ -0.0021,
+ -0.0032,
+ -0.003,
+ -0.00217,
+ ],
+ [
+ 0.00026,
+ 0.00173,
+ -0.0008,
+ -0.00149,
+ 0.00029,
+ -0.00087,
+ 0.00144,
+ 0.00407,
+ 0.00111,
+ 0.00049,
+ 0.00259,
+ 0.00066,
+ ],
+ [
+ 0.00053,
+ 0.00159,
+ 0.00175,
+ 0.00138,
+ 0.00208,
+ 0.00126,
+ -0.00079,
+ 0.00159,
+ 0.00116,
+ 0.00015,
+ 0.00234,
+ 0.00039,
+ ],
+ [
+ 0.00134,
+ -0.0057,
+ -0.00168,
+ 0.00108,
+ -0.00633,
+ -0.00364,
+ 0.00217,
+ -0.00445,
+ -0.00129,
+ 0.00107,
+ -0.00475,
+ -0.00236,
+ ],
+ [
+ 0.0007,
+ -0.0035,
+ -5e-05,
+ 0.00104,
+ -0.00361,
+ 0.00135,
+ -0.00275,
+ -0.00597,
+ -0.00207,
+ -0.00031,
+ -0.00486,
+ -0.00053,
+ ],
+ [
+ 0.00028,
+ -0.00258,
+ 0.00058,
+ 0.00203,
+ -0.00123,
+ 0.0017,
+ 0.00346,
+ -0.00044,
+ 0.00301,
+ 0.00378,
+ -0.0009,
+ 0.00191,
+ ],
+ [
+ 0.00304,
+ -0.00127,
+ 0.00229,
+ 0.00189,
+ -0.00215,
+ 0.00131,
+ 0.00362,
+ -0.00141,
+ 0.00132,
+ 0.00238,
+ -0.00182,
+ 0.00169,
+ ],
+ [
+ -0.00425,
+ -0.00452,
+ -0.0023,
+ -0.00796,
+ -0.00737,
+ -0.00569,
+ -0.00862,
+ -0.00793,
+ -0.00547,
+ -0.00897,
+ -0.00852,
+ -0.00638,
+ ],
+ [
+ -0.00332,
+ -0.0053,
+ -0.00437,
+ -0.00162,
+ -0.00478,
+ -0.00411,
+ -0.00556,
+ -0.00774,
+ -0.00712,
+ -0.00581,
+ -0.00821,
+ -0.00718,
+ ],
+ [
+ -0.00378,
+ -0.00563,
+ -0.00681,
+ -0.00434,
+ -0.00581,
+ -0.00626,
+ -0.00053,
+ -0.00304,
+ -0.00497,
+ -0.00275,
+ -0.00459,
+ -0.0063,
+ ],
+ [
+ -0.00436,
+ -0.00614,
+ -0.00893,
+ -0.0034,
+ -0.00624,
+ -0.00941,
+ -0.00362,
+ -0.00683,
+ -0.00912,
+ -0.00189,
+ -0.0054,
+ -0.00777,
+ ],
+ [
+ 0.00814,
+ -0.00759,
+ -0.00549,
+ 0.00604,
+ -0.00837,
+ -0.00708,
+ 0.00326,
+ -0.00933,
+ -0.00714,
+ 0.00596,
+ -0.00561,
+ -0.00413,
+ ],
+ [
+ 0.00677,
+ -0.00809,
+ -0.00267,
+ 0.00973,
+ -0.00615,
+ -0.00033,
+ 0.00897,
+ -0.00261,
+ 0.00299,
+ 0.0084,
+ -0.00427,
+ 0.00141,
+ ],
+ [
+ 0.00692,
+ -0.00625,
+ -0.00408,
+ 0.00766,
+ -0.00433,
+ -0.00269,
+ 0.01194,
+ -0.0047,
+ -0.00224,
+ 0.00934,
+ -0.00591,
+ -0.00382,
+ ],
+ [
+ 0.00761,
+ -0.00225,
+ -0.00058,
+ 0.00661,
+ -0.00451,
+ -0.00238,
+ 0.00835,
+ -0.00552,
+ -0.00441,
+ 0.0117,
+ -0.00397,
+ -0.00221,
+ ],
+ [
+ 0.00238,
+ 0.00453,
+ 0.00421,
+ 0.00135,
+ 0.00362,
+ 0.00317,
+ 0.00187,
+ 0.00371,
+ 0.00307,
+ -4e-05,
+ 0.00255,
+ 0.00228,
+ ],
+ [
+ 0.00081,
+ 0.00073,
+ -0.00051,
+ 0.0023,
+ 0.00243,
+ 0.00222,
+ -0.00165,
+ -0.00119,
+ -0.00288,
+ 0.00066,
+ 0.00124,
+ 0.00062,
+ ],
+ [
+ 0.00275,
+ 0.00457,
+ 0.00414,
+ 0.00084,
+ 0.00295,
+ 0.00392,
+ 0.00297,
+ 0.00396,
+ 0.00379,
+ 0.00186,
+ 0.00295,
+ 0.00311,
+ ],
+ [
+ 0.00079,
+ 0.00213,
+ 0.00348,
+ -0.00028,
+ 0.00167,
+ 0.00196,
+ 0.00239,
+ 0.00316,
+ 0.00414,
+ 0.00117,
+ 0.00229,
+ 0.00275,
+ ],
+ [
+ -0.00272,
+ -0.00134,
+ 0.00417,
+ -0.00231,
+ -0.00119,
+ 0.00519,
+ -0.00217,
+ -0.00184,
+ 0.00464,
+ -0.00034,
+ -0.00017,
+ 0.00646,
+ ],
+ [
+ 0.00038,
+ 0.00097,
+ 0.00518,
+ -0.0,
+ 0.00142,
+ 0.00411,
+ 0.00089,
+ 0.00061,
+ 0.00538,
+ -0.00059,
+ -0.00039,
+ 0.00367,
+ ],
+ [
+ -0.00099,
+ -0.00132,
+ 0.00033,
+ -0.00108,
+ -0.00314,
+ -0.00131,
+ -0.00121,
+ -0.00086,
+ 0.00046,
+ -0.00105,
+ -0.00229,
+ 0.0,
+ ],
+ [
+ -0.00321,
+ -0.00457,
+ 0.0002,
+ -0.00284,
+ -0.0034,
+ 0.00076,
+ -0.00381,
+ -0.00461,
+ 0.00106,
+ -0.0036,
+ -0.0041,
+ -0.00053,
+ ],
+ [
+ 0.00282,
+ 0.00367,
+ -0.00093,
+ 0.0048,
+ 0.00661,
+ 0.00068,
+ 0.00321,
+ 0.00483,
+ -0.00143,
+ 0.004,
+ 0.00625,
+ -0.00102,
+ ],
+ [
+ -0.00402,
+ -0.00044,
+ -0.00184,
+ -0.00643,
+ -0.00374,
+ -0.00501,
+ -0.00306,
+ 0.00093,
+ -0.00138,
+ -0.00494,
+ -0.00118,
+ -0.003,
+ ],
+ [
+ 0.00036,
+ 0.00119,
+ -0.00573,
+ -0.00027,
+ -0.00026,
+ -0.00729,
+ -0.00072,
+ -0.00157,
+ -0.00772,
+ 0.0019,
+ 0.00141,
+ -0.00533,
+ ],
+ [
+ -0.00493,
+ -0.00292,
+ -0.00778,
+ -0.00651,
+ -0.00438,
+ -0.00976,
+ -0.00471,
+ -0.00285,
+ -0.00601,
+ -0.00722,
+ -0.00712,
+ -0.01046,
+ ],
+ [
+ 0.00743,
+ 0.00717,
+ 0.0099,
+ 0.00579,
+ 0.00613,
+ 0.00927,
+ 0.00539,
+ 0.00664,
+ 0.00831,
+ 0.00324,
+ 0.00466,
+ 0.00644,
+ ],
+ [
+ 0.00396,
+ 0.00619,
+ 0.01018,
+ 0.00817,
+ 0.01009,
+ 0.01491,
+ 0.00083,
+ 0.00371,
+ 0.00768,
+ 0.00373,
+ 0.0065,
+ 0.01025,
+ ],
+ [
+ 0.00608,
+ 0.00567,
+ 0.00834,
+ 0.0015,
+ 0.00163,
+ 0.00472,
+ 0.00861,
+ 0.0076,
+ 0.01246,
+ 0.0034,
+ 0.00285,
+ 0.00815,
+ ],
+ [
+ -0.00038,
+ 0.00092,
+ 0.00301,
+ 0.0029,
+ 0.00357,
+ 0.00506,
+ 0.00107,
+ 0.00227,
+ 0.00432,
+ 0.00515,
+ 0.00576,
+ 0.00877,
+ ],
+ [
+ -0.0019,
+ 0.00655,
+ 0.00693,
+ -0.00382,
+ 0.00204,
+ 0.00191,
+ -4e-05,
+ 0.0036,
+ 0.00315,
+ -0.0011,
+ 0.00172,
+ 0.00189,
+ ],
+ [
+ -0.00124,
+ 0.00041,
+ -0.00179,
+ -0.00048,
+ 0.00514,
+ 0.00327,
+ -0.00245,
+ -0.00193,
+ -0.00417,
+ -0.00042,
+ 0.00083,
+ -0.00221,
+ ],
+ [
+ 0.0031,
+ 0.00717,
+ 0.00512,
+ 0.00288,
+ 0.00485,
+ 0.00243,
+ 0.0048,
+ 0.01299,
+ 0.01174,
+ 0.00331,
+ 0.00815,
+ 0.00572,
+ ],
+ [
+ 0.00037,
+ -0.0013,
+ -0.00435,
+ 0.00208,
+ 0.00216,
+ -0.00064,
+ -0.00027,
+ -0.0015,
+ -0.00429,
+ 0.00179,
+ 0.00468,
+ 0.00298,
+ ],
+ [
+ -0.00789,
+ -0.0092,
+ -0.01014,
+ -0.00958,
+ -0.01004,
+ -0.01208,
+ -0.00671,
+ -0.00764,
+ -0.00931,
+ -0.00637,
+ -0.00707,
+ -0.00842,
+ ],
+ [
+ -0.00697,
+ -0.00885,
+ -0.00759,
+ -0.00697,
+ -0.00985,
+ -0.00828,
+ -0.00578,
+ -0.00674,
+ -0.00574,
+ -0.00611,
+ -0.00816,
+ -0.00737,
+ ],
+ [
+ -0.00375,
+ -0.00426,
+ -0.00535,
+ -0.00375,
+ -0.00344,
+ -0.00421,
+ -0.00653,
+ -0.00677,
+ -0.00646,
+ -0.00637,
+ -0.00611,
+ -0.00629,
+ ],
+ [
+ -0.00447,
+ -0.00405,
+ -0.00381,
+ -0.00482,
+ -0.00539,
+ -0.00605,
+ -0.00604,
+ -0.00583,
+ -0.0054,
+ -0.00834,
+ -0.00738,
+ -0.00668,
+ ],
+ [
+ 0.00856,
+ 0.00472,
+ 0.00801,
+ 0.00561,
+ 0.00116,
+ 0.00395,
+ 0.00496,
+ 0.00109,
+ 0.00309,
+ 0.00497,
+ 0.00046,
+ 0.00186,
+ ],
+ [
+ 0.00101,
+ -0.0038,
+ -0.00633,
+ 0.00472,
+ 3e-05,
+ -0.00079,
+ 0.00168,
+ -0.00385,
+ -0.00611,
+ 0.00304,
+ -0.00291,
+ -0.00494,
+ ],
+ [
+ 0.00164,
+ -0.00205,
+ 0.00015,
+ 0.00182,
+ -0.00209,
+ -0.00034,
+ 0.00368,
+ 0.00028,
+ 0.00411,
+ 0.00101,
+ -0.0032,
+ -0.00041,
+ ],
+ [
+ 0.00174,
+ -0.0042,
+ -0.00415,
+ 0.00437,
+ -0.00165,
+ -0.00051,
+ 0.00129,
+ -0.00385,
+ -0.00486,
+ 0.00554,
+ 0.00054,
+ 0.00208,
+ ],
+ [
+ -0.00027,
+ -0.00289,
+ -0.00784,
+ 0.00207,
+ -0.00194,
+ -0.00195,
+ 0.00533,
+ 0.0009,
+ 0.00011,
+ 0.0064,
+ 0.00147,
+ 0.00167,
+ ],
+ [
+ 0.00148,
+ -0.00362,
+ -0.00312,
+ -0.00266,
+ -0.00513,
+ -0.01008,
+ 0.0039,
+ -0.00185,
+ -0.00179,
+ 0.00217,
+ -0.0028,
+ -0.00347,
+ ],
+ [
+ -0.00012,
+ -0.00482,
+ -0.00335,
+ 0.00481,
+ -0.00116,
+ -0.00082,
+ -0.00821,
+ -0.01088,
+ -0.01271,
+ -0.00144,
+ -0.00529,
+ -0.00293,
+ ],
+ [
+ 0.00089,
+ -0.00108,
+ 0.00069,
+ -0.00055,
+ -0.00095,
+ 0.00174,
+ -0.00165,
+ -0.00217,
+ 0.0022,
+ -0.00598,
+ -0.00429,
+ -0.0054,
+ ],
+ [
+ -0.00062,
+ -0.00136,
+ 0.00422,
+ -0.00287,
+ -0.00241,
+ -0.00053,
+ -0.00173,
+ -0.00176,
+ 0.00145,
+ -0.00137,
+ -0.00082,
+ 0.00124,
+ ],
+ [
+ -0.00194,
+ -0.00314,
+ -0.00303,
+ -0.00031,
+ -0.00284,
+ 0.00141,
+ -0.004,
+ -0.00388,
+ -0.00273,
+ -0.00338,
+ -0.0037,
+ -0.00151,
+ ],
+ [
+ 0.00203,
+ 0.00237,
+ 0.00478,
+ 0.00327,
+ 0.00389,
+ 0.00532,
+ 0.00529,
+ 0.00398,
+ 0.00843,
+ 0.00324,
+ 0.00392,
+ 0.00491,
+ ],
+ [
+ -0.00158,
+ -0.00373,
+ -0.0038,
+ -0.00199,
+ -0.00296,
+ -0.00157,
+ -0.0005,
+ -0.00265,
+ -0.00256,
+ 0.00073,
+ -0.00214,
+ 0.00218,
+ ],
+ [
+ -0.00367,
+ 0.0058,
+ 0.00709,
+ 0.00017,
+ 0.00574,
+ 0.00444,
+ -0.00098,
+ 0.004,
+ 0.00317,
+ -0.00035,
+ 0.0037,
+ 0.00308,
+ ],
+ [
+ -0.00586,
+ 0.00182,
+ -0.0006,
+ -0.00996,
+ 0.00037,
+ 0.00036,
+ -0.00349,
+ 0.00165,
+ -0.00053,
+ -0.00527,
+ 0.0007,
+ -0.00128,
+ ],
+ [
+ -0.00451,
+ 0.00159,
+ 8e-05,
+ -0.00361,
+ 0.00072,
+ -0.00137,
+ -0.00918,
+ 0.00084,
+ 0.001,
+ -0.00531,
+ 0.00047,
+ -0.00156,
+ ],
+ [
+ -0.00379,
+ -0.0002,
+ -0.00354,
+ -0.00428,
+ 0.00079,
+ -0.00243,
+ -0.0058,
+ 0.00024,
+ -0.00306,
+ -0.00928,
+ 0.00019,
+ -0.00096,
+ ],
+ [
+ 0.00447,
+ 0.00151,
+ 0.00217,
+ 0.00384,
+ 0.00144,
+ 0.00146,
+ 0.00232,
+ -0.00015,
+ -0.00103,
+ 0.00126,
+ -0.00015,
+ -0.00032,
+ ],
+ [
+ 0.00405,
+ 0.00495,
+ 0.00236,
+ 0.00428,
+ 0.0041,
+ 0.00323,
+ 0.0023,
+ 0.00413,
+ 0.00284,
+ 0.0012,
+ 0.00252,
+ 0.00068,
+ ],
+ [
+ 0.00193,
+ 0.00164,
+ 0.00261,
+ 0.00016,
+ 0.0012,
+ 0.00244,
+ 0.00258,
+ 0.00205,
+ 0.0035,
+ 0.00231,
+ 0.00262,
+ 0.00317,
+ ],
+ [
+ 0.00414,
+ 0.00411,
+ 0.00486,
+ 0.00712,
+ 0.00702,
+ 0.00862,
+ 0.0053,
+ 0.0055,
+ 0.00623,
+ 0.00792,
+ 0.00693,
+ 0.00924,
+ ],
+ [
+ 0.00174,
+ -0.00286,
+ -0.00523,
+ -0.00137,
+ -0.00365,
+ -0.00395,
+ -0.0012,
+ -0.00431,
+ -0.00516,
+ -0.00123,
+ -0.00305,
+ -0.00329,
+ ],
+ [
+ -0.0006,
+ -0.00395,
+ -0.00252,
+ 0.00227,
+ -0.00278,
+ -0.00278,
+ -0.00168,
+ -0.00315,
+ -0.00204,
+ -0.00198,
+ -0.00453,
+ -0.00308,
+ ],
+ [
+ 0.0043,
+ -0.00082,
+ -0.00364,
+ 0.00374,
+ -0.00077,
+ -0.00354,
+ 0.0102,
+ 0.00292,
+ -0.0013,
+ 0.00557,
+ -0.00015,
+ -0.00295,
+ ],
+ [
+ 0.00277,
+ -0.00122,
+ -0.00372,
+ 0.00305,
+ -0.00134,
+ -0.00337,
+ 0.00392,
+ -0.00089,
+ -0.00261,
+ 0.00768,
+ 0.00216,
+ -0.00059,
+ ],
+ ],
+ "bias": [
+ 0.52554,
+ 0.48592,
+ 0.45838,
+ 0.52523,
+ 0.48561,
+ 0.45744,
+ 0.52059,
+ 0.47895,
+ 0.45037,
+ 0.51983,
+ 0.47927,
+ 0.44994,
+ ],
+ },
+ "hv15": {
+ "layout": "bcthw",
+ "down": 16,
+ "patch": 1,
+ "weight": [
+ [0.01207, -0.01996, 0.00948],
+ [0.02031, 0.00588, 0.0088],
+ [0.01839, 0.02344, 0.01662],
+ [-0.03987, -0.03781, -0.0145],
+ [0.01253, 0.0283, 0.01849],
+ [-0.00156, 0.01453, -0.04429],
+ [0.03095, 0.03067, 0.01381],
+ [0.00342, -0.01683, 0.01089],
+ [0.01106, -0.03479, -0.01099],
+ [-0.01059, -0.01903, -0.0017],
+ [0.00911, 0.00266, -0.00015],
+ [0.01034, 0.01915, 0.01915],
+ [0.03468, 0.0391, 0.03793],
+ [0.00733, -0.00648, -0.02944],
+ [0.00128, -0.00178, 0.00294],
+ [0.02098, 0.00422, -0.0068],
+ [0.01996, -0.00631, 0.00214],
+ [0.01613, 0.00389, 0.00156],
+ [0.00264, 0.01911, 0.00919],
+ [0.01432, 0.01678, 0.03499],
+ [0.01932, 0.02393, 0.02045],
+ [0.00531, 0.00923, -0.01168],
+ [-0.00316, 0.00859, 0.0057],
+ [-0.0125, -0.02525, -0.02497],
+ [0.04287, -0.00685, 0.00987],
+ [0.03067, 0.03266, 0.03409],
+ [0.01018, 0.01245, 0.02909],
+ [-0.01777, -0.01011, -0.00035],
+ [0.02379, 0.02755, 0.02656],
+ [0.0113, 0.02523, -0.01971],
+ [-0.00235, 0.00749, -0.00217],
+ [-0.02267, -0.04033, 0.00061],
+ ],
+ "bias": [0.53727, 0.49377, 0.47773],
+ },
+ "ltx2": {
+ "layout": "tokens",
+ "down": 32,
+ "patch": 1,
+ "weight": [
+ [-0.00033, -0.01167, -0.01031],
+ [-0.00558, -0.00394, -0.00331],
+ [-0.00135, 0.00059, 0.00141],
+ [-0.00113, -0.00014, -0.00118],
+ [-0.00414, -0.00401, -0.00244],
+ [0.00685, 0.00685, 0.00466],
+ [-0.0063, -0.00646, -0.00555],
+ [-0.01844, -0.00461, -0.00308],
+ [-0.0002, 0.00327, 0.00243],
+ [0.00443, 0.00305, -0.00058],
+ [-0.00152, -0.00168, -0.00086],
+ [0.00294, 0.0054, 0.00463],
+ [-0.00149, -0.00451, -0.00684],
+ [0.00563, -0.00156, -0.00167],
+ [-0.00179, 0.00067, 0.0011],
+ [0.00115, 0.00078, 0.00049],
+ [-0.00224, -0.00566, -0.00566],
+ [-0.00744, -0.0054, -0.00504],
+ [0.00334, 0.00396, 0.00379],
+ [0.01197, 0.0107, 0.00947],
+ [0.00515, 0.00172, 0.00033],
+ [-0.00133, -0.00093, -0.00131],
+ [0.00421, 0.00087, 0.00142],
+ [0.00456, -0.00022, 0.00438],
+ [-0.00021, 0.01093, 0.01333],
+ [-0.00754, -0.00863, -0.00664],
+ [-0.00539, -0.00528, -0.00613],
+ [-0.01053, -0.00629, -0.00341],
+ [0.00048, -0.00253, -0.00353],
+ [0.00051, -0.00118, -0.00147],
+ [-0.00185, -0.00045, -0.00198],
+ [-0.00092, -0.00035, 0.00013],
+ [0.00273, 0.00189, 0.00218],
+ [-0.00128, -0.00243, -0.00181],
+ [0.00103, 0.00075, 0.00162],
+ [-0.00092, 0.00124, 0.0027],
+ [-0.00539, -0.00479, -0.00356],
+ [0.00027, 0.00138, -0.00092],
+ [0.00136, 0.00103, -6e-05],
+ [0.00101, -0.00136, -0.00123],
+ [0.00242, 0.00382, 0.00296],
+ [0.00109, 0.00042, 0.00161],
+ [-0.00276, -0.00212, -0.00136],
+ [-0.00487, -0.00289, -0.00417],
+ [-0.00346, -0.00344, -0.00334],
+ [0.01159, 0.00788, 0.01133],
+ [-0.00231, -0.00221, -0.00316],
+ [0.00202, 0.00339, 0.00352],
+ [-0.00233, -0.00336, -0.00357],
+ [-0.00207, -0.0034, -0.00328],
+ [-0.00293, -0.00372, -0.00066],
+ [-0.00183, 0.00049, -6e-05],
+ [-0.00345, -0.00445, -0.00366],
+ [-0.00335, -0.00375, -0.0015],
+ [-0.00391, -0.00366, -0.00485],
+ [-0.00297, -0.00113, 0.00224],
+ [-0.00108, -0.00278, -0.003],
+ [-0.01219, 0.0134, 0.01686],
+ [0.00186, 0.00278, 0.00301],
+ [-0.00669, -0.00551, -0.00398],
+ [0.00359, 0.00394, 0.00297],
+ [-0.00028, -0.00143, -0.0016],
+ [-0.00135, 0.00289, 0.00267],
+ [0.00601, -0.01123, -0.01572],
+ [-0.00481, 0.00316, 0.0076],
+ [-0.00262, -0.00317, -0.00841],
+ [-0.00479, -0.00024, 0.00083],
+ [-0.00701, -0.0028, -0.00276],
+ [0.00606, 0.00192, -0.00011],
+ [-0.00057, -0.00169, -0.0008],
+ [0.00082, 0.00048, -0.00122],
+ [0.00893, 0.00578, 0.00424],
+ [-0.00867, -0.00941, -0.01304],
+ [-0.00136, -0.00214, -0.00128],
+ [-0.00399, -0.00131, -0.00151],
+ [-0.02502, -0.01957, -0.02759],
+ [-0.0019, -0.00132, -0.00056],
+ [0.0008, 0.00151, 0.00169],
+ [-0.00199, -0.00377, -0.00521],
+ [0.00044, -0.00177, 8e-05],
+ [0.0007, -0.00464, -0.00351],
+ [0.01022, 0.01108, 0.00927],
+ [0.00399, -0.00158, -0.00021],
+ [0.00335, 0.00367, 0.00267],
+ [-0.00308, -0.00408, -0.0038],
+ [-0.00524, -0.00348, -0.00255],
+ [0.01709, 0.01402, 0.01219],
+ [0.00556, 0.00049, 0.00024],
+ [0.00021, 0.00086, 0.0013],
+ [-0.00272, 0.0013, 0.00076],
+ [-0.00048, -0.00243, -0.00237],
+ [0.00261, 0.0061, 0.00457],
+ [0.00039, 0.00388, 0.00801],
+ [0.00289, 0.00247, 0.00273],
+ [-0.0024, -0.00444, -0.00549],
+ [-0.00059, 0.00116, 0.00112],
+ [-0.00704, -0.00327, -0.0069],
+ [-0.03296, -0.05963, -0.07192],
+ [0.00367, 0.00312, -0.00184],
+ [-0.00469, -0.00415, -0.00291],
+ [-0.00781, -0.00395, -0.0033],
+ [0.00213, -0.00366, -0.00382],
+ [0.00275, 0.00097, 0.00177],
+ [0.08043, 0.0814, 0.07265],
+ [0.00493, 0.00257, 0.00145],
+ [0.01226, 0.0069, 0.00668],
+ [0.00383, -0.00085, -0.00033],
+ [0.00036, 0.00458, 0.00506],
+ [0.00135, 0.0018, 0.00938],
+ [0.00345, 0.00408, 0.00873],
+ [0.00108, -0.00421, -0.02465],
+ [0.00247, 0.00732, 0.00811],
+ [-0.00606, -0.00312, -0.0012],
+ [-0.00466, -0.00092, -0.0014],
+ [-0.00286, -0.00584, -0.00207],
+ [0.00754, 0.00874, 0.00585],
+ [-0.08201, -0.0637, -0.04926],
+ [-0.00016, -0.00078, -0.00345],
+ [-5e-05, 0.00191, 0.00108],
+ [0.00689, 0.00605, 0.00461],
+ [0.00322, 0.00072, -0.00036],
+ [-0.0016, -0.00517, -0.00343],
+ [-0.00196, -0.00229, -0.00199],
+ [0.00062, 0.00161, 0.00109],
+ [-0.00091, -0.00182, -0.00247],
+ [0.00313, 0.00638, 0.00459],
+ [0.00222, -0.00211, -0.00487],
+ [0.00274, 0.00232, 0.00218],
+ ],
+ "bias": [0.39977, 0.35828, 0.3417],
+ },
+ "qwen_image": {
+ "layout": "tokens",
+ "down": 16,
+ "patch": 2,
+ "weight": [
+ [
+ -0.0324,
+ -0.00673,
+ 0.13537,
+ -0.03818,
+ -0.03666,
+ 0.02367,
+ -0.01875,
+ -0.03055,
+ 0.02713,
+ -0.02942,
+ -0.02517,
+ -0.00306,
+ ],
+ [
+ -0.06646,
+ -0.04248,
+ -0.0044,
+ -0.04962,
+ -0.00402,
+ 0.12318,
+ -0.03972,
+ -0.02169,
+ -0.00426,
+ -0.04172,
+ -0.03294,
+ 0.01659,
+ ],
+ [
+ -0.01905,
+ -0.03443,
+ -0.00862,
+ -0.02653,
+ -0.03083,
+ -0.02597,
+ -0.04765,
+ -0.0251,
+ 0.09134,
+ -0.03924,
+ -0.04476,
+ -0.00099,
+ ],
+ [
+ -0.04725,
+ -0.04856,
+ -0.03867,
+ -0.04915,
+ -0.05985,
+ -0.027,
+ -0.06195,
+ -0.06649,
+ -0.04115,
+ -0.05354,
+ -0.03794,
+ 0.07017,
+ ],
+ [
+ 0.00894,
+ -0.00264,
+ 0.03225,
+ -0.00404,
+ -0.01833,
+ 0.0006,
+ -0.00193,
+ -0.00286,
+ 0.0074,
+ 0.00967,
+ 0.00113,
+ 0.00906,
+ ],
+ [
+ -0.00788,
+ -0.01337,
+ -0.00415,
+ 0.01027,
+ 0.0031,
+ 0.02751,
+ -0.00786,
+ -4e-05,
+ -0.00246,
+ -0.00525,
+ -0.00095,
+ -0.00314,
+ ],
+ [
+ -0.01429,
+ -0.00754,
+ -0.00551,
+ -0.00086,
+ 0.00358,
+ -0.00048,
+ 0.01095,
+ -0.00482,
+ 0.01765,
+ -0.0092,
+ -0.01407,
+ -0.00733,
+ ],
+ [
+ 0.00423,
+ 0.00778,
+ 0.00687,
+ -0.00883,
+ -0.00284,
+ -0.00355,
+ 0.00272,
+ -0.00087,
+ 0.00998,
+ 0.0165,
+ 0.00917,
+ 0.03439,
+ ],
+ [
+ 0.10698,
+ 0.05372,
+ 0.03688,
+ -0.03048,
+ -0.02901,
+ -0.01508,
+ -0.03996,
+ -0.02413,
+ -0.01609,
+ -0.04254,
+ -0.03415,
+ -0.01691,
+ ],
+ [
+ -0.02818,
+ -0.03751,
+ -0.01051,
+ 0.11289,
+ 0.04845,
+ 0.04183,
+ -0.02011,
+ -0.0276,
+ -0.00461,
+ -0.02033,
+ -0.01973,
+ -0.00609,
+ ],
+ [
+ -0.02033,
+ -0.01956,
+ -0.00157,
+ -0.01041,
+ -0.01494,
+ -0.00029,
+ 0.12465,
+ 0.06429,
+ 0.05352,
+ -0.00556,
+ -0.01437,
+ -0.00446,
+ ],
+ [
+ -0.01083,
+ -0.02375,
+ 0.01201,
+ -0.01842,
+ -0.02885,
+ 0.00686,
+ -0.01447,
+ -0.03154,
+ 0.00786,
+ 0.11427,
+ 0.04616,
+ 0.05911,
+ ],
+ [
+ 0.08623,
+ 0.11729,
+ 0.05039,
+ 0.02166,
+ 0.02454,
+ -0.00945,
+ 0.02576,
+ 0.02631,
+ -0.00975,
+ 0.01503,
+ 0.00116,
+ -0.01426,
+ ],
+ [
+ -0.01987,
+ -0.00927,
+ -0.01604,
+ 0.05564,
+ 0.08893,
+ 0.04211,
+ -0.00307,
+ -0.01227,
+ -0.01564,
+ -0.00557,
+ 0.00102,
+ -0.02461,
+ ],
+ [
+ -0.01708,
+ 0.00265,
+ -0.04941,
+ -0.02392,
+ -0.00962,
+ -0.03955,
+ 0.06181,
+ 0.09472,
+ 0.01337,
+ -0.01596,
+ 0.00611,
+ -0.03902,
+ ],
+ [
+ -0.02255,
+ -0.01917,
+ -0.01978,
+ -0.03059,
+ -0.01187,
+ -0.02934,
+ -0.03131,
+ -0.01383,
+ -0.0166,
+ 0.0539,
+ 0.08236,
+ 0.03947,
+ ],
+ [
+ -0.0048,
+ -0.02557,
+ -0.02555,
+ -0.00913,
+ -0.00983,
+ -0.00648,
+ -0.00014,
+ -0.00914,
+ 0.00145,
+ -0.00787,
+ -0.00882,
+ 0.00032,
+ ],
+ [
+ -0.008,
+ -0.00936,
+ -0.00349,
+ 0.00041,
+ -0.02151,
+ -0.02236,
+ -0.00549,
+ -0.00496,
+ -0.00325,
+ -0.00054,
+ -0.00523,
+ -0.00197,
+ ],
+ [
+ -0.0011,
+ -0.01067,
+ -0.00226,
+ -0.00319,
+ -0.00745,
+ -0.00067,
+ -0.00121,
+ -0.01913,
+ -0.02359,
+ -0.01231,
+ -0.00773,
+ -0.01013,
+ ],
+ [
+ -0.00253,
+ -0.00305,
+ 0.00277,
+ -0.00299,
+ -0.00703,
+ 0.00182,
+ -0.00735,
+ -0.00016,
+ 0.01258,
+ 0.0026,
+ -0.01221,
+ -0.00519,
+ ],
+ [
+ 0.05633,
+ -0.03841,
+ -0.06147,
+ 0.01998,
+ -0.01248,
+ -0.02578,
+ 0.01042,
+ -0.02312,
+ -0.03284,
+ 0.00835,
+ -0.00825,
+ -0.02115,
+ ],
+ [
+ -0.00852,
+ -0.01351,
+ -0.03245,
+ 0.03493,
+ -0.0307,
+ -0.05257,
+ -0.00954,
+ 0.00184,
+ -0.01355,
+ -0.01048,
+ -0.01548,
+ -0.02637,
+ ],
+ [
+ 0.00347,
+ -0.00963,
+ -0.02372,
+ -0.00376,
+ 0.00076,
+ -0.01638,
+ 0.03864,
+ -0.03339,
+ -0.05592,
+ 0.00467,
+ -0.00958,
+ -0.02595,
+ ],
+ [
+ -0.01356,
+ 0.00242,
+ -0.01283,
+ -0.00983,
+ -0.00728,
+ -0.01763,
+ -0.01533,
+ -0.01199,
+ -0.03342,
+ 0.0322,
+ -0.02335,
+ -0.04551,
+ ],
+ [
+ -0.12466,
+ -0.19143,
+ -0.1257,
+ -0.02272,
+ -0.07014,
+ -0.02017,
+ -0.02718,
+ -0.08664,
+ -0.03917,
+ -0.01971,
+ -0.05511,
+ -0.00683,
+ ],
+ [
+ -0.00219,
+ -0.03648,
+ -0.03273,
+ -0.09927,
+ -0.14796,
+ -0.11454,
+ -0.00654,
+ -0.0271,
+ -0.01432,
+ -0.01851,
+ -0.05662,
+ -0.0365,
+ ],
+ [
+ -0.0087,
+ -0.03625,
+ -0.02508,
+ 0.00212,
+ -0.01564,
+ -0.01292,
+ -0.10182,
+ -0.14538,
+ -0.114,
+ -0.01209,
+ -0.03758,
+ -0.02566,
+ ],
+ [
+ -0.00399,
+ -0.02058,
+ 0.00092,
+ -0.0182,
+ -0.04125,
+ -0.00519,
+ 0.0108,
+ -0.0286,
+ -0.01285,
+ -0.08177,
+ -0.13071,
+ -0.0837,
+ ],
+ [
+ -0.03368,
+ 0.02108,
+ 0.02206,
+ -0.00502,
+ -0.00315,
+ -0.01092,
+ -0.00357,
+ 0.01502,
+ 0.00395,
+ 0.0069,
+ -0.00231,
+ -0.01569,
+ ],
+ [
+ 0.03852,
+ 0.02247,
+ 0.01322,
+ 0.00175,
+ 0.04422,
+ 0.04011,
+ 0.02819,
+ 0.01477,
+ -0.00211,
+ 0.02195,
+ 0.03214,
+ 0.01598,
+ ],
+ [
+ 0.00251,
+ 0.01772,
+ -0.00294,
+ 0.00964,
+ 0.01183,
+ -0.00892,
+ -0.02449,
+ 0.03459,
+ 0.02526,
+ -0.00465,
+ 0.01207,
+ -0.00128,
+ ],
+ [
+ 0.01614,
+ 0.01153,
+ 0.00699,
+ 0.02369,
+ 0.0334,
+ 0.02543,
+ 0.03076,
+ 0.0394,
+ 0.04383,
+ 0.00723,
+ 0.06342,
+ 0.06631,
+ ],
+ [
+ -0.12522,
+ -0.10784,
+ -0.12309,
+ -0.02272,
+ -0.03118,
+ -0.03222,
+ -0.02126,
+ -0.01199,
+ -0.01343,
+ 0.0166,
+ 0.01328,
+ 0.01475,
+ ],
+ [
+ -0.03948,
+ -0.02989,
+ -0.01085,
+ -0.13717,
+ -0.11393,
+ -0.1129,
+ -0.01796,
+ -0.01487,
+ 0.00859,
+ -0.04987,
+ -0.03784,
+ -0.01932,
+ ],
+ [
+ 6e-05,
+ 0.02311,
+ 0.01727,
+ -0.00108,
+ 0.02416,
+ 0.02513,
+ -0.12229,
+ -0.07672,
+ -0.09739,
+ -0.02367,
+ -0.0041,
+ -0.00917,
+ ],
+ [
+ -0.02504,
+ 0.01343,
+ 0.02819,
+ -0.02865,
+ 0.00773,
+ 0.009,
+ -0.02962,
+ 6e-05,
+ 0.00306,
+ -0.12193,
+ -0.07515,
+ -0.096,
+ ],
+ [
+ -0.08822,
+ 0.01912,
+ 0.05758,
+ -0.03336,
+ -0.00364,
+ 0.01729,
+ -0.02863,
+ -0.00794,
+ 0.00961,
+ -0.01768,
+ -0.01836,
+ -0.00544,
+ ],
+ [
+ -0.02241,
+ -0.02353,
+ -0.00982,
+ -0.07143,
+ 0.00641,
+ 0.03508,
+ -0.01593,
+ -0.02188,
+ -0.01423,
+ -0.03153,
+ -0.01384,
+ -0.00359,
+ ],
+ [
+ -0.00832,
+ -0.01957,
+ -0.01112,
+ -0.01075,
+ -0.03547,
+ -0.02109,
+ -0.06585,
+ 0.00791,
+ 0.03513,
+ -0.02506,
+ -0.02329,
+ -0.01172,
+ ],
+ [
+ 0.0058,
+ -0.0289,
+ -0.0172,
+ 0.00155,
+ -0.02073,
+ -0.012,
+ -0.00714,
+ -0.03816,
+ -0.02164,
+ -0.04905,
+ -0.00667,
+ 0.02623,
+ ],
+ [
+ 0.01321,
+ 0.10845,
+ 0.10135,
+ 0.01046,
+ 0.04107,
+ 0.04473,
+ 0.01382,
+ 0.02957,
+ 0.03211,
+ 0.02208,
+ 0.01755,
+ 0.03222,
+ ],
+ [
+ 0.00838,
+ 0.02516,
+ 0.02354,
+ 0.0108,
+ 0.09207,
+ 0.08924,
+ 0.00449,
+ 0.00905,
+ 0.02405,
+ 0.01455,
+ 0.03189,
+ 0.04031,
+ ],
+ [
+ 0.01237,
+ 0.03238,
+ 0.03682,
+ 0.00526,
+ 0.01009,
+ 0.02603,
+ 0.01698,
+ 0.10224,
+ 0.0936,
+ 0.00232,
+ 0.03924,
+ 0.04255,
+ ],
+ [
+ 0.00214,
+ 0.01562,
+ 0.03074,
+ 0.00924,
+ 0.03817,
+ 0.0385,
+ 0.00592,
+ 0.04025,
+ 0.0361,
+ 0.00821,
+ 0.1019,
+ 0.09069,
+ ],
+ [
+ 0.01735,
+ 0.05209,
+ 0.03809,
+ 0.01975,
+ 0.02492,
+ 0.00276,
+ 0.03531,
+ 0.02166,
+ 0.00553,
+ 0.01875,
+ 0.00871,
+ -0.00288,
+ ],
+ [
+ 0.02028,
+ 0.02408,
+ 0.02824,
+ 0.0042,
+ 0.03955,
+ 0.04554,
+ 0.01983,
+ 0.01782,
+ 0.02052,
+ 0.02713,
+ 0.02118,
+ 0.01873,
+ ],
+ [
+ 0.02409,
+ 0.01372,
+ 0.00585,
+ 0.00782,
+ 0.01122,
+ 0.00569,
+ -0.00832,
+ 0.03601,
+ 0.02987,
+ 0.00312,
+ 0.01408,
+ -0.00548,
+ ],
+ [
+ 0.00828,
+ 0.01556,
+ 0.01755,
+ 0.0304,
+ 0.0265,
+ 0.02697,
+ 0.01719,
+ 0.0291,
+ 0.03016,
+ -0.00315,
+ 0.04604,
+ 0.0519,
+ ],
+ [
+ -0.08127,
+ 0.00599,
+ -0.0024,
+ -0.0144,
+ -0.00615,
+ -0.02331,
+ -0.01017,
+ -0.00319,
+ -0.02588,
+ 0.00535,
+ -0.0054,
+ -0.03174,
+ ],
+ [
+ -0.02372,
+ -0.02119,
+ -0.02715,
+ -0.08517,
+ -0.00234,
+ 0.00262,
+ -0.01648,
+ -0.02083,
+ -0.02829,
+ -0.02228,
+ -0.01276,
+ -0.02069,
+ ],
+ [
+ 0.00837,
+ 0.01391,
+ -0.01192,
+ 0.01462,
+ 0.01512,
+ -0.00688,
+ -0.06642,
+ 0.02458,
+ 0.01708,
+ -0.00591,
+ 0.0107,
+ -0.00486,
+ ],
+ [
+ 0.01084,
+ -0.00018,
+ -0.01272,
+ 0.00886,
+ 0.00326,
+ -0.01287,
+ -0.00451,
+ -0.00238,
+ -0.01406,
+ -0.05871,
+ 0.01715,
+ 0.01973,
+ ],
+ [
+ 0.01438,
+ -0.00047,
+ -0.00189,
+ -0.00767,
+ 0.00219,
+ -0.00453,
+ -0.00452,
+ -0.00647,
+ -0.02485,
+ -0.00456,
+ 0.00482,
+ -0.01155,
+ ],
+ [
+ 0.00644,
+ -0.00024,
+ -0.0126,
+ 0.02101,
+ -0.00205,
+ -0.0056,
+ 0.00208,
+ -0.00016,
+ -0.01879,
+ 0.00395,
+ -0.00805,
+ -0.02691,
+ ],
+ [
+ 0.00845,
+ 0.00387,
+ -0.01713,
+ 0.01168,
+ 0.01102,
+ -0.01303,
+ 0.02231,
+ 0.00709,
+ 0.00227,
+ 0.00778,
+ 0.00856,
+ -0.00499,
+ ],
+ [
+ 0.00929,
+ 0.00117,
+ -0.00958,
+ 0.01279,
+ 0.00015,
+ -0.00686,
+ 0.00811,
+ -0.00128,
+ -0.00842,
+ 0.02328,
+ -0.00144,
+ 0.00164,
+ ],
+ [
+ 0.13542,
+ 0.05647,
+ 0.11605,
+ 0.03297,
+ -0.0161,
+ 0.00867,
+ 0.02673,
+ -0.00447,
+ 0.02135,
+ -0.003,
+ -0.00824,
+ 0.00637,
+ ],
+ [
+ 0.00912,
+ -0.03464,
+ -0.01829,
+ 0.11197,
+ 0.03655,
+ 0.07978,
+ -0.00991,
+ -0.02045,
+ -0.00935,
+ 0.01908,
+ -0.01059,
+ 0.00842,
+ ],
+ [
+ 0.00671,
+ -0.0221,
+ 0.01427,
+ -0.01468,
+ -0.01798,
+ 0.01136,
+ 0.10637,
+ 0.04243,
+ 0.11382,
+ 0.02289,
+ -0.02273,
+ 0.01138,
+ ],
+ [
+ 0.00173,
+ 0.00475,
+ 0.01017,
+ 0.02077,
+ -0.00751,
+ 0.0077,
+ 0.02668,
+ -0.01694,
+ -0.00634,
+ 0.10665,
+ 0.04023,
+ 0.0853,
+ ],
+ [
+ 0.07887,
+ 0.06584,
+ 0.08034,
+ 0.03237,
+ 0.03708,
+ 0.03193,
+ 0.01607,
+ 0.01814,
+ 0.01485,
+ 0.01754,
+ 0.0303,
+ 0.0268,
+ ],
+ [
+ 0.03135,
+ 0.03354,
+ -0.00764,
+ 0.07986,
+ 0.07029,
+ 0.06554,
+ 0.00712,
+ 0.02526,
+ -0.00105,
+ 0.01711,
+ 0.02266,
+ 0.00287,
+ ],
+ [
+ 0.00905,
+ 0.0229,
+ 0.00829,
+ 0.00084,
+ 0.01896,
+ -0.00073,
+ 0.0673,
+ 0.07521,
+ 0.07907,
+ 0.02049,
+ 0.04248,
+ 0.02573,
+ ],
+ [
+ -0.00534,
+ 0.00855,
+ -0.02243,
+ 0.00977,
+ 0.01897,
+ -0.01242,
+ -0.00128,
+ 0.01866,
+ -0.03167,
+ 0.05963,
+ 0.06144,
+ 0.03953,
+ ],
+ ],
+ "bias": [
+ 0.40842,
+ 0.38833,
+ 0.26115,
+ 0.41248,
+ 0.39707,
+ 0.26929,
+ 0.41495,
+ 0.40128,
+ 0.2748,
+ 0.41766,
+ 0.40629,
+ 0.2787,
+ ],
+ },
+ "qwen_image_21": {
+ "layout": "tokens",
+ "down": 16,
+ "patch": 2,
+ "weight": [
+ [
+ -0.00733,
+ -0.00506,
+ -0.00701,
+ -0.01299,
+ -0.01242,
+ -0.01595,
+ -0.01057,
+ -0.00742,
+ -0.01169,
+ 0.00251,
+ 0.00015,
+ -0.00816,
+ ],
+ [
+ -0.01092,
+ 0.00257,
+ 0.00765,
+ -0.01863,
+ 0.00243,
+ 0.00757,
+ -0.00871,
+ 0.0082,
+ 0.01374,
+ -0.01403,
+ 0.00808,
+ 0.01287,
+ ],
+ [
+ 0.05166,
+ 0.03328,
+ -0.00901,
+ 0.04592,
+ 0.02803,
+ -0.01465,
+ 0.04565,
+ 0.03148,
+ -0.01091,
+ 0.03501,
+ 0.02328,
+ -0.01808,
+ ],
+ [
+ 0.021,
+ 0.03004,
+ 0.02052,
+ 0.01705,
+ 0.02912,
+ 0.02534,
+ 0.01012,
+ 0.02075,
+ 0.01183,
+ 0.01549,
+ 0.02729,
+ 0.02351,
+ ],
+ [
+ -0.01941,
+ 0.00284,
+ 0.00133,
+ -0.01245,
+ 0.00861,
+ 0.00871,
+ -0.0083,
+ 0.00594,
+ 0.00693,
+ 0.00023,
+ 0.01114,
+ 0.01103,
+ ],
+ [
+ 0.03658,
+ 0.03832,
+ 0.00286,
+ 0.0333,
+ 0.03252,
+ -0.00124,
+ 0.02121,
+ 0.01683,
+ -0.01829,
+ 0.02244,
+ 0.01454,
+ -0.02103,
+ ],
+ [
+ 0.0001,
+ -0.00412,
+ -0.00213,
+ -0.01048,
+ -0.00594,
+ 0.00282,
+ -0.00734,
+ -0.01362,
+ -0.01431,
+ -0.00759,
+ -0.00881,
+ -0.00386,
+ ],
+ [
+ -0.03673,
+ -0.05723,
+ -0.05963,
+ -0.02723,
+ -0.05027,
+ -0.05329,
+ -0.0251,
+ -0.04236,
+ -0.04799,
+ -0.00198,
+ -0.02527,
+ -0.03409,
+ ],
+ [
+ -0.00163,
+ -0.02284,
+ 0.01037,
+ -0.01612,
+ -0.03038,
+ 0.00216,
+ -0.00557,
+ -0.01966,
+ 0.01513,
+ -0.02506,
+ -0.03261,
+ 0.00117,
+ ],
+ [
+ -0.052,
+ -0.00682,
+ 0.02792,
+ -0.05692,
+ -0.00976,
+ 0.02423,
+ -0.05847,
+ -0.02322,
+ 0.00845,
+ -0.05826,
+ -0.01516,
+ 0.0189,
+ ],
+ [
+ -0.00135,
+ -0.01546,
+ -0.02322,
+ -0.00734,
+ -0.02077,
+ -0.02744,
+ -0.00926,
+ -0.01804,
+ -0.03044,
+ -0.01324,
+ -0.02289,
+ -0.03466,
+ ],
+ [
+ 0.0073,
+ 0.01639,
+ -0.01066,
+ -0.01084,
+ -0.00237,
+ -0.03081,
+ 0.01631,
+ 0.02375,
+ -0.00148,
+ 0.00665,
+ 0.01474,
+ -0.01206,
+ ],
+ [
+ -0.0026,
+ -0.02131,
+ 0.00529,
+ -0.00773,
+ -0.02371,
+ 0.00559,
+ -0.00968,
+ -0.03396,
+ -0.01113,
+ -0.01197,
+ -0.03415,
+ -0.00897,
+ ],
+ [
+ -0.03718,
+ -0.01967,
+ -0.0155,
+ -0.04889,
+ -0.02491,
+ -0.01979,
+ -0.01548,
+ 0.00689,
+ 0.00713,
+ -0.02217,
+ -0.00241,
+ -0.00645,
+ ],
+ [
+ 0.02467,
+ 0.02921,
+ 0.02577,
+ 0.00718,
+ 0.00637,
+ 0.00038,
+ 0.03213,
+ 0.02725,
+ 0.0243,
+ 0.0213,
+ 0.01561,
+ 0.01091,
+ ],
+ [
+ 0.00855,
+ -0.03203,
+ -0.00618,
+ -0.00206,
+ -0.03927,
+ -0.01223,
+ -0.013,
+ -0.03703,
+ -0.00915,
+ -0.01324,
+ -0.034,
+ -0.00444,
+ ],
+ [
+ -0.01042,
+ -0.00389,
+ 0.0264,
+ -0.0124,
+ -0.01161,
+ 0.01529,
+ -0.01341,
+ -0.00267,
+ 0.02781,
+ -0.00398,
+ -0.00292,
+ 0.02289,
+ ],
+ [
+ -0.01917,
+ -0.01159,
+ -0.00046,
+ -0.00554,
+ -0.00419,
+ 0.00331,
+ -0.01839,
+ -0.01168,
+ -0.00194,
+ -0.00678,
+ -0.00932,
+ -0.00646,
+ ],
+ [
+ -0.00304,
+ -0.00368,
+ -0.00387,
+ -0.02062,
+ -0.01195,
+ -0.00841,
+ -0.00841,
+ -0.01781,
+ -0.02615,
+ -0.02261,
+ -0.02002,
+ -0.02343,
+ ],
+ [
+ 0.00128,
+ -0.0262,
+ -2e-05,
+ -0.00124,
+ -0.03763,
+ -0.01637,
+ -0.01615,
+ -0.02261,
+ 0.00823,
+ -0.01036,
+ -0.02893,
+ -0.00484,
+ ],
+ [
+ 0.00594,
+ -0.0017,
+ 0.01667,
+ 0.0153,
+ 0.00627,
+ 0.02577,
+ 0.00579,
+ 0.00144,
+ 0.02116,
+ 0.01941,
+ 0.01257,
+ 0.03312,
+ ],
+ [
+ -0.00825,
+ -0.02568,
+ 0.00415,
+ 0.00438,
+ -0.01038,
+ 0.01972,
+ -0.0055,
+ -0.00595,
+ 0.02202,
+ -0.00255,
+ -0.00642,
+ 0.01776,
+ ],
+ [
+ 0.02049,
+ 0.00084,
+ 0.00266,
+ 0.0211,
+ -0.0038,
+ -0.00158,
+ 0.0542,
+ 0.03345,
+ 0.03658,
+ 0.04278,
+ 0.01867,
+ 0.02205,
+ ],
+ [
+ 0.01705,
+ 0.00623,
+ 0.01637,
+ -0.01383,
+ -0.01459,
+ -0.0027,
+ 0.02422,
+ 0.0125,
+ 0.01595,
+ -0.00183,
+ -0.00398,
+ 0.00065,
+ ],
+ [
+ -0.02613,
+ 0.02322,
+ 0.0021,
+ -0.06456,
+ -0.01166,
+ -0.03288,
+ -0.00853,
+ 0.02977,
+ 0.00127,
+ -0.0412,
+ -0.0006,
+ -0.03037,
+ ],
+ [
+ 0.01837,
+ 0.02678,
+ 0.0476,
+ 0.01001,
+ 0.01424,
+ 0.03361,
+ 0.00433,
+ 0.02538,
+ 0.05702,
+ -0.00557,
+ 0.01132,
+ 0.04075,
+ ],
+ [
+ -0.00564,
+ -0.00987,
+ 0.01999,
+ -0.00289,
+ -0.00222,
+ 0.02671,
+ -0.00422,
+ -0.00575,
+ 0.02448,
+ -0.00188,
+ -0.00361,
+ 0.02307,
+ ],
+ [
+ -0.00137,
+ 0.01313,
+ -0.02641,
+ 0.01564,
+ 0.0296,
+ -0.00616,
+ -0.0097,
+ 0.00521,
+ -0.038,
+ -0.0026,
+ 0.01752,
+ -0.01819,
+ ],
+ [
+ 0.00206,
+ -0.00418,
+ -0.00228,
+ -0.01652,
+ -0.0151,
+ -0.01128,
+ -0.00434,
+ -0.00283,
+ -0.01017,
+ -0.0237,
+ -0.01437,
+ -0.01815,
+ ],
+ [
+ -0.00694,
+ -0.01892,
+ -0.01105,
+ 0.00357,
+ -0.01725,
+ -0.01412,
+ -0.01386,
+ -0.00696,
+ 0.00723,
+ -0.0124,
+ -0.01168,
+ 0.00037,
+ ],
+ [
+ 0.01341,
+ 0.02677,
+ 0.00747,
+ 0.01291,
+ 0.02633,
+ 0.01238,
+ 0.01614,
+ 0.01867,
+ -0.00628,
+ 0.0106,
+ 0.01775,
+ -0.00181,
+ ],
+ [
+ -0.01109,
+ -0.01585,
+ -0.02039,
+ -0.01937,
+ -0.0085,
+ -0.00433,
+ 0.00557,
+ -0.00777,
+ -0.01151,
+ -0.02549,
+ -0.01831,
+ -0.01178,
+ ],
+ [
+ 0.00925,
+ 0.01561,
+ 0.01189,
+ 0.00868,
+ 0.00991,
+ 0.00359,
+ 0.0186,
+ 0.01656,
+ 0.00592,
+ 0.01281,
+ 0.01455,
+ 0.00734,
+ ],
+ [
+ -0.01265,
+ 0.0111,
+ -0.01283,
+ -0.00023,
+ 0.00984,
+ -0.01688,
+ -0.01626,
+ 0.00701,
+ -0.01131,
+ -0.00254,
+ 0.01217,
+ -0.00583,
+ ],
+ [
+ -0.00692,
+ 0.01749,
+ 0.05051,
+ -0.0117,
+ 0.0268,
+ 0.06109,
+ 0.00833,
+ 0.03019,
+ 0.05722,
+ -0.00218,
+ 0.0338,
+ 0.06339,
+ ],
+ [
+ -0.01714,
+ -0.01213,
+ 0.01479,
+ -0.01999,
+ -0.00774,
+ 0.01613,
+ -0.0086,
+ -0.00757,
+ 0.01695,
+ -0.00961,
+ -0.00911,
+ 0.00947,
+ ],
+ [
+ 0.00751,
+ -0.00317,
+ 0.00073,
+ 0.01229,
+ 0.00734,
+ 0.01477,
+ 0.01093,
+ 0.00241,
+ 0.00966,
+ 0.00478,
+ 0.00075,
+ 0.01211,
+ ],
+ [
+ 0.03669,
+ 0.038,
+ 0.0046,
+ 0.02547,
+ 0.02365,
+ -0.01219,
+ 0.03779,
+ 0.03103,
+ 0.00374,
+ 0.02923,
+ 0.02404,
+ -0.00458,
+ ],
+ [
+ 0.00501,
+ 0.01001,
+ 0.00875,
+ -0.01158,
+ -0.00198,
+ -0.00144,
+ 0.0103,
+ 0.01363,
+ 0.01605,
+ -0.0028,
+ 0.00531,
+ 0.01146,
+ ],
+ [
+ 0.01099,
+ -0.01592,
+ 0.00859,
+ 0.00665,
+ -0.01941,
+ 0.00396,
+ 0.01695,
+ 0.00294,
+ 0.02388,
+ 0.01773,
+ -0.00045,
+ 0.01766,
+ ],
+ [
+ 0.01823,
+ 0.02964,
+ 0.01799,
+ 0.00021,
+ 0.01049,
+ -0.00743,
+ 0.01367,
+ 0.01768,
+ 0.00543,
+ -8e-05,
+ 0.00359,
+ -0.01638,
+ ],
+ [
+ 0.08068,
+ 0.03887,
+ 0.04497,
+ 0.05833,
+ 0.00489,
+ 0.00448,
+ 0.07836,
+ 0.04018,
+ 0.05244,
+ 0.05091,
+ 0.00087,
+ 0.00483,
+ ],
+ [
+ 0.02272,
+ 0.00673,
+ -0.00472,
+ 0.01474,
+ 0.00055,
+ -0.01215,
+ 0.0145,
+ -0.00309,
+ -0.01572,
+ 0.01693,
+ -0.00153,
+ -0.01796,
+ ],
+ [
+ 0.01256,
+ -0.00838,
+ 0.00802,
+ 0.01691,
+ -0.00651,
+ 0.01021,
+ 0.0035,
+ -0.0073,
+ 0.00837,
+ 0.00209,
+ -0.0098,
+ 0.00688,
+ ],
+ [
+ 0.02052,
+ 0.02047,
+ 0.00986,
+ 0.03118,
+ 0.02071,
+ 0.00462,
+ 0.01421,
+ 0.02281,
+ 0.01241,
+ 0.02287,
+ 0.0174,
+ -0.00241,
+ ],
+ [
+ -0.03142,
+ -0.01604,
+ -0.01923,
+ -0.00598,
+ -0.00428,
+ -0.00952,
+ -0.03011,
+ -0.01572,
+ -0.01827,
+ 0.00036,
+ -0.00153,
+ -0.00455,
+ ],
+ [
+ 0.02732,
+ 0.00226,
+ -0.04569,
+ 0.00266,
+ -0.02183,
+ -0.06918,
+ 0.03078,
+ -0.00277,
+ -0.05017,
+ 0.01077,
+ -0.02176,
+ -0.0705,
+ ],
+ [
+ -0.04844,
+ -0.00806,
+ 0.01913,
+ -0.05912,
+ -0.02712,
+ -0.00422,
+ -0.0538,
+ -0.00785,
+ 0.01634,
+ -0.08046,
+ -0.04476,
+ -0.0268,
+ ],
+ [
+ 0.01157,
+ 0.03238,
+ 0.00919,
+ 0.03921,
+ 0.04747,
+ 0.02193,
+ 0.01827,
+ 0.02823,
+ 0.00236,
+ 0.04206,
+ 0.04659,
+ 0.0225,
+ ],
+ [
+ 0.01105,
+ 0.05195,
+ 0.0229,
+ 0.0075,
+ 0.05102,
+ 0.02368,
+ 0.00239,
+ 0.05831,
+ 0.02748,
+ -0.00439,
+ 0.0501,
+ 0.0187,
+ ],
+ [
+ -0.00013,
+ 0.02944,
+ 0.01243,
+ -0.01134,
+ 0.02042,
+ 0.00502,
+ -0.0073,
+ 0.01901,
+ 0.00097,
+ -0.02015,
+ 0.00747,
+ -0.01055,
+ ],
+ [
+ 0.07334,
+ 0.06559,
+ 0.01989,
+ 0.07722,
+ 0.05205,
+ -0.00085,
+ 0.05124,
+ 0.04417,
+ 0.00286,
+ 0.05576,
+ 0.03552,
+ -0.01297,
+ ],
+ [
+ -0.01979,
+ -0.00266,
+ 0.00574,
+ -0.0092,
+ -0.00405,
+ 0.0008,
+ -0.0101,
+ 0.00209,
+ 0.01531,
+ -0.01987,
+ -0.02022,
+ -0.01248,
+ ],
+ [
+ 0.01303,
+ -0.03786,
+ -0.04022,
+ 0.01764,
+ -0.02871,
+ -0.03055,
+ 0.03038,
+ -0.01864,
+ -0.02547,
+ 0.02418,
+ -0.0189,
+ -0.02093,
+ ],
+ [
+ -0.00841,
+ -0.01546,
+ -0.01729,
+ -0.01713,
+ -0.01457,
+ -0.014,
+ -0.0074,
+ -0.00707,
+ -0.00982,
+ -0.01884,
+ -0.00774,
+ -0.00687,
+ ],
+ [
+ -0.03872,
+ 0.00611,
+ -0.0055,
+ -0.03513,
+ 0.00906,
+ -0.00557,
+ -0.00826,
+ 0.01995,
+ -0.00042,
+ -0.00546,
+ 0.02799,
+ 0.00925,
+ ],
+ [
+ 0.00478,
+ 0.01471,
+ 0.02482,
+ 0.0174,
+ 0.02332,
+ 0.03193,
+ 0.01916,
+ 0.00215,
+ 0.00735,
+ 0.04961,
+ 0.02501,
+ 0.02839,
+ ],
+ [
+ -0.02573,
+ -0.03989,
+ -0.0354,
+ -0.00211,
+ -0.01302,
+ -0.00636,
+ -0.02954,
+ -0.02146,
+ -0.00939,
+ -0.0055,
+ -0.00176,
+ 0.00726,
+ ],
+ [
+ -0.02274,
+ -0.02412,
+ -0.01763,
+ -0.0127,
+ -0.00689,
+ 0.0032,
+ -0.01558,
+ -0.01589,
+ -0.0101,
+ -0.02456,
+ -0.01797,
+ -0.00956,
+ ],
+ [
+ -0.0348,
+ -0.03117,
+ 0.0085,
+ -0.01601,
+ -0.011,
+ 0.02859,
+ -0.05263,
+ -0.03369,
+ 0.00801,
+ -0.04339,
+ -0.02806,
+ 0.01325,
+ ],
+ [
+ 0.029,
+ 0.01699,
+ 0.02431,
+ 0.01885,
+ 0.00925,
+ 0.01475,
+ 0.02833,
+ 0.01984,
+ 0.02511,
+ 0.00911,
+ 0.00928,
+ 0.01799,
+ ],
+ [
+ 0.00819,
+ 0.01486,
+ -0.00675,
+ 0.02258,
+ 0.01832,
+ -0.00395,
+ 0.00229,
+ 0.0095,
+ -0.0159,
+ 0.0392,
+ 0.03763,
+ 0.01132,
+ ],
+ [
+ 0.0082,
+ -0.00344,
+ -0.01746,
+ 0.02388,
+ 0.01373,
+ 0.00057,
+ 0.00786,
+ -0.01569,
+ -0.03317,
+ 0.03313,
+ 0.01164,
+ -0.0047,
+ ],
+ [
+ 0.00843,
+ 0.02291,
+ -0.00014,
+ 0.02998,
+ 0.04197,
+ 0.0219,
+ 0.0115,
+ 0.02002,
+ -0.00143,
+ 0.03164,
+ 0.03604,
+ 0.01436,
+ ],
+ ],
+ "bias": [
+ 0.50218,
+ 0.41949,
+ 0.49937,
+ 0.43479,
+ 0.36377,
+ 0.4359,
+ 0.41488,
+ 0.38798,
+ 0.45143,
+ 0.51557,
+ 0.46185,
+ 0.50604,
+ ],
+ },
+ "sdxl": {
+ "layout": "bchw",
+ "down": 8,
+ "patch": 1,
+ "weight": [
+ [0.20886, 0.19514, 0.20743],
+ [-0.09015, 0.00718, 0.02259],
+ [0.05552, 0.07225, -0.02682],
+ [-0.15554, -0.13265, -0.10832],
+ ],
+ "bias": [0.58401, 0.49837, 0.43021],
+ },
+ "wan22_5b": {
+ "layout": "bcthw",
+ "down": 16,
+ "patch": 1,
+ "weight": [
+ [-0.01543, -0.03, -0.00492],
+ [-0.06577, -0.02208, -0.02397],
+ [0.01811, 0.03534, 0.00345],
+ [-0.00806, -0.06798, -0.00982],
+ [0.02384, 0.01947, 0.00698],
+ [-0.02251, 0.00029, 0.00169],
+ [-0.00057, 0.01233, 0.01518],
+ [-0.00922, -0.01959, 0.00152],
+ [-0.00727, -0.04298, 0.02546],
+ [-0.04777, -0.0512, -0.02753],
+ [0.02969, 0.01289, 0.03269],
+ [-0.05357, 0.04247, 0.01337],
+ [0.0526, 0.01102, 0.00899],
+ [-0.03103, -0.03994, -0.00165],
+ [0.00182, 0.01752, -0.02517],
+ [0.00747, 0.03391, 0.00435],
+ [0.02885, 0.01274, 0.00951],
+ [-0.00806, -0.00895, -0.00023],
+ [0.02568, -0.00904, -0.01708],
+ [0.03077, -0.00202, -0.01884],
+ [-0.01396, -0.01706, -0.01872],
+ [0.08712, 0.02055, 0.17224],
+ [0.00274, 0.00354, -0.0117],
+ [-0.00821, -0.02783, -0.01502],
+ [-0.02113, -0.04437, -0.03197],
+ [-0.03807, -0.01259, 0.00164],
+ [0.02152, 0.03811, -0.00354],
+ [-0.01861, -0.03098, -0.02218],
+ [0.0133, 0.01477, 0.00631],
+ [-0.00316, 0.02187, -0.01308],
+ [0.03242, 0.04196, 0.05273],
+ [0.00211, -0.0198, -0.01131],
+ [0.0415, 0.01756, 0.05332],
+ [0.00392, -0.02255, 0.02562],
+ [-0.03574, -0.00247, 0.01287],
+ [0.00176, 0.004, -0.01075],
+ [-0.04203, -0.00114, -0.01798],
+ [-0.00883, 0.0337, 0.04405],
+ [-0.00682, 0.01072, 0.02071],
+ [-0.0744, -0.0614, -0.00849],
+ [0.00083, -0.00155, 0.00689],
+ [0.02623, 0.04258, 0.10098],
+ [0.0116, 0.02441, 0.0275],
+ [0.0225, 0.03628, -0.02053],
+ [-0.0089, 0.01173, -0.00708],
+ [-0.01411, -0.01366, 0.00457],
+ [0.00799, -0.01602, -0.03706],
+ [-0.00296, 0.02719, -0.0187],
+ ],
+ "bias": [0.46235, 0.4487, 0.40525],
+ },
+ "zimage": {
+ "layout": "bchw",
+ "down": 8,
+ "patch": 1,
+ "weight": [
+ [-0.01135, 0.02438, 0.03877],
+ [0.01586, 0.02707, 0.04433],
+ [0.02319, -0.02222, -0.01576],
+ [-0.00346, 0.01279, 0.02957],
+ [0.0343, 0.02289, 0.01133],
+ [0.00213, 0.0241, 0.01192],
+ [0.01143, 0.03295, 0.03137],
+ [-0.02001, -0.0178, -0.02908],
+ [-0.0188, 0.00441, 0.04446],
+ [0.04364, 0.0347, -0.01386],
+ [-0.01676, 0.02136, 0.00716],
+ [0.05298, 0.0199, 0.02366],
+ [0.02398, 0.01905, 0.02032],
+ [-0.06277, -0.02421, -0.04964],
+ [-0.00225, -0.03826, -0.01859],
+ [-0.05272, -0.0364, -0.02536],
+ ],
+ "bias": [0.48269, 0.45827, 0.45745],
+ },
+}
diff --git a/studio/backend/core/inference/media_decode_phase.py b/studio/backend/core/inference/media_decode_phase.py
index 3fc13857429..b8ce152f87f 100644
--- a/studio/backend/core/inference/media_decode_phase.py
+++ b/studio/backend/core/inference/media_decode_phase.py
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-"""Detect when a diffusion pipeline leaves its denoise loop and enters the decoder."""
+"""Detect when a diffusion pipeline enters its denoise loop, and when it leaves it for the decoder."""
from __future__ import annotations
@@ -59,3 +59,40 @@ def decode_phase(
del owner.decode
except Exception: # noqa: BLE001 -- cleanup is best-effort
pass
+
+
+def denoise_phase(pipe: Any, on_denoise: Any):
+ """Call ``on_denoise`` once when the loop is entered: every diffusers pipeline opens
+ ``self.progress_bar`` right after the prompt encode and latent setup. A HOST position."""
+ original = getattr(pipe, "progress_bar", None)
+ if not callable(original):
+ yield
+ return
+ fired = {"done": False}
+ had_own = "progress_bar" in getattr(pipe, "__dict__", {})
+
+ def _progress_bar(*args: Any, **kwargs: Any) -> Any:
+ if not fired["done"]:
+ fired["done"] = True
+ try:
+ on_denoise()
+ except Exception: # noqa: BLE001 -- a phase label must never fail a render
+ pass
+ return original(*args, **kwargs)
+
+ try:
+ pipe.progress_bar = _progress_bar
+ except Exception: # noqa: BLE001 -- a pipe that refuses assignment keeps the step-callback fallback
+ yield
+ return
+ try:
+ yield
+ finally:
+ try:
+ if had_own:
+ pipe.progress_bar = original
+ else:
+ del pipe.progress_bar
+ except Exception: # noqa: BLE001 -- cleanup is best-effort
+ pass
diff --git a/studio/backend/core/inference/video.py b/studio/backend/core/inference/video.py
index 2ff5a9b3c60..d0f844c1f78 100644
--- a/studio/backend/core/inference/video.py
+++ b/studio/backend/core/inference/video.py
@@ -126,6 +126,7 @@ from .diffusion_memory import (
)
from .diffusion_torchao_patches import install_torchao_int_mm_patch
from .media_decode_phase import decode_phase as _decode_phase
+from .media_decode_phase import denoise_phase as _denoise_phase
from . import diffusion_render_thread as render_thread
from .diffusion_fp16_guard import fp16_promotes_to_fp32
from .diffusion_speed import (
@@ -7981,6 +7982,7 @@ class VideoBackend:
audio_flow_shift: Optional[float] = None,
video_id: Optional[str] = None,
expected_state: Optional[object] = None,
+ live_preview: Optional[bool] = None,
) -> dict[str, int]:
"""Validate cheaply, then run generate + gallery persist on a daemon thread.
@@ -8092,6 +8094,7 @@ class VideoBackend:
seed = seed,
_resolved_inputs = resolved_inputs,
cancel_event = cancel,
+ live_preview = live_preview,
),
daemon = True,
)
@@ -8361,6 +8364,8 @@ class VideoBackend:
audio_flow_shift: Optional[float] = None,
cancel_event: Optional[threading.Event] = None,
_resolved_inputs: Optional[_VideoResolvedInputs] = None,
+ # None = on unless UNSLOTH_DIFFUSION_PREVIEW=0.
+ live_preview: Optional[bool] = None,
) -> dict[str, Any]:
# begin_generate passes its already-registered event; a direct call makes its own.
cancel = cancel_event if cancel_event is not None else threading.Event()
@@ -8721,13 +8726,28 @@ class VideoBackend:
started = time.monotonic()
self._gen = {
"active": True,
- "phase": "denoise",
+ "phase": "encode",
"step": 0,
"total": steps,
"started": started,
"eta_seconds": None,
"error": None,
}
+ job_gen = self._gen
+
+ def _publish_preview(url: str, seq: int) -> None:
+ # A late frame must not land on a successor job's record.
+ if self._gen is job_gen:
+ job_gen.update(preview = url, preview_seq = seq)
+
+ from .diffusion_preview import LatentPreviewer, scheduler_step_preview
+
+ # Started just before the try below, whose finally finish()es it: its worker thread polls until then.
+ previewer = None
+
+ def _enter_denoise() -> None:
+ if self._gen.get("phase") == "encode":
+ self._gen.update(phase = "denoise")
ticker = _CompletedStepTicker(steps)
@@ -8735,6 +8755,8 @@ class VideoBackend:
"""Publish a step the GPU has actually finished. Monotonic, and silent once the
denoise is over so a late poll cannot walk the bar back under a later phase."""
done = max(0, min(int(done), steps))
+ if done > 0:
+ _enter_denoise()
if self._gen.get("phase") != "denoise":
return
if done <= int(self._gen.get("step") or 0):
@@ -8758,6 +8780,7 @@ class VideoBackend:
pipeline's is not, and Studio runs image and video renders side by side. A tick
skipped here costs that step its marker and nothing else: the step number travels
with the event, so the later ones do not shift, and the poller keeps reporting."""
+ _enter_denoise()
with _hold_off_cuda_graph_capture() as clear:
if not clear:
return
@@ -8802,7 +8825,7 @@ class VideoBackend:
def _pump() -> None:
"""One poll, inside the capture hold-off. Advances the step from the GPU, and
takes the denoise to complete only once the GPU has reached the marked end."""
- if self._gen.get("phase") != "denoise":
+ if self._gen.get("phase") not in ("encode", "denoise"):
return
if ticker.boundary_marked and ticker.boundary_reached():
_enter_decode_phase()
@@ -8820,6 +8843,10 @@ class VideoBackend:
p._interrupt = True
return callback_kwargs
_tick(step_index + 1)
+ if previewer is not None:
+ previewer.on_step(
+ callback_kwargs.get("latents"), getattr(p, "scheduler", None)
+ )
return callback_kwargs
def _on_scheduler_step_cancel(done: int) -> None:
@@ -8850,6 +8877,8 @@ class VideoBackend:
stack.enter_context(
_scheduler_step_progress(pipe, _on_scheduler_step_cancel, _tick)
)
+ stack.enter_context(scheduler_step_preview(pipe, previewer))
+ stack.enter_context(_denoise_phase(pipe, _enter_denoise))
# Family-agnostic: no video family has a callback between its denoise loop and its decode, so
# every one of them gets its decode phase from the decoder itself.
stack.enter_context(_decode_phase(pipe, _on_decode))
@@ -8902,6 +8931,15 @@ class VideoBackend:
if not _render_under_no_grad(state)
else torch.no_grad()
)
+ previewer = LatentPreviewer.create(
+ family = fam.name,
+ requested = live_preview,
+ height = height,
+ width = width,
+ device = state.device,
+ publish = _publish_preview,
+ total_steps = steps,
+ )
try:
with grad_ctx, protect_ctx, progress_ctx(), sigma_ctx:
output = render_thread.run("video", lambda: pipe(**kwargs))
@@ -8919,6 +8957,8 @@ class VideoBackend:
# A guarded compiled block that failed to build at its first forward now runs eager; the status
# must not keep reporting it compiled (a forced-compile quantised load runs ~30x slower eager),
# whether this render finished, was cancelled or failed.
+ if previewer is not None:
+ previewer.finish()
settle_compile_fallback(state, pipe, logger)
if static_skip:
logger.debug(
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 27f7ef2e3ab..3962790b37a 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -4496,6 +4496,11 @@ class DiffusionGenerateRequest(BaseModel):
"by this multiple and re-denoises at low strength. Requires init_image; "
"ignored for txt2img/inpaint/edit.",
)
+ live_preview: Optional[bool] = Field(
+ None,
+ description = "Stream a small live preview of the image while it denoises (generate-progress "
+ "'preview'). Null = the server default (on unless UNSLOTH_DIFFUSION_PREVIEW=0).",
+ )
allow_oversized: bool = Field(
False,
description = "Run even when the generate-time memory check estimates this size will not "
@@ -4771,8 +4776,13 @@ class DiffusionGenerateProgressResponse(BaseModel):
fraction: float = Field(0.0, description = "step / total_steps, clamped to [0,1]")
eta_seconds: Optional[float] = Field(None, description = "Estimated seconds remaining")
phase: Optional[str] = Field(
- None, description = "denoise | decode; null from engines that report no phase (sd.cpp)"
+ None,
+ description = "encode | denoise | decode; null from engines that report no phase (sd.cpp)",
+ )
+ preview: Optional[str] = Field(
+ None, description = "Live latent preview of the image being denoised, as a JPEG data URL"
)
+ preview_seq: int = Field(0, description = "Moves each time a new preview is published")
class DiffusionLoadProgressResponse(BaseModel):
@@ -5751,6 +5761,11 @@ class VideoGenerateRequest(BaseModel):
"where a downloaded model that is not the resident one is loaded first; omit to use "
"whatever is loaded. The Video page never sends it.",
)
+ live_preview: Optional[bool] = Field(
+ None,
+ description = "Stream a small live preview of the first frame while the clip denoises "
+ "(generate-progress 'preview'). Null = the server default (on unless UNSLOTH_DIFFUSION_PREVIEW=0).",
+ )
# Width/height/num_frames/fps default per loaded family, so they are optional here. These bounds
# stay a COARSE family-agnostic outer guard: the enforced rule is the LOADED family's own
# (resolution presets and the k * frame_step + frame_offset lattice), which the route checks with
@@ -6000,7 +6015,7 @@ class VideoGenerateProgressResponse(BaseModel):
active: bool = Field(False, description = "Whether a generation is running")
phase: Optional[str] = Field(
None,
- description = "Current phase: queued | denoise | export | completed | failed | null",
+ description = "Current phase: queued | encode | denoise | decode | export | completed | failed | null",
)
step: int = Field(0, description = "Denoising steps completed so far")
total: int = Field(0, description = "Total denoising steps for this run")
@@ -6008,6 +6023,11 @@ class VideoGenerateProgressResponse(BaseModel):
total_steps: int = Field(0, description = "Total denoising steps (alias of total)")
fraction: float = Field(0.0, description = "step / total, clamped to [0,1]")
eta_seconds: Optional[float] = Field(None, description = "Estimated seconds remaining")
+ preview: Optional[str] = Field(
+ None,
+ description = "Live latent preview of the first frame being denoised, as a JPEG data URL",
+ )
+ preview_seq: int = Field(0, description = "Moves each time a new preview is published")
video: Optional[GalleryVideo] = Field(
None, description = "Saved gallery record when phase is 'completed'"
)
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index ed0b72b6eb1..c9af3127731 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -45126,6 +45126,17 @@ async def load_diffusion_model_gated(
raise HTTPException(status_code = 409, detail = str(exc))
+def _live_preview_kwarg(generate: Any, requested: Optional[bool]) -> dict:
+ """``live_preview`` for an engine whose generate() takes it (sd.cpp's does not), else nothing."""
+ try:
+ import inspect
+ if "live_preview" in inspect.signature(generate).parameters:
+ return {"live_preview": requested}
+ except (TypeError, ValueError):
+ pass
+ return {}
+
+
# Count of finished generations still writing their PNG/gallery records; generate-progress reports active while above 0. Mutated only on the event loop, so no lock.
_diffusion_persist_active = 0
@@ -45257,6 +45268,7 @@ async def generate_diffusion_image(
if request.controlnet
else None
),
+ **_live_preview_kwarg(backend.generate, request.live_preview),
)
break
except ImageActivationShortfallError as exc:
diff --git a/studio/backend/routes/video.py b/studio/backend/routes/video.py
index 3f86c04ce54..50ba75dcbcb 100644
--- a/studio/backend/routes/video.py
+++ b/studio/backend/routes/video.py
@@ -669,6 +669,7 @@ async def generate_video(
reference_image_size = request.reference_image_size,
flow_shift = request.flow_shift,
audio_flow_shift = request.audio_flow_shift,
+ live_preview = request.live_preview,
)
# Authorize the exact resident token from generation_snapshot and pin it to the reservation,
# so a load committing in the gap cannot render another account's weights here; on a mismatch,
diff --git a/studio/backend/tests/test_diffusion_preview.py b/studio/backend/tests/test_diffusion_preview.py
new file mode 100644
index 00000000000..27afc82609b
--- /dev/null
+++ b/studio/backend/tests/test_diffusion_preview.py
@@ -0,0 +1,324 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Live latent previews: layout handling, the x0 estimate, the fitted maps, and (on CUDA) that a preview
+never synchronises the host, never touches the latent, and publishes a JPEG."""
+
+from __future__ import annotations
+
+import base64
+import io
+import threading
+import time
+
+import pytest
+
+torch = pytest.importorskip("torch")
+
+from core.inference import diffusion_preview as DP
+from core.inference.diffusion_preview_factors import FACTORS, FAMILY_FACTORS
+
+
+def _spec(
+ layout,
+ channels,
+ patch = 1,
+ down = 8,
+):
+ out = 3 * patch * patch
+ weight = tuple(tuple(0.01 * ((c + o) % 7) for o in range(out)) for c in range(channels))
+ return DP.LatentRGB(layout = layout, down = down, patch = patch, weight = weight, bias = (0.5,) * out)
+
+
+def test_kill_switch_and_request_toggle(monkeypatch):
+ monkeypatch.delenv(DP.PREVIEW_ENV, raising = False)
+ assert DP.preview_wanted(None) is True
+ assert DP.preview_wanted(False) is False
+ monkeypatch.setenv(DP.PREVIEW_ENV, "0")
+ assert DP.preview_wanted(True) is False
+
+
+def test_tokens_grid_is_the_first_image_or_frame():
+ spec = _spec("tokens", 64, patch = 2, down = 16)
+ lat = torch.arange(2 * 4 * 6 * 64, dtype = torch.float32).reshape(2, 24, 64)
+ g = DP.latent_grid(lat, spec, height = 64, width = 96)
+ assert tuple(g.shape) == (4, 6, 64)
+ assert torch.equal(g.reshape(24, 64), lat[0])
+ # Two whole frames of tokens (packed video): frame 0 leads.
+ video = torch.randn(1, 48, 64)
+ assert torch.equal(DP.latent_grid(video, spec, 64, 96).reshape(24, 64), video[0, :24])
+ # A sequence the render size does not tile is refused rather than shown scrambled.
+ assert DP.latent_grid(torch.randn(1, 25, 64), spec, 64, 96) is None
+ assert DP.latent_grid(torch.randn(1, 24, 63), spec, 64, 96) is None
+
+
+def test_unpacked_layouts_take_their_own_shape():
+ spec = _spec("bchw", 16)
+ lat = torch.randn(2, 16, 5, 7)
+ assert torch.equal(DP.latent_grid(lat, spec, 0, 0), lat[0].permute(1, 2, 0))
+ spec5 = _spec("bcthw", 48, down = 16)
+ vid = torch.randn(1, 48, 3, 5, 7)
+ assert torch.equal(DP.latent_grid(vid, spec5, 0, 0), vid[0, :, 0].permute(1, 2, 0))
+ assert DP.latent_grid(torch.randn(1, 16, 5, 7), spec5, 0, 0) is None
+
+
+def test_project_places_each_patch_pixel():
+ # One channel per output value, identity map: the pixel shuffle must land (dy, dx, rgb) where it belongs.
+ patch, out = 2, 12
+ weight = torch.eye(out)
+ grid = torch.arange(3 * 2 * out, dtype = torch.float32).reshape(3, 2, out)
+ rgb = DP.project(grid, weight, torch.zeros(out), patch)
+ assert tuple(rgb.shape) == (6, 4, 3)
+ for gy in range(3):
+ for gx in range(2):
+ cell = grid[gy, gx].reshape(patch, patch, 3)
+ assert torch.equal(rgb[gy * 2 : gy * 2 + 2, gx * 2 : gx * 2 + 2], cell)
+
+
+def test_x0_estimate_recovers_the_prediction_of_an_euler_step():
+ x0, noise = torch.rand(4, 4, 3), torch.randn(4, 4, 3)
+ s_prev, s_cur = 0.8, 0.6
+ prev = (1 - s_prev) * x0 + s_prev * noise
+ v = noise - x0 # flow matching velocity
+ cur = prev + (s_cur - s_prev) * v
+ assert torch.allclose(DP.x0_estimate(prev, cur, (s_prev, s_cur)), x0, atol = 1e-5)
+ # Same from device-style 0-dim tensors, and an affine map commutes with it (the weights sum to 1).
+ pair = (torch.tensor(s_prev), torch.tensor(s_cur))
+ assert torch.allclose(DP.x0_estimate(prev * 2 + 1, cur * 2 + 1, pair), x0 * 2 + 1, atol = 1e-5)
+ assert DP.x0_estimate(None, cur, (s_prev, s_cur)) is cur
+ assert DP.x0_estimate(prev, cur, None) is cur
+ assert DP.x0_estimate(prev, cur, (0.5, 0.5)) is cur
+
+
+def test_to_uint8_caps_the_long_side():
+ img = DP.to_uint8(torch.rand(300, 120, 3), max_side = 128)
+ assert img.dtype == torch.uint8 and img.shape[0] <= 128 and img.is_contiguous()
+
+
+def test_every_mapped_family_has_a_consistent_map():
+ assert FACTORS, "no fitted maps"
+ for family, key in FAMILY_FACTORS.items():
+ spec = DP.factors_for(family)
+ if key not in FACTORS:
+ assert spec is None
+ continue
+ assert spec.layout in ("tokens", "bchw", "bcthw")
+ outs = 3 * spec.patch * spec.patch
+ assert len(spec.bias) == outs
+ assert all(len(row) == outs for row in spec.weight)
+ assert DP.factors_for("no-such-family") is None
+
+
+def test_scheduler_step_preview_feeds_and_restores():
+ seen = []
+
+ class _Prev:
+ def on_step(
+ self,
+ latents,
+ scheduler = None,
+ final = False,
+ ):
+ seen.append(latents)
+
+ class _Sched:
+ def step(self, x):
+ return (x + 1,)
+
+ class _Pipe:
+ scheduler = _Sched()
+
+ pipe = _Pipe()
+ with DP.scheduler_step_preview(pipe, _Prev()):
+ assert pipe.scheduler.step(1) == (2,)
+ assert seen == [2]
+ assert "step" not in pipe.scheduler.__dict__
+ with DP.scheduler_step_preview(pipe, None):
+ assert "step" not in pipe.scheduler.__dict__
+
+
+def test_create_declines_without_a_map_or_off_cuda(monkeypatch):
+ monkeypatch.delenv(DP.PREVIEW_ENV, raising = False)
+ pub = lambda url, seq: None
+ assert (
+ DP.LatentPreviewer.create(
+ family = "no-such", requested = None, height = 64, width = 64, device = "cpu", publish = pub
+ )
+ is None
+ )
+ assert (
+ DP.LatentPreviewer.create(
+ family = "flux.1", requested = None, height = 64, width = 64, device = "cpu", publish = pub
+ )
+ is None
+ )
+ assert (
+ DP.LatentPreviewer.create(
+ family = "flux.1", requested = False, height = 64, width = 64, device = "cuda", publish = pub
+ )
+ is None
+ )
+
+
[email protected](not torch.cuda.is_available(), reason = "needs CUDA")
+def test_cuda_preview_never_syncs_never_writes_and_publishes(monkeypatch):
+ from PIL import Image
+
+ monkeypatch.delenv(DP.PREVIEW_ENV, raising = False)
+ got = []
+ done = threading.Event()
+
+ def publish(url, seq):
+ got.append((url, seq))
+ done.set()
+
+ prev = DP.LatentPreviewer.create(
+ family = "flux.1",
+ requested = None,
+ height = 512,
+ width = 768,
+ device = "cuda",
+ publish = publish,
+ min_interval_s = 0.0,
+ )
+ assert prev is not None
+ lat = torch.randn(1, (512 // 16) * (768 // 16), 64, device = "cuda", dtype = torch.bfloat16)
+ before = lat.clone()
+
+ class _Sched:
+ sigmas = torch.tensor([1.0, 0.75, 0.5, 0.25, 0.0], device = "cuda")
+ _step_index = 0
+
+ sched = _Sched()
+ torch.cuda.synchronize()
+ torch.cuda.set_sync_debug_mode("error")
+ try:
+ # Positive control: the guard does catch a host sync.
+ with pytest.raises(RuntimeError):
+ lat.float().sum().item()
+ for i in range(4):
+ sched._step_index = i + 1
+ prev.on_step(lat, sched)
+ lat = (
+ lat * 0.9
+ ) # the loop moves on; the preview must have read its own copy in stream order
+ finally:
+ torch.cuda.set_sync_debug_mode(0)
+ assert not prev.failed
+ # Step 1 has no previous latent to pair with, so the first snapshot waits for step 2 (no raw noise).
+ assert prev.emitted == 3
+ assert done.wait(10.0)
+ prev.finish()
+ url, _ = got[-1]
+ assert url.startswith("data:image/jpeg;base64,")
+ img = Image.open(io.BytesIO(base64.b64decode(url.split(",", 1)[1])))
+ assert img.size == (768 // 16 * 2, 512 // 16 * 2)
+ del before
+
+
[email protected](not torch.cuda.is_available(), reason = "needs CUDA")
[email protected]("side", [1024, 2048, 4096])
+def test_cuda_preview_slot_fits_the_picture_at_every_size(monkeypatch, side):
+ # At 2048 px a padded slot size once picked a coarser divisor than to_uint8, so every frame was dropped.
+ monkeypatch.delenv(DP.PREVIEW_ENV, raising = False)
+ got = []
+ done = threading.Event()
+
+ def publish(url, seq):
+ got.append(url)
+ done.set()
+
+ prev = DP.LatentPreviewer.create(
+ family = "flux.1",
+ requested = None,
+ height = side,
+ width = side,
+ device = "cuda",
+ publish = publish,
+ min_interval_s = 0.0,
+ )
+ assert prev is not None
+ lat = torch.randn(1, (side // 16) ** 2, 64, device = "cuda", dtype = torch.bfloat16)
+
+ class _Sched:
+ sigmas = torch.tensor([1.0, 0.5, 0.0], device = "cuda")
+ _step_index = 0
+
+ sched = _Sched()
+ for i in range(2):
+ sched._step_index = i + 1
+ prev.on_step(lat, sched)
+ assert prev.emitted == 1
+ assert done.wait(10.0)
+ prev.finish()
+ from PIL import Image
+
+ img = Image.open(io.BytesIO(base64.b64decode(got[-1].split(",", 1)[1])))
+ assert max(img.size) <= DP.MAX_SIDE and min(img.size) > 0
+
+
[email protected](not torch.cuda.is_available(), reason = "needs CUDA")
+def test_cuda_preview_leaves_the_latent_bit_identical(monkeypatch):
+ monkeypatch.delenv(DP.PREVIEW_ENV, raising = False)
+ prev = DP.LatentPreviewer.create(
+ family = "flux.1",
+ requested = None,
+ height = 256,
+ width = 256,
+ device = "cuda",
+ publish = lambda u, s: None,
+ min_interval_s = 0.0,
+ )
+ lat = torch.randn(1, 256, 64, device = "cuda", dtype = torch.bfloat16)
+ snap = lat.clone()
+ for _ in range(3):
+ prev.on_step(lat, None)
+ prev.finish()
+ torch.cuda.synchronize()
+ assert torch.equal(lat, snap)
+
+
[email protected](not torch.cuda.is_available(), reason = "needs CUDA")
+def test_snapshots_are_planned_by_step_and_publishing_keeps_only_the_newest(monkeypatch):
+ """With CUDA graphs the host enqueues every step long before the GPU runs them, so a host clock cannot
+ pace snapshots: they are spread by step, each in its own slot, and the worker publishes only the
+ newest one the GPU has finished."""
+ monkeypatch.delenv(DP.PREVIEW_ENV, raising = False)
+ got = []
+ prev = DP.LatentPreviewer.create(
+ family = "flux.1",
+ requested = None,
+ height = 256,
+ width = 256,
+ device = "cuda",
+ publish = lambda u, s: got.append(s),
+ total_steps = 8,
+ max_snapshots = 4,
+ min_interval_s = 3600.0,
+ )
+ assert prev.stride == 2
+ lat = torch.randn(1, 256, 64, device = "cuda")
+ # A long kernel queued ahead keeps every snapshot in flight, as a run-ahead host would.
+ torch.cuda._sleep(int(2e8))
+ for _ in range(8): # host far ahead of the GPU: all 8 steps enqueued at once
+ prev.on_step(lat, None)
+ assert prev.emitted == 4 # steps 1, 3, 5, 7: none dropped for want of a free slot
+ torch.cuda.synchronize()
+ prev.finish(timeout = 30.0)
+ # Rate limit of an hour: the first finished snapshot publishes, and finish() flushes the newest.
+ assert got and got[-1] == 4
+ assert len(got) <= 2
+
+
+def test_smoothing_removes_the_period_two_patch_grid():
+ # A flat picture with a 2x2 checker on top (the packed-patch artefact) comes back flat.
+ h = w = 16
+ yy, xx = torch.meshgrid(torch.arange(h), torch.arange(w), indexing = "ij")
+ checker = ((yy + xx) % 2).float() * 0.2 - 0.1
+ rgb = (0.5 + checker)[..., None].expand(h, w, 3).contiguous()
+ out = DP.smooth_patch_grid(rgb)
+ assert tuple(out.shape) == (h, w, 3)
+ assert float((out[1:-1, 1:-1] - 0.5).abs().max()) < 1e-6
+ # A smooth ramp passes through (interior; edges are replicated).
+ ramp = torch.linspace(0, 1, w).expand(h, w)[..., None].expand(h, w, 3).contiguous()
+ assert torch.allclose(DP.smooth_patch_grid(ramp)[2:-2, 2:-2], ramp[2:-2, 2:-2], atol = 1e-6)
diff --git a/studio/backend/tests/test_image_decode_phase.py b/studio/backend/tests/test_image_decode_phase.py
index 99400c42120..96c6cb3a245 100644
--- a/studio/backend/tests/test_image_decode_phase.py
+++ b/studio/backend/tests/test_image_decode_phase.py
@@ -59,8 +59,9 @@ def test_a_pipe_with_no_decoder_is_a_no_op():
def test_generate_progress_reports_the_phase():
from core.inference.diffusion import _GenState
+ # Published before the pre-denoise setup, so it starts in "encode", not "denoise".
gen = _GenState(total_steps = 40)
- assert gen.phase == "denoise"
+ assert gen.phase == "encode"
class _Backend:
_gen = gen
@@ -68,7 +69,7 @@ def test_generate_progress_reports_the_phase():
from core.inference.diffusion import DiffusionBackend
progress = DiffusionBackend.generate_progress(_Backend())
- assert progress["phase"] == "denoise"
+ assert progress["phase"] == "encode"
gen.step, gen.phase = 40, "decode"
progress = DiffusionBackend.generate_progress(_Backend())
@@ -81,3 +82,40 @@ def test_generate_progress_reports_the_phase():
_Backend._gen = None
assert DiffusionBackend.generate_progress(_Backend())["phase"] == "denoise"
+
+
+def test_denoise_phase_fires_when_the_loop_opens_its_progress_bar_and_is_removed():
+ from core.inference.media_decode_phase import denoise_phase
+
+ class _Bar:
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *a):
+ return False
+
+ class _LoopPipe:
+ def progress_bar(self, total = None):
+ return _Bar()
+
+ pipe, seen = _LoopPipe(), []
+ with denoise_phase(pipe, lambda: seen.append("denoise")):
+ with pipe.progress_bar(total = 4):
+ pass
+ with pipe.progress_bar(total = 4):
+ pass
+ assert seen == ["denoise"]
+ assert "progress_bar" not in pipe.__dict__
+
+
+def test_generate_progress_carries_the_live_preview_through_the_route_model():
+ from core.inference.diffusion import DiffusionBackend, _GenState
+ from models.inference import DiffusionGenerateProgressResponse
+
+ class _Backend:
+ _gen = _GenState(total_steps = 8, step = 2, phase = "encode")
+
+ _Backend._gen.preview, _Backend._gen.preview_seq = "data:image/jpeg;base64,AA==", 3
+ resp = DiffusionGenerateProgressResponse(**DiffusionBackend.generate_progress(_Backend()))
+ assert resp.phase == "encode"
+ assert resp.preview == "data:image/jpeg;base64,AA==" and resp.preview_seq == 3
diff --git a/studio/backend/tests/test_video_backend.py b/studio/backend/tests/test_video_backend.py
index b34d29722c1..7cafb332bb0 100644
--- a/studio/backend/tests/test_video_backend.py
+++ b/studio/backend/tests/test_video_backend.py
@@ -10685,6 +10685,29 @@ def test_cancellation_is_still_checked_before_the_step_runs(fake_runtime, monkey
assert len(events) == 1
+def test_phase_reads_encode_until_the_denoise_loop_starts(fake_runtime, monkeypatch):
+ # The prompt encode runs inside pipe() before the first step; the bar said "denoise" through it.
+ _patch_events(monkeypatch)
+ backend = VideoBackend()
+ backend.load_pipeline(
+ "hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v", model_kind = "pipeline"
+ )
+ pipe = _FakeHV15Pipeline.instance
+ phases: list = []
+ pipe.scheduler.on_step = lambda n: phases.append(backend._gen.get("phase"))
+ original_call = type(pipe).__call__
+
+ def _call(self, *args, **kwargs):
+ phases.append(("at_call", backend._gen.get("phase")))
+ return original_call(self, *args, **kwargs)
+
+ monkeypatch.setattr(type(pipe), "__call__", _call)
+ backend.generate(prompt = "a fox", steps = 3, num_frames = 9, fps = 24)
+ assert phases[0] == ("at_call", "encode")
+ # From the first step on, the host is in the loop: denoise (steps 2 and 3 are seen after step 1's tick).
+ assert phases[2:] == ["denoise", "denoise"]
+
+
def test_hv15_bar_never_outruns_the_gpu_and_holds_the_phase(fake_runtime, monkeypatch):
# End to end on the scheduler-wrap path (HunyuanVideo-1.5 exposes no step callback, like H3's
# modular workflow). The host enqueues every step and enters the decoder while the GPU has
@@ -12799,3 +12822,39 @@ def test_resident_wan_load_decodes_untiled_when_it_fits(
assert status["loaded"] is True
assert calls == (["wan2.2-ti2v-5b"] if installed else [])
assert ("vae_untiled_when_fits" in status["speed_optims"]) is installed
+
+
+def test_previewer_is_finished_when_the_render_fails_before_its_loop(fake_runtime, monkeypatch):
+ # The previewer starts a polling worker thread; a raise between its creation and the guarded
+ # render (here protect_generation) used to leave that thread polling for the life of the process.
+ import core.inference.diffusion_nvfp4_protect as protect_mod
+ import core.inference.diffusion_preview as preview_mod
+
+ _patch_events(monkeypatch)
+ started: list = []
+
+ class _Previewer:
+ finished = False
+
+ def on_step(self, *args, **kwargs):
+ pass
+
+ def finish(self):
+ self.finished = True
+
+ def _create(**kwargs):
+ started.append(_Previewer())
+ return started[-1]
+
+ def _refuse(*args, **kwargs):
+ raise RuntimeError("protect refused")
+
+ monkeypatch.setattr(preview_mod.LatentPreviewer, "create", staticmethod(_create))
+ monkeypatch.setattr(protect_mod, "protect_generation", _refuse)
+ backend = VideoBackend()
+ backend.load_pipeline(
+ "hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v", model_kind = "pipeline"
+ )
+ with pytest.raises(RuntimeError, match = "protect refused"):
+ backend.generate(prompt = "a fox", steps = 3, num_frames = 9, fps = 24)
+ assert all(p.finished for p in started)
diff --git a/studio/frontend/src/features/images/api.ts b/studio/frontend/src/features/images/api.ts
index cd98f9b499c..d27dd16818f 100644
--- a/studio/frontend/src/features/images/api.ts
+++ b/studio/frontend/src/features/images/api.ts
@@ -98,8 +98,11 @@ export interface DiffusionGenerateProgress {
total_steps: number;
fraction: number;
eta_seconds: number | null;
- // Absent (sd.cpp engine) means "denoise".
- phase?: "denoise" | "decode" | null;
+ // Absent (sd.cpp engine) means "denoise". "encode" runs before the denoise loop starts.
+ phase?: "encode" | "denoise" | "decode" | null;
+ // Live latent preview of the image being denoised (small JPEG data URL), and a counter that moves with each one.
+ preview?: string | null;
+ preview_seq?: number;
}
export interface DiffusionLoadProgress {
@@ -161,6 +164,8 @@ export interface DiffusionLoadRequest {
export interface DiffusionGenerateRequest {
prompt: string;
+ // Stream a live preview on generate-progress; omitted = the server default (on).
+ live_preview?: boolean;
negative_prompt?: string;
width?: number;
height?: number;
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsx
index 8d3ecf7fbfd..307c9393cc6 100644
--- a/studio/frontend/src/features/images/images-page.tsx
+++ b/studio/frontend/src/features/images/images-page.tsx
@@ -150,6 +150,7 @@ import {
} from "@/features/generation-presets";
import { getHfToken, hfApiToken } from "@/features/hub/stores/hf-token-store";
import { formatBytes, formatEta } from "@/features/hub/lib/format";
+import { generatePhaseLabel, sameGenerateProgress } from "@/lib/media-generate-phase";
import { ChevronDown } from "lucide-react";
import { NegativePromptField } from "@/components/negative-prompt-field";
import { cn } from "@/lib/utils";
@@ -572,12 +573,7 @@ function formatTimestamp(epochSeconds: number): string {
}
function genStepLabel(p: DiffusionGenerateProgress): string {
- // Text encoding happens before the first scheduler tick, so step 0 means "working, not denoising yet".
- if (p.step === 0) return "Preparing (text encoding + warmup)…";
- if (p.phase === "decode") return "Decoding…";
- const base = `Step ${p.step}/${p.total_steps}`;
- const eta = p.eta_seconds != null ? formatEta(p.eta_seconds) : "";
- return eta ? `${base} · ~${eta}` : base;
+ return generatePhaseLabel({ ...p, total: p.total_steps }, { formatEta });
}
// Settling a generation whose POST response was lost: the backend keeps denoising, so poll until it goes idle.
@@ -1507,6 +1503,9 @@ export function ImagesPage({
const [allowOversized, setAllowOversized] = usePersistedToggle(
"unsloth_images_allow_oversized",
);
+ // Live latent preview while denoising, on by default: only the opt-out is stored.
+ const [livePreviewOff, setLivePreviewOff] = usePersistedToggle("unsloth_images_live_preview_off");
+ const livePreview = !livePreviewOff;
const oversizedOnce = useRef(false);
// Queued: "Generate anyway" is clickable before the refused run releases busy.
const [oversizedRetryQueued, setOversizedRetryQueued] = useState(false);
@@ -1889,6 +1888,9 @@ export function ImagesPage({
);
const selectedSrc = selected ? srcById[selected.id] : undefined;
const selectedThumb = selected ? thumbById[selected.id] : undefined;
+ // The in-flight run's live preview, when the backend streams one and the toggle is on.
+ const livePreviewSrc =
+ busy === "generating" && livePreview ? (genStep?.preview ?? undefined) : undefined;
const [viewerId, setViewerId] = useState<string | null>(null);
const viewerImage = viewerId ? (images.find((image) => image.id === viewerId) ?? null) : null;
const viewerSrc = viewerImage ? srcById[viewerImage.id] : undefined;
@@ -2666,7 +2668,7 @@ export function ImagesPage({
return;
}
setGenStep((prev) => {
- if (prev && prev.step === p.step && prev.eta_seconds === p.eta_seconds && prev.phase === p.phase) return prev;
+ if (prev && sameGenerateProgress(prev, p)) return prev;
return p;
});
} catch {
@@ -4247,7 +4249,7 @@ export function ImagesPage({
// Skip the state update (and re-render) when nothing the bar shows moved.
setGenStep((prev) => {
if (!p.active) return null;
- if (prev && prev.step === p.step && prev.eta_seconds === p.eta_seconds && prev.phase === p.phase) return prev;
+ if (prev && sameGenerateProgress(prev, p)) return prev;
return p;
});
} catch {
@@ -4306,6 +4308,7 @@ export function ImagesPage({
strength: condStrength,
upscale: condUpscale,
allow_oversized: allowOversizedSent ? true : undefined,
+ live_preview: livePreview,
...condFields,
// Drop empty and zero-weight rows and trim hand-typed repo ids, so the recipe records only
// adapters that applied. Gated on loraCapable, since a restore can leave adapters in state.
@@ -4392,7 +4395,7 @@ export function ImagesPage({
setGenStep(null);
setStopping(false);
}
- }, [allowOversized, prompt, negativePrompt, width, height, steps, guidance, seed, batchSize, count, workflow, initImage, maskImage, strength, extendPct, extendSides, upscaleFactor, upscaleStrength, referenceImages, loras, loraCapable, controlnetCapable, controlnetId, controlImage, controlType, controlStrength, ensureSrc, loadGallery, refreshStatus, unifiedEdit, localizedMode, localizedLayer, maxExtras, referenceResolution, conditioning, editSize, editSizing, sizeLimits]);
+ }, [allowOversized, livePreview, prompt, negativePrompt, width, height, steps, guidance, seed, batchSize, count, workflow, initImage, maskImage, strength, extendPct, extendSides, upscaleFactor, upscaleStrength, referenceImages, loras, loraCapable, controlnetCapable, controlnetId, controlImage, controlType, controlStrength, ensureSrc, loadGallery, refreshStatus, unifiedEdit, localizedMode, localizedLayer, maxExtras, referenceResolution, conditioning, editSize, editSizing, sizeLimits]);
// Stop the in-flight generation. Latch FIRST, so a multi-run request stops even if the POST
// races the run that is already finishing.
@@ -4702,6 +4705,17 @@ export function ImagesPage({
aria-label={ALLOW_OVERSIZED_LABEL}
/>
</div>
+ <div className="flex items-center justify-between">
+ <span className="flex items-center gap-1 text-xs font-medium text-muted-foreground">
+ Live preview
+ <InfoHint>Show a rough preview of the image while it denoises. Costs no measurable speed and never changes the final image.</InfoHint>
+ </span>
+ <Switch
+ checked={livePreview}
+ onCheckedChange={(on) => setLivePreviewOff(!on)}
+ aria-label="Live preview"
+ />
+ </div>
<LoadedBuildSummary status={status} />
</>
);
@@ -5569,7 +5583,17 @@ export function ImagesPage({
</MediaViewer>
)}
<div className="hover-scrollbar relative flex flex-1 items-center justify-center overflow-auto p-6 px-10 @[50rem]:pt-[calc(60px*var(--ui-space-scale,1))]">
- {selected && selectedSrc ? (
+ {livePreviewSrc ? (
+ // Live latent preview: a small projection of the image being denoised, scaled up to the
+ // requested size (the aspect comes from the preview itself). The finished image replaces it.
+ <img
+ src={livePreviewSrc}
+ alt="Live preview of the image being generated"
+ data-testid="images-live-preview"
+ style={{ maxWidth: width, maxHeight: height }}
+ className="size-full object-contain shadow-sm"
+ />
+ ) : selected && selectedSrc ? (
<>
<img
src={selectedSrc}
@@ -5703,7 +5727,7 @@ export function ImagesPage({
<div
className={cn(
"pointer-events-none absolute flex justify-center px-4",
- selectedSrc ? "inset-x-0 bottom-4" : "inset-0 items-center",
+ selectedSrc || livePreviewSrc ? "inset-x-0 bottom-4" : "inset-0 items-center",
)}
>
<div className="w-72 max-w-full rounded-xl bg-background/85 p-3 shadow-lg ring-1 ring-border backdrop-blur">
@@ -5739,8 +5763,12 @@ export function ImagesPage({
{/* In-progress generation: a placeholder tile at the front so past images stay browsable while
the new one renders. */}
{busy === "generating" && (
- <div className="flex size-16 shrink-0 animate-pulse items-center justify-center rounded-lg bg-muted/50 ring-2 ring-primary/30">
- <Spinner className="size-5 text-muted-foreground" />
+ <div className="flex size-16 shrink-0 animate-pulse items-center justify-center overflow-hidden rounded-lg bg-muted/50 ring-2 ring-primary/30">
+ {livePreviewSrc ? (
+ <img src={livePreviewSrc} alt="" className="size-full object-cover" />
+ ) : (
+ <Spinner className="size-5 text-muted-foreground" />
+ )}
</div>
)}
{/* The tile is a wrapper, not a button: the actions menu must be the select button's SIBLING,
diff --git a/studio/frontend/src/features/video/api.ts b/studio/frontend/src/features/video/api.ts
index e56338b3cd6..35623c11491 100644
--- a/studio/frontend/src/features/video/api.ts
+++ b/studio/frontend/src/features/video/api.ts
@@ -104,12 +104,16 @@ export interface VideoStatus {
export interface VideoGenerateProgress {
active: boolean;
- // "queued" | "denoise" | "decode" | "export" | "completed" | "failed" | null; the terminal
- // phases carry the background job's outcome.
+ // "queued" | "encode" | "denoise" | "decode" | "export" | "completed" | "failed" | null; the
+ // terminal phases carry the background job's outcome.
phase?: string | null;
step: number;
total: number;
eta_seconds?: number | null;
+ // Live latent preview of the first frame being denoised (small JPEG data URL), and a counter
+ // that moves with each one.
+ preview?: string | null;
+ preview_seq?: number;
// Saved gallery record when phase is "completed".
video?: GalleryVideo | null;
// Client-safe failure detail when phase is "failed".
@@ -180,6 +184,8 @@ export interface VideoReferenceVideo {
export interface VideoGenerateRequest {
prompt: string;
+ // Stream a live preview on generate-progress; omitted = the server default (on).
+ live_preview?: boolean;
negative_prompt?: string;
// Width/height/num_frames/fps default per loaded family, so they are optional. When sent they
// must match that family's rules -- a resolution preset, and num_frames on the
diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsx
index 735ce95c147..1d1a6ee7192 100644
--- a/studio/frontend/src/features/video/video-page.tsx
+++ b/studio/frontend/src/features/video/video-page.tsx
@@ -104,6 +104,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { InfoHint } from "@/components/ui/info-hint";
+import { Switch } from "@/components/ui/switch";
import { useSidebar } from "@/components/ui/sidebar";
import { NegativePromptField } from "@/components/negative-prompt-field";
import { usePersistedChoice } from "@/hooks/use-persisted-choice";
@@ -147,6 +148,7 @@ import {
} from "@/features/generation-presets";
import { getHfToken, hfApiToken } from "@/features/hub/stores/hf-token-store";
import { formatBytes, formatEta } from "@/features/hub/lib/format";
+import { generatePhaseLabel, sameGenerateProgress } from "@/lib/media-generate-phase";
import { useNavigate, useSearch } from "@tanstack/react-router";
import { useStagedDownload } from "@/features/hub/download-manager";
import { isTauri } from "@/lib/api-base";
@@ -384,15 +386,8 @@ function clipMeta(video: GalleryVideo): string {
return `${secs} · ${video.width}×${video.height}`;
}
-function genStepLabel(p: VideoGenerateProgress): string {
- if (p.phase === "decode") return "Decoding video and audio…";
- if (p.phase === "export") return "Encoding video…";
- // Text encoding and the first-step warmup run before the first scheduler tick, so step 0 means
- // "working, not denoising yet" - up to a minute at 720p.
- if (p.step === 0) return "Preparing (text encoding + warmup)…";
- const base = p.total > 0 ? `Denoising step ${p.step}/${p.total}` : "Denoising…";
- const eta = p.eta_seconds != null ? formatEta(p.eta_seconds) : "";
- return eta ? `${base} · ~${eta}` : base;
+function genStepLabel(p: VideoGenerateProgress, hasAudio: boolean): string {
+ return generatePhaseLabel(p, { hasAudio, formatEta });
}
// The chat tab's model-load toast styling, reused verbatim so the video load toast is identical.
@@ -1034,6 +1029,9 @@ function VideoGenerator({
const [advancedOpen, setAdvancedOpen] = usePersistedToggle(
"unsloth_video_advanced_open",
);
+ // Live latent preview while denoising, on by default: only the opt-out is stored.
+ const [livePreviewOff, setLivePreviewOff] = usePersistedToggle("unsloth_video_live_preview_off");
+ const livePreview = !livePreviewOff;
// Advanced (load-time) options; "auto"/"off" map to the backend defaults. "Reapply" reloads with new values.
const [memoryMode, setMemoryMode] = useState<"auto" | "fast" | "balanced" | "low_vram">("auto");
// "auto", or the physical index to pin this load to; offered only on a multi-card CUDA/ROCm
@@ -1210,6 +1208,9 @@ function VideoGenerator({
[videos, selectedId],
);
const selectedSrc = selected ? srcById[selected.id] : undefined;
+ // The in-flight clip's live first-frame preview, when the backend streams one and the toggle is on.
+ const livePreviewSrc =
+ busy === "generating" && livePreview ? (genStep?.preview ?? undefined) : undefined;
const [viewer, setViewer] = useState<{ id: string; from: Playback } | null>(null);
const viewerVideoRef = useRef<HTMLVideoElement | null>(null);
const viewerPositioned = useRef(false);
@@ -1261,6 +1262,10 @@ function VideoGenerator({
}
return FALLBACK_RESOLUTION_PRESETS;
}, [status?.defaults?.resolution_presets]);
+ const livePreviewPreset = resolutionPresets[resolutionIdx] ?? resolutionPresets[0];
+ const livePreviewBox = livePreviewPreset
+ ? { maxWidth: livePreviewPreset[0], maxHeight: livePreviewPreset[1] }
+ : undefined;
const frameStep = status?.defaults?.frame_step ?? FALLBACK_FRAME_STEP;
const frameOffset = status?.defaults?.frame_offset ?? FALLBACK_FRAME_OFFSET;
@@ -2470,13 +2475,7 @@ function VideoGenerator({
}
setGenStep((prev) => {
if (!p.active) return null;
- if (
- prev &&
- prev.step === p.step &&
- prev.phase === p.phase &&
- prev.eta_seconds === p.eta_seconds
- )
- return prev;
+ if (prev && sameGenerateProgress(prev, p)) return prev;
return p;
});
} catch {
@@ -3477,6 +3476,7 @@ function VideoGenerator({
canPickAudioFlowShift && audioFlowShift != null && audioFlowShift !== defaultAudioFlowShift
? audioFlowShift
: undefined,
+ live_preview: livePreview,
});
} catch (err) {
if (!isMounted.current) return;
@@ -3491,6 +3491,7 @@ function VideoGenerator({
}
startGenPoll();
}, [
+ livePreview,
prompt,
negativePrompt,
guidance,
@@ -3629,6 +3630,17 @@ function VideoGenerator({
["static", "Static skip"],
]}
/>
+ <div className="flex items-center justify-between">
+ <span className="flex items-center gap-1 text-xs font-medium text-muted-foreground">
+ Live preview
+ <InfoHint>Show a rough preview of the first frame while the clip denoises. Costs no measurable speed and never changes the final video.</InfoHint>
+ </span>
+ <Switch
+ checked={livePreview}
+ onCheckedChange={(on) => setLivePreviewOff(!on)}
+ aria-label="Live preview"
+ />
+ </div>
<LoadedBuildSummary status={status} />
</>
);
@@ -4439,7 +4451,17 @@ function VideoGenerator({
</MediaViewer>
)}
<div className="hover-scrollbar relative flex flex-1 items-center justify-center overflow-auto p-6">
- {selected && selectedSrc ? (
+ {livePreviewSrc ? (
+ // Live latent preview of the first frame, scaled up to the clip size (aspect from the
+ // preview itself). The finished clip replaces it.
+ <img
+ src={livePreviewSrc}
+ alt="Live preview of the first frame being generated"
+ data-testid="video-live-preview"
+ style={livePreviewBox}
+ className="size-full object-contain shadow-sm"
+ />
+ ) : selected && selectedSrc ? (
<>
{/* autoPlay + muted + playsInline so it plays inline without a gesture; controls let the user
scrub. onEnded replays up to 3 total plays, reset per selection. */}
@@ -4556,7 +4578,7 @@ function VideoGenerator({
<div
className={cn(
"pointer-events-none absolute flex justify-center px-4",
- selectedSrc ? "inset-x-0 bottom-4" : "inset-0 items-center",
+ selectedSrc || livePreviewSrc ? "inset-x-0 bottom-4" : "inset-0 items-center",
)}
>
<div className="w-72 max-w-full rounded-xl bg-background/85 p-3 shadow-lg ring-1 ring-border backdrop-blur">
@@ -4569,7 +4591,7 @@ function VideoGenerator({
? (genStep.step / genStep.total) * 100
: null
}
- progressLabel={genStep ? genStepLabel(genStep) : null}
+ progressLabel={genStep ? genStepLabel(genStep, Boolean(status?.has_audio)) : null}
/>
</div>
</div>
@@ -4590,8 +4612,12 @@ function VideoGenerator({
{/* In-progress generation: a placeholder tile at the front so past clips stay browsable while
the new one renders. */}
{busy === "generating" && (
- <div className="flex size-16 shrink-0 animate-pulse items-center justify-center rounded-[10px] bg-muted/50 ring-2 ring-primary/30">
- <Spinner className="size-5 text-muted-foreground" />
+ <div className="flex size-16 shrink-0 animate-pulse items-center justify-center overflow-hidden rounded-[10px] bg-muted/50 ring-2 ring-primary/30">
+ {livePreviewSrc ? (
+ <img src={livePreviewSrc} alt="" className="size-full object-cover" />
+ ) : (
+ <Spinner className="size-5 text-muted-foreground" />
+ )}
</div>
)}
{/* The card is a wrapper, not a button: the actions menu must be the select button's SIBLING,
diff --git a/studio/frontend/src/lib/media-generate-phase.ts b/studio/frontend/src/lib/media-generate-phase.ts
new file mode 100644
index 00000000000..abf691f76de
--- /dev/null
+++ b/studio/frontend/src/lib/media-generate-phase.ts
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+export interface MediaGeneratePhaseProgress {
+ // encode | denoise | decode | export (video); absent or null (sd.cpp) reads as denoise.
+ phase?: string | null;
+ step: number;
+ total: number;
+ eta_seconds?: number | null;
+}
+
+/** Spinner label shared by the Images and Video pages. */
+export function generatePhaseLabel(
+ p: MediaGeneratePhaseProgress,
+ opts: { hasAudio?: boolean; formatEta?: (seconds: number) => string } = {},
+): string {
+ if (p.phase === "encode") return "Encoding prompt…";
+ if (p.phase === "decode") return opts.hasAudio ? "Decoding video and audio…" : "Decoding…";
+ if (p.phase === "export") return "Encoding video…";
+ const base = "Denoising please wait…";
+ // Step 0 is the first step still running (compile warmup included), so show no 0/N.
+ if (p.step <= 0 || p.total <= 0) return base;
+ const fmt = opts.formatEta ?? ((seconds: number) => `${Math.max(0, Math.round(seconds))}s`);
+ const eta = p.eta_seconds != null ? fmt(p.eta_seconds) : "";
+ // " \u2022 " = ModelLoadDescription's line split: on one line the 18rem card truncated the ETA.
+ return `${base} \u2022 Step ${p.step}/${p.total}${eta ? ` · ~${eta}` : ""}`;
+}
+
+export function sameGenerateProgress(
+ a: { step: number; eta_seconds?: number | null; phase?: string | null; preview_seq?: number },
+ b: { step: number; eta_seconds?: number | null; phase?: string | null; preview_seq?: number },
+): boolean {
+ return (
+ a.step === b.step &&
+ a.eta_seconds === b.eta_seconds &&
+ a.phase === b.phase &&
+ (a.preview_seq ?? 0) === (b.preview_seq ?? 0)
+ );
+}
diff --git a/studio/frontend/tests/images-gallery-thumbnails.test.ts b/studio/frontend/tests/images-gallery-thumbnails.test.ts
index 8964c9cba1e..d119945195d 100644
--- a/studio/frontend/tests/images-gallery-thumbnails.test.ts
+++ b/studio/frontend/tests/images-gallery-thumbnails.test.ts
@@ -50,7 +50,9 @@ test("the canvas, viewer and downloads read only the original", () => {
const preview = between(page, "// The preview is what the user looks at", "// Drop an image from the strip.");
assert.ok(preview.includes("await ensureSrc(selected);"));
- const canvas = between(page, "{selected && selectedSrc ? (", ") : selected ? (");
+ // The live denoise preview branch comes first while a run is in flight, so the canvas proper is the
+ // `selected && selectedSrc` branch that follows it.
+ const canvas = between(page, ") : selected && selectedSrc ? (", ") : selected ? (");
assert.ok(canvas.includes("src={selectedSrc}"));
for (const format of ["png", "jpeg", "webp"]) {
assert.ok(canvas.includes(`downloadImage(selectedSrc, selected, "${format}")`));
@@ -71,3 +73,16 @@ test("the thumbnail placeholder offers no action that needs the original", () =>
assert.ok(!placeholder.includes(action), action);
}
});
+
+test("the live denoise preview shows only the in-flight preview and offers no action on it", () => {
+ assert.ok(
+ page.includes(
+ 'busy === "generating" && livePreview ? (genStep?.preview ?? undefined) : undefined;',
+ ),
+ );
+ const live = between(page, "{livePreviewSrc ? (", ") : selected && selectedSrc ? (");
+ assert.ok(live.includes("src={livePreviewSrc}"));
+ for (const forbidden of ["selectedSrc", "thumbById", "selectedThumb", "downloadImage", "openViewer", "GalleryItemMenu"]) {
+ assert.ok(!live.includes(forbidden), forbidden);
+ }
+});
diff --git a/studio/frontend/tests/media-generate-phase.test.ts b/studio/frontend/tests/media-generate-phase.test.ts
new file mode 100644
index 00000000000..7606ca3f6c9
--- /dev/null
+++ b/studio/frontend/tests/media-generate-phase.test.ts
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { registerBundlerResolver } from "./helpers/kit.ts";
+
+registerBundlerResolver();
+
+const { generatePhaseLabel, sameGenerateProgress } = await import(
+ "../src/lib/media-generate-phase.ts"
+);
+
+test("each phase gets its own label next to the spinner", () => {
+ assert.equal(generatePhaseLabel({ phase: "encode", step: 0, total: 8 }), "Encoding prompt…");
+ assert.equal(generatePhaseLabel({ phase: "denoise", step: 0, total: 8 }), "Denoising please wait…");
+ assert.equal(
+ generatePhaseLabel({ phase: "denoise", step: 3, total: 8 }),
+ "Denoising please wait… \u2022 Step 3/8",
+ );
+ assert.equal(generatePhaseLabel({ phase: "decode", step: 8, total: 8 }), "Decoding…");
+ assert.equal(
+ generatePhaseLabel({ phase: "decode", step: 8, total: 8 }, { hasAudio: true }),
+ "Decoding video and audio…",
+ );
+ assert.equal(generatePhaseLabel({ phase: "export", step: 8, total: 8 }), "Encoding video…");
+});
+
+test("a missing phase (sd.cpp) reads as denoising, with the ETA when known", () => {
+ const label = generatePhaseLabel({ phase: null, step: 2, total: 4, eta_seconds: 5 });
+ assert.match(label, /^Denoising please wait… \u2022 Step 2\/4 · ~/);
+});
+
+test("a new preview re-renders even when nothing else moved", () => {
+ const a = { step: 2, eta_seconds: 1, phase: "denoise", preview_seq: 1 };
+ assert.equal(sameGenerateProgress(a, { ...a }), true);
+ assert.equal(sameGenerateProgress(a, { ...a, preview_seq: 2 }), false);
+ assert.equal(sameGenerateProgress({ step: 1, phase: "encode" }, { step: 1, phase: "denoise" }), false);
+});