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.
Python ai-filmmakingai-videoai-video-generatorapple-siliconhailuoimage-to-videolip-synclocal-ailora-trainingltx-2ltx-2-5ltx-videomacosminimax-h3mlxmusic-generationoffline-aipinokiotext-to-videovideo-generation
Merge PR #10: distilled accel + Patch 7 watchdog + decoder-free (colinbdesign)
colinbdesigne58714db2afa
diff --git a/mlx_warm_helper.py b/mlx_warm_helper.pyindex c21e1bb..020f598 100644--- a/mlx_warm_helper.py+++ b/mlx_warm_helper.py@@ -1015,6 +1015,23 @@ def _free_pipe_for_decode(pipe):def _generate_latents(pipe, *, needs_image: bool, kwargs: dict):+ # On second+ runs the video/audio decoders (~2.5 GB combined) remain+ # resident from the previous job's decode phase. During the+ # block-by-block DiT+LoRA materialization that follows (48 blocks ×+ # ~300 MB each), the combined Metal heap can stall allocation past the+ # 10-second GPU watchdog threshold. Free decoders here so they don't+ # compete with the DiT load; they reload lazily when decode starts.+ if LOW_MEMORY:+ if hasattr(pipe, "video_decoder_block"):+ pipe.video_decoder_block.free()+ if hasattr(pipe, "audio_decoder_block"):+ pipe.audio_decoder_block.free()+ try:+ from ltx_core_mlx.utils.memory import aggressive_cleanup as _ac+ _ac()+ except Exception:+ pass+# Pre-refactor packages: old TextToVideoPipeline.generate /# ImageToVideoPipeline.generate_from_image — single-stage Q4# path with explicit frame_rate plumbing.@@ -1423,6 +1440,7 @@ def configure_acceleration(mode: str) -> str:import ltx_pipelines_mlx.ti2vid_one_stage as ti2vidimport ltx_pipelines_mlx.utils.samplers as samplers+ import ltx_pipelines_mlx.distilled as distilled_modif _ORIGINAL_DENOISE_LOOP is None:_ORIGINAL_DENOISE_LOOP = samplers.denoise_loop@@ -1436,14 +1454,17 @@ def configure_acceleration(mode: str) -> str:if requested == "off":samplers.denoise_loop = _ORIGINAL_DENOISE_LOOPti2vid.denoise_loop = _ORIGINAL_DENOISE_LOOP+ distilled_mod.denoise_loop = _ORIGINAL_DENOISE_LOOPelif requested == "boost":loop = _build_adaptive_x0_loop("boost", max_skips=2, video_thresh=0.02, audio_thresh=0.02)samplers.denoise_loop = loopti2vid.denoise_loop = loop+ distilled_mod.denoise_loop = loopelse:loop = _build_adaptive_x0_loop("turbo", max_skips=3, video_thresh=0.03, audio_thresh=0.03)samplers.denoise_loop = loopti2vid.denoise_loop = loop+ distilled_mod.denoise_loop = loop_CURRENT_ACCEL_MODE = requestedemit({"event": "log", "line": f"accel:mode {requested}"})diff --git a/patch_ltx_codec.py b/patch_ltx_codec.pyindex 3a37254..0592706 100644--- a/patch_ltx_codec.py+++ b/patch_ltx_codec.py@@ -267,6 +267,30 @@ PATCH_VAE_STREAM_NEW = ''' try:aggressive_cleanup()'''+# ---- Patch 6: distilled generate_from_image — tighten DiT eval cadence for I2V ----+# Why: DistilledPipeline.generate_from_image() sets+# _DIT_EVAL_EVERY = min(2, orig)+# to limit Metal command-buffer size. That value was calibrated for T2V at+# ~4800 tokens (16×15×20 at 121f, 640×480). I2V prepends a conditioning frame+# (+15×20 = 300 tokens), pushing the total to 5100. The first cold-compile+# Metal kernel at 5100 tokens consistently exceeds the 10-second watchdog+# (MTLCommandBufferErrorInternal code 0x0e / 14) and crashes the helper.+# Fix: use min(1, orig) — 1 block per buffer halves per-buffer compute cost.+# ~48 extra mx.eval() syncs per step add ~20 ms total (negligible vs. ~2 min).+# Reference: 640×480 × 121f I2V with ≥1 LoRA (extra VRAM → tighter watchdog+# budget) is the reliably-reproducible trigger. Smaller resolutions or fewer+# frames sit under the threshold with min(2).+PATCH_DISTILLED_EVAL_OLD = ' _dit_mod._DIT_EVAL_EVERY = min(2, _orig_eval_every) if _orig_eval_every > 0 else _orig_eval_every'+PATCH_DISTILLED_EVAL_NEW = (+ ' # PATCHED (LTX23MLX): I2V at 121f adds conditioning-frame tokens on top of\n'+ ' # generation tokens (4800 + 300 = 5100 at 640×480). The upstream min(2, ...)\n'+ ' # means 2 DiT blocks per Metal command buffer; at 5100 tokens the first\n'+ ' # cold-compile buffer consistently exceeds the 10-second Metal watchdog\n'+ ' # (MTLCommandBufferErrorInternal code 0x0e). Using 1 block/buffer halves\n'+ ' # per-buffer compute; ~48 extra mx.eval() syncs add ~20 ms total.\n'+ ' _dit_mod._DIT_EVAL_EVERY = min(1, _orig_eval_every) if _orig_eval_every > 0 else _orig_eval_every'+)+# NOTE: Keyframe interpolation OOMs at the stage-1 → stage-2 transition on# 64 GB Macs. We tried free-DiT-before-upscale + reload-after-upscale; that# *didn't* help (the reload hit the same memory peak from a different angle@@ -581,6 +605,27 @@ def main() -> int:fps_outcome = OUTCOME_ALREADYoutcomes.append(("one-stage frame_rate (12→24fps long clips)", fps_outcome))+ # Patch 7: tighten DiT eval cadence in generate_from_image for I2V.+ # Optional — if dgrauet changes the block structure or removes the explicit+ # _DIT_EVAL_EVERY override, DRIFT is a warning rather than a hard failure;+ # the worst case is the upstream behavior (min(2,...)) which crashes on 121f+ # I2V at 640×480 but works at smaller resolutions.+ distilled_target = _find("ltx_pipelines_mlx/distilled.py")+ eval_outcome = apply_patch(+ distilled_target, PATCH_DISTILLED_EVAL_OLD, PATCH_DISTILLED_EVAL_NEW,+ marker="PATCHED (LTX23MLX): I2V at 121f adds conditioning-frame tokens",+ label="distilled DiT eval cadence (I2V watchdog fix)",+ )+ if eval_outcome in (OUTCOME_DRIFT, OUTCOME_MISSING):+ print(+ " [distilled DiT eval cadence] note: anchor not found — upstream may have "+ "changed _DIT_EVAL_EVERY handling. 121f I2V at 640×480 may crash with "+ "MTLCommandBufferErrorInternal code 14. T2V unaffected.",+ file=sys.stderr,+ )+ eval_outcome = OUTCOME_ALREADY+ outcomes.append(("distilled DiT eval cadence (I2V watchdog fix)", eval_outcome))+# (Keyframe OOM patch was removed — see NOTE in the patches block above.# The fix is currently a panel-side resolution clamp, not a pipeline edit.)