Skip to content

Looking Ahead: Modeling Future Evolution in Autoregressive Video Generation

Run inference on Windows

hiroki-abe-58710309727dde
diff --git a/src/utils/attention.py b/src/utils/attention.py
index 14fc90e..e2a3421 100644
--- a/src/utils/attention.py
+++ b/src/utils/attention.py
@@ -6,7 +6,11 @@ from transformers.utils.import_utils import is_flash_attn_4_available
FLASH_ATTN_4_AVAILABLE = is_flash_attn_4_available()
if FLASH_ATTN_4_AVAILABLE:
- import flash_attn.cute
+ try:
+ import flash_attn.cute
+ except ImportError:
+ # Installed but not importable, e.g. on Windows, where its quack dependency imports fcntl.
+ FLASH_ATTN_4_AVAILABLE = False
__all__ = [
diff --git a/src/utils/ckpt_cache.py b/src/utils/ckpt_cache.py
index fb9e3ee..c5e6bde 100644
--- a/src/utils/ckpt_cache.py
+++ b/src/utils/ckpt_cache.py
@@ -58,6 +58,11 @@ import time
import torch
+try:
+ import fcntl
+except ImportError: # Windows has no flock; checkpoints then load from their own path.
+ fcntl = None
+
__all__ = [
"stage_ckpt_to_local",
"load_ckpt",
@@ -100,7 +105,7 @@ def _should_stage(path: str) -> bool:
to ``cache/y`` would be pointless and would also break the
"directory hash -> staged subdir" mapping.
"""
- if not _CKPT_LOCAL_CACHE_ENABLE:
+ if fcntl is None or not _CKPT_LOCAL_CACHE_ENABLE:
return False
if _REMOTE_FUSE_PREFIX:
return path.startswith(_REMOTE_FUSE_PREFIX)
@@ -157,7 +162,6 @@ def stage_ckpt_to_local(path: str, *, logger=None, copy_siblings: bool = True) -
if not _should_stage(path):
return path
- import fcntl
import hashlib
import shutil
diff --git a/src/utils/wan_wrapper.py b/src/utils/wan_wrapper.py
index 54945bd..807723d 100644
--- a/src/utils/wan_wrapper.py
+++ b/src/utils/wan_wrapper.py
@@ -7,6 +7,11 @@ from contextlib import contextmanager, nullcontext
import torch
+try:
+ import fcntl
+except ImportError: # Windows has no flock; the base model then loads from WAN_ROOT directly.
+ fcntl = None
+
from src.utils.scheduler import FlowMatchScheduler
from src.utils.wan_model_family import get_wan_model_family
from src.wan.modules.t5 import umt5_xxl
@@ -198,7 +203,7 @@ def _resolve_wan_model_dir(model_name: str) -> str:
already_local = wan_root_abs == cache_root_abs or wan_root_abs.startswith(
cache_root_abs.rstrip("/") + "/"
)
- if not WAN_LOCAL_CACHE_ENABLE or already_local or not os.path.isdir(src):
+ if fcntl is None or not WAN_LOCAL_CACHE_ENABLE or already_local or not os.path.isdir(src):
_RESOLVED_MODEL_DIRS[model_name] = src
return src
@@ -213,8 +218,6 @@ def _resolve_wan_model_dir(model_name: str) -> str:
_RESOLVED_MODEL_DIRS[model_name] = dst
return dst
- import fcntl
-
os.makedirs(dst, exist_ok=True)
logging.info(
f"[wan-cache] staging {src} -> {dst} "
diff --git a/src/wan/modules/attention.py b/src/wan/modules/attention.py
index 1a80e25..bb003b0 100644
--- a/src/wan/modules/attention.py
+++ b/src/wan/modules/attention.py
@@ -4,7 +4,11 @@ import torch
from transformers.utils.import_utils import is_flash_attn_4_available
FLASH_ATTN_4_AVAILABLE = is_flash_attn_4_available()
if FLASH_ATTN_4_AVAILABLE:
- import flash_attn.cute
+ try:
+ import flash_attn.cute
+ except ImportError:
+ # Installed but not importable, e.g. on Windows, where its quack dependency imports fcntl.
+ FLASH_ATTN_4_AVAILABLE = False
import warnings
diff --git a/src/wan/modules/model.py b/src/wan/modules/model.py
index 52d2f59..f88bd9a 100644
--- a/src/wan/modules/model.py
+++ b/src/wan/modules/model.py
@@ -2,7 +2,7 @@
# Copyright 2024-2025 The Alibaba Wan Team Authors. All rights reserved.
import torch
import torch.nn as nn
-from .attention import flash_attention
+from .attention import attention
class WanRMSNorm(nn.Module):
@@ -84,7 +84,7 @@ class WanT2VCrossAttention(WanSelfAttention):
v = self.v(context).view(b, -1, n, d)
# compute attention
- x = flash_attention(q, k, v, k_lens=context_lens)
+ x = attention(q, k, v, k_lens=context_lens)
# output
x = x.flatten(2)