Skip to content

Comments

[Fix][NSA] Fixed a bug in pytest parameter passing in test_deepseek_nsa_cmp_fwd.#171

Merged
michaelwithu merged 20 commits intotile-ai:mainfrom
michaelwithu:pr-window
Feb 10, 2026
Merged

[Fix][NSA] Fixed a bug in pytest parameter passing in test_deepseek_nsa_cmp_fwd.#171
michaelwithu merged 20 commits intotile-ai:mainfrom
michaelwithu:pr-window

Conversation

@michaelwithu
Copy link
Collaborator

Description

The error TypeError: NSACmpFwdVarlenBenchmark.init() got an unexpected keyword argument '@py_assert1' occurs because:

  • locals().copy() captures all local variables in the current scope
  • pytest may inject internal variables (such as @py_assert1) during assertion rewriting
  • These internal variables are inadvertently passed to NSACmpFwdVarlenBenchmark.init(), causing the TypeError

Type of Change

  • Bug fix

Checklist

  • I have run pre-commit run --all-files and fixed all linting issues.
  • I have verified that my changes pass local unit tests.

@michaelwithu michaelwithu requested a review from a team February 9, 2026 03:53
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @michaelwithu, 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 resolves a TypeError in a pytest benchmark by refining how test parameters are collected and passed. Previously, pytest's internal assertion rewriting variables were inadvertently included when using locals().copy(), leading to errors. The fix ensures only relevant function arguments are used, improving the robustness of the test setup.

Highlights

  • Bug Fix in Pytest Parameter Passing: Addressed a TypeError occurring in test_nsa_cmp_fwd_varlen_op when locals().copy() was used to pass parameters to NSACmpFwdVarlenBenchmark.__init__.
  • Exclusion of Pytest Internal Variables: Modified the parameter collection logic to explicitly exclude pytest's internal variables (those starting with '@') from the dictionary passed to the benchmark constructor, preventing unexpected keyword arguments.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/ops/test_deepseek_nsa_cmp_fwd.py
    • Imported the inspect module to facilitate introspection of function signatures.
    • Updated the parameter collection mechanism in test_nsa_cmp_fwd_varlen_op to use inspect.signature and filter out pytest-injected variables (starting with '@') when creating the params dictionary for NSACmpFwdVarlenBenchmark.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
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 fixes a bug where pytest internal variables were passed to a class constructor, causing a TypeError. The fix correctly uses inspect.signature to gather only the explicit function arguments. I've suggested a small simplification to make the code cleaner and the comments more accurate, as the current implementation has a redundant check.

RMLYC added a commit that referenced this pull request Feb 10, 2026
1. Refactor the current testing framework using the pytest framework;
2. Remove profile testing in ci.yml, retaining only unit tests;
3. Fix the precision thresholds for some test cases;
4. Other minor bug fixes.
5. '@py_assert1' in `test_deepseek_nsa_cmp_fwd.py` will be fixed in #171
@michaelwithu
Copy link
Collaborator Author

/gemini review

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 a bug where pytest-injected variables were causing a TypeError during benchmark initialization. The fix correctly uses inspect.signature to filter arguments, which is a robust solution. The change is well-implemented and resolves the issue described. I have one minor suggestion to improve maintainability by dynamically referencing the test function, avoiding a hardcoded name.

@michaelwithu
Copy link
Collaborator Author

/gemini review

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 fixes a bug where pytest-injected variables were being passed to a class constructor, causing a TypeError. The fix correctly filters for only the intended function parameters. While the fix is correct, I've suggested an alternative implementation that is more explicit and readable by avoiding the use of inspect.stack(), which can be fragile and have performance implications. This change also makes the new inspect import unnecessary.

Copy link
Collaborator

@superAngGao superAngGao left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Collaborator

@stelladuyx stelladuyx left a comment

Choose a reason for hiding this comment

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

LGTM

@michaelwithu michaelwithu merged commit 1b9b66f into tile-ai:main Feb 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants