[showo2] Fix env setup and T2I generation failure when resolution > 432 #104
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.
Problem
This PR fixes two critical issues that prevent inference at resolutions different from the pretrained model's training resolution (432x432):
1. Dependency Conflict in Environment Setup
Issue: Installing
flash-attnoverwrites PyTorch versiontorch==2.5.1is installed firstflash-attninstallation downgrades totorch==2.9.0(incompatible)Root Cause:
flash-attnhas strict PyTorch version requirements that conflict with the specified version.Solution: Update
requirements.txtwith compatible versions and installation order.2. Position Embedding Dimension Mismatch
Issue: RuntimeError when using resolutions different from pretrained model
Root Cause:
show-o2-1.5B-HQ/config.json) contains fixed resolution settings:__init__loads model with these hardcoded values (27×27=729 tokens)image_position_idsbuffer (initialized at Line 81) remains at 729 tokensSolution:
Add dynamic position ID recreation in the
forward()method to match actual input shape:This allows the model to handle any input resolution dynamically, utilizing the existing position embedding interpolation logic when needed.
Changes
Files Modified
requirements.txt(NEW)flash-attninstallationmodels/modeling_showo2_qwen2_5.pyimage_position_idsrecreation inforward()method (Line ~310)Testing
Tested configurations: