Skip to content

Commit 90b03ae

Browse files
committed
feedback
1 parent 0ca6499 commit 90b03ae

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/source/en/using-diffusers/reusing_seeds.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ Pipelines rely on [torch.randn](https://pytorch.org/docs/stable/generated/torch.
2323
> [!TIP]
2424
> If reproducibility is important to your use case, we recommend always using a CPU `Generator`. The performance loss is often negligible and you'll generate more similar values.
2525
26-
The `Generator` object should be passed to the pipeline instead of an integer seed. `Generator` maintains a *random state* that is consumed and modified when used. Once consumed, the same `Generator` object produces different results in subsequent calls, even across different pipelines, because it's *state* has changed.
27-
2826
<hfoptions id="generator">
2927
<hfoption id="GPU">
3028

@@ -62,6 +60,16 @@ print(np.abs(image).sum())
6260
</hfoption>
6361
</hfoptions>
6462

63+
The `Generator` object should be passed to the pipeline instead of an integer seed. `Generator` maintains a *random state* that is consumed and modified when used. Once consumed, the same `Generator` object produces different results in subsequent calls, even across different pipelines, because it's *state* has changed.
64+
65+
```py
66+
generator = torch.manual_seed(0)
67+
68+
for _ in range(5):
69+
- image = pipeline(prompt, generator=generator)
70+
+ image = pipeline(prompt, generator=torch.manual_seed(0))
71+
```
72+
6573
## Deterministic algorithms
6674

6775
PyTorch supports [deterministic algorithms](https://docs.pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms) - where available - for certain operations so they produce the same results. Deterministic algorithms may be slower and decrease performance.

0 commit comments

Comments
 (0)