feat(mlx): support CorridorKeyBlue on the MLX backend (Apple Silicon)
Context
PR #241 added a dedicated blue-screen checkpoint (CorridorKeyBlue) to the Torch backend. The MLX backend on Apple Silicon does not yet have a blue checkpoint, and the project's MLX wrapper repo (nikopueringer/corridorkey-mlx) only ships the green weights at v1.0.0.
For now, this combination fails fast with an actionable error:
# CorridorKeyModule/backend.py — _discover_checkpoint(MLX_EXT, screen_color="blue")
raise RuntimeError(
"Blue-screen support is not yet available on the MLX backend. "
"Use --backend torch with --screen-color blue, or wait for the MLX blue release."
)Mac users who try --screen-color blue see this message and fall back to Torch (or wait). The keyer is otherwise fully functional on MLX for green plates.
Why this is a tracker issue, not a coding task
There is genuinely nothing to write until the upstream artifact exists:
- The MLX engine (
nikopueringer/corridorkey-mlx) consumes a single.safetensorsfile at runtime — same architecture as Torch but with MLX-specific weight layout. - There is no public release of an MLX-compiled blue checkpoint yet.
- We can't trial-balloon a fix without a test fixture; the whole point of the MLX path is the converted weight format.
Once the blue MLX weight ships (typically as a new GitHub release on the corridorkey-mlx repo), the implementation is small and mechanical — see Approach below.
Definition of done
uv run corridorkey run-inference --backend mlx --screen-color bluesucceeds on a clean Apple Silicon install:- Downloads
corridorkey_blue_mlx.safetensors(or whatever the published filename ends up being) intoCorridorKeyModule/checkpoints/if absent. - Loads it via the same
CorridorKeyMLXEnginepath used today for green. - Despill is applied to the blue channel — see #241 for the channel-routing contract that the existing Torch path already exercises.
- Downloads
uv run corridorkey run-inference --backend mlx --screen-color autocorrectly auto-detects blue plates and routes to the blue weight.- Existing green-MLX users keep working with no change to their install.
Approach (when the weight ships)
Roughly four edits in CorridorKeyModule/backend.py:
- Constants (next to lines ~62–64 today):
MLX_MODEL_URL_BLUE = "https://github.com/nikopueringer/corridorkey-mlx/releases/download/<TAG>/corridorkey_blue_mlx.safetensors"
MLX_MODEL_FILENAME_BLUE = "corridorkey_blue_mlx.safetensors" The exact tag/filename comes from whatever corridorkey-mlx publishes.
_auto_detect_backend(lines ~67–117): the existing function only knows about the green MLX file. Either: (a) widen it to keep working as long as either MLX file exists, or (b) leave it green-only and let_discover_checkpointhandle the blue download lazily on first use. (b) is simpler and matches the Torch lazy-download pattern._discover_checkpoint(MLX_EXT, screen_color="blue"): replace the currentraise RuntimeErrorblock (lines ~296–300) with the same shape as the green MLX path —_filter_by_color+ a new_ensure_mlx_checkpoint(screen_color="blue")helper that downloads from the GitHub release URL viaurllib.request.urlretrieve(mirroring the existing green MLX download)._MLXEngineAdapter.process_frame: today the despill in_wrap_mlx_outputis hard-coded to channel 1. With a real blue weight the adapter must routescreen_channelinto despill — replace theif screen_channel != 1: raise NotImplementedErrorguard with the actual routing. The Torch path's pattern is the model:
fg_despilled = cu.despill_opencv(fg, limit_mode="average", strength=despill_strength, screen_channel=screen_channel)- Tests: add one mock-based test in
tests/test_backend.pymirroringtest_blue_with_only_green_present_triggers_download(which already exists for Torch) — assert_discover_checkpoint(MLX_EXT, screen_color="blue")calls the right release URL and copies the result intocheckpoints/. Also: drop the existingtest_mlx_blue_raises— it'll start failing once we land this and we want it to.
Tracking
Watch nikopueringer/corridorkey-mlx releases for a blue artifact. When one lands, this issue can be picked up — the work is contained to backend.py and a couple of tests, probably under 100 lines of net change.
Source: nikopueringer/CorridorKey