Studio diffusion (Phase 16) review fixes: native engine robustness
- sd_cpp_backend: stop truncating explicit seeds to 53 bits (mask to int64); a large requested seed was silently collapsed (2**53 -> 0) and distinct seeds aliased to the same image. Random seeds stay 53-bit (JS-safe). - sd_cpp_backend: sanitize empty/whitespace hf_token to None so HfApi/hf_hub fall back to anonymous instead of failing auth on a blank token. - sd_cpp_backend: a superseding load now cancels the in-flight generation, so the old sd-cli can no longer return/persist an image from the previous model. - diffusion_engine_router: run the previous engine's unload() OUTSIDE the lock so a slow 10+ GB free / CUDA sync does not block engine selection. - diffusion_engine_router: probe sd-cli runnability (version()) before committing to native, so a present-but-unrunnable binary falls back to diffusers at selection. - diffusion_device: resolve a torch-free CPU target when torch is unavailable, so a CPU-only install can still reach the native sd.cpp engine instead of failing load. - tests updated for the runnability probe + a not-runnable fallback case.
This commit is contained in:
parent
2823793a97
commit
656d11c731
5 changed files with 84 additions and 10 deletions
|
|
@ -59,8 +59,24 @@ def resolve_diffusion_device_target() -> DiffusionDeviceTarget:
|
|||
(CUDA -> XPU -> MPS -> CPU). On Apple Silicon Studio reports MLX/CPU when its
|
||||
product backend is gated on the ``mlx`` package, but diffusers runs on
|
||||
PyTorch's MPS backend, so those cases still fall through to the MPS probe.
|
||||
|
||||
Torch is optional here: on a CPU-only install without PyTorch the native
|
||||
stable-diffusion.cpp engine still runs (it shells out to sd-cli), so a missing
|
||||
torch reports a torch-free CPU target instead of crashing the whole
|
||||
``/images/load`` before the engine router can select the native backend.
|
||||
"""
|
||||
import torch
|
||||
try:
|
||||
import torch
|
||||
except Exception:
|
||||
return DiffusionDeviceTarget(
|
||||
device = "cpu",
|
||||
dtype = None,
|
||||
backend = "cpu",
|
||||
vendor = None,
|
||||
supports_model_cpu_offload = False,
|
||||
supports_default_torch_compile = False,
|
||||
supports_pinned_transfer = False,
|
||||
)
|
||||
|
||||
try:
|
||||
from utils.hardware import DeviceType, get_device
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue