Skip to content

Fix GlmImagePipeline image-to-image with enable_model_cpu_offload() - #15453

Open
saeekailas wants to merge 1 commit into
huggingface:mainfrom
saeekailas:main
Open

saeekailas wants to merge 1 commit into
huggingface:mainfrom
saeekailas:main

Conversation

@saeekailas

Copy link
Copy Markdown

Fixes #15449

Image-to-image with enable_model_cpu_offload() crashes with:

RuntimeError: Input type (CUDABFloat16Type) and weight type (CPUBFloat16Type) should be the same

generate_prior_tokens calls vision_language_encoder.get_image_features() and get_image_tokens() directly. The offload hook is only attached to forward(), so it never fires here and the encoder stays on CPU while the pixel values are on CUDA.

This calls the hook's pre_forward first, if one is attached, so the encoder is moved to the GPU. Without a hook (pipe.to("cuda"), device_map), nothing changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GlmImagePipeline: image-to-image fails with enable_model_cpu_offload() (device mismatch in get_image_features)

1 participant