codemichaeld commited on
Commit
25821d3
·
verified ·
1 Parent(s): 8f603a7

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +43 -0
README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: diffusers
3
+ tags:
4
+ - fp8
5
+ - safetensors
6
+ - lora
7
+ - low-rank
8
+ - diffusion
9
+ - converted-by-gradio
10
+ ---
11
+
12
+ # FP8 Model with Low-Rank LoRA
13
+
14
+ - **Source**: `https://huggingface.co/Kijai/WanVideo_comfy`
15
+ - **File**: `Wan2_1_VAE_bf16.safetensors`
16
+ - **FP8 Format**: `E5M2`
17
+ - **LoRA Rank**: 32
18
+ - **LoRA File**: `Wan2_1_VAE_bf16-lora-r32.safetensors`
19
+
20
+ ## Usage (Inference)
21
+
22
+ ```python
23
+ from safetensors.torch import load_file
24
+ import torch
25
+
26
+ # Load FP8 model
27
+ fp8_state = load_file("Wan2_1_VAE_bf16-fp8-e5m2.safetensors")
28
+ lora_state = load_file("Wan2_1_VAE_bf16-lora-r32.safetensors")
29
+
30
+ # Reconstruct approximate original weights
31
+ reconstructed = {}
32
+ for key in fp8_state:
33
+ if f"lora_A.{key}" in lora_state and f"lora_B.{key}" in lora_state:
34
+ A = lora_state[f"lora_A.{key}"].to(torch.float32)
35
+ B = lora_state[f"lora_B.{key}"].to(torch.float32)
36
+ lora_weight = B @ A # (rank, out) @ (in, rank) -> (out, in)
37
+ fp8_weight = fp8_state[key].to(torch.float32)
38
+ reconstructed[key] = fp8_weight + lora_weight
39
+ else:
40
+ reconstructed[key] = fp8_state[key].to(torch.float32)
41
+ ```
42
+
43
+ > Requires PyTorch ≥ 2.1 for FP8 support.