HunyuanVideo: A Systematic Framework For Large Video Generation Model
fix(load): load checkpoints with weights_only and pin torch 2.7.1
KimbingNgf0b3aa920408
diff --git a/hyvideo/inference.py b/hyvideo/inference.pyindex 636b37f..2f3d7f1 100644--- a/hyvideo/inference.py+++ b/hyvideo/inference.py@@ -338,7 +338,11 @@ class Inference(object):if not model_path.exists():raise ValueError(f"model_path not exists: {model_path}")logger.info(f"Loading torch model {model_path}...")- state_dict = torch.load(model_path, map_location=lambda storage, loc: storage)+ state_dict = torch.load(+ model_path,+ map_location=lambda storage, loc: storage,+ weights_only=True,+ )if bare_model == "unknown" and ("ema" in state_dict or "module" in state_dict):bare_model = Falsediff --git a/hyvideo/modules/fp8_optimization.py b/hyvideo/modules/fp8_optimization.pyindex b95c1f4..c26c3ea 100644--- a/hyvideo/modules/fp8_optimization.py+++ b/hyvideo/modules/fp8_optimization.py@@ -85,7 +85,11 @@ def convert_fp8_linear(module, dit_weight_path, original_dtype, params_to_keep={# loading fp8 mapping filefp8_map_path = dit_weight_path.replace('.pt', '_map.pt')if os.path.exists(fp8_map_path):- fp8_map = torch.load(fp8_map_path, map_location=lambda storage, loc: storage)+ fp8_map = torch.load(+ fp8_map_path,+ map_location=lambda storage, loc: storage,+ weights_only=True,+ )else:raise ValueError(f"Invalid fp8_map path: {fp8_map_path}.")diff --git a/hyvideo/vae/__init__.py b/hyvideo/vae/__init__.pyindex 7a0d396..6e8d8b0 100644--- a/hyvideo/vae/__init__.py+++ b/hyvideo/vae/__init__.py@@ -36,7 +36,7 @@ def load_vae(vae_type: str="884-16c-hy",vae_ckpt = Path(vae_path) / "pytorch_model.pt"assert vae_ckpt.exists(), f"VAE checkpoint not found: {vae_ckpt}"- ckpt = torch.load(vae_ckpt, map_location=vae.device)+ ckpt = torch.load(vae_ckpt, map_location=vae.device, weights_only=True)if "state_dict" in ckpt:ckpt = ckpt["state_dict"]if any(k.startswith("vae.") for k in ckpt.keys()):diff --git a/requirements.txt b/requirements.txtindex 543cdf3..3e3647e 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,4 +1,4 @@-torch==2.6.0+torch==2.7.1opencv-python==4.9.0.80diffusers==0.31.0transformers==4.46.3