Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/diffusers/utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ def randn_tensor(
)
elif gen_device_type != device.type and gen_device_type == "cuda":
raise ValueError(f"Cannot generate a {device} tensor from a generator of type {gen_device_type}.")
elif gen_device_type == "cuda" and device.type == "cuda":
logger.warning(
"Using a CUDA random generator may produce different results than a CPU generator with the same seed."
" This is expected because PyTorch uses different random number generation algorithms on CPU and CUDA."
" If you need reproducible results across devices, use a CPU generator (e.g., torch.Generator('cpu'))."
)

# make sure generator list of length 1 is treated like a non-list
if isinstance(generator, list) and len(generator) == 1:
Expand Down