FIX: Fixes unexpected behaviour for Llava / LLama & AWQ Fused modules + revert #30070 at the same time#30317
Merged
LysandreJik merged 5 commits intomainfrom Apr 18, 2024
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
fxmarty
reviewed
Apr 18, 2024
fxmarty
reviewed
Apr 18, 2024
ArthurZucker
approved these changes
Apr 18, 2024
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
Let's make sure to run the slow Llama tests at least before merging to iterate fast if they fail
Comment on lines
+253
to
+255
| # For AWQ fused + Llama we need to set `config._attn_implementation` = "custom" to avoid unexpected behavior and pass | ||
| # `None` attention mask to the fused attention modules as now the attention mask is dropped by our models and dealt | ||
| # by the `AttentionMaskConverter` module. |
Collaborator
There was a problem hiding this comment.
Suggested change
| # For AWQ fused + Llama we need to set `config._attn_implementation` = "custom" to avoid unexpected behavior and pass | |
| # `None` attention mask to the fused attention modules as now the attention mask is dropped by our models and dealt | |
| # by the `AttentionMaskConverter` module. | |
| # For AWQ fused + Llama we need to set `config._attn_implementation` = "custom" to avoid unexpected behaviors. We loop over the layers to make sure the vision/text config are | |
| # modified only if some of their modules were fused |
Collaborator
There was a problem hiding this comment.
nit but more understandable
fxmarty
reviewed
Apr 18, 2024
Comment on lines
+269
to
+270
| if sliding_window is None or key_value_length < sliding_window: | ||
| ignore_causal_mask = not is_tracing |
Contributor
There was a problem hiding this comment.
pls apply this fix here: https://github.com/huggingface/transformers/pull/30311/files
fxmarty
approved these changes
Apr 18, 2024
Contributor
There was a problem hiding this comment.
Please apply the above fix and LGTM
If you can run
from transformers import WhisperForCausalLM, WhisperForConditionalGeneration, WhisperProcessor
import torch
from datasets import load_dataset
processor = WhisperProcessor.from_pretrained("openai/whisper-large-v2")
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large-v2")
assistant_model = WhisperForCausalLM.from_pretrained("distil-whisper/distil-large-v2")
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
sample = ds[0]["audio"]
input_features = processor(
sample["array"], sampling_rate=sample["sampling_rate"], return_tensors="pt"
).input_features
predicted_ids = model.generate(input_features, assistant_model=assistant_model)
# decode token ids to text
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
print(transcription)& llava AWQ test & llama slow test to be sure as well
Contributor
Author
|
Thanks @fxmarty @ArthurZucker ! just tested everything seems to all pass ! |
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 a silent behaviour introduced by a recent PR, passing a
Noneattention mask results in unexpected behaviour for awq fused modules. The fix is simply to force set a dummy_attn_implementationon the config objects of the modules that contain fused modulesI can confirm the failing slow tests now pass with these changes
cc @ArthurZucker @fxmarty