diff --git a/src/maxdiffusion/configs/base_wan_1_3b.yml b/src/maxdiffusion/configs/base_wan_1_3b.yml index 97c1317c7..8b5670f81 100644 --- a/src/maxdiffusion/configs/base_wan_1_3b.yml +++ b/src/maxdiffusion/configs/base_wan_1_3b.yml @@ -420,6 +420,12 @@ flow_shift: 3.0 # Diffusion CFG cache (FasterCache-style, WAN 2.1 T2V only) use_cfg_cache: False use_kv_cache: False +# MagCache (WAN 2.1 T2V); generate_wan.py reads these keys on every T2V run. +use_magcache: False +magcache_thresh: 0.12 +magcache_K: 2 +retention_ratio: 0.2 +mag_ratios_base: [1.0, 1.0, 1.0124, 1.02213, 1.00166, 1.0041, 0.99791, 1.00061, 0.99682, 0.99762, 0.99634, 0.99685, 0.99567, 0.99586, 0.99416, 0.99422, 0.99578, 0.99575, 0.9957, 0.99563, 0.99511, 0.99506, 0.99535, 0.99531, 0.99552, 0.99549, 0.99541, 0.99539, 0.9954, 0.99536, 0.99489, 0.99485, 0.99518, 0.99514, 0.99484, 0.99478, 0.99481, 0.99479, 0.99415, 0.99413, 0.99419, 0.99416, 0.99396, 0.99393, 0.99388, 0.99386, 0.99349, 0.99349, 0.99309, 0.99304, 0.9927, 0.9927, 0.99228, 0.99226, 0.99171, 0.9917, 0.99137, 0.99135, 0.99068, 0.99063, 0.99005, 0.99003, 0.98944, 0.98942, 0.98849, 0.98849, 0.98758, 0.98757, 0.98644, 0.98643, 0.98504, 0.98503, 0.9836, 0.98359, 0.98202, 0.98201, 0.97977, 0.97978, 0.97717, 0.97718, 0.9741, 0.97411, 0.97003, 0.97002, 0.96538, 0.96541, 0.9593, 0.95933, 0.95086, 0.95089, 0.94013, 0.94019, 0.92402, 0.92414, 0.90241, 0.9026, 0.86821, 0.86868, 0.81838, 0.81939] # WAN-VACE training: compute the VACE hints from zero latents at timestep 999, the first inference timestep, # instead of from the noisy latents. This fine-tunes the model for use_vace_cache=True in the VACE pipeline, which # computes the hints once and reuses them at every denoising step. diff --git a/src/maxdiffusion/pipelines/wan/wan_pipeline_2_1.py b/src/maxdiffusion/pipelines/wan/wan_pipeline_2_1.py index b40cddc96..5650b35b8 100644 --- a/src/maxdiffusion/pipelines/wan/wan_pipeline_2_1.py +++ b/src/maxdiffusion/pipelines/wan/wan_pipeline_2_1.py @@ -436,6 +436,8 @@ def scan_body(carry, t): magcache_thresh, magcache_K, skip_warmup, + # Never skip before a residual has been cached (e.g. the 2-step compile warmup). + use_magcache=False if cached_residual is None else None, ) noise_pred, residual_x_cur = transformer_forward_pass( diff --git a/src/maxdiffusion/pipelines/wan/wan_pipeline_i2v_2p1.py b/src/maxdiffusion/pipelines/wan/wan_pipeline_i2v_2p1.py index 3ee802e9d..6e7979c46 100644 --- a/src/maxdiffusion/pipelines/wan/wan_pipeline_i2v_2p1.py +++ b/src/maxdiffusion/pipelines/wan/wan_pipeline_i2v_2p1.py @@ -465,6 +465,8 @@ def scan_body(carry, t): magcache_thresh, magcache_K, skip_warmup, + # Never skip before a residual has been cached (e.g. the 2-step compile warmup). + use_magcache=False if cached_residual is None else None, ) latents_input = latents