Merge pull request #370 from sfinktah/sfink-debug

Fix for AMD error when not using tiled VAE decoding
This commit is contained in:
deepbeepmeep 2025-06-18 00:41:27 +02:00 committed by GitHub
commit e8dc653604
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,9 +33,27 @@ class CausalConv3d(nn.Conv3d):
padding[4] -= cache_x.shape[2]
cache_x = None
x = F.pad(x, padding)
x = super().forward(x)
return x
try:
out = super().forward(x)
return out
except RuntimeError as e:
if "miopenStatus" in str(e):
print("⚠️ MIOpen fallback: AMD gets upset when trying to work with large areas, and so CPU will be "
"used for this decoding (which is very slow). Consider using tiled VAE Decoding.")
x_cpu = x.float().cpu()
weight_cpu = self.weight.float().cpu()
bias_cpu = self.bias.float().cpu() if self.bias is not None else None
print(f"[Fallback] x shape: {x_cpu.shape}, weight shape: {weight_cpu.shape}")
out = F.conv3d(x_cpu, weight_cpu, bias_cpu,
self.stride, (0, 0, 0), # avoid double padding here
self.dilation, self.groups)
out = out.to(x.device)
if x.dtype in (torch.float16, torch.bfloat16):
out = out.half()
if x.dtype != out.dtype:
out = out.to(x.dtype)
return out
raise
class RMS_norm(nn.Module):