diff --git a/invokeai/backend/model_manager/load/model_loaders/krea2.py b/invokeai/backend/model_manager/load/model_loaders/krea2.py index fbd681c8025..2c28661479d 100644 --- a/invokeai/backend/model_manager/load/model_loaders/krea2.py +++ b/invokeai/backend/model_manager/load/model_loaders/krea2.py @@ -409,7 +409,7 @@ def _load_from_gguf(self, config: AnyModelConfig) -> AnyModel: model_path = Path(config.path) target_device = TorchDevice.choose_torch_device() - compute_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device) + compute_dtype = TorchDevice.choose_krea2_gguf_dtype(target_device) # GGMLTensor wrappers (kept on CPU; dequantized on-the-fly by the cache during inference). sd = gguf_sd_loader(model_path, compute_dtype=compute_dtype) diff --git a/invokeai/backend/util/devices.py b/invokeai/backend/util/devices.py index 1b53fd521bf..35cb6cae063 100644 --- a/invokeai/backend/util/devices.py +++ b/invokeai/backend/util/devices.py @@ -431,3 +431,18 @@ def choose_anima_inference_dtype(cls, device: Optional[torch.device] = None) -> if config.precision == "auto": return cls.choose_bfloat16_safe_dtype(device) return NAME_TO_PRECISION[config.precision] + + @classmethod + def choose_krea2_gguf_dtype(cls, device: Optional[torch.device] = None) -> torch.dtype: + """Choose the compute dtype for Krea-2 GGUF weights. + + Krea-2 GGUF dequantization in BF16 is unreliable on MPS, so use FP32 there. On other devices, + explicit precision settings are honored and ``auto`` retains the BF16-safe default used by Krea-2. + """ + device = device or cls.choose_torch_device() + if device.type == "mps": + return torch.float32 + config = get_config() + if config.precision == "auto": + return cls.choose_bfloat16_safe_dtype(device) + return NAME_TO_PRECISION[config.precision]