Update bloom attention forward reshape follwing the transformer change#1360
Merged
Conversation
regisss
approved these changes
Sep 26, 2024
alekseyfa
pushed a commit
to alekseyfa/optimum-habana
that referenced
this pull request
Jun 25, 2025
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?
https://github.com/huggingface/transformers/blob/main/src/transformers/models/bloom/modeling_bloom.py#L262 _reshape() function covers OH transpose change. No need to transpose in OH.
The current code is failed at text-getneration CI.
CI run command: python3 /root/optimum-habana/examples/text-generation/run_generation.py --model_name_or_path bigscience/bloomz-7b1 --batch_size 1 --use_kv_cache --max_new_tokens 100 --use_hpu_graphs --bf16
Error message:
File "/usr/local/lib/python3.10/dist-packages/optimum/habana/transformers/models/bloom/modeling_bloom.py", line 142, in gaudi_bloom_attention_forward
query_layer = query_layer.transpose(1, 2).reshape(batch_size * self.num_heads, q_length, self.head_dim)
RuntimeError: shape '[32, 32, 128]' is invalid for input of size 438272
Fixes # (issue)
Before submitting