-
Notifications
You must be signed in to change notification settings - Fork 31.1k
fix 3 failed test cases for video_llama_3 model on Intel XPU #41931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+23
−5
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
be6a37d
fix 3 failed test cases for video_llama_3 model on Intel XPU
kaixuanliu 1051ccf
update
kaixuanliu 4ddc86f
adjust format
kaixuanliu 52c2754
Merge branch 'main' into video_llama_3
kaixuanliu f15e9ce
update code
kaixuanliu cf51ff3
Merge branch 'video_llama_3' of https://github.com/kaixuanliu/transfo…
kaixuanliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| is_torch_available, | ||
| ) | ||
| from transformers.testing_utils import ( | ||
| Expectations, | ||
| backend_empty_cache, | ||
| require_flash_attn, | ||
| require_torch, | ||
|
|
@@ -831,7 +832,14 @@ def test_small_model_integration_test(self): | |
| torch.testing.assert_close(expected_pixel_slice, inputs.pixel_values[:6, :3], atol=1e-4, rtol=1e-4) | ||
|
|
||
| output = model.generate(**inputs, max_new_tokens=20, do_sample=False, repetition_penalty=None) | ||
| EXPECTED_DECODED_TEXT = "user\n\nDescribe the image.\nassistant\nThe image captures a vibrant nighttime scene on a bustling city street. A woman in a striking red dress" | ||
| # fmt: off | ||
| EXPECTED_DECODED_TEXT = Expectations( | ||
| { | ||
| ("cuda", None): "user\n\nDescribe the image.\nassistant\nThe image captures a vibrant nighttime scene on a bustling city street. A woman in a striking red dress", | ||
| ("xpu", None): "user\n\nDescribe the image.\nassistant\nThe image captures a vibrant night scene in a bustling Japanese city. A woman in a striking red dress", | ||
| } | ||
| ).get_expectation() | ||
ydshieh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # fmt: on | ||
|
|
||
| self.assertEqual( | ||
| self.processor.decode(output[0], skip_special_tokens=True), | ||
|
|
@@ -874,11 +882,21 @@ def test_small_model_integration_test_batch_wo_image(self): | |
|
|
||
| # it should not matter whether two images are the same size or not | ||
| output = model.generate(**inputs, max_new_tokens=20, do_sample=False, repetition_penalty=None) | ||
| # fmt: off | ||
| EXPECTED_DECODED_TEXT = Expectations( | ||
| { | ||
| ("cuda", None): [ | ||
| "user\n\nDescribe the image.\nassistant\nThe image captures a vibrant nighttime scene on a bustling city street. A woman in a striking red dress", | ||
| "user\nWhat is relativity?\nassistant\nRelativity is a scientific theory that describes the relationship between space and time. It was first proposed by", | ||
| ], | ||
| ("xpu", None): [ | ||
| "user\n\nDescribe the image.\nassistant\nThe image captures a vibrant night scene in a bustling Japanese city. A woman in a striking red dress", | ||
| "user\nWhat is relativity?\nassistant\nRelativity is a scientific theory that describes the relationship between space and time. It was first proposed by", | ||
| ], | ||
| } | ||
| ).get_expectation() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above |
||
| # fmt: on | ||
|
|
||
| EXPECTED_DECODED_TEXT = [ | ||
| "user\n\nDescribe the image.\nassistant\nThe image captures a vibrant nighttime scene on a bustling city street. A woman in a striking red dress", | ||
| "user\nWhat is relativity?\nassistant\nRelativity is a scientific theory that describes the relationship between space and time. It was first proposed by", | ||
| ] # fmt: skip | ||
| self.assertEqual( | ||
| self.processor.batch_decode(output, skip_special_tokens=True), | ||
| EXPECTED_DECODED_TEXT, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what is the issue here that requires this new
KeyError?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When i run
pytest -rA tests/models/video_llama_3/test_modeling_video_llama_3.py::VideoLlama3ModelTest::test_generate_with_quant_cache, it will fail and return error:Here is to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaixuanliu it shows
'optimum': ['optimum-quanto', 'optimum-onnx', 'optimum'],inPACKAGE_DISTRIBUTION_MAPPING, so we may need another logic to searchoptimum-quantodistribution inoptimumpackage, rather than using your current logic, because the package actually there, just we find it in a wrong way in this case. @ydshieh , WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check ,thank you for explaining the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, when we catch the
keyErrorexception, it will loadoptimum-quantoin package = importlib.import_module(pkg_name), wherepkg_nameisoptimum.quanto, and it can be imported properly.