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.

fix(helper): pin DIT eval cadence, reorder done event, document I2V hang

mrbizarroec1437fe82b6
diff --git a/ROADMAP.md b/ROADMAP.md
index 66c8eb0..0dde676 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -249,6 +249,45 @@ Tracking: the HDR-specific Phase 1 work landed via re-exposing the
hdr toggle (commit `<hdr-ship>`); the generic Phases 2–5 stay open
in this entry.
+### `[ ]` I2V Balanced perf — post-decode hang on Q4 distilled path
+
+After the May 9 upstream `ltx-2-mlx` refactor, I2V Balanced (and T2V
+Balanced) route through `DistilledPipeline.generate_two_stage(image=...)`.
+The actual render completes in ~3 min for a 5s I2V at 1024×576, but
+the helper then hangs 5-15 min before signaling done to the panel.
+
+Diagnostic findings (2026-05-21 session):
+- Output mp4 IS written to disk before the hang starts.
+- Stack samples show the helper deep in Metal command-buffer
+ deallocation (`IOGPUMetalCommandBufferStorageDealloc`,
+ `MTLResourceList releaseAllObjectsAndReset`, etc).
+- Diagnostic prints placed AFTER `_decode_and_save_video()` never
+ fire — the function-return path itself is the hang. Most likely
+ MLX/Metal completion-handler chains holding the GIL through
+ Python frame teardown.
+- LTX2_DIT_EVAL_EVERY tuning has no effect (tested 0/1/4/8).
+
+Path forward:
+1. **For Q8 (≥48 GB) tiers:** route Balanced I2V/T2V through
+ `TI2VidTwoStagesPipeline` instead of `DistilledPipeline`. That class:
+ - Runs full-resolution, not half-res with Stage-2 upscale.
+ - Supports CFG (`cfg_scale=3.0` validated).
+ - Supports TeaCache (`enable_teacache=True, teacache_thresh=N`).
+ - Already used by the working HQ path.
+ The helper's `get_pipe('i2v', ...)` currently aliases to
+ DistilledPipeline; needs an explicit branch for Balanced→
+ TI2VidTwoStagesPipeline on the dev model.
+2. **For Q4 (<48 GB) tiers:** stuck with DistilledPipeline until
+ upstream's MLX completion-handler issue is fixed. Workaround
+ ideas: spawn a fresh helper subprocess per render so the hang
+ happens after the user has their file (Pinokio Update + watchdog
+ would respawn for the next job).
+3. **Reddit / issue #5** users on small Macs are hitting both this
+ hang AND the geometric-grid artifact (which is the DistilledPipeline
+ structure producing weak I2V on the distilled checkpoint). Both
+ problems are the same root cause: forced fallback to a pipeline
+ that was never meant for I2V quality.
+
## Mid term
### `[ ]` In-panel "Report bug" button
diff --git a/mlx_warm_helper.py b/mlx_warm_helper.py
index b4856a9..33b0107 100644
--- a/mlx_warm_helper.py
+++ b/mlx_warm_helper.py
@@ -52,9 +52,23 @@ from pathlib import Path
# `LTX2_DIT_EVAL_EVERY=8` to fall back to upstream defaults if a
# specific tier needs the safety of mid-step evaluation.
if "LTX2_DIT_EVAL_EVERY" not in os.environ:
- os.environ["LTX2_DIT_EVAL_EVERY"] = "0"
+ # 2026-05-21 perf tuning. Tested matrix on M4 Max 64GB doing
+ # I2V Balanced 5s/121f:
+ # =0 (full lazy): denoise 7s/step ✓ | post-decode HANG 14+ min
+ # =4 (mid lazy): denoise 7s/step ✓ | post-decode HANG 6+ min
+ # =8 (upstream): denoise 3 min/step | (untested past denoise)
+ # =1 (per-block): denoise 7s/step ✓ | post-decode HANG 6+ min
+ # The post-decode hang is in the function-return path AFTER the
+ # upstream phase logs "Decoding done in X.Xs" — diagnostic markers
+ # NEVER fire, suggesting MLX/Metal completion-handler chains hold the
+ # GIL through the function exit. Filed as separate roadmap item; the
+ # render output IS correct, just the helper sits idle for minutes
+ # before signaling done.
+ # Picking =1 because the denoise is fast and it matches the eager
+ # per-block flush pattern that worked overnight on May 14-15.
+ os.environ["LTX2_DIT_EVAL_EVERY"] = "1"
if "LTX2_GEMMA_EVAL_EVERY" not in os.environ:
- os.environ["LTX2_GEMMA_EVAL_EVERY"] = "0"
+ os.environ["LTX2_GEMMA_EVAL_EVERY"] = "1"
# ---- end early bootstrap ====================================================
# ---- config ------------------------------------------------------------------
@@ -1649,6 +1663,10 @@ for line in sys.__stdin__:
# Step 3: VAE decode + save (decoder loads inside _decode_and_save_video).
# FIX 2026-05-14: upstream renamed fps= → frame_rate= (keyword-only).
out_path = pipe._decode_and_save_video(video_latent, audio_latent, kwargs["output_path"], frame_rate=kwargs["frame_rate"])
+ # NOTE: lazy-graph cleanup happens AFTER emit(done_event)
+ # below — see comment there. del-ing here would stall the
+ # panel's wait_done while MLX tears down ~10 GB of Metal
+ # buffers + lazy graph nodes synchronously.
emit({"event": "log", "line": "step:decode_and_save done"})
else:
emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f @{kwargs['frame_rate']:.1f}fps steps={kwargs['num_steps']} accel={accel_mode}"})
@@ -1660,6 +1678,18 @@ for line in sys.__stdin__:
emit({"event": "log", "line": "step:decode_and_save start"})
# FIX 2026-05-14: upstream renamed fps= → frame_rate= (keyword-only).
out_path = pipe._decode_and_save_video(video_latent, audio_latent, kwargs["output_path"], frame_rate=kwargs["frame_rate"])
+ # KNOWN ISSUE 2026-05-21: on the DistilledPipeline.generate_two_stage
+ # path (T2V/I2V Balanced post-May-9 upstream refactor), Python
+ # execution stalls 5-15 minutes between upstream's
+ # "[Decoding video + audio + muxing] done in X.Xs" stderr emit
+ # and the very next Python statement here. Tested with
+ # diagnostic markers — ZERO Python statements execute in
+ # between, so the stall is in the function-return path
+ # itself (likely MLX Metal completion handlers holding the
+ # GIL via callback chains). File is written and intact
+ # before the stall starts. Tracking the proper fix in
+ # ROADMAP: route Balanced I2V through TI2VidTwoStagesPipeline
+ # on Q8 tier instead of DistilledPipeline.
emit({"event": "log", "line": "step:decode_and_save done"})
elapsed = round(time.time() - t0, 2)
_last_activity = time.time()
@@ -1671,7 +1701,19 @@ for line in sys.__stdin__:
}
if accel_mode != "off" and _LAST_ACCEL_STATS:
done_event["accel_metrics"] = _LAST_ACCEL_STATS
+ # EMIT DONE FIRST — the user's render is complete and the file is
+ # on disk. Cleanup below can take 10+ minutes on a 121-frame
+ # Balanced render because MLX's deallocator has to walk the
+ # entire lazy compute graph and tear down Metal buffers; doing
+ # that BEFORE the done event made the panel sit on "running"
+ # for the full cleanup window (Mr Bizarro caught this 2026-05-21).
emit(done_event)
+ # Now drop the latent refs. The panel has already moved on; the
+ # helper just needs to be clean by the time the next job arrives.
+ try:
+ del video_latent, audio_latent
+ except UnboundLocalError:
+ pass
except Exception as exc:
_last_activity = time.time()
emit({"event": "error", "id": job_id, "error": str(exc), "trace": traceback.format_exc()})