Skip to content

Commit 57fde87

Browse files
yiyixuxuyiyixuxusayakpaul
authored
offload the optional module image_encoder (#6151)
* offload image_encoder * add test --------- Co-authored-by: yiyixuxu <yixu310@gmail,com> Co-authored-by: Sayak Paul <[email protected]>
1 parent 68e9623 commit 57fde87

13 files changed

+39
-12
lines changed

src/diffusers/pipelines/animatediff/pipeline_animatediff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
106106
[`DDIMScheduler`], [`LMSDiscreteScheduler`], or [`PNDMScheduler`].
107107
"""
108108

109-
model_cpu_offload_seq = "text_encoder->unet->vae"
109+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
110110
_optional_components = ["feature_extractor", "image_encoder"]
111111

112112
def __init__(

src/diffusers/pipelines/controlnet/pipeline_controlnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class StableDiffusionControlNetPipeline(
176176
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
177177
"""
178178

179-
model_cpu_offload_seq = "text_encoder->unet->vae"
179+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
180180
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
181181
_exclude_from_cpu_offload = ["safety_checker"]
182182
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]

src/diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class StableDiffusionControlNetInpaintPipeline(
291291
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
292292
"""
293293

294-
model_cpu_offload_seq = "text_encoder->unet->vae"
294+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
295295
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
296296
_exclude_from_cpu_offload = ["safety_checker"]
297297
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]

src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class StableDiffusionXLControlNetPipeline(
165165
"""
166166

167167
# leave controlnet out on purpose because it iterates with unet
168-
model_cpu_offload_seq = "text_encoder->text_encoder_2->unet->vae"
168+
model_cpu_offload_seq = "text_encoder->text_encoder_2->image_encoder->unet->vae"
169169
_optional_components = [
170170
"tokenizer",
171171
"tokenizer_2",

src/diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class AltDiffusionPipeline(
155155
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
156156
"""
157157

158-
model_cpu_offload_seq = "text_encoder->unet->vae"
158+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
159159
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
160160
_exclude_from_cpu_offload = ["safety_checker"]
161161
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]

src/diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class AltDiffusionImg2ImgPipeline(
195195
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
196196
"""
197197

198-
model_cpu_offload_seq = "text_encoder->unet->vae"
198+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
199199
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
200200
_exclude_from_cpu_offload = ["safety_checker"]
201201
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class StableDiffusionPipeline(
151151
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
152152
"""
153153

154-
model_cpu_offload_seq = "text_encoder->unet->vae"
154+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
155155
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
156156
_exclude_from_cpu_offload = ["safety_checker"]
157157
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class StableDiffusionImg2ImgPipeline(
191191
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
192192
"""
193193

194-
model_cpu_offload_seq = "text_encoder->unet->vae"
194+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
195195
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
196196
_exclude_from_cpu_offload = ["safety_checker"]
197197
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class StableDiffusionInpaintPipeline(
255255
A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
256256
"""
257257

258-
model_cpu_offload_seq = "text_encoder->unet->vae"
258+
model_cpu_offload_seq = "text_encoder->image_encoder->unet->vae"
259259
_optional_components = ["safety_checker", "feature_extractor", "image_encoder"]
260260
_exclude_from_cpu_offload = ["safety_checker"]
261261
_callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds", "mask", "masked_image_latents"]

src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class StableDiffusionXLPipeline(
198198
watermarker will be used.
199199
"""
200200

201-
model_cpu_offload_seq = "text_encoder->text_encoder_2->unet->vae"
201+
model_cpu_offload_seq = "text_encoder->text_encoder_2->image_encoder->unet->vae"
202202
_optional_components = [
203203
"tokenizer",
204204
"tokenizer_2",

0 commit comments

Comments
 (0)