You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/using-diffusers/models.md
+8-11Lines changed: 8 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,7 @@ model = QwenImageTransformer2DModel.from_pretrained("Qwen/Qwen-Image", subfolder
38
38
from diffusers import AutoModel
39
39
40
40
model = AutoModel.from_pretrained(
41
-
"Qwen/Qwen-Image",
42
-
subfolder="transformer"
41
+
"Qwen/Qwen-Image", subfolder="transformer"
43
42
)
44
43
```
45
44
@@ -53,19 +52,18 @@ from diffusers import QwenImageTransformer2DModel
53
52
54
53
model = QwenImageTransformer2DModel.from_pretrained(
55
54
"Qwen/Qwen-Image",
56
-
subfolder="transformer"
57
-
torch_dtype=torch.float16
55
+
subfolder="transformer",
56
+
torch_dtype=torch.bfloat16
58
57
)
59
58
```
60
59
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))
62
61
63
62
```py
64
63
from diffusers import QwenImageTransformer2DModel
65
64
66
65
model = QwenImageTransformer2DModel.from_pretrained(
67
-
"Qwen/Qwen-Image",,
68
-
subfolder="transformer"
66
+
"Qwen/Qwen-Image", subfolder="transformer"
69
67
)
70
68
model = model.to(dtype=torch.float16)
71
69
```
@@ -78,20 +76,19 @@ Diffusers currently provides three options to `device_map` for individual models
78
76
79
77
| parameter | description |
80
78
|---|---|
81
-
|`"cuda"`| places pipeline on CUDA device|
79
+
|`"cuda"`| places pipeline on a supported accelerator (CUDA)|
82
80
|`"balanced"`| evenly distributes pipeline on all GPUs |
83
81
|`"auto"`| distribute model from fastest device first to slowest |
84
82
85
83
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.
0 commit comments