Files
xiaolibai-sys 164896ed78 bump v1.1.4: nvfp4 support, GPU LoRA fold, loader I/O pipeline, async D2H, unified logging
- nvfp4: _quantization_metadata -> comfy_quant synthesis, SlotEntry extra params (block_scale), dual-scale LoRA fold, orig_dtype fixup
- LoRA: plain-mode block LoRAs no longer silently dropped; folded on GPU after weights land
- loader: parallel positioned reads, pipelined group load, no per-tensor clone, header-only dtype probes
- block swap: read_block intra-block parallel + disk_workers node option; async D2H write-back on transfer stream; lazy evict_all skips wasted write-back
- arch: split models/loader.py out of wan_model.py; single utils/keys.py; LoRA folding consolidated in utils/lora.py; global utils/log.py ([BerniniR][Tag] format, BERNINI_LOG_LEVEL)
2026-07-21 14:07:05 +08:00

26 lines
967 B
Python

"""Canonical safetensors/state-dict key normalisation.
Single authoritative implementation shared by the checkpoint loader
(``models.loader``), the random-access block readers (``utils.block_reader``)
and the LoRA folding helpers (``utils.lora``), so prefix handling can never
drift between the read path and the fold path.
"""
from __future__ import annotations
def _normalize_unet_key(k: str) -> str:
"""Strip common checkpoint prefixes so state-dict keys line up with the
diffusion_model's own keys (``model.diffusion_model.blocks.0...`` →
``blocks.0...``).
"""
if k.startswith("model.diffusion_model."):
return k[len("model.diffusion_model."):]
if k.startswith("model."):
return k[len("model."):]
if k.startswith("video_model."):
return k[len("video_model."):].replace("modulation.modulation", "modulation")
if k.startswith("diffusion_model."):
return k[len("diffusion_model."):]
return k