Skip to content

Conversation

liuchuting
Copy link
Contributor

@liuchuting liuchuting commented Oct 13, 2025

What does this PR do?

  • fix bigbird fast ut
    Refer to: pr1359.The changes in this PR will lead to input modifications. Increase the bigbird model test error passing threshold for BF16 to avoid unnecessary test failures for valid results. refer to: issue1357

  • fix owlv2 fast ut
    When zeros appear in the input_ids, filling with torch.finfo(input_dtype).min results in extremely small values like -3.40282e+38 or -3.38953e+38. Computing np.linalg.norm(-3.38953e+38) returns inf.
    Change the random seed to avoid zeros in the randomly generated input_ids.

Fixes # (issue)#1357

Adds # (feature)

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?
  • Did you make sure to update the documentation with your changes? E.g. record bug fixes or new features in What's New. Here are the
    documentation guidelines
  • Did you build and run the code without any errors?
  • Did you report the running environment (NPU type/MS version) and performance in the doc? (better record it for data loading, model inference, or training tasks)
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@xxx

@liuchuting liuchuting requested a review from vigo999 as a code owner October 13, 2025 07:05
Copy link
Contributor

Summary of Changes

Hello @liuchuting, 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 focuses on enhancing the stability and reliability of unit tests for the BigBird and OWLv2 models. It addresses issues related to floating-point precision in BigBird tests by adjusting error thresholds and resolves a numerical instability in OWLv2 tests by preventing zero values in input data that caused infinite results during norm calculations. Additionally, it tackles a global random number generator state issue to ensure consistent test execution.

Highlights

  • BigBird Test Stability: Increased the bf16 error passing threshold for BigBird model tests from 1e-2 to 2e-2 to prevent unnecessary failures due to precision differences.
  • OWLv2 Test Robustness: Modified the generation of input_ids in OWLv2 tests to explicitly avoid zero values in the first column, which previously led to np.linalg.norm returning inf and causing test failures.
  • Random Number Generator Fix: Addressed an issue where the global random number generator became inactive after a second call within a single process by ensuring get_rng creates a new instance for each call, preventing state-related test inconsistencies. (Note: This change is described in the PR body but not directly visible in the provided diffs.)
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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 addresses two separate unit test failures. For the BigBird model tests, the error threshold for the bf16 data type is increased, which is a reasonable adjustment to handle precision differences. For the OWLv2 model tests, the code prevents a test failure caused by inf values during norm calculation by ensuring the initial token ID in the test data is never zero. While the pull request description for the OWLv2 fix mentions changing the random seed, the implementation correctly patches the generated data directly, which is a more robust solution. I've provided one suggestion to make that part of the code more concise.

Comment on lines 144 to 149

def prepare_config_and_inputs(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness and improved readability, these two lines can be replaced with a single call to np.maximum. This achieves the same goal of ensuring the first token ID is non-zero in a more idiomatic way.

Suggested change
def prepare_config_and_inputs(self):
input_ids[..., 0] = np.maximum(input_ids[..., 0], 1)

@liuchuting liuchuting changed the title Fix ut Fix owlv2/bigbird ut Oct 13, 2025
fix ut

fix ut

fix bigbird ut

fix bigbird ut

fix bigbird ut
@vigo999 vigo999 added the ut/st label Oct 16, 2025
@vigo999 vigo999 added this to mindone Oct 16, 2025
@vigo999 vigo999 moved this to In Progress in mindone Oct 16, 2025
@vigo999 vigo999 added this pull request to the merge queue Oct 18, 2025
Merged via the queue into mindspore-lab:master with commit 41b8d04 Oct 18, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in mindone Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants