Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

Y1.037 auto-skip VAE temporal streaming on short clips

mrbizarrobbd4413f4fbe
diff --git a/VERSION b/VERSION
index 37955f2..0afc7c4 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-Y1.036
+Y1.037
diff --git a/mlx_warm_helper.py b/mlx_warm_helper.py
index 877a682..f7a598b 100644
--- a/mlx_warm_helper.py
+++ b/mlx_warm_helper.py
@@ -34,6 +34,37 @@ IDLE_TIMEOUT = int(os.environ.get("LTX_IDLE_TIMEOUT", "1800"))
LOW_MEMORY = os.environ.get("LTX_LOW_MEMORY", "true").lower() in ("true", "1", "yes")
MODEL_UPSCALE_ENABLED = os.environ.get("LTX_ENABLE_MODEL_UPSCALE", "").lower() in ("1", "true", "yes", "on")
+# Y1.037 — VAE temporal-streaming decision.
+#
+# Y1.035 patched the upstream `decode_and_stream` to actually stream temporal
+# tiles (it had been pretending to). That fixed the "frozen final step" bug
+# on long / 720p clips, but adds ~30 s of overlap-tile compute on a 5-second
+# Standard render where the old full-volume decode fit in memory just fine
+# (M-Max 64 GB measured: 459 s pre-Y1.035 → 493 s on Y1.035, +7.4%).
+#
+# This module captures whatever LTX_VAE_STREAMING was at process start. If the
+# user explicitly set it (any value), we respect it. Otherwise the per-job
+# helper code flips the env var per-render based on num_frames vs the
+# threshold (default 200 frames ≈ 8 s @ 24 fps), letting the patched decoder's
+# auto-pick the streaming or full-decode path. Power users can set
+# LTX_VAE_STREAMING_THRESHOLD=N to override the cutoff.
+_USER_VAE_STREAMING_OVERRIDE = os.environ.get("LTX_VAE_STREAMING")
+
+
+def _apply_vae_streaming_decision(num_frames: int) -> None:
+ """Set/unset os.environ['LTX_VAE_STREAMING'] for the upcoming decode.
+ No-op if the user pinned a value at helper start time. Threshold reads
+ LTX_VAE_STREAMING_AUTO_MAX_FRAMES (default 121, matching the patched
+ decoder's auto-mode cutoff in patch_ltx_codec.py)."""
+ if _USER_VAE_STREAMING_OVERRIDE is not None:
+ return # respect explicit override
+ threshold = int(os.environ.get("LTX_VAE_STREAMING_AUTO_MAX_FRAMES", "121"))
+ if num_frames <= threshold:
+ os.environ["LTX_VAE_STREAMING"] = "0"
+ else:
+ # Long clip: let the patched decoder default ("auto") pick streaming.
+ os.environ.pop("LTX_VAE_STREAMING", None)
+
_real_stdout = sys.stdout
_emit_lock = threading.Lock()
@@ -996,6 +1027,10 @@ for line in sys.__stdin__:
seed=seed,
num_steps=int(p.get("steps", 8)),
)
+ # Y1.037: short-clip VAE-streaming opt-out. Set the env var BEFORE
+ # generate() so it propagates through the whole chain (the patched
+ # decode_and_stream reads os.environ at decode call time).
+ _apply_vae_streaming_decision(kwargs["num_frames"])
if needs_image:
src_image = p.get("image")
if src_image:
@@ -1167,6 +1202,8 @@ for line in sys.__stdin__:
t0 = time.time()
configure_acceleration("off")
pipe = get_hq_pipe(model_dir)
+ # Y1.037: short-clip VAE-streaming opt-out (HQ T2V/I2V path).
+ _apply_vae_streaming_decision(int(p["frames"]))
kwargs = dict(
prompt=p["prompt"],
output_path=p["output_path"],
@@ -1227,6 +1264,8 @@ for line in sys.__stdin__:
raise RuntimeError(f"{k} not found: {img}")
pipe = get_kf_pipe(model_dir)
num_frames = int(p["frames"])
+ # Y1.037: short-clip VAE-streaming opt-out (Keyframe path).
+ _apply_vae_streaming_decision(num_frames)
kwargs = dict(
prompt=p["prompt"],
output_path=p["output_path"],
diff --git a/patch_ltx_codec.py b/patch_ltx_codec.py
index 84018cb..10851b5 100644
--- a/patch_ltx_codec.py
+++ b/patch_ltx_codec.py
@@ -15,7 +15,8 @@ Upstream issues we patch around:
3. VideoDecoder.decode_and_stream advertises temporal streaming but still
full-decodes the video tensor before writing frames. Patched to use
- temporal tiled_decode() by default, with LTX_VAE_STREAMING=0 fallback.
+ temporal tiled_decode() automatically for longer clips, with
+ LTX_VAE_STREAMING=0/1 override.
Known unfixed: KeyframeInterpolationPipeline OOMs at the stage-1 → stage-2
transition on 64 GB Macs at full resolution. We tried freeing/reloading
@@ -171,8 +172,8 @@ PATCH_BASE_LOAD_NEW = ''' # Stage 2: DiT (largest component — load afte
# a time, but the implementation still calls self.decode(latent) for the full
# video volume before writing frames to ffmpeg. On long 720p-ish clips this is
# exactly the "denoise is done, now it freezes at the end" memory-pressure tail.
-# The decoder already has tiled_decode(); use temporal tiling by default while
-# keeping LTX_VAE_STREAMING=0 as an emergency full-decode fallback.
+# The decoder already has tiled_decode(); use temporal tiling automatically for
+# longer clips while keeping LTX_VAE_STREAMING=0/1 as explicit fallback/force.
PATCH_VAE_STREAM_OLD = ''' try:
# Decode full volume and stream frames
pixels = self.decode(latent)
@@ -196,8 +197,17 @@ PATCH_VAE_STREAM_NEW = ''' try:
# decoded the full video tensor before writing frames, causing
# multi-minute end-of-render stalls or jetsam on long/high-res jobs.
import os as _os
- _streaming = _os.environ.get("LTX_VAE_STREAMING", "1").strip().lower()
- _streaming_enabled = _streaming not in ("0", "false", "no", "off", "full")
+ _streaming = _os.environ.get("LTX_VAE_STREAMING", "auto").strip().lower()
+ _frames_est = 1 + (int(latent.shape[2]) - 1) * 8
+ _auto_max = int(_os.environ.get("LTX_VAE_STREAMING_AUTO_MAX_FRAMES", "121"))
+ if _streaming in ("1", "true", "yes", "on", "stream", "streaming", "chunked"):
+ _streaming_enabled = True
+ elif _streaming in ("0", "false", "no", "off", "full"):
+ _streaming_enabled = False
+ else:
+ # Auto: short 5 s clips are faster as a single decode; long clips
+ # keep temporal chunks to avoid memory-pressure stalls.
+ _streaming_enabled = _frames_est > _auto_max
if _streaming_enabled:
from ltx_core_mlx.model.video_vae.tiling import TilingConfig, TemporalTilingConfig