-
Notifications
You must be signed in to change notification settings - Fork 87
fix(transformers): fix v4.50.0 fast ut graph mode and random inputs #1375
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
Conversation
Summary of ChangesHello @Fzilan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses critical fixes for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces two main changes to fix unit tests for v4.50.0. First, it removes jit_syntax_level=ms.STRICT from ms.set_context in numerous test files, likely to address compatibility issues in graph mode. Second, it makes random inputs deterministic in the owlvit and poolformer model tests by introducing a seeded random number generator.
While making the tests deterministic is a good practice, the current implementation of get_rng() creates a new random.Random instance with the same seed on every call. This leads to different parts of the tests receiving identical sequences of 'random' numbers, which is likely not the intended behavior and can hide bugs. I've added comments with suggestions to use functools.lru_cache to ensure a single RNG instance is created and reused, thus providing proper random number sequences across the tests.
tests/transformers_tests/models/poolformer/test_modeling_poolformer.py
Outdated
Show resolved
Hide resolved
tests/transformers_tests/models/poolformer/test_modeling_poolformer.py
Outdated
Show resolved
Hide resolved
| if dtype == "fp32": | ||
| pytest.skip( | ||
| "skipping fp32 cases during overall tests for unexpected assertion errors, which do not occur in indicidual test." | ||
| ) | ||
|
|
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.
后面可以考虑放到上面的函数装饰方法中进行选择
Fixes
Temporarily remove the unnecessary strict graph mode settings.
The graph mode tests failed during the overall test run, while running them individually caused no errors. The reason is that in the overall test, a previous test may have modified the context configuration (for example, by setting strict graph mode through set_context), but the graph mode context was not properly reset before the next test, which affected subsequent cases.
Use specific random seeds in some tests to reproduce results and avoid occasional NaN issues.
Before submitting
What's New. Here are thedocumentation guidelines
@wcrzlh @CaitinZhao @vigo999 @zhanghuiyao