From e6d97f4d44dac2105c05e6e83e79c6c77e3073b6 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 7 Jul 2025 19:45:30 -0400 Subject: [PATCH] monkeypatch numpy for gradio Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 3 ++- TODO.md | 7 ++++--- modules/loader.py | 9 ++++++++- modules/sdnq/__init__.py | 5 ++++- wiki | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be344276e..1a43554fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,7 +93,8 @@ Although upgrades and existing installations are tested and should work fine! - override `gradio` installer - major refactoring of requirements and dependencies to unblock `numpy>=2.1.0` - patch `insightface` - - patch `facelib` + - patch `facelib` + - patch `numpy` - stronger lint rules add separate `npm run lint`, `npm run todo`, `npm run test`, `npm run format` macros diff --git a/TODO.md b/TODO.md index 3f9aa76c1..67e573184 100644 --- a/TODO.md +++ b/TODO.md @@ -4,16 +4,15 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma ## Current +- Bug: FramePack with SQND + ## Future Candidates - Feature: Common repo for `T5` and `CLiP` - Feature: LoRA add OMI format support for SD35/FLUX.1 - Feature: Merge FramePack into core - Refactor: sampler options -- Refactor: cleanup `/repositories/codeformer` -- Remove: Agent Scheduler - Video: API support -- ModernUI: Lite vs Expert mode ### Blocked items @@ -32,6 +31,8 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma - [Nunchaku PulID](https://github.com/mit-han-lab/nunchaku/pull/274) - [Dream0 guidance](https://huggingface.co/ByteDance/DreamO) - [SUPIR upscaler](https://github.com/Fanghua-Yu/SUPIR) +- Remove: Agent Scheduler +- ModernUI: Lite vs Expert mode ### Future Considerations - [TensorRT](https://github.com/huggingface/diffusers/pull/11173) diff --git a/modules/loader.py b/modules/loader.py index 9d364daad..7f5449380 100644 --- a/modules/loader.py +++ b/modules/loader.py @@ -18,10 +18,16 @@ np = None try: import numpy as np # pylint: disable=W0611,C0411 import numpy.random # pylint: disable=W0611,C0411 # this causes failure if numpy version changed + def obj2sctype(obj): + return np.dtype(obj).type + np.obj2sctype = obj2sctype # noqa: NPY201 + np.bool8 = np.bool + np.float_ = np.float64 # noqa: NPY201 except Exception as e: errors.log.error(f'Loader: numpy=={np.__version__ if np is not None else None} {e}') errors.log.error('Please restart the app to fix this issue') sys.exit(1) +timer.startup.record("numpy") try: import scipy # pylint: disable=W0611,C0411 @@ -29,6 +35,7 @@ except Exception as e: errors.log.error(f'Loader: scipy=={np.__version__ if np is not None else None} {e}') errors.log.error('Please restart the app to fix this issue') sys.exit(1) +timer.startup.record("scipy") import torch # pylint: disable=C0411 if torch.__version__.startswith('2.5.0'): @@ -64,12 +71,12 @@ if ".dev" in torch.__version__ or "+git" in torch.__version__: torch.__version__ = re.search(r'[\d.]+[\d]', torch.__version__).group(0) timer.startup.record("torch") - try: import bitsandbytes # pylint: disable=W0611,C0411 except Exception: from diffusers.utils import import_utils import_utils._bitsandbytes_available = False # pylint: disable=protected-access +timer.startup.record("bnb") import transformers # pylint: disable=W0611,C0411 from transformers import logging as transformers_logging # pylint: disable=W0611,C0411 diff --git a/modules/sdnq/__init__.py b/modules/sdnq/__init__.py index 22fdf3ed3..69c5f78a9 100644 --- a/modules/sdnq/__init__.py +++ b/modules/sdnq/__init__.py @@ -54,7 +54,10 @@ def sdnq_quantize_layer(layer, weights_dtype="int8", torch_dtype=None, group_siz else: is_linear_type = True reduction_axes = -1 - output_channel_size, channel_size = layer.weight.shape + try: + output_channel_size, channel_size = layer.weight.shape + except Exception as e: + raise ValueError(f"SDNQ: layer_class_name={layer_class_name} layer_weight_shape={layer.weight.shape} weights_dtype={weights_dtype} unsupported") from e if use_quantized_matmul: use_quantized_matmul = weights_dtype in quantized_matmul_dtypes and channel_size >= 32 and output_channel_size >= 32 if use_quantized_matmul: diff --git a/wiki b/wiki index 5f7416649..0cd1d57c1 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 5f7416649949e5cc014e1d94aff2aa47195180dd +Subproject commit 0cd1d57c1dc175ac5e375656815817feb00404a0