Commit Graph

8 Commits (39eae9f009c8302eed77b0942e1e634f6125d53e)

Author SHA1 Message Date
hidenorly 39eae9f009 Revert "Add FP32 fallback support on sd_vae_approx"
This reverts commit 58c19545c8.
Since the modification is expected to move to mac_specific.py
(https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/14046#issuecomment-1826731532)
2023-11-29 04:07:48 +09:00
hidenorly 58c19545c8 Add FP32 fallback support on sd_vae_approx
This tries to execute interpolate with FP32 if it failed.

Background is that
on some environment such as Mx chip MacOS devices, we get error as follows:

```
"torch/nn/functional.py", line 3931, in interpolate
        return torch._C._nn.upsample_nearest2d(input, output_size, scale_factors)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: "upsample_nearest2d_channels_last" not implemented for 'Half'
```

In this case, ```--no-half``` doesn't help to solve. Therefore this commits add the FP32 fallback execution to solve it.

Note that the submodule may require additional modifications. The following is the example modification on the other submodule.

```repositories/stable-diffusion-stability-ai/ldm/modules/diffusionmodules/openaimodel.py

class Upsample(nn.Module):
..snip..
    def forward(self, x):
        assert x.shape[1] == self.channels
        if self.dims == 3:
            x = F.interpolate(
                x, (x.shape[2], x.shape[3] * 2, x.shape[4] * 2), mode="nearest"
            )
        else:
            try:
                x = F.interpolate(x, scale_factor=2, mode="nearest")
            except:
                x = F.interpolate(x.to(th.float32), scale_factor=2, mode="nearest").to(x.dtype)
        if self.use_conv:
            x = self.conv(x)
        return x
..snip..
```

You can see the FP32 fallback execution as same as sd_vae_approx.py.
2023-11-21 01:13:53 +09:00
Kohaku-Blueleaf 75336dfc84 add TAESD for i2i and t2i 2023-08-04 13:38:52 +08:00
AUTOMATIC1111 ac2d47ff4c add cheap VAE approximation coeffs for SDXL 2023-07-14 20:27:41 +03:00
AUTOMATIC1111 b8159d0919 add XL support for live previews: approx and TAESD 2023-07-13 17:24:54 +03:00
Zhang Hua 8e0d16e746
modules/sd_vae_approx.py: fix VAE-approx path 2023-03-11 20:00:12 +08:00
brkirch eef1990a5e Fix Approx NN on devices other than CUDA 2023-01-15 08:13:33 -05:00
AUTOMATIC 56e557c6ff added cheap NN approximation for VAE 2022-12-24 22:39:10 +03:00