Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions LOCAL-FIXES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Local patches — FreeVideo macOS fast2 (this checkout is NOT a clean upstream clone)

**Original upstream source:** https://github.com/FlashML-org/FreeVideo (cloned 2026-11-28)
**Base commit:** `git rev-parse HEAD` at the time of this file
**Status:** 2 fixes to make fast2 mode (the "极速档" / Fastest mode) work on Apple Silicon. Originally un-patched; do **not** delete this file.

## The two fixes (do not lose on upgrade)

All fixes are in-place edits under `freevideo_engine/`. The exact diff is saved next to this README as `fixes-2026-11-28-fast2-mac.patch` — apply with `git apply` from this directory.

1. `freevideo_engine/macos_runtime.py`
- Line ~280: `self.cursor = ScheduleCursor(times)` → `self.cursor = None if fast is not None else ScheduleCursor(times)`
- Line ~337: wrap the `register_forward_pre_hook(self.cursor.before, ...)` call in `if self.cursor is not None:`
- Line ~627: wrap `self.cursor.reset(...)` in `if self.cursor is not None:`
- Why: in fast2 mode the scheduler uses pi-H3's RAW_GRID `(.93, .56, 0.)`. Building the *default*-schedule cursor makes the sampled timestep mismatch ("The request changed the precomputed AdaLN schedule"). CUDA already keeps the cursor None in fast mode; this aligns the macOS runtime.

2. `freevideo_engine/macos_stages.py`
- In the `phase == 'decode' and value.get('fast_tier') is not None:` branch, before `from .dwd_decode import pixels_to_file`:
```python
from .macos_vdn import activate
activate()
```
- Why: the fast2 decode subprocess imports `src.inference.render` (VDN Mac overlay) at module import time. Without activate, it crashes with `ModuleNotFoundError: No module named 'src'`.

## Upgrading

`git pull` (or `git fetch && git merge` / `git rebase`) **keeps this README and the patch file** (untracked), but it **overwrites the two files with upstream versions** — wiping these fixes.

