Wan2.1-FLF2V-14B — 4-step, int5 + SVD, MLX
First-and-last-frame video generation (FLF2V) with Wan2.1-FLF2V-14B-720P, running natively on Apple Silicon with MLX.
Give it a start image, an end image, and a prompt; it generates the video in between.
- 4 steps, no CFG: the lightx2v I2V step/CFG-distill LoRA
(
wan2.1_i2v_lora_rank64_lightx2v_4step) is merged into the weights (all 1749 LoRA tensors, incl. bias/norm deltas). FLF2V-14B is fine-tuned from I2V-14B-720P and shares its architecture, so the I2V LoRA applies directly. - int5 + rank-32 SVD: every transformer linear is
x @ Q5(W − UV)ᵀ + (x @ Vᵀ) @ Uᵀ: the top-32 singular directions stay in bf16, only the residual is quantized (weights-only SVDQuant). 65.6 GB fp32 → 11 GB. - Runs in 32 GB of unified memory (peak footprint 18.9 GB at 832×464×49).
Top: Wan2.2-TI2V-5B Turbo int4. Bottom: this model. Same Flux-generated start/end poses, prompt and seed.
Quick start
pip install -r requirements.txt # pins mlx 0.31.2 + the mlx-video fork this was built on
hf download bahae98/Wan2.1-FLF2V-14B-4step-int5-SVD-mlx --local-dir Wan-FLF2V-14B-mlx
cd Wan-FLF2V-14B-mlx
python generate_flf14b.py --first start.png --last end.png \
--prompt "A woman raises both arms above her head in a stretch, smiling. Static camera." \
--frames 49 --out out.mp4
The int8 umT5-XXL text encoder is shared by all these Wan MLX models and lives in
bahae98/umt5-xxl-enc-int8-mlx;
it is downloaded automatically on first use. Prompt embeddings are cached in t5_cache/,
so repeating a prompt skips the text encoder entirely.
| Option | Default | Notes |
|---|---|---|
--frames | 81 | must be 4n+1 (49 = 3 s at 16 fps) |
--max-area | 832·480 | output area; aspect ratio follows the first image. 1280*720 is the native 720p |
--seed | 42 | |
--shift | 5.0 | flow-matching shift used by the distill LoRA |
Performance (M1 Pro, 32 GB)
832×464, 49 frames, 4 steps:
| Stage | Time | MLX peak |
|---|---|---|
| CLIP (both frames) | 3.5 s | 1.6 GB |
| VAE encode | 70 s | 16.4 GB |
| Denoise, per step | ~350 s | 17.2 GB |
| VAE decode | 60 s | 19.5 GB |
| Total | ~27 min | footprint 18.9 GB |
Attention cost grows with the square of the token count, so smaller --max-area / fewer frames
speed it up a lot.
Quality notes
Measured quantization error (relative Frobenius, per block): int5 ≈ 0.036–0.041.
On real layers, int4 = 0.092, int4 + SVD = 0.087, int5 = 0.045, int5 + SVD = 0.042, int6 = 0.023
(svd_errors.json lists every layer).
Compared with Wan2.2-TI2V-5B Turbo (int4) on a pose-change pair: faces stay coherent through the motion (the 5B visibly melts mid-clip), the motion is spread over the whole clip instead of finishing early, the last frame lands much closer to the target (7.0 vs 14.5 mean abs diff /255), the background stays put (2.5 vs 9.4 drift) and detail is kept (−9% vs −27% sharpness). The cost is speed: ~14× slower than the 5B. One seed, one pair: indicative, not a benchmark.
Correctness
Each ported piece was checked against the reference PyTorch Wan code:
| Component | Check | Result |
|---|---|---|
CLIP ViT-H/14 image tower (clip_vision.py) | vs wan/modules/clip.py, penultimate block | 0.6% rel. err (ref runs attention in bf16) |
| Transformer block (I2V cross-attn, RoPE, modulation) | vs WanAttentionBlock, same dequantized weights | cos 0.99995 |
img_emb + FLF emb_pos (1, 514, 1280) | vs MLPProj | exact |
VAE decode (vae21_stream.py) | vs WanVAE_.decode | 1.5e-6 rel. err, 1+4(T−1) frames |
vae21_stream.py also fixes two issues in mlx-video's Wan2.1 VAE: its decode is non-causal
(T latents → 4T frames, so frame 0 is not the start image), and its encode builds the whole clip
into one lazy graph (31.5 GB peak; the per-chunk version gives identical output at 16.4 GB).
Files
config.json model + quantization config
transformer/misc.safetensors embeddings, img_emb, head (bf16)
transformer/block_XX.safetensors 40 blocks, int5 + SVD
clip_vision_f16.safetensors CLIP ViT-H/14 image tower (31 blocks)
vae.safetensors Wan2.1 VAE (fp32, encoder + decoder)
generate_flf14b.py inference
flf14b_model.py FLF2V model on top of mlx-video's WanModel
svd_linear.py SVDQuantLinear
clip_vision.py CLIP image tower
vae21_stream.py causal per-chunk VAE encode/decode
build_flf14b.py how the weights were made (streams the fp32 source from the Hub
via HTTP range reads, merges the LoRA, quantizes block by block)
Fewer steps / other distill LoRAs (experimental)
python generate_flf14b.py ... --steps 2 # same model, 2 steps (~2x faster)
python generate_flf14b.py ... --steps 2 --sampler lcm \
--swap-lora Wan_2_1_T2V_14B_720p_rCM_lora_average_rank_94_bf16.safetensors
--swap-lora (lora_swap.py) replaces the merged lightx2v LoRA with another distill LoRA at load
time: -lightx2v and +new are appended as extra low-rank rows to each block's SVD branch (exact, no
requantization); layers the new LoRA does not cover keep lightx2v. Tested with Kijai's rCM
extraction (Kijai/WanVideo_comfy, LoRAs/rCM/...720p_rCM_lora_average_rank_94) on a
raising-arms pose change, 832x464x49:
| Setup | Time | Result |
|---|---|---|
| lightx2v, 4 steps (default) | 27 min | clean |
| rCM, 2 steps, LCM | 13.7 min | face OK, arms ghost/transparent during motion |
| rCM, 1 step | 7.7 min | mid-clip is a blurred blend of both poses |
For large motions keep the default 4 steps. (The rCM LoRA is extracted from the T2V model and does not touch the image-conditioning layers.)
Sampling
Matches lightx2v's step-distill scheduler: sigmas warp([1, .75, .5, .25]) with shift 5
(= timesteps 1000, 937.5, 833.3, 625), Euler to 0, one forward pass per step, no negative prompt.
License
Apache-2.0, same as the base model and the LoRA.