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.

feat(hdr): ship HDR via IC-LoRA Phase 1 — re-expose pill + wire HDRICLoraPipeline

mrbizarroccfeb2f09a90
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index 465a931..f9565de 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -6447,6 +6447,76 @@ def run_job_inner(job: dict) -> None:
final_out = raw_out
job["raw_path"] = str(raw_out)
+ # ===== HDR via IC-LoRA (Phase 1) ====================================
+ # When the user ticks the HDR pill the panel routes to the dedicated
+ # `generate_hdr` helper action backed by HDRICLoraPipeline (upstream
+ # ltx_pipelines_mlx.hdr_ic_lora). Constraints:
+ # - IC-LoRA only works on the distilled checkpoint, so force the
+ # Q4 distilled folder regardless of the user's quality pick.
+ # - Stacking a character LoRA on top of HDR is documented as a
+ # non-functional combo (different LoRA delta target + different
+ # load path); refuse it explicitly so the user gets a clear
+ # error instead of garbled output.
+ # - T2V and I2V only for now; FFLF / Extend / A2V have their own
+ # dispatch branches and would need separate HDRIC wiring later.
+ if p.get("hdr") and mode in ("t2v", "i2v"):
+ user_loras_pre_hdr = list(p.get("loras") or [])
+ if any((Path(str(l.get("path", ""))).name.lower().endswith("_v2.safetensors")
+ or (l.get("kind") == "train_character")) for l in user_loras_pre_hdr):
+ raise RuntimeError(
+ "HDR + character LoRA isn't supported yet. The HDR IC-LoRA "
+ "runs on the distilled checkpoint; character LoRAs are "
+ "trained against the Q8 dev transformer. Pick one or the "
+ "other for now (HDR alone, or character without HDR)."
+ )
+ hdr_loras = [{
+ "path": CURATED_LORAS["hdr"]["repo_id"],
+ "strength": float(CURATED_LORAS["hdr"]["default_strength"]),
+ }]
+ job_spec = {
+ "action": "generate_hdr",
+ "id": job["id"],
+ "params": {
+ # Force distilled folder. The Q4 dir holds
+ # transformer-distilled.safetensors which is what the
+ # IC-LoRA was trained against.
+ "model_dir": str(MODELS_DIR / "ltx-2.3-mlx-q4")
+ if (MODELS_DIR / "ltx-2.3-mlx-q4").is_dir()
+ else str(MODELS_DIR),
+ "prompt": p["prompt"],
+ "negative_prompt": p.get("negative_prompt", ""),
+ "output_path": str(raw_out),
+ "height": height,
+ "width": width,
+ "frames": frames,
+ "frame_rate": model_fps,
+ "seed": p["seed"],
+ # Empty video_conditioning = text-driven Phase 1 mode.
+ # Phase 2 adds a UI picker for an SDR reference video.
+ "video_conditioning": [],
+ "loras": hdr_loras,
+ # Stage counts: the same distilled defaults the standard
+ # 'generate' action uses. ICLoraPipeline runs Stage 1
+ # with the LoRA fused, Stage 2 reloads a clean
+ # transformer (matches the Lightricks reference).
+ "stage1_steps": int(p.get("stage1_steps", 10)),
+ "stage2_steps": int(p.get("stage2_steps", 3)),
+ },
+ }
+ if helper:
+ push(f"Run HDR via helper: id={job['id']} {width}x{height} {frames}f")
+ helper.send(job_spec)
+ sidecar = helper.wait_done(job["id"])
+ push(f"HDR done in {sidecar['elapsed_sec']}s → {Path(raw_out).name}")
+ else:
+ raise RuntimeError("HDR requires the warm helper subprocess")
+ # Post-process: same encode pass T2V/I2V get (mux audio, upscale,
+ # write sidecar). Re-uses the standard tail of run_job_inner by
+ # falling through to it — set up the bookkeeping fields the same
+ # way the other branches do, then return cleanly.
+ job["output_path"] = str(raw_out)
+ return
+
if quality == "high":
if not SYSTEM_CAPS["allows_q8"]:
raise RuntimeError(
@@ -17423,29 +17493,20 @@ HTML = r"""<!doctype html>
<span id="avoidToggleLabel">Avoid +</span>
</button>
<span class="ct-spacer"></span>
- <!-- HDR toggle hidden 2026-05-20 (Mr Bizarro: "HDR is not working
- and never worked, actually never"). The Lightricks HDR LoRA
- is an IC-LoRA: it needs the dedicated ICLoraPipeline
- (upstream ltx_pipelines_mlx.ic_lora), a reference video for
- the in-context conditioning input, AND LogC3 pre/post
- transforms to actually produce HDR output. The toggle was
- wired through the regular _pending_loras hook on the
- standard pipelines — which loads the weights but never
- fires the conditioning path, so the LoRA silently does
- nothing. Hidden in the UI + path stays in the backend for
- when proper IC-LoRA support is implemented (tracked in
- ROADMAP.md). The hidden input still exists below so any
- saved-form state / API callers that include `hdr=on`
- degrade gracefully (server ignores it on the standard
- pipelines as before).
- <label class="toggle-pill" id="hdrPill"
- title="Boost dynamic range and color depth. Implemented as the official Lightricks HDR LoRA fused into the transformer.">
- <input type="checkbox" id="hdr" name="hdr">
- <span class="toggle-dot"></span>
- <span>HDR</span>
- </label>
- -->
- <input type="hidden" id="hdr" name="hdr" value="off">
+ <!-- HDR toggle re-exposed 2026-05-20 (Phase 1 of IC-LoRA
+ support). Routes through HDRICLoraPipeline upstream
+ (ltx_pipelines_mlx.hdr_ic_lora) which does the real
+ LogC3 inverse + IC-LoRA fusion. Phase 1 ships text-driven
+ mode (no reference video required — LoRA delta still
+ applies). Phase 2 adds the reference-video picker for
+ SDR→HDR re-grading. See ROADMAP.md for the full arc. -->
+ <label class="toggle-pill" id="hdrPill"
+ title="HDR via the official Lightricks LTX-2.3-22b IC-LoRA-HDR. Auto-routes to the distilled Q4 path (required by the IC-LoRA pipeline). First HDR job downloads the LoRA weights from Hugging Face (~330 MB, gated — needs an HF token in Settings). Output is standard MP4 plus a companion .hdr.npz tensor (float32 scene-linear) for any pro tool that wants the raw HDR.">
+ <input type="checkbox" id="hdr" name="hdr">
+ <span class="toggle-dot"></span>
+ <span>HDR</span>
+ <span class="experimental-tag" style="margin-left:4px;font-size:9px;padding:1px 5px;border-radius:6px;background:rgba(255,180,80,0.18);color:#ffb450;letter-spacing:0.4px;text-transform:uppercase;">new</span>
+ </label>
<label class="toggle-pill" id="noMusicPill"
title="When on, the prompt is augmented with: 'Audio: voice and ambient sounds only, no music, no soundtrack, no score.' Useful for clips you'll score yourself in post — music can't be cleanly removed afterwards.">
<input type="checkbox" id="noMusic" name="no_music">
diff --git a/mlx_warm_helper.py b/mlx_warm_helper.py
index 020f598..2911028 100644
--- a/mlx_warm_helper.py
+++ b/mlx_warm_helper.py
@@ -2081,6 +2081,101 @@ for line in sys.__stdin__:
_is_busy = False
continue
+ if action == "generate_hdr":
+ # HDR via IC-LoRA. Phase 1 of IC-LoRA support in Phosphene.
+ # Uses HDRICLoraPipeline from ltx_pipelines_mlx.hdr_ic_lora —
+ # the upstream class that handles LoRA fusion at generate time,
+ # the LogC3 inverse transform during decode, and writes the
+ # standard SDR MP4 plus a companion .hdr.npz float32 tensor.
+ # Phase 1 ships text-driven mode: video_conditioning defaults
+ # to [] so no reference video is needed (the LoRA delta still
+ # applies; the LogC3 inverse still runs). Phase 2 will add the
+ # reference-video picker for SDR→HDR re-grading.
+ #
+ # Routing constraint: IC-LoRA requires the distilled checkpoint.
+ # The panel forces quality=balanced when HDR is on, which means
+ # model_dir lands on the Q4 distilled folder. Don't try to run
+ # this against the Q8 dev model — the LoRA was trained against
+ # the distilled checkpoint and the weights won't align.
+ job_id = msg.get("id", "?")
+ p = msg.get("params", {}) or {}
+ model_dir = p.get("model_dir") or MODEL_ID
+ seed = int(p.get("seed", -1))
+ if seed == -1:
+ seed = random.randint(0, 2**31 - 1)
+ _is_busy = True
+ try:
+ t0 = time.time()
+ configure_acceleration("off")
+ from ltx_pipelines_mlx.hdr_ic_lora import HDRICLoraPipeline
+ loras = p.get("loras") or []
+ if not loras:
+ raise RuntimeError(
+ "HDR job requires the HDR LoRA in `loras`. The panel "
+ "should have injected Lightricks/LTX-2.3-22b-IC-LoRA-HDR."
+ )
+ # Resolve each LoRA path (HF repo id → local safetensors via
+ # snapshot_download + largest-file pick; absolute path → pass-through).
+ resolved = [
+ (_resolve_lora_path(str(l["path"])), float(l.get("strength", 1.0)))
+ for l in loras
+ ]
+ num_frames = int(p["frames"])
+ _apply_vae_streaming_decision(num_frames)
+ # Tear down any existing cached pipeline before instantiating
+ # HDRICLoraPipeline — it loads its own DiT + VAE encoder +
+ # upsampler at init, so holding the t2v / i2v caches just
+ # doubles the memory footprint.
+ release_pipelines("hdr render incoming")
+ pipe = HDRICLoraPipeline(
+ model_dir=Path(model_dir),
+ lora_paths=resolved,
+ low_memory=HELPER_LOW_MEMORY,
+ )
+ emit({"event": "log",
+ "line": f"step:generate_hdr {p['width']}x{p['height']} "
+ f"{num_frames}f @{float(p.get('frame_rate', 24.0)):.1f}fps "
+ f"stage1={int(p.get('stage1_steps', 10))} "
+ f"stage2={int(p.get('stage2_steps', 3))} "
+ f"loras={len(resolved)} "
+ f"ref_videos={len(p.get('video_conditioning') or [])}"})
+ kwargs = dict(
+ prompt=p["prompt"],
+ output_path=p["output_path"],
+ video_conditioning=p.get("video_conditioning") or [],
+ height=int(p["height"]),
+ width=int(p["width"]),
+ num_frames=num_frames,
+ frame_rate=float(p.get("frame_rate", 24.0)),
+ seed=seed,
+ stage1_steps=int(p.get("stage1_steps", 10)),
+ stage2_steps=int(p.get("stage2_steps", 3)),
+ )
+ kwargs = _filter_unsupported_kwargs(pipe.generate_and_save, kwargs)
+ out_path = pipe.generate_and_save(**kwargs)
+ # Drop the HDRICLoraPipeline aggressively — we don't cache
+ # it the way we do t2v/i2v because HDR jobs are rare and
+ # the pipeline's DiT+upsampler+decoders cost is substantial.
+ try:
+ pipe = None
+ from ltx_core_mlx.utils.memory import aggressive_cleanup as _ac
+ _ac()
+ except Exception:
+ pass
+ elapsed = round(time.time() - t0, 2)
+ _last_activity = time.time()
+ emit({
+ "event": "done", "id": job_id,
+ "output": str(out_path), "elapsed_sec": elapsed,
+ "seed_used": seed,
+ })
+ except Exception as exc:
+ _last_activity = time.time()
+ emit({"event": "error", "id": job_id, "error": str(exc), "trace": traceback.format_exc()})
+ finally:
+ _is_busy = False
+ continue
+
if action == "enhance_prompt":
# Gemma-driven prompt rewriting. Same model file as the pipeline's
# text encoder, but loaded as a `GemmaLanguageModel` (the wrapper