AIBRUH commited on
Commit
eadaef6
·
verified ·
1 Parent(s): c38c592

fix: bf16 text encoder patch + trigger A10G rebuild

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -70,6 +70,20 @@ print("[2/4] Models ready.")
70
  # "./wan_models/Wan2.1-T2V-1.3B/..." so CWD must be the repo root.
71
  os.chdir(REPO_DIR)
72
  print(f"[3/4] CWD → {REPO_DIR}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  print("[3/4] Loading AvatarForcing pipeline...")
74
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
75
 
 
70
  # "./wan_models/Wan2.1-T2V-1.3B/..." so CWD must be the repo root.
71
  os.chdir(REPO_DIR)
72
  print(f"[3/4] CWD → {REPO_DIR}")
73
+
74
+ # Patch wan_wrapper.py: change text encoder from float32 → bfloat16
75
+ # This halves CPU RAM usage for the UMT5-XXL encoder (~10GB → ~5GB)
76
+ _ww_path = os.path.join(REPO_DIR, "utils", "wan_wrapper.py")
77
+ with open(_ww_path, "r") as _f:
78
+ _ww_src = _f.read()
79
+ _ww_patched = _ww_src.replace(
80
+ "dtype=torch.float32,\n device=torch.device('cpu')",
81
+ "dtype=torch.bfloat16,\n device=torch.device('cpu')",
82
+ )
83
+ with open(_ww_path, "w") as _f:
84
+ _f.write(_ww_patched)
85
+ print("[3/4] Patched wan_wrapper.py: text encoder dtype float32 → bfloat16")
86
+
87
  print("[3/4] Loading AvatarForcing pipeline...")
88
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
89