Skip to content

Qwen Image incorrect device assignment during prompt encode #12066

@vladmandic

Description

@vladmandic

Describe the bug

In the new QwenImagePipeline method _get_qwen_prompt_embeds it does following:

        txt_tokens = self.tokenizer(
            txt, max_length=self.tokenizer_max_length + drop_idx, padding=True, truncation=True, return_tensors="pt"
        ).to(self.device)

i assume this is a typo as it doesn't use actual device which is passed as function param and as such it breaks with any type of offloading with device mismatch since self.device defaults to entire model placement - which doesnt match.

simple solution is to change last part from .to(self.device) to .to(device)

Reproduction

N/A

Logs

RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when checking argument in method wrapper_CUDA__index_select)

System Info

diffusers==7ea065c5070a5278259e6f1effa9dccea232e62a

Who can help?

cc @naykun @yiyixuxu @sayakpaul @a-r-r-o-w

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions