-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Description
🐛 Describe the bug
(I'm happy to report this over on the diffusers repo, but I suspect it's actually a bug in the ROCm build of Pytorch 2.4.0 as you will see)
Since Pytorch 2.4.0, I found that the HuggingFace Diffusers Stable Diffusion 3 pipeline was producing corrupted images on AMD accelerators I had access to (a weird grid pattern over the first image, followed by gibberish for subsequent images.
Example code:
import torch
from diffusers import StableDiffusion3Pipeline
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers",torch_dtype=torch.float16)
pipe = pipe.to("cuda")
generator = torch.Generator("cuda")
generator.manual_seed(123456)
image1 = pipe(
"A cat holding a sign that says hello world",
negative_prompt="",
num_inference_steps=32,
guidance_scale=7.0,
generator=generator
).images[0]
image2 = pipe(
"A cat holding a sign that says hello world",
negative_prompt="",
num_inference_steps=32,
guidance_scale=7.0,
generator=generator
).images[0]
image1
image2
Generating further images from the pipeline generates more gibberish. I have reproduced this on AMD Mi300x, AMD Mi250 and AMD Mi210.
On experimentation I have determined that this is due to the addition of memory efficient attention in the ROCm build of PyTorch 2.4.0 because disabling this torch.backends.cuda.enable_mem_efficient_sdp(False)
produces "correct" images.
This problem does not occur on:
- Pytorch 2.3.1 for ROCm (which does not have memory efficient attention compiled in, as per the warning it prints).
- Pytorch 2.4.0 on Nvidia GPUs (tested A100)
Versions
On the Mi250 box (I no longer have access to the Mi300x system, which was running AlmaLinux 9.4 with the latest install of ROCm 6):
Collecting environment information...
PyTorch version: 2.4.0+rocm6.0
Is debug build: False
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: 6.0.32830-d62f6a171
OS: Rocky Linux release 8.9 (Green Obsidian) (x86_64)
GCC version: (GCC) 15.0.0 20240724 (experimental)
Clang version: Could not collect
CMake version: version 3.26.5
Libc version: glibc-2.28
Python version: 3.11.7 (main, Jan 16 2024, 03:27:23) [GCC 10.2.0] (64-bit runtime)
Python platform: Linux-4.18.0-513.24.1.el8_9.x86_64-x86_64-with-glibc2.28
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: AMD Instinct MI250X/MI250 (gfx90a:sramecc+:xnack-)
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: 6.0.32830
MIOpen runtime version: 3.0.0
Is XNNPACK available: True
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 128
On-line CPU(s) list: 0-127
Thread(s) per core: 1
Core(s) per socket: 64
Socket(s): 2
NUMA node(s): 8
Vendor ID: AuthenticAMD
CPU family: 25
Model: 1
Model name: AMD EPYC 7763 64-Core Processor
Stepping: 1
CPU MHz: 2450.000
CPU max MHz: 3529.0520
CPU min MHz: 1500.0000
BogoMIPS: 4900.05
Virtualization: AMD-V
L1d cache: 32K
L1i cache: 32K
L2 cache: 512K
L3 cache: 32768K
NUMA node0 CPU(s): 0-15
NUMA node1 CPU(s): 16-31
NUMA node2 CPU(s): 32-47
NUMA node3 CPU(s): 48-63
NUMA node4 CPU(s): 64-79
NUMA node5 CPU(s): 80-95
NUMA node6 CPU(s): 96-111
NUMA node7 CPU(s): 112-127
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr wbnoinvd amd_ppin brs arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca
Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] pytorch-triton-rocm==3.0.0
[pip3] torch==2.4.0+rocm6.0
[pip3] torchaudio==2.4.0+rocm6.0
[pip3] torchvision==0.19.0+rocm6.0
[conda] Could not collect
cc @ezyang @gchanan @zou3519 @kadeng @msaroufim @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @jataylo @hongxiayang
Metadata
Metadata
Assignees
Labels
Type
Projects
Status