-
Notifications
You must be signed in to change notification settings - Fork 19.6k
[OpenVINO backend] fix randomuniform issue #21670
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
base: master
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @Mohamed-Ashraf273, 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 aims to enhance the reliability of random number generation within the Keras OpenVINO backend. It addresses a known issue where the randomuniform
operation yielded inconsistent results, ensuring that random operations are now deterministic and reproducible for improved model stability and debugging.
Highlights
- Addressing
randomuniform
indeterminism: This PR resolves an issue where therandomuniform
operation in the OpenVINO backend produced undeterministic outputs, as reported in OpenVINO issue #32045 and discovered via keras-team/keras-hub/pull/2389. - Switching to NumPy for random number generation: The implementation of
uniform
in the OpenVINO backend has been updated to usenumpy.random.default_rng
for generating random values, replacing the direct use ofov_opset.random_uniform
. - Simplified seed handling: The seed handling logic within the
uniform
function has been streamlined to directly passseed_data
to the NumPy random number generator, improving consistency.
Using Gemini Code Assist
The 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 /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands on the current page.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 aims to fix a non-determinism issue with random.uniform
in the OpenVINO backend by switching from ov_opset.random_uniform
to a NumPy-based implementation.
While this correctly addresses the determinism for concrete shapes, it introduces a critical regression by breaking support for symbolic shapes, which is a common use case in Keras. I've left a detailed comment with a suggested fix that uses a hybrid approach to support both concrete and symbolic shapes.
Additionally, the random.categorical
function also uses ov_opset.random_uniform
and is likely affected by the same non-determinism bug. This should also be investigated and fixed to fully resolve the issue.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21670 +/- ##
==========================================
+ Coverage 82.55% 82.56% +0.01%
==========================================
Files 571 571
Lines 57626 57713 +87
Branches 9001 9016 +15
==========================================
+ Hits 47572 47650 +78
- Misses 7759 7765 +6
- Partials 2295 2298 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@rkazants
@fchollet
Solve openvino issue for the undeterministic output of
randomuniform
, by implementing it likeops.normal
above.Issue: openvinotoolkit/openvino#32045
Discovred from: keras-team/keras-hub#2389.
running
pytest keras_hub/src/models/gemma/gemma_causal_lm_test.py::GemmaCausalLMTest::test_causal_lm_basics -v -s
without fix gives:
with fix: