mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 08:44:33 +02:00
@@ -182,7 +182,7 @@ def make_lora(fn, maxrank, auto_rank, rank_ratio, modules, overwrite):
|
||||
progress.remove_task(task)
|
||||
t3 = time.time()
|
||||
|
||||
# TODO: Handle quant for Flux
|
||||
# TODO: make lora for quantized flux
|
||||
# if 'te' in modules and getattr(shared.sd_model, 'transformer', None) is not None:
|
||||
# for name, module in shared.sd_model.transformer.named_modules():
|
||||
# if "norm" in name and "linear" not in name:
|
||||
|
||||
@@ -149,7 +149,7 @@ def load_quants(kwargs, repo_id, cache_dir):
|
||||
quant_args = model_quant.create_bnb_config(quant_args)
|
||||
quant_args = model_quant.create_ao_config(quant_args)
|
||||
if not quant_args:
|
||||
return
|
||||
return kwargs
|
||||
model_quant.load_bnb(f'Load model: type=FLUX quant={quant_args}')
|
||||
if 'Model' in shared.opts.bnb_quantization and 'transformer' not in kwargs:
|
||||
kwargs['transformer'] = diffusers.FluxTransformer2DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=cache_dir, torch_dtype=devices.dtype, **quant_args)
|
||||
@@ -208,7 +208,7 @@ def load_transformer(file_path): # triggered by opts.sd_unet change
|
||||
_transformer, _text_encoder_2 = load_flux_bnb(file_path, diffusers_load_config)
|
||||
if _transformer is not None:
|
||||
transformer = _transformer
|
||||
elif 'nf4' in quant: # TODO right now this is not working for civitai published nf4 models
|
||||
elif 'nf4' in quant: # TODO fix flux loader for civitai nf4 models
|
||||
from modules.model_flux_nf4 import load_flux_nf4
|
||||
_transformer, _text_encoder_2 = load_flux_nf4(file_path)
|
||||
if _transformer is not None:
|
||||
|
||||
@@ -13,7 +13,7 @@ def load_quants(kwargs, repo_id, cache_dir):
|
||||
quant_args = model_quant.create_ao_config(quant_args)
|
||||
load_args = kwargs.copy()
|
||||
if not quant_args:
|
||||
return
|
||||
return kwargs
|
||||
model_quant.load_bnb(f'Load model: type=SD3 quant={quant_args} args={load_args}')
|
||||
if 'Model' in shared.opts.bnb_quantization and 'transformer' not in kwargs:
|
||||
kwargs['transformer'] = diffusers.models.SanaTransformer2DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=cache_dir, **load_args, **quant_args)
|
||||
|
||||
@@ -55,7 +55,7 @@ def load_quants(kwargs, repo_id, cache_dir):
|
||||
quant_args = model_quant.create_bnb_config(quant_args)
|
||||
quant_args = model_quant.create_ao_config(quant_args)
|
||||
if not quant_args:
|
||||
return
|
||||
return kwargs
|
||||
model_quant.load_bnb(f'Load model: type=SD3 quant={quant_args}')
|
||||
if 'Model' in shared.opts.bnb_quantization and 'transformer' not in kwargs:
|
||||
kwargs['transformer'] = diffusers.SD3Transformer2DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=cache_dir, torch_dtype=devices.dtype, **quant_args)
|
||||
|
||||
@@ -170,7 +170,7 @@ class StableDiffusionProcessing:
|
||||
self.image_cfg_scale = image_cfg_scale
|
||||
self.scale_by = scale_by
|
||||
self.mask = mask
|
||||
self.image_mask = mask # TODO duplciate mask params
|
||||
self.image_mask = mask # TODO remove duplicate mask params
|
||||
self.latent_mask = latent_mask
|
||||
self.mask_blur = mask_blur
|
||||
self.inpainting_fill = inpainting_fill
|
||||
|
||||
@@ -1495,7 +1495,7 @@ def reload_model_weights(sd_model=None, info=None, reuse_dict=False, op='model',
|
||||
unload_model_weights(op=op)
|
||||
sd_model = None
|
||||
timer = Timer()
|
||||
# TODO implement caching after diffusers implement state_dict loading
|
||||
# TODO implement model in-memory caching
|
||||
state_dict = get_checkpoint_state_dict(checkpoint_info, timer) if not shared.native else None
|
||||
checkpoint_config = sd_models_config.find_checkpoint_config(state_dict, checkpoint_info)
|
||||
timer.record("config")
|
||||
|
||||
@@ -515,7 +515,7 @@ def torchao_quantization(sd_model):
|
||||
if fn is None:
|
||||
shared.log.error(f"Quantization: type=TorchAO type={shared.opts.torchao_quantization_type} not supported")
|
||||
return sd_model
|
||||
def torchao_model(model, op=None, sd_model=None):
|
||||
def torchao_model(model, op=None, sd_model=None): # pylint: disable=unused-argument
|
||||
q.quantize_(model, fn(), device=devices.device)
|
||||
return model
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import time
|
||||
import torch
|
||||
import safetensors.torch
|
||||
from PIL import Image
|
||||
from modules import shared, devices, sd_models, errors
|
||||
from modules import shared, devices, errors
|
||||
from modules.textual_inversion.image_embedding import embedding_from_b64, extract_image_data_embed
|
||||
from modules.files_cache import directory_files, directory_mtime, extension_filter
|
||||
|
||||
|
||||
Reference in New Issue
Block a user