[XPU][SDXL] Fix text encoder input device under CPU offload (#6125)
Signed-off-by: Joshna Medisetty <joshna.medisetty@intel.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Nick Cao <ncao@redhat.com>
This commit is contained in:
1 file changed
+3
-3
@@ -98,7 +98,7 @@ class StableDiffusionXLPipeline(
|
||||
prefetch_list=sdxl_subfolders,
|
||||
local_files_only=local_files_only,
|
||||
torch_dtype=dtype,
|
||||
)
|
||||
).to(self.device)
|
||||
self.text_encoder_2 = from_pretrained_with_prefetch(
|
||||
CLIPTextModelWithProjection.from_pretrained,
|
||||
model,
|
||||
@@ -106,7 +106,7 @@ class StableDiffusionXLPipeline(
|
||||
prefetch_list=sdxl_subfolders,
|
||||
local_files_only=local_files_only,
|
||||
torch_dtype=dtype,
|
||||
)
|
||||
).to(self.device)
|
||||
self.unet = SDXLUNet2DConditionModel(od_config=od_config)
|
||||
self.vae = from_pretrained_with_prefetch(
|
||||
DistributedAutoencoderKL.from_pretrained,
|
||||
@@ -146,7 +146,7 @@ class StableDiffusionXLPipeline(
|
||||
)
|
||||
text_input_ids = text_inputs.input_ids
|
||||
|
||||
text_encoder_device = next(text_encoder.parameters()).device
|
||||
text_encoder_device = self.device
|
||||
outputs = text_encoder(text_input_ids.to(text_encoder_device), output_hidden_states=True)
|
||||
prompt_embeds = outputs.hidden_states[-2].to(dtype=self.od_config.dtype, device=self.device)
|
||||
|
||||
|
||||
Reference in new issue
Block a user