Repository navigation
Conversation
…ers>=5.18 for image-to-image
chsu-amd
marked this pull request as ready for review
December 4, 2026 03:05
5 of 10 tasks
Member
|
/diffusers-bot pytest tests/pipelines/glm_image/test_glm_image.py |
Contributor
|
✅ |
sayakpaul
approved these changes
Dec 4, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #15482
Since transformers 5.18.0 (#45783),
GlmImageForConditionalGeneration.get_image_featurestakesimages_per_sampleand drops each sample's target grid itself,pooler_outputis a per-image list of(hidden_size, height, width)maps, andget_image_tokensloops over that list.generate_prior_tokensstill passes only the source grids andtorch.cats the features, so image-to-image raises a channel mismatch in the VQ encoder.This PR checks whether
get_image_featuresacceptsimages_per_sample(sameinspect.signaturecheck asretrieve_timestepsin this file). If it does, it passes all grids +images_per_sampleand handspooler_outputtoget_image_tokensunchanged; otherwise it keeps the old call. No transformers version check. The same call also works with the current head of transformers #50733, which drops the last grid whenimages_per_sampleis not passed.Results
mainat facc812 + this diff.mainmainon 5.16.1, same condition-image tokensmain, #50733 headmainon 5.16.1, same condition-image tokensenable_model_cpu_offload(), transformers 5.21.0mainOffload rows include #15456 in both arms. All-on-GPU, the run passes
get_image_tokenson 5.21.0, then runs out of memory in the VAE decode, asmaindoes on 5.16.1.Outside the reported case (CPU, tiny components, every transformers version in the table):
mainon 5.16.1.prior_token_idsgiven:generate_prior_tokensis not called.mainand with this PR (condition-image tokens not compared).num_images_per_prompt=2, 2 prompts x 2 images): same output and tokens asmainon 5.16.1;mainraises on 5.18+.pytest tests/pipelines/glm_image(CPU, transformers 5.16.1 and 5.25.0): same results onmainand this branch (all skipped byrequire_torch_accelerator; with it removed, 26 passed, 7 skipped, 4 failed on both).ruff check/format --checkpass.Self-review notes (
self-reviewskill): blocking none, dead code none. Left for review: no image-to-image fast test (dummy visionpatch_size8, processor 16); ifget_image_featuresis wrapped withoutfunctools.wraps, the signature check picks the old call.Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@yiyixuxu @sayakpaul