Spaces:
Runtime error
Runtime error
nsfwalex Claude Opus 4.8 (1M context) commited on
Commit Β·
c46762a
1
Parent(s): 877c9af
Anima loader: fix cosmetic tensor-count log + assert DiT fully materialized
Browse filesfrom_single_file's converter pops the input state dict empty, so logging len(dit_sd)
after the load printed '0 tensors'. Capture counts before the load, and assert no
transformer param is left on the meta device (a half-mapped checkpoint would
otherwise crash later in pipe.to('cuda')).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
app.py
CHANGED
|
@@ -316,7 +316,8 @@ def _load_anima(entry):
|
|
| 316 |
k[len(ADAPTER_PREFIX):]: v for k, v in raw.items()
|
| 317 |
if k.startswith(ADAPTER_PREFIX)
|
| 318 |
}
|
| 319 |
-
|
|
|
|
| 320 |
raise RuntimeError(
|
| 321 |
f"[anima] {entry['label']}: no '{DIT_PREFIX}*' keys in checkpoint "
|
| 322 |
f"(got prefixes {sorted({k.split('.')[0] for k in raw})}); "
|
|
@@ -328,6 +329,14 @@ def _load_anima(entry):
|
|
| 328 |
dit_sd, config=ANIMA_BASE, subfolder="transformer",
|
| 329 |
torch_dtype=torch.bfloat16,
|
| 330 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
pipe.update_components(transformer=transformer)
|
| 332 |
|
| 333 |
# Finetuned LLM adapter -> the `text_conditioner` component. Its keys match the
|
|
@@ -345,8 +354,8 @@ def _load_anima(entry):
|
|
| 345 |
print(f"[anima] {entry['label']}: no text_conditioner / adapter weights "
|
| 346 |
f"(adapter_tensors={len(adapter_sd)}); using base adapter")
|
| 347 |
|
| 348 |
-
print(f"[anima] {entry['label']}: loaded finetuned DiT ({
|
| 349 |
-
f"+ adapter ({
|
| 350 |
pipe.to("cuda")
|
| 351 |
return pipe
|
| 352 |
|
|
|
|
| 316 |
k[len(ADAPTER_PREFIX):]: v for k, v in raw.items()
|
| 317 |
if k.startswith(ADAPTER_PREFIX)
|
| 318 |
}
|
| 319 |
+
n_dit, n_adapter = len(dit_sd), len(adapter_sd) # capture now: from_single_file
|
| 320 |
+
if not dit_sd: # pops dit_sd empty during convert
|
| 321 |
raise RuntimeError(
|
| 322 |
f"[anima] {entry['label']}: no '{DIT_PREFIX}*' keys in checkpoint "
|
| 323 |
f"(got prefixes {sorted({k.split('.')[0] for k in raw})}); "
|
|
|
|
| 329 |
dit_sd, config=ANIMA_BASE, subfolder="transformer",
|
| 330 |
torch_dtype=torch.bfloat16,
|
| 331 |
)
|
| 332 |
+
# A half-mapped checkpoint would leave params on the meta device (later crashing
|
| 333 |
+
# in pipe.to("cuda")); assert the swap fully materialized so a key-format drift
|
| 334 |
+
# fails here with a clear message instead of silently degrading.
|
| 335 |
+
meta = [n for n, p in transformer.named_parameters() if p.device.type == "meta"]
|
| 336 |
+
if meta:
|
| 337 |
+
raise RuntimeError(
|
| 338 |
+
f"[anima] {entry['label']}: {len(meta)} transformer params unloaded "
|
| 339 |
+
f"(meta) after from_single_file, e.g. {meta[:3]} β key mapping is wrong.")
|
| 340 |
pipe.update_components(transformer=transformer)
|
| 341 |
|
| 342 |
# Finetuned LLM adapter -> the `text_conditioner` component. Its keys match the
|
|
|
|
| 354 |
print(f"[anima] {entry['label']}: no text_conditioner / adapter weights "
|
| 355 |
f"(adapter_tensors={len(adapter_sd)}); using base adapter")
|
| 356 |
|
| 357 |
+
print(f"[anima] {entry['label']}: loaded finetuned DiT ({n_dit} tensors) "
|
| 358 |
+
f"+ adapter ({n_adapter} tensors)")
|
| 359 |
pipe.to("cuda")
|
| 360 |
return pipe
|
| 361 |
|