codemichaeld commited on
Commit
3ad5b0b
·
verified ·
1 Parent(s): 6c989b7

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +31 -14
README.md CHANGED
@@ -7,20 +7,34 @@ tags:
7
  - mixed-method
8
  - converted-by-gradio
9
  ---
10
- # FP8 Model with Mixed Precision Recovery
11
  - **Source**: `https://huggingface.co/spacepxl/Wan2.1-VAE-upscale2x`
12
  - **Original File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors`
13
  - **FP8 Format**: `E5M2`
14
  - **FP8 File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors`
15
- - **Recovery File**: `None`
16
 
17
- ## Recovery Configuration
18
  ```json
19
  [
20
  {
21
- "element": "all",
22
- "method": "lora",
23
- "rank": 64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
  ]
26
  ```
@@ -34,7 +48,7 @@ import torch
34
  fp8_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors")
35
 
36
  # Load recovery weights if available
37
- recovery_state = load_file("") if "" and os.path.exists("") else {}
38
 
39
  # Reconstruct high-precision weights
40
  reconstructed = {}
@@ -42,16 +56,19 @@ for key in fp8_state:
42
  fp8_weight = fp8_state[key].to(torch.float32) # Convert to float32 for computation
43
 
44
  # Apply LoRA recovery if available
45
- if f"lora_A.{key}" in recovery_state and f"lora_B.{key}" in recovery_state:
46
- A = recovery_state[f"lora_A.{key}"].to(torch.float32)
47
- B = recovery_state[f"lora_B.{key}"].to(torch.float32)
 
 
48
  # Reconstruct the low-rank approximation
49
  lora_weight = B @ A
50
  fp8_weight = fp8_weight + lora_weight
51
 
52
  # Apply difference recovery if available
53
- if f"diff.{key}" in recovery_state:
54
- diff = recovery_state[f"diff.{key}"].to(torch.float32)
 
55
  fp8_weight = fp8_weight + diff
56
 
57
  reconstructed[key] = fp8_weight
@@ -65,6 +82,6 @@ model.load_state_dict(reconstructed)
65
 
66
  ## Statistics
67
  - **Total layers**: 194
68
- - **Layers with recovery**: 0
69
  - LoRA recovery: 0
70
- - Difference recovery: 0
 
7
  - mixed-method
8
  - converted-by-gradio
9
  ---
10
+ # FP8 Model with Per-Tensor Precision Recovery
11
  - **Source**: `https://huggingface.co/spacepxl/Wan2.1-VAE-upscale2x`
12
  - **Original File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors`
13
  - **FP8 Format**: `E5M2`
14
  - **FP8 File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors`
15
+ - **Recovery File**: `Wan2.1_VAE_upscale2x_imageonly_real_v1-recovery.safetensors`
16
 
17
+ ## Recovery Rules Used
18
  ```json
19
  [
20
  {
21
+ "key_pattern": "vae",
22
+ "dim": 4,
23
+ "method": "diff"
24
+ },
25
+ {
26
+ "key_pattern": "encoder",
27
+ "dim": 4,
28
+ "method": "diff"
29
+ },
30
+ {
31
+ "key_pattern": "decoder",
32
+ "dim": 4,
33
+ "method": "diff"
34
+ },
35
+ {
36
+ "key_pattern": "all",
37
+ "method": "none"
38
  }
39
  ]
40
  ```
 
48
  fp8_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-fp8-e5m2.safetensors")
49
 
50
  # Load recovery weights if available
51
+ recovery_state = load_file("Wan2.1_VAE_upscale2x_imageonly_real_v1-recovery.safetensors") if "Wan2.1_VAE_upscale2x_imageonly_real_v1-recovery.safetensors" and os.path.exists("Wan2.1_VAE_upscale2x_imageonly_real_v1-recovery.safetensors") else {}
52
 
53
  # Reconstruct high-precision weights
54
  reconstructed = {}
 
56
  fp8_weight = fp8_state[key].to(torch.float32) # Convert to float32 for computation
57
 
58
  # Apply LoRA recovery if available
59
+ lora_a_key = f"lora_A.{key}"
60
+ lora_b_key = f"lora_B.{key}"
61
+ if lora_a_key in recovery_state and lora_b_key in recovery_state:
62
+ A = recovery_state[lora_a_key].to(torch.float32)
63
+ B = recovery_state[lora_b_key].to(torch.float32)
64
  # Reconstruct the low-rank approximation
65
  lora_weight = B @ A
66
  fp8_weight = fp8_weight + lora_weight
67
 
68
  # Apply difference recovery if available
69
+ diff_key = f"diff.{key}"
70
+ if diff_key in recovery_state:
71
+ diff = recovery_state[diff_key].to(torch.float32)
72
  fp8_weight = fp8_weight + diff
73
 
74
  reconstructed[key] = fp8_weight
 
82
 
83
  ## Statistics
84
  - **Total layers**: 194
85
+ - **Layers with recovery**: 60
86
  - LoRA recovery: 0
87
+ - Difference recovery: 60