codemichaeld commited on
Commit
b103a01
·
verified ·
1 Parent(s): c4cd0bc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +26 -15
README.md CHANGED
@@ -3,18 +3,17 @@ library_name: diffusers
3
  tags:
4
  - fp8
5
  - safetensors
6
- - lora
7
- - low-rank
8
  - diffusion
9
  - converted-by-gradio
10
  ---
11
- # FP8 Model with Low-Rank LoRA
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
- - **LoRA Rank**: 128
16
- - **Architecture**: all
17
- - **LoRA File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-lora-r128.safetensors`
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
- lora_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-lora-r128.safetensors")
26
- # Reconstruct approximate original weights
 
27
  reconstructed = {}
28
  for key in fp8_state:
29
- if f"lora_A.{key}" in lora_state and f"lora_B.{key}" in lora_state:
30
- A = lora_state[f"lora_A.{key}"].to(torch.float32)
31
- B = lora_state[f"lora_B.{key}"].to(torch.float32)
32
- lora_weight = B @ A # (out_features, rank) @ (rank, in_features) -> (out_features, in_features)
33
- fp8_weight = fp8_state[key].to(torch.float32)
34
- reconstructed[key] = fp8_weight + lora_weight
 
 
 
 
 
 
 
 
 
 
 
35
  else:
36
- reconstructed[key] = fp8_state[key].to(torch.float32)
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.