diff --git a/CHANGELOG.md b/CHANGELOG.md index 45ac06a67..05964ddde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,10 +54,11 @@ - **Fixes** - ui: fix image metadata display when switching selected image in control tab - framepack: add explicit hf-login before framepack load + - framepack: patch solver for unsupported gpus - benchmark: remove forced sampler from system info benchmark - xyz-grid: fix xyz grid with random seeds - - fix download for sd15/sdxl reference models - + - reference: fix download for sd15/sdxl reference models + ## Update for 2025-09-15 ### Highlights for 2025-09-15 diff --git a/modules/framepack/framepack_worker.py b/modules/framepack/framepack_worker.py index 1b87334ec..eedbad13b 100644 --- a/modules/framepack/framepack_worker.py +++ b/modules/framepack/framepack_worker.py @@ -54,7 +54,7 @@ def worker( from modules.framepack.pipeline import hunyuan from modules.framepack.pipeline import utils - from modules.framepack.pipeline.k_diffusion_hunyuan import sample_hunyuan + from modules.framepack.pipeline import k_diffusion_hunyuan is_f1 = variant == 'forward-only' total_generated_frames = 0 @@ -244,7 +244,7 @@ def worker( transformer.initialize_teacache(enable_teacache=use_teacache, num_steps=steps, rel_l1_thresh=shared.opts.teacache_thresh) t_sample = time.time() - generated_latents = sample_hunyuan( + generated_latents = k_diffusion_hunyuan.sample_hunyuan( transformer=transformer, sampler='unipc', width=width, diff --git a/modules/framepack/pipeline/uni_pc_fm.py b/modules/framepack/pipeline/uni_pc_fm.py index 6ce7c15ce..2066cd8e3 100644 --- a/modules/framepack/pipeline/uni_pc_fm.py +++ b/modules/framepack/pipeline/uni_pc_fm.py @@ -5,7 +5,7 @@ import torch - +import numpy as np from tqdm.auto import trange @@ -13,6 +13,36 @@ def expand_dims(v, dims): return v[(...,) + (None,) * (dims - 1)] +torch_linalg_solve = None + + +def test_solver(): + from modules import devices, shared + try: + a = torch.randn(50, 50).to(device=devices.device, dtype=torch.float32) + b = torch.randn(50, 2).to(device=devices.device, dtype=torch.float32) + _x = torch.linalg.solve(a, b) + return True + except Exception as e: + shared.log.debug(f'FramePack: solver=cpu {e}') + return False + + +def linalg_solve(A, B, device): + global torch_linalg_solve # pylint: disable=global-statement + if torch_linalg_solve is None: + torch_linalg_solve = test_solver() + if torch_linalg_solve: + X = torch.linalg.solve(A, B) + return X + else: + A_np = A.float().cpu().numpy() + B_np = B.float().cpu().numpy() + X_np = np.linalg.solve(A_np, B_np) + X = torch.from_numpy(X_np).to(device=device, dtype=A.dtype) + return X + + class FlowMatchUniPC: def __init__(self, model, extra_args, variant='bh1'): self.model = model @@ -78,7 +108,7 @@ class FlowMatchUniPC: if order == 2: rhos_p = torch.tensor([0.5], device=b.device) else: - rhos_p = torch.linalg.solve(R[:-1, :-1], b[:-1]) + rhos_p = linalg_solve(R[:-1, :-1], b[:-1], x.device) else: D1s = None rhos_p = None @@ -86,7 +116,7 @@ class FlowMatchUniPC: if order == 1: rhos_c = torch.tensor([0.5], device=b.device) else: - rhos_c = torch.linalg.solve(R, b) + rhos_c = linalg_solve(R, b, x.device) x_t_ = expand_dims(t / t_prev_0, dims) * x - expand_dims(h_phi_1, dims) * model_prev_0 diff --git a/wiki b/wiki index 3df7dbfc9..bd9905932 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 3df7dbfc9c3e2f39c825f8d76541e13d3c3f097d +Subproject commit bd990593287f36d4c76828a2db0eaa019ca0630f