Fix .reshape(...) in GaudiCLIPAttention
#2338
Merged
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?
When using deepspeed parallelization the
attn_outputshape is smaller than expected by one of the reshape operations [1]. This commit fixes this issue by loosening the size assumption of the last tensor dimension, i.e., instead of using.reshape(batch_size, seq_length, embed_dim)it now performs.reshape(batch_size, seq_length, -1)to automatically determine that last dimension size.[1]
optimum-habana/optimum/habana/transformers/models/clip/modeling_clip.py
Line 138 in 568f643
Example command that is currently broken (README example):
PT_HPU_LAZY_MODE=1 QUANT_CONFIG=./quantization_config/maxabs_measure.json python ../gaudi_spawn.py --use_deepspeed --world_size 8 run_pipeline.py \ --model_name_or_path llava-hf/llava-v1.6-mistral-7b-hf \ --image_path "https://llava-vl.github.io/static/images/view.jpg" \ --use_hpu_graphs \ --bf16 \ --use_flash_attention \ --flash_attention_recompute