add chronoedit prequants and lora loading

Signed-off-by: Vladimir Mandic <mandic00@live.com>
pull/4321/head
Vladimir Mandic 2025-10-31 11:04:28 -04:00
parent 0b3248c90a
commit 526472a921
7 changed files with 49 additions and 17 deletions

View File

@ -80,6 +80,7 @@ Less than 2 weeks since last release, here's a service-pack style update with a
- log available attention mechanisms on startup
- support for switching back-and-forth **t2i** and **t2v** for *wan-2.x* models
- control `api` cache controlnets
- additional model modules **deduplication** for both normal and pre-quant models: *umt5, qwen25-vl*
- **Fixes**
- startup error with `--profile` enabled if using `--skip`
- restore orig init image for each batch sequence

View File

@ -1013,9 +1013,19 @@
"size": 16.10,
"extras": ""
},
"Tencent HunyuanImage 3.0": {
"nVidia ChronoEdit sdnq-svd-uint4": {
"path": "Disty0/ChronoEdit-14B-SDNQ-uint4-svd-r32",
"preview": "nvidia--ChronoEdit-14B-Diffusers.jpg",
"desc": "Quantization of nvidia/ChronoEdit-14B-Diffusers using SDNQ: sdnq-svd 4-bit uint with svd rank 32.",
"skip": true,
"tags": "quantized",
"date": "2025 October",
"size": 18.10,
"extras": ""
},
"Tencent HunyuanImage 3.0 sdnq-svd-uint4": {
"path": "Disty0/HunyuanImage3-SDNQ-uint4-svd-r32",
"desc": "HunyuanImage-3.0 is a groundbreaking native multimodal model that unifies multimodal understanding and generation within an autoregressive framework.",
"desc": "Quantization of tencent/HunyuanImage-3.0 using SDNQ: sdnq-svd 4-bit uint with svd rank 32.",
"preview": "Disty0--HunyuanImage3-SDNQ-uint4-svd-r32.jpg",
"extras": "",
"skip": true,

View File

@ -13,6 +13,9 @@ available_network_aliases = {}
forbidden_network_aliases = {}
available_network_hash_lookup = {}
dump_lora_keys = os.environ.get('SD_LORA_DUMP', None) is not None
exclude_errors = [
"'ChronoEditTransformer3DModel'",
]
def lora_dump(lora, dct):
@ -285,7 +288,8 @@ def network_load(names, te_multipliers=None, unet_multipliers=None, dyn_dims=Non
shared.log.trace(f'Network load: type=LoRA active={sd_model.get_active_adapters()}')
sd_model.set_adapters(adapter_names=lora_diffusers.diffuser_loaded, adapter_weights=lora_diffusers.diffuser_scales)
except Exception as e:
shared.log.error(f'Network load: type=LoRA action=set {e}')
if str(e) not in exclude_errors:
shared.log.error(f'Network load: type=LoRA action=strength {str(e)}')
if l.debug:
errors.display(e, 'LoRA')
try:
@ -294,7 +298,7 @@ def network_load(names, te_multipliers=None, unet_multipliers=None, dyn_dims=Non
sd_model.unload_lora_weights()
l.timer.activate += time.time() - t1
except Exception as e:
shared.log.error(f'Network load: type=LoRA action=fuse {e}')
shared.log.error(f'Network load: type=LoRA action=fuse {str(e)}')
if l.debug:
errors.display(e, 'LoRA')

View File

@ -38,10 +38,12 @@ force_models_diffusers = [ # forced always
'bria',
'flite',
'cosmos',
'chrono',
# video models
'hunyuanvideo',
'cogvideo',
'wanai',
'chrono',
'ltxvideo',
'mochivideo',
'allegrovideo',

View File

@ -76,8 +76,10 @@ def get_model_type(pipe):
elif "Allegro" in name:
model_type = 'allegrovideo'
# hybrid models
elif 'Wan' in name or 'ChronoEdit' in name:
elif 'Wan' in name:
model_type = 'wanai'
if 'ChronoEdit' in name:
model_type = 'chrono'
elif 'HDM-xut' in name:
model_type = 'hdm'
elif 'HunyuanImage3' in name:

View File

@ -36,7 +36,7 @@ prev_cls = ''
prev_type = ''
prev_model = ''
lock = threading.Lock()
supported = ['sd', 'sdxl', 'sd3', 'f1', 'h1', 'lumina2', 'hunyuanvideo', 'wanai', 'mochivideo', 'pixartsigma', 'pixartalpha', 'hunyuandit', 'omnigen', 'qwen']
supported = ['sd', 'sdxl', 'sd3', 'f1', 'h1', 'lumina2', 'hunyuanvideo', 'wanai', 'chrono', 'mochivideo', 'pixartsigma', 'pixartalpha', 'hunyuandit', 'omnigen', 'qwen']
def warn_once(msg, variant=None):
@ -59,7 +59,7 @@ def get_model(model_type = 'decoder', variant = None):
model_cls = 'sdxl'
elif model_cls in {'h1', 'lumina2', 'chroma'}:
model_cls = 'f1'
elif model_cls in {'wanai', 'qwen'}:
elif model_cls in {'wanai', 'qwen', 'chrono'}:
variant = variant or 'TAE WanVideo'
elif model_cls not in supported:
warn_once(f'cls={shared.sd_model.__class__.__name__} type={model_cls} unsuppported', variant=variant)

View File

@ -1,3 +1,4 @@
import sys
import transformers
from modules import shared, devices, sd_models, model_quant, sd_hijack_te, sd_hijack_vae
from pipelines import generic
@ -19,19 +20,31 @@ def load_chrono(checkpoint_info, diffusers_load_config=None):
load_args, _quant_args = model_quant.get_dit_args(diffusers_load_config, allow_quant=False)
shared.log.debug(f'Load model: type=ChronoEdit repo="{repo_id}" config={diffusers_load_config} offload={shared.opts.diffusers_offload_mode} dtype={devices.dtype} args={load_args}')
from pipelines.chrono.pipeline_chronoedit import ChronoEditPipeline as pipe_cls
from pipelines.chrono.transformer_chronoedit import ChronoEditTransformer3DModel
from pipelines.chrono import pipeline_chronoedit
from pipelines.chrono import transformer_chronoedit
transformer = generic.load_transformer(repo_id, cls_name=ChronoEditTransformer3DModel, load_config=diffusers_load_config, subfolder="transformer")
# monkey patch for <https://huggingface.co/Disty0/ChronoEdit-14B-SDNQ-uint4-svd-r32/blob/main/model_index.json>
import pipelines.chrono
sys.modules['chronoedit_diffusers'] = pipelines.chrono
from diffusers.pipelines import pipeline_loading_utils
pipeline_loading_utils.LOADABLE_CLASSES['chronoedit_diffusers.transformer_chronoedit'] = {}
transformer = generic.load_transformer(repo_id, cls_name=transformer_chronoedit.ChronoEditTransformer3DModel, load_config=diffusers_load_config, subfolder="transformer")
text_encoder = generic.load_text_encoder(repo_id, cls_name=transformers.UMT5EncoderModel, load_config=diffusers_load_config, subfolder="text_encoder")
pipe = pipe_cls.from_pretrained(
repo_id,
transformer=transformer,
text_encoder=text_encoder,
cache_dir=shared.opts.diffusers_dir,
**load_args,
)
try:
pipe = pipeline_chronoedit.ChronoEditPipeline.from_pretrained(
repo_id,
transformer=transformer,
text_encoder=text_encoder,
cache_dir=shared.opts.diffusers_dir,
**load_args,
)
except Exception as e:
import os
from modules import errors
errors.display(e, 'Chrono')
os._exit(1)
pipe.postprocess = postprocess
pipe.task_args = {
'num_temporal_reasoning_steps': shared.opts.model_chrono_temporal_steps,