diff --git a/.github/skills/github-issues/SKILL.md b/.github/skills/github-issues/SKILL.md index 4e929fa5b..ad8bd88f8 100644 --- a/.github/skills/github-issues/SKILL.md +++ b/.github/skills/github-issues/SKILL.md @@ -1,6 +1,6 @@ --- name: github-issues -description: "Read SD.Next GitHub issues with [Issues] in the title and generate a markdown report with short summary, status, and suggested next steps per issue." +description: "Read SD.Next GitHub issues with [Issue] in the title and generate a markdown report with short summary, status, and suggested next steps per issue." argument-hint: "Optionally specify state (open/closed/all), max issues, and whether to include labels/assignees" --- @@ -34,11 +34,11 @@ Create markdown containing, for each matching issue: ### 1. Search Matching Issues -Use GitHub search to find issues with `[Issues]` in title. +Use GitHub search to find issues with `[Issue]` in title. Preferred search query template: -- `is:issue in:title "[Issues]" repo:vladmandic/sdnext` +- `is:issue in:title "[Issue]" repo:vladmandic/sdnext` State filters (when requested): @@ -96,7 +96,7 @@ If there are many issues, keep summaries short and prioritize clarity. A successful run must: -- search SD.Next issues with `[Issues]` in title +- search SD.Next issues with `[Issue]` in title - include all matched issues in scope (or explicitly mention applied limit) - provide summary, status, and suggested next steps for each issue - return the final result as markdown diff --git a/modules/lora/lora_apply.py b/modules/lora/lora_apply.py index 21f26ea2c..0c3ff6ef3 100644 --- a/modules/lora/lora_apply.py +++ b/modules/lora/lora_apply.py @@ -13,12 +13,10 @@ if TYPE_CHECKING: import diffusers.models.lora -bnb = None re_network_name = re.compile(r"(.*)\s*\([0-9a-fA-F]+\)") def network_backup_weights(self: torch.nn.Conv2d | torch.nn.Linear | torch.nn.GroupNorm | torch.nn.LayerNorm | diffusers.models.lora.LoRACompatibleLinear | diffusers.models.lora.LoRACompatibleConv, network_layer_name: str, wanted_names: tuple): - global bnb # pylint: disable=W0603 backup_size = 0 if len(l.loaded_networks) > 0 and network_layer_name is not None and any([net.modules.get(network_layer_name, None) for net in l.loaded_networks]): # noqa: C419 # pylint: disable=R1729 t0 = time.time() @@ -35,35 +33,23 @@ def network_backup_weights(self: torch.nn.Conv2d | torch.nn.Linear | torch.nn.Gr if weights_backup is None and wanted_names != (): # pylint: disable=C1803 weight = getattr(self, 'weight', None) self.network_weights_backup = None - if getattr(weight, "quant_type", None) in ['nf4', 'fp4']: - if bnb is None: - bnb = model_quant.load_bnb('Network load: type=LoRA', silent=True) - if bnb is not None: - if shared.opts.lora_fuse_native: - self.network_weights_backup = True - else: - self.network_weights_backup = bnb.functional.dequantize_4bit(weight, quant_state=weight.quant_state, quant_type=weight.quant_type, blocksize=weight.blocksize,) - self.quant_state, self.quant_type, self.blocksize = weight.quant_state, weight.quant_type, weight.blocksize - else: - self.network_weights_backup = weight.clone().to(devices.cpu) if not shared.opts.lora_fuse_native else True + if shared.opts.lora_fuse_native: + self.network_weights_backup = True else: - if shared.opts.lora_fuse_native: - self.network_weights_backup = True - else: - self.network_weights_backup = weight.clone().to(devices.cpu) - if hasattr(self, "sdnq_dequantizer"): - self.sdnq_dequantizer_backup = self.sdnq_dequantizer - self.sdnq_scale_backup = self.scale.clone().to(devices.cpu) - if self.zero_point is not None: - self.sdnq_zero_point_backup = self.zero_point.clone().to(devices.cpu) - else: - self.sdnq_zero_point_backup = None - if self.svd_up is not None: - self.sdnq_svd_up_backup = self.svd_up.clone().to(devices.cpu) - self.sdnq_svd_down_backup = self.svd_down.clone().to(devices.cpu) - else: - self.sdnq_svd_up_backup = None - self.sdnq_svd_down_backup = None + self.network_weights_backup = weight.clone().to(devices.cpu) + if hasattr(self, "sdnq_dequantizer"): + self.sdnq_dequantizer_backup = self.sdnq_dequantizer + self.sdnq_scale_backup = self.scale.clone().to(devices.cpu) + if self.zero_point is not None: + self.sdnq_zero_point_backup = self.zero_point.clone().to(devices.cpu) + else: + self.sdnq_zero_point_backup = None + if self.svd_up is not None: + self.sdnq_svd_up_backup = self.svd_up.clone().to(devices.cpu) + self.sdnq_svd_down_backup = self.svd_down.clone().to(devices.cpu) + else: + self.sdnq_svd_up_backup = None + self.sdnq_svd_down_backup = None if bias_backup is None: if getattr(self, 'bias', None) is not None: @@ -161,16 +147,7 @@ def network_add_weights(self: torch.nn.Conv2d | torch.nn.Linear | torch.nn.Group if model_weights is None: # weights are used if provided-from-backup else use self.weight model_weights = self.weight weight, new_weight = None, None - if self.__class__.__name__ == 'Linear4bit' and bnb is not None: - try: - dequant_weight = bnb.functional.dequantize_4bit(model_weights.to(devices.device), quant_state=self.quant_state, quant_type=self.quant_type, blocksize=self.blocksize) - new_weight = dequant_weight.to(devices.device) + lora_weights.to(devices.device) - weight = bnb.nn.Params4bit(new_weight.to(device), quant_state=self.quant_state, quant_type=self.quant_type, blocksize=self.blocksize, requires_grad=False) - # TODO lora: maybe force imediate quantization - # weight._quantize(devices.device) / weight.to(device=device) - except Exception as e: - log.error(f'Network load: type=LoRA quant=bnb cls={self.__class__.__name__} type={self.quant_type} blocksize={self.blocksize} state={vars(self.quant_state)} weight={self.weight} bias={lora_weights} {e}') - elif not bias and hasattr(self, "sdnq_dequantizer"): + if not bias and hasattr(self, "sdnq_dequantizer"): try: from modules.sdnq import sdnq_quantize_layer if hasattr(self, "sdnq_dequantizer_backup"): diff --git a/modules/model_quant.py b/modules/model_quant.py index 2259670bc..93ec598d6 100644 --- a/modules/model_quant.py +++ b/modules/model_quant.py @@ -8,9 +8,6 @@ from installer import install from modules.logger import log -ao = None -bnb = None -optimum_quanto = None trt = None quant_last_model_name = None quant_last_model_device = None