Skip to content

Commit 89fc965

Browse files
committed
feedback
1 parent 8816f52 commit 89fc965

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ model = QwenImageTransformer2DModel.from_pretrained("Qwen/Qwen-Image", subfolder
3838
from diffusers import AutoModel
3939

4040
model = AutoModel.from_pretrained(
41-
"Qwen/Qwen-Image",
42-
subfolder="transformer"
41+
"Qwen/Qwen-Image", subfolder="transformer"
4342
)
4443
```
4544

@@ -53,19 +52,18 @@ from diffusers import QwenImageTransformer2DModel
5352

5453
model = QwenImageTransformer2DModel.from_pretrained(
5554
"Qwen/Qwen-Image",
56-
subfolder="transformer"
57-
torch_dtype=torch.float16
55+
subfolder="transformer",
56+
torch_dtype=torch.bfloat16
5857
)
5958
```
6059

61-
[torch.Tensor.to](https://docs.pytorch.org/docs/stable/generated/torch.Tensor.to.html) can also convert to a specific data type on the fly. However, it converts *all* weights to the requested data type unlike `torch_dtype` which respects `_keep_in_fp32_modules`. This argument preserves layers in `torch.float32` for numerical stability and best generation quality (see example [_keep_in_fp32_modules](https://github.com/huggingface/diffusers/blob/f864a9a352fa4a220d860bfdd1782e3e5af96382/src/diffusers/models/transformers/transformer_wan.py#L374))
60+
[nn.Module.to](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.to) can also convert to a specific data type on the fly. However, it converts *all* weights to the requested data type unlike `torch_dtype` which respects `_keep_in_fp32_modules`. This argument preserves layers in `torch.float32` for numerical stability and best generation quality (see example [_keep_in_fp32_modules](https://github.com/huggingface/diffusers/blob/f864a9a352fa4a220d860bfdd1782e3e5af96382/src/diffusers/models/transformers/transformer_wan.py#L374))
6261

6362
```py
6463
from diffusers import QwenImageTransformer2DModel
6564

6665
model = QwenImageTransformer2DModel.from_pretrained(
67-
"Qwen/Qwen-Image",,
68-
subfolder="transformer"
66+
"Qwen/Qwen-Image", subfolder="transformer"
6967
)
7068
model = model.to(dtype=torch.float16)
7169
```
@@ -78,20 +76,19 @@ Diffusers currently provides three options to `device_map` for individual models
7876

7977
| parameter | description |
8078
|---|---|
81-
| `"cuda"` | places pipeline on CUDA device |
79+
| `"cuda"` | places pipeline on a supported accelerator (CUDA) |
8280
| `"balanced"` | evenly distributes pipeline on all GPUs |
8381
| `"auto"` | distribute model from fastest device first to slowest |
8482

8583
Use the `max_memory` argument in [`~ModelMixin.from_pretrained`] to allocate a maximum amount of memory to use on each device. By default, Diffusers uses the maximum amount available.
8684

8785
```py
8886
import torch
89-
from diffusers import QwenImageTransformer2DModel
87+
from diffusers import QwenImagePipeline
9088

9189
max_memory = {0: "16GB", 1: "16GB"}
92-
transformer = QwenImageTransformer2DModel.from_pretrained(
90+
pipeline = QwenImagePipeline.from_pretrained(
9391
"Qwen/Qwen-Image",
94-
subfolder="transformer",
9592
torch_dtype=torch.bfloat16,
9693
device_map="cuda",
9794
max_memory=max_memory

0 commit comments

Comments
 (0)