File size: 2,197 Bytes
e992d9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# model name to class mapping
from acwm.model.dit.dit import DiT
from acwm.model.dit.dit_wrapper import DiTWrapper
from acwm.model.dit.shortcut_dit import ShortcutDiT
from acwm.model.tokenizer.wan_tokenizer import WanVAEWrapper, WanVAEPerFrameWrapper

DIT_CLASS_MAP = {
    'VideoDiT': DiT,
    'DiTWrapper': DiTWrapper,
    'ShortcutDiT': ShortcutDiT,
}

VAE_CLASS_MAP = {
    'WanVAE': WanVAEWrapper,
    'WanVAEPerFrame': WanVAEPerFrameWrapper,   # WanVAE per-frame: T_latent = T_pixel, no temporal compression
    # SDVAE removed for Space (needs diffusers)                      # SD-VAE per-frame: 4ch, 8x spatial, T_latent = T_pixel
    'FluxVAE': lambda *args, **kwargs: _load_flux_vae(*args, **kwargs),
}

def _load_flux_vae(*args, **kwargs):
    import os
    from acwm.model.tokenizer.flux_vae import FluxVAEWrapper
    # Allow FLUX_VAE_DEBUG=1 to skip real download (useful on nodes without internet)
    if os.environ.get("FLUX_VAE_DEBUG", "0") == "1":
        return FluxVAEWrapper(debug_mode=True)
    try:
        return FluxVAEWrapper(*args, **kwargs)
    except Exception as e:
        print(f"[FluxVAE] Failed to load real weights ({e}), falling back to debug stub.")
        return FluxVAEWrapper(debug_mode=True)

def get_dynamics_class(name):
    if name == 'Bidirectional_FullTrajectory':
        from acwm.dynamics.bi_fulltrajectory import Bidirectional_FullTrajectory
        return Bidirectional_FullTrajectory
    elif name == 'DiffusionForcing_WM':
        from acwm.dynamics.diffusion_forcing_wm import DiffusionForcing_WM
        return DiffusionForcing_WM
    elif name == 'PixelVideoDiffusion_WM':
        # Pixel-space (VAE-free) diffusion-forcing world model; spatial downsample
        # folded into the DiT patchify. See acwm/dynamics/pixel_wm.py.
        from acwm.dynamics.pixel_wm import PixelVideoDiffusion_WM
        return PixelVideoDiffusion_WM
    elif name == 'ShortcutForcing_WM':
        # Autoregressive shortcut-forcing world model (Dreamer4). See acwm/dynamics/shortcut_forcing_wm.py.
        from acwm.dynamics.shortcut_forcing_wm import ShortcutForcing_WM
        return ShortcutForcing_WM
    raise ValueError(f"Unknown dynamics class: {name}")