Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -3,18 +3,17 @@ library_name: diffusers
|
|
| 3 |
tags:
|
| 4 |
- fp8
|
| 5 |
- safetensors
|
| 6 |
-
-
|
| 7 |
-
- low-rank
|
| 8 |
- diffusion
|
| 9 |
- converted-by-gradio
|
| 10 |
---
|
| 11 |
-
# FP8 Model with
|
| 12 |
- **Source**: `https://huggingface.co/spacepxl/Wan2.1-VAE-upscale2x`
|
| 13 |
- **File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors`
|
| 14 |
- **FP8 Format**: `E5M2`
|
| 15 |
-
- **
|
| 16 |
-
- **
|
| 17 |
-
- **
|
| 18 |
- **FP8 File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors`
|
| 19 |
## Usage (Inference)
|
| 20 |
```python
|
|
@@ -22,17 +21,29 @@ from safetensors.torch import load_file
|
|
| 22 |
import torch
|
| 23 |
# Load FP8 model
|
| 24 |
fp8_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors")
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
reconstructed = {}
|
| 28 |
for key in fp8_state:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
else:
|
| 36 |
-
reconstructed[key] =
|
| 37 |
```
|
| 38 |
> Requires PyTorch ≥ 2.1 for FP8 support.
|
|
|
|
| 3 |
tags:
|
| 4 |
- fp8
|
| 5 |
- safetensors
|
| 6 |
+
- precision-recovery
|
|
|
|
| 7 |
- diffusion
|
| 8 |
- converted-by-gradio
|
| 9 |
---
|
| 10 |
+
# FP8 Model with Precision Recovery
|
| 11 |
- **Source**: `https://huggingface.co/spacepxl/Wan2.1-VAE-upscale2x`
|
| 12 |
- **File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors`
|
| 13 |
- **FP8 Format**: `E5M2`
|
| 14 |
+
- **Architecture**: vae
|
| 15 |
+
- **Precision Recovery Type**: Correction Factors
|
| 16 |
+
- **Precision Recovery File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-correction-vae.safetensors`
|
| 17 |
- **FP8 File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors`
|
| 18 |
## Usage (Inference)
|
| 19 |
```python
|
|
|
|
| 21 |
import torch
|
| 22 |
# Load FP8 model
|
| 23 |
fp8_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors")
|
| 24 |
+
# Load precision recovery file
|
| 25 |
+
recovery_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 {}
|
| 26 |
+
# Reconstruct high-precision weights
|
| 27 |
reconstructed = {}
|
| 28 |
for key in fp8_state:
|
| 29 |
+
fp8_weight = fp8_state[key].to(torch.float32)
|
| 30 |
+
if recovery_state:
|
| 31 |
+
# For LoRA approach
|
| 32 |
+
if "lora_A" in recovery_state:
|
| 33 |
+
if f"lora_A.{key}" in recovery_state and f"lora_B.{key}" in recovery_state:
|
| 34 |
+
A = recovery_state[f"lora_A.{key}"].to(torch.float32)
|
| 35 |
+
B = recovery_state[f"lora_B.{key}"].to(torch.float32)
|
| 36 |
+
lora_weight = B @ A
|
| 37 |
+
reconstructed[key] = fp8_weight + lora_weight
|
| 38 |
+
else:
|
| 39 |
+
reconstructed[key] = fp8_weight
|
| 40 |
+
# For correction factor approach
|
| 41 |
+
elif f"correction.{key}" in recovery_state:
|
| 42 |
+
correction = recovery_state[f"correction.{key}"].to(torch.float32)
|
| 43 |
+
reconstructed[key] = fp8_weight + correction
|
| 44 |
+
else:
|
| 45 |
+
reconstructed[key] = fp8_weight
|
| 46 |
else:
|
| 47 |
+
reconstructed[key] = fp8_weight
|
| 48 |
```
|
| 49 |
> Requires PyTorch ≥ 2.1 for FP8 support.
|