Skip to content

Conversation

@aroun-coumar
Copy link
Contributor

@aroun-coumar aroun-coumar commented Oct 7, 2024

What does this PR do?

Fixes #33963

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@qubvel

@aroun-coumar
Copy link
Contributor Author

@qubvel Please review the changes and comment
Thanks!

Copy link
Contributor

@qubvel qubvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Can you please:

  1. Fix quality tests, you should run make modified_only_fixup, make repo-consistency
  2. When quality tests are fixed, please push an empty commit with the message [run_slow] paligemma to ensure slow tests are also fine.

@aroun-coumar
Copy link
Contributor Author

make modified_only_fixup

all the tests passed but,

(myvenv)
Arun kumar@LAPTOP-0U925LO8 MINGW64 ~/OneDrive/Desktop/Transformers/transformers (enable-flash-attention-paligemma)
$ make repo-consistency
python utils/check_copies.py
python utils/check_modular_conversion.py

Differences found between the generated code and
src/transformers/models\gemma\modeling_gemma.py:

   1 --- src/transformers/models\gemma\modeling_gemma.py_generated
   2 +++ src/transformers/models\gemma\modeling_gemma.py
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 Google Inc. HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\gemma\configuration_gemma.py:

   1 --- src/transformers/models\gemma\configuration_gemma.py_generated
   2 +++ src/transformers/models\gemma\configuration_gemma.py
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 Google Inc. HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\gemma2\modeling_gemma2.py:

   1 --- src/transformers/models\gemma2\modeling_gemma2.py_generated
   2 +++ src/transformers/models\gemma2\modeling_gemma2.py
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 Google Inc. HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\gemma2\configuration_gemma2.py:

   1 --- src/transformers/models\gemma2\configuration_gemma2.py_generated
   2 +++ src/transformers/models\gemma2\configuration_gemma2.py
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 Google Inc. HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\instructblipvideo\modeling_instructblipvideo.py:

   1 --- src/transformers/models\instructblipvideo\modeling_instructblipvideo.p
   2 +++ src/transformers/models\instructblipvideo\modeling_instructblipvideo.p
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\instructblipvideo\configuration_instructblipvideo.py:

   1 --- src/transformers/models\instructblipvideo\configuration_instructblipvi
   2 +++ src/transformers/models\instructblipvideo\configuration_instructblipvi
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\llava_next_video\modeling_llava_next_video.py:

   1 --- src/transformers/models\llava_next_video\modeling_llava_next_video.py_
   2 +++ src/transformers/models\llava_next_video\modeling_llava_next_video.py
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 HuggingFace Inc. team. All rights reserved.
  14  #

Differences found between the generated code and
src/transformers/models\llava_next_video\configuration_llava_next_video.py:

   1 --- src/transformers/models\llava_next_video\configuration_llava_next_vide
   2 +++ src/transformers/models\llava_next_video\configuration_llava_next_vide
   3 @@ -1,9 +1,9 @@
   4 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
   5 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
   6  #               This file was automatically generated from <path_to_modul
   7  #         Do NOT edit this file manually as any edits will be overwritten
   8  #         the file from the modular. If any change should be done, please
   9  #                           modular_xxx.py file directly. One of our CI e
  10 -#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  11 +#           🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨ð
  12  # coding=utf-8
  13  # Copyright 2024 HuggingFace Inc. team. All rights reserved.
  14  #
Traceback (most recent call last):
  File "C:\Users\Arun kumar\OneDrive\Desktop\Transformers\transformers\utils\check_modular_conversion.py", line 76, in <module>
    raise ValueError("Some diff and their modeling code did not match.")
ValueError: Some diff and their modeling code did not match.
make: *** [Makefile:39: repo-consistency] Error 1

Can you please point out what might be wrong?
I couldnt fix this part

Thanks!

@qubvel
Copy link
Contributor

qubvel commented Oct 8, 2024

Hi @aroun-coumar

The following error is in CI:
ValueError: paligemma should be in listed in the flash attention documentation but is not. Please update the documentation.

You have to add the model to the following doc file:
https://github.com/huggingface/transformers/blob/main/docs/source/en/perf_infer_gpu_one.md

@aroun-coumar
Copy link
Contributor Author

Hey @qubvel Thanks a lot!

All the tests passed

@HuggingFaceDocBuilderDev

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.

@qubvel
Copy link
Contributor

qubvel commented Oct 9, 2024

Can you please once again push [run_slow] paligemma, it should be the last commit to run slow tests

@aroun-coumar
Copy link
Contributor Author

Hey @qubvel the single and multi gpu tests didnt pass.

i couldnt figure it out from the ci tests

I an working on it , if you find out what might be the problem Please let me know

@aroun-coumar
Copy link
Contributor Author

Hey @qubvel sorry but i cant circle down the cause of this error
Both the GPU tests fail
Please give some suggestion how to debug this

Thanks

@aroun-coumar aroun-coumar requested a review from qubvel October 21, 2024 13:08
@qubvel
Copy link
Contributor

qubvel commented Oct 21, 2024

Hi, I will take a look next week! Thanks for patience!

Copy link
Contributor

@qubvel qubvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aroun-coumar, can you please rebase your branch to the current main to include recent changes and resolve conflicts (hopefully slow tests issues also will be resolved)

@aroun-coumar aroun-coumar force-pushed the enable-flash-attention-paligemma branch 3 times, most recently from 169500d to 39ebb03 Compare October 31, 2024 04:40
Copy link
Contributor

@qubvel qubvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we no longer need to pass attn_implementation=config._attn_implementation with this PR merged, can you check if Flash Attention / SDPA is enabled for PaliGemma on main?

You can use it as

model = PaliGemmaForConditionalGeneration.from_pretrained(..., attn_implementation={"vision_config": "flash_attention_2", "text_config": "sdpa"})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flash attention 2 support for PaliGemma model

3 participants