Safe upgrade flow:
```bash
cd /Users/cuijs/ComfyUI/custom_nodes/FreeVideo
git stash # stash local modifications
git pull # bring upstream version
git stash pop # try to restore local fixes
# if the pop conflicts (likely): discard the stashed edits, apply the saved diff instead
git checkout -- freevideo_engine/macos_runtime.py freevideo_engine/macos_stages.py
git apply ./fixes-2026-11-28-fast2-mac.patch
```
(If a future upstream release includes these fixes upstream, `git apply` will fail with "already applied" — then it's a no-op re-check, not a problem; see upstream release notes.)

**Better long-term:** send a PR upstream with these two fixes (or ask the FreeVideo team). When upstream merges them, delete this README and patch file and drop the manual fixes.
46 changes: 46 additions & 0 deletions fixes-2026-11-28-fast2-mac.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/freevideo_engine/macos_runtime.py b/freevideo_engine/macos_runtime.py
index c9b9c60c..95e35d07 100644
--- a/freevideo_engine/macos_runtime.py
+++ b/freevideo_engine/macos_runtime.py
@@ -277,7 +277,7 @@ class Engine:
fast.install_features(model, steps)
model.rope.to('mps')
times = schedule_timesteps(steps, device='mps', task=schedule_task)
- self.cursor = ScheduleCursor(times)
+ self.cursor = None if fast is not None else ScheduleCursor(times)
tables = None if fast is not None else TableCache(self.cache, manifest['source_id'], steps,
manifest=manifest, timesteps=times, channels=model.config.hidden_size, device='cpu', task=schedule_task)
embeddings = None
@@ -334,7 +334,8 @@ class Engine:
f'transformer_blocks.{index}.', ('adaln_proj.',)))
self._ff_originals.append((layer.ff, layer.ff.forward))
self.backend.install_chunked_ff(layer.ff, ff_chunk)
- self.schedule_hook = model.register_forward_pre_hook(self.cursor.before, with_kwargs=True)
+ if self.cursor is not None:
+ self.schedule_hook = model.register_forward_pre_hook(self.cursor.before, with_kwargs=True)
if attention_impl == 'mlx':
from .backends.mps_mlx_attention import MLXWindowAttention
self.attention = MLXWindowAttention(batch_bytes=attention_batch_bytes)
@@ -624,7 +625,8 @@ class Engine:
+ 2 * continuation['audio'].shape[2])
self._plan_compute(canvas, prompt.shape[0])
previous_block_calls = self._block_metrics()
- self.cursor.reset(self.steps - refine_steps if refining and refine_schedule is None else start)
+ if self.cursor is not None:
+ self.cursor.reset(self.steps - refine_steps if refining and refine_schedule is None else start)
progress.start()
resident = getattr(self, 'resident_bytes', 0)
retention = (dict(resident_bytes=resident, working_reserve_bytes=self.reserve_bytes)
diff --git a/freevideo_engine/macos_stages.py b/freevideo_engine/macos_stages.py
index b60cc966..c98ad44b 100644
--- a/freevideo_engine/macos_stages.py
+++ b/freevideo_engine/macos_stages.py
@@ -550,6 +550,8 @@ def worker(value):
elif phase == 'decode' and value.get('fast_tier') is not None:
# The fastest mode draws its pixels with the adapter's head; the video VAE is never read. No
# continuation, preview or hidden tail reaches this mode (fast_tier.request refuses them).
+ from .macos_vdn import activate
+ activate()
from .dwd_decode import pixels_to_file
initial = torch.load(artifacts / 'latents.pt', map_location='cpu', weights_only=True)
kept = torch.load(artifacts / 'pixel-features.pt', map_location='cpu', weights_only=True)
8 changes: 5 additions & 3 deletions freevideo_engine/macos_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def path(name):
fast.install_features(model, steps)
model.rope.to('mps')
times = schedule_timesteps(steps, device='mps', task=schedule_task)
self.cursor = ScheduleCursor(times)
self.cursor = None if fast is not None else ScheduleCursor(times)
tables = None if fast is not None else TableCache(self.cache, manifest['source_id'], steps,
manifest=manifest, timesteps=times, channels=model.config.hidden_size, device='cpu', task=schedule_task)
embeddings = None
Expand Down Expand Up @@ -334,7 +334,8 @@ def path(name):
f'transformer_blocks.{index}.', ('adaln_proj.',)))
self._ff_originals.append((layer.ff, layer.ff.forward))
self.backend.install_chunked_ff(layer.ff, ff_chunk)
self.schedule_hook = model.register_forward_pre_hook(self.cursor.before, with_kwargs=True)
if self.cursor is not None:
self.schedule_hook = model.register_forward_pre_hook(self.cursor.before, with_kwargs=True)
if attention_impl == 'mlx':
from .backends.mps_mlx_attention import MLXWindowAttention
self.attention = MLXWindowAttention(batch_bytes=attention_batch_bytes)
Expand Down Expand Up @@ -624,7 +625,8 @@ def host_guard(module, inputs):
+ 2 * continuation['audio'].shape[2])
self._plan_compute(canvas, prompt.shape[0])
previous_block_calls = self._block_metrics()
self.cursor.reset(self.steps - refine_steps if refining and refine_schedule is None else start)
if self.cursor is not None:
self.cursor.reset(self.steps - refine_steps if refining and refine_schedule is None else start)
progress.start()
resident = getattr(self, 'resident_bytes', 0)
retention = (dict(resident_bytes=resident, working_reserve_bytes=self.reserve_bytes)
Expand Down
2 changes: 2 additions & 0 deletions freevideo_engine/macos_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ def first_saved(video, audio, metrics):
elif phase == 'decode' and value.get('fast_tier') is not None:
# The fastest mode draws its pixels with the adapter's head; the video VAE is never read. No
# continuation, preview or hidden tail reaches this mode (fast_tier.request refuses them).
from .macos_vdn import activate
activate()
from .dwd_decode import pixels_to_file
initial = torch.load(artifacts / 'latents.pt', map_location='cpu', weights_only=True)
kept = torch.load(artifacts / 'pixel-features.pt', map_location='cpu', weights_only=True)
Expand Down