Views
No views yet
https://huggingface.co/spacepxl/Wan2.1-VAE-upscale2xWan2.1_VAE_upscale2x_imageonly_real_v1.safetensorsE5M2Wan2.1_VAE_upscale2x_imageonly_real_v1-correction-vae.safetensorsWan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors1from safetensors.torch import load_file
2import torch
3# Load FP8 model
4fp8_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors")
5# Load precision recovery file
6recovery_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-correction-vae.safetensors") if "Wan2.1_VAE_upscale2x_imageonly_real_v1-correction-vae.safetensors" else {}
7# Reconstruct high-precision weights
8reconstructed = {}
9for key in fp8_state:
10 fp8_weight = fp8_state[key].to(torch.float32)
11 if recovery_state:
12 # For LoRA approach
13 if "lora_A" in recovery_state:
14 if f"lora_A.{key}" in recovery_state and f"lora_B.{key}" in recovery_state:
15 A = recovery_state[f"lora_A.{key}"].to(torch.float32)
16 B = recovery_state[f"lora_B.{key}"].to(torch.float32)
17 lora_weight = B @ A
18 reconstructed[key] = fp8_weight + lora_weight
19 else:
20 reconstructed[key] = fp8_weight
21 # For correction factor approach
22 elif f"correction.{key}" in recovery_state:
23 correction = recovery_state[f"correction.{key}"].to(torch.float32)
24 reconstructed[key] = fp8_weight + correction
25 else:
26 reconstructed[key] = fp8_weight
27 else:
28 reconstructed[key] = fp8_weightRequires PyTorch ≥ 2.1 for FP8 support.