mirror of
https://github.com/vladmandic/automatic
synced 2026-09-17 16:24:33 +02:00
Merge branch 'dev' into ext-table
This commit is contained in:
@@ -19,7 +19,7 @@ def readfile(filename: str, silent: bool = False, lock: bool = False, *, as_type
|
||||
def readfile(filename: str, silent: bool = False, lock: bool = False) -> dict | list: ...
|
||||
def readfile(filename: str, silent: bool = False, lock: bool = False, *, as_type="") -> dict | list:
|
||||
global locking_available # pylint: disable=global-statement
|
||||
data = {}
|
||||
data = {} if as_type == "dict" else []
|
||||
lock_file = None
|
||||
locked = False
|
||||
if lock and locking_available:
|
||||
@@ -59,11 +59,17 @@ def readfile(filename: str, silent: bool = False, lock: bool = False, *, as_type
|
||||
except Exception:
|
||||
locking_available = False
|
||||
if isinstance(data, list) and as_type == "dict":
|
||||
if not data:
|
||||
return {}
|
||||
log.warning(f"Read: Expected dictionary from '{filename}' but got list")
|
||||
data0 = data[0]
|
||||
if isinstance(data0, dict):
|
||||
return data0
|
||||
return {}
|
||||
if isinstance(data, dict) and as_type == "list":
|
||||
if not data:
|
||||
return []
|
||||
log.warning(f"Read: Expected list from '{filename}' but got dictionary")
|
||||
return [data]
|
||||
return data
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import torch
|
||||
|
||||
from modules import shared, devices
|
||||
|
||||
sdnq_version = "0.1.3"
|
||||
sdnq_version = "0.1.4"
|
||||
|
||||
dtype_dict = {
|
||||
### Integers
|
||||
|
||||
@@ -32,7 +32,7 @@ def pack_float(x: torch.FloatTensor, weights_dtype: str) -> torch.Tensor:
|
||||
x = x.to(dtype=torch.float32).view(torch.int32)
|
||||
|
||||
x = torch.where(
|
||||
torch.greater(
|
||||
torch.gt(
|
||||
torch.bitwise_and(x, -(1 << (mantissa_difference-4)) & ~(-mantissa_mask)),
|
||||
(1 << (mantissa_difference-1)),
|
||||
),
|
||||
|
||||
@@ -391,7 +391,7 @@ def sdnq_quantize_layer_weight(weight, layer_class_name=None, weights_dtype="int
|
||||
|
||||
|
||||
@devices.inference_context()
|
||||
def sdnq_quantize_layer_weight_dynamic(weight, layer_class_name=None, weights_dtype="int2", quantized_matmul_dtype=None, torch_dtype=None, group_size=0, svd_rank=32, svd_steps=8, dynamic_loss_threshold=1e-2, use_svd=False, use_quantized_matmul=False, use_dynamic_quantization=False, use_stochastic_rounding=False, dequantize_fp32=False, svd_up=None, svd_down=None, param_name=None): # pylint: disable=unused-argument
|
||||
def sdnq_quantize_layer_weight_dynamic(weight, layer_class_name=None, weights_dtype="int2", quantized_matmul_dtype=None, torch_dtype=None, group_size=0, svd_rank=32, svd_steps=8, dynamic_loss_threshold=1e-2, use_svd=False, use_quantized_matmul=False, use_dynamic_quantization=False, use_stochastic_rounding=False, dequantize_fp32=False, param_name=None): # pylint: disable=unused-argument
|
||||
if torch_dtype is None:
|
||||
torch_dtype = weight.dtype
|
||||
weights_dtype_order_to_use = weights_dtype_order_fp32 if torch_dtype in {torch.float32, torch.float64} else weights_dtype_order
|
||||
@@ -431,7 +431,7 @@ def sdnq_quantize_layer_weight_dynamic(weight, layer_class_name=None, weights_dt
|
||||
param_name=param_name,
|
||||
)
|
||||
|
||||
if not svd_is_transposed and sdnq_dequantizer.use_quantized_matmul:
|
||||
if use_svd and not svd_is_transposed and sdnq_dequantizer.use_quantized_matmul:
|
||||
svd_up = svd_up.t_()
|
||||
svd_down = svd_down.t_()
|
||||
svd_is_transposed = True
|
||||
|
||||
@@ -40,7 +40,7 @@ def list_extensions():
|
||||
fn = os.path.join(paths.script_path, "html", "extensions.json")
|
||||
extensions_list = shared.readfile(fn, silent=True, as_type="list")
|
||||
if len(extensions_list) == 0:
|
||||
shared.log.info(f'Extension list is empty or invalid. Try refreshing or verifying downloaded data. file="{fn}"')
|
||||
shared.log.info("Extension List: No information found. Refresh required.")
|
||||
found = []
|
||||
for ext in extensions.extensions:
|
||||
ext.read_info()
|
||||
@@ -107,7 +107,7 @@ def check_updates(_id_task, disable_list, search_text, sort_column):
|
||||
ext.check_updates()
|
||||
if ext.can_update:
|
||||
ext.git_fetch()
|
||||
ext.read_info(True)
|
||||
ext.read_info()
|
||||
commit_date = ext.commit_date or 1577836800
|
||||
shared.log.info(f'Extensions updated: {ext.name} {ext.commit_hash[:8]} {extensions.format_dt(extensions.ts2utc(commit_date), seconds=True)}')
|
||||
else:
|
||||
@@ -228,7 +228,7 @@ def update_extension(extension_path, search_text, sort_column):
|
||||
ext.check_updates()
|
||||
if ext.can_update:
|
||||
ext.git_fetch()
|
||||
ext.read_info(True)
|
||||
ext.read_info()
|
||||
commit_date = ext.commit_date or 1577836800
|
||||
shared.log.info(f'Extensions updated: {ext.name} {ext.commit_hash[:8]} {extensions.format_dt(extensions.ts2utc(commit_date), seconds=True)}')
|
||||
else:
|
||||
@@ -339,7 +339,7 @@ def create_html(search_text, sort_column):
|
||||
debug(f'Extension not from github: name={ext["name"]} url={ext["url"]}')
|
||||
except Exception as e:
|
||||
debug(f'Extension get updated error: name={ext["name"]} url={ext["url"]} {e}')
|
||||
local_ver_date = datetime.fromtimestamp(ext['commit_date'], timezone.utc) # TZ-aware
|
||||
local_ver_date = extensions.ts2utc(ext['commit_date']) # TZ-aware
|
||||
update_available = (installed is not None) and (not ext['is_builtin']) and (ext['remote'] is not None) and (updated > local_ver_date) # TZ-aware
|
||||
if update_available:
|
||||
debug(f'Extension update available: name={ext["name"]} updated={extensions.format_dt(updated, seconds=True)} commit={extensions.format_dt(local_ver_date, seconds=True)}') # TZ-aware
|
||||
|
||||
Reference in New Issue
Block a user