Skip to content

Fix solid green Refine Details output on Apple Silicon (blocking upload of tile blend weights) - #200

Open
Cemalettin Serit (cemserit) wants to merge 1 commit into
Lightricks:mainfrom
cemserit:fix/mps-tiling-blend-weights-green-refine
Open

Cemalettin Serit (cemserit) wants to merge 1 commit into
Lightricks:mainfrom
cemserit:fix/mps-tiling-blend-weights-green-refine

Conversation

@cemserit

@cemserit Cemalettin Serit (cemserit) commented Nov 11, 2026 •

Copy link
Copy Markdown

Fixes #199.

Problem

On Apple Silicon, LTX Desktop 1.3.2 finishes every Refine Details job as succeeded and writes a solid green video (all frames zero in Y, U and V). Details, reproduction and measurements are in #199.

Cause

ltx-core 1.6.0 added _device_weights in ltx_core/modality_tiling.py. It uploads a tile's blend weights with non_blocking=True on every backend. ltx_core.devices.allow_async_transfer states that only CUDA orders a non-blocking transfer against the kernel that consumes it, and upload_from_host follows that rule, but _device_weights does not. On MPS VideoModalityTilingHelper.blend then multiplies the tile prediction by weights that have not landed.

Change

A new module in backend/services/patches/, following the existing pattern (mps_transfer_sync and others):

  • mps_tiling_weights_sync.py replaces modality_tiling._device_weights. Where allow_async_transfer(like.device) is true (CUDA) it calls upstream's function unchanged. Elsewhere it builds the weights once per plan and uploads them with a blocking .to.
  • It raises at import if upstream's signature changes, like the other patches.
  • Registered in ltx2_server.py next to mps_transfer_sync, with its "Remove once ..." note.

The root fix belongs in ltx-core and is one line in _device_weights:

cache[key] = host.to(device=like.device, non_blocking=allow_async_transfer(like.device))

Verification

On a MacBook Pro M5 Pro, 48 GB, macOS 26.5.1, with the Python environment bundled in the 1.3.2 app (ltx-core 1.6.0, torch 2.11.0), calling LTXIcLoraPipeline with the app's start-up patches and catalog settings for refine-details:

Run (9 frames, 576 x 1024, same seed) Result
As shipped denoised at step 1 in -3.0e28 .. 3.8e28, non-finite from step 2, output YAVG=0 UAVG=0 VAVG=0
With this patch file loaded all steps finite, output YAVG=122 UAVG=110 VAVG=145, correct picture

The same replacement (blocking copy in _device_weights, nothing else changed) also refined seven clips of 49 to 113 frames to 1080p correctly, including two-window runs.

Tests

backend/tests/test_mps_tiling_weights_sync.py, one bug per test:

  • test_patch_replaces_modality_tiling_device_weights: the patch is imported but not installed.
  • test_mps_upload_is_never_non_blocking: the MPS upload goes back to non_blocking=True (fails against upstream's function, checked).
  • test_mps_weights_are_built_and_uploaded_once_per_plan: the patch loses upstream's once-per-plan cache.
  • test_cuda_keeps_the_upstream_upload: the patch changes the CUDA path.

Your guide asks for the test list to be agreed before tests are written. As an outside contributor I could not do that first, so the list is above; I am happy to cut or change any of them.

CI

CI on this pull request waits for a maintainer's approval, so I ran the same workflow on the same commit (13495a2) inside my fork: https://github.com/cemserit/LTX-Desktop/actions/runs/43383238059

  • Type Checking (Pyright, OpenAPI contract, TypeScript, ESLint, pack helper tests, file sizes): passed
  • Python Tests, Linux, 4 shards: 3932 passed, 25 skipped, including the four new tests and the patch import smoke test
  • Python Tests, Windows (ci_os): passed
  • Frontend Build: passed
  • Archive markers: skipped (internal repository only)

🤖 Generated with Claude Code

ltx-core 1.6.0 uploads tile blend weights in modality_tiling._device_weights
with non_blocking=True on every backend. MPS does not order the consumer
after such a copy (ltx_core.devices.allow_async_transfer), so
VideoModalityTilingHelper.blend multiplies the tile prediction by weights
that have not landed. Every IC-LoRA job that tiles the transformer then
ends as "succeeded" with an all-zero (solid green) video.

Add a services.patches module that keeps upstream's upload where
allow_async_transfer permits it (CUDA) and uses a blocking copy elsewhere.

Fixes Lightricks#199

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.3.2 on Apple Silicon: Refine Details (IC-LoRA) writes a solid green video and reports success

1 participant