Skip to content

Commit 6846f4e

Browse files
authored
Merge pull request #3586 from vladmandic/dev
Release refresh
2 parents a141e8c + 2b14727 commit 6846f4e

17 files changed

+188
-152
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Change Log for SD.Next
22

3+
## Update for 2024-11-22
4+
5+
- Model loader improvements:
6+
- detect model components on model load fail
7+
- Flux, SD35: force unload model
8+
- Flux: apply `bnb` quant when loading *unet/transformer*
9+
- Flux: all-in-one safetensors
10+
example: <https://civitai.com/models/646328?modelVersionId=1040235>
11+
- Flux: do not recast quants
12+
- Sampler improvements
13+
- update DPM FlowMatch samplers
14+
- Fixes:
15+
- update `diffusers`
16+
- fix README links
17+
- fix sdxl controlnet single-file loader
18+
- relax settings validator
19+
320
## Update for 2024-11-21
421

522
### Highlights for 2024-11-21

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ For screenshots and informations on other available themes, see [Themes Wiki](ht
5656
## Model support
5757

5858
Additional models will be added as they become available and there is public interest in them
59-
See [models overview](wiki/Models) for details on each model, including their architecture, complexity and other info
59+
See [models overview](https://github.com/vladmandic/automatic/wiki/Models) for details on each model, including their architecture, complexity and other info
6060

6161
- [RunwayML Stable Diffusion](https://github.com/Stability-AI/stablediffusion/) 1.x and 2.x *(all variants)*
6262
- [StabilityAI Stable Diffusion XL](https://github.com/Stability-AI/generative-models), [StabilityAI Stable Diffusion 3.0](https://stability.ai/news/stable-diffusion-3-medium) Medium, [StabilityAI Stable Diffusion 3.5](https://huggingface.co/stabilityai/stable-diffusion-3.5-large) Medium, Large, Large Turbo
@@ -101,17 +101,17 @@ See [models overview](wiki/Models) for details on each model, including their ar
101101

102102
## Getting started
103103

104-
- Get started with **SD.Next** by following the [installation instructions](wiki/Installation)
105-
- For more details, check out [advanced installation](wiki/Advanced-Install) guide
106-
- List and explanation of [command line arguments](wiki/CLI-Arguments)
104+
- Get started with **SD.Next** by following the [installation instructions](https://github.com/vladmandic/automatic/wiki/Installation)
105+
- For more details, check out [advanced installation](https://github.com/vladmandic/automatic/wiki/Advanced-Install) guide
106+
- List and explanation of [command line arguments](https://github.com/vladmandic/automatic/wiki/CLI-Arguments)
107107
- Install walkthrough [video](https://www.youtube.com/watch?v=nWTnTyFTuAs)
108108

109109
> [!TIP]
110110
> And for platform specific information, check out
111-
> [WSL](wiki/WSL) | [Intel Arc](wiki/Intel-ARC) | [DirectML](wiki/DirectML) | [OpenVINO](wiki/OpenVINO) | [ONNX & Olive](wiki/ONNX-Runtime) | [ZLUDA](wiki/ZLUDA) | [AMD ROCm](wiki/AMD-ROCm) | [MacOS](wiki/MacOS-Python.md) | [nVidia](wiki/nVidia)
111+
> [WSL](https://github.com/vladmandic/automatic/wiki/WSL) | [Intel Arc](https://github.com/vladmandic/automatic/wiki/Intel-ARC) | [DirectML](https://github.com/vladmandic/automatic/wiki/DirectML) | [OpenVINO](https://github.com/vladmandic/automatic/wiki/OpenVINO) | [ONNX & Olive](https://github.com/vladmandic/automatic/wiki/ONNX-Runtime) | [ZLUDA](https://github.com/vladmandic/automatic/wiki/ZLUDA) | [AMD ROCm](https://github.com/vladmandic/automatic/wiki/AMD-ROCm) | [MacOS](https://github.com/vladmandic/automatic/wiki/MacOS-Python.md) | [nVidia](https://github.com/vladmandic/automatic/wiki/nVidia)
112112
113113
> [!WARNING]
114-
> If you run into issues, check out [troubleshooting](wiki/Troubleshooting) and [debugging](wiki/Debug) guides
114+
> If you run into issues, check out [troubleshooting](https://github.com/vladmandic/automatic/wiki/Troubleshooting) and [debugging](https://github.com/vladmandic/automatic/wiki/Debug) guides
115115
116116
> [!TIP]
117117
> All command line options can also be set via env variable

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma
88
- SD35 LoRA: <https://github.com/huggingface/diffusers/issues/9950>
99
- Flux IPAdapter: <https://github.com/huggingface/diffusers/issues/9825>
1010
- Flux Fill/ControlNet/Redux: <https://github.com/huggingface/diffusers/pull/9985>
11+
- Flux NF4: <https://github.com/huggingface/diffusers/issues/9996>
1112
- SANA: <https://github.com/huggingface/diffusers/pull/9982>
1213

1314
## Other

cli/model-keys.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ def list_to_dict(flat_list):
3838
return result_dict
3939

4040

41+
def list_compact(flat_list):
42+
result_list = []
43+
for item in flat_list:
44+
keys = item.split('.')
45+
keys = '.'.join(keys[:2])
46+
if keys not in result_list:
47+
result_list.append(keys)
48+
return result_list
49+
50+
4151
def guess_dct(dct: dict):
4252
# if has(dct, 'model.diffusion_model.input_blocks') and has(dct, 'model.diffusion_model.label_emb'):
4353
# return 'sdxl'
@@ -65,7 +75,9 @@ def read_keys(fn):
6575
except Exception as e:
6676
pprint(e)
6777
dct = list_to_dict(keys)
78+
lst = list_compact(keys)
6879
pprint(f'file: {fn}')
80+
pprint(lst)
6981
pprint(remove_entries_after_depth(dct, 3))
7082
pprint(remove_entries_after_depth(dct, 6))
7183
guess = guess_dct(dct)

installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def check_python(supported_minors=[9, 10, 11, 12], reason=None):
459459
def check_diffusers():
460460
if args.skip_all or args.skip_requirements:
461461
return
462-
sha = 'cd6ca9df2987c000b28e13b19bd4eec3ef3c914b'
462+
sha = 'b5fd6f13f5434d69d919cc8cedf0b11db664cf06'
463463
pkg = pkg_resources.working_set.by_key.get('diffusers', None)
464464
minor = int(pkg.version.split('.')[1] if pkg is not None else 0)
465465
cur = opts.get('diffusers_version', '') if minor > 0 else ''

modules/model_flux.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def load_transformer(file_path): # triggered by opts.sd_unet change
194194
if _transformer is not None:
195195
transformer = _transformer
196196
else:
197+
diffusers_load_config = model_quant.create_bnb_config(diffusers_load_config)
197198
transformer = diffusers.FluxTransformer2DModel.from_single_file(file_path, **diffusers_load_config)
198199
if transformer is None:
199200
shared.log.error('Failed to load UNet model')
@@ -213,6 +214,11 @@ def load_flux(checkpoint_info, diffusers_load_config): # triggered by opts.sd_ch
213214
text_encoder_2 = None
214215
vae = None
215216

217+
# unload current model
218+
sd_models.unload_model_weights()
219+
shared.sd_model = None
220+
devices.torch_gc(force=True)
221+
216222
# load overrides if any
217223
if shared.opts.sd_unet != 'None':
218224
try:
@@ -305,8 +311,21 @@ def load_flux(checkpoint_info, diffusers_load_config): # triggered by opts.sd_ch
305311
repo_id = 'black-forest-labs/FLUX.1-dev' # workaround since sayakpaul model is missing model_index.json
306312
for c in kwargs:
307313
if kwargs[c].dtype == torch.float32 and devices.dtype != torch.float32:
308-
shared.log.warning(f'Load model: type=FLUX component={c} dtype={kwargs[c].dtype} cast dtype={devices.dtype}')
314+
shared.log.warning(f'Load model: type=FLUX component={c} dtype={kwargs[c].dtype} cast dtype={devices.dtype} recast')
309315
kwargs[c] = kwargs[c].to(dtype=devices.dtype)
310-
kwargs = model_quant.create_bnb_config(kwargs)
311-
pipe = diffusers.FluxPipeline.from_pretrained(repo_id, cache_dir=shared.opts.diffusers_dir, **kwargs, **diffusers_load_config)
316+
317+
allow_bnb = 'gguf' not in (sd_unet.loaded_unet or '')
318+
kwargs = model_quant.create_bnb_config(kwargs, allow_bnb)
319+
if checkpoint_info.path.endswith('.safetensors') and os.path.isfile(checkpoint_info.path):
320+
pipe = diffusers.FluxPipeline.from_single_file(checkpoint_info.path, cache_dir=shared.opts.diffusers_dir, **kwargs, **diffusers_load_config)
321+
else:
322+
pipe = diffusers.FluxPipeline.from_pretrained(repo_id, cache_dir=shared.opts.diffusers_dir, **kwargs, **diffusers_load_config)
323+
324+
# release memory
325+
transformer = None
326+
text_encoder_1 = None
327+
text_encoder_2 = None
328+
vae = None
329+
devices.torch_gc()
330+
312331
return pipe

modules/model_quant.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
quanto = None
88

99

10-
def create_bnb_config(kwargs = None):
10+
def create_bnb_config(kwargs = None, allow_bnb: bool = True):
1111
from modules import shared, devices
12-
if len(shared.opts.bnb_quantization) > 0:
13-
if 'Model' in shared.opts.bnb_quantization and 'transformer' not in (kwargs or {}):
12+
if len(shared.opts.bnb_quantization) > 0 and allow_bnb:
13+
if 'Model' in shared.opts.bnb_quantization:
1414
load_bnb()
1515
bnb_config = diffusers.BitsAndBytesConfig(
1616
load_in_8bit=shared.opts.bnb_quantization_type in ['fp8'],

modules/model_sd3.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ def load_sd3(checkpoint_info, cache_dir=None, config=None):
120120
repo_id = sd_models.path_to_repo(checkpoint_info.name)
121121
fn = checkpoint_info.path
122122

123+
# unload current model
124+
sd_models.unload_model_weights()
125+
shared.sd_model = None
126+
devices.torch_gc(force=True)
127+
123128
kwargs = {}
124129
kwargs = load_overrides(kwargs, cache_dir)
125130
if fn is None or not os.path.exists(fn):
@@ -152,5 +157,5 @@ def load_sd3(checkpoint_info, cache_dir=None, config=None):
152157
config=config,
153158
**kwargs,
154159
)
155-
devices.torch_gc(force=True)
160+
devices.torch_gc()
156161
return pipe

modules/model_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ def remove_entries_after_depth(d, depth, current_depth=0):
1313
return d
1414

1515

16+
def list_compact(flat_list):
17+
result_list = []
18+
for item in flat_list:
19+
keys = item.split('.')
20+
keys = '.'.join(keys[:2])
21+
if keys not in result_list:
22+
result_list.append(keys)
23+
return result_list
24+
25+
1626
def list_to_dict(flat_list):
1727
result_dict = {}
1828
try:

0 commit comments

Comments
 (0)