Skip to content

fix: fix MockModelRunner in attention tests#18240

Merged
Kangyan-Zhou merged 1 commit intosgl-project:mainfrom
zack041:fix-mock-model-runner
Feb 4, 2026
Merged

fix: fix MockModelRunner in attention tests#18240
Kangyan-Zhou merged 1 commit intosgl-project:mainfrom
zack041:fix-mock-model-runner

Conversation

@zack041
Copy link
Contributor

@zack041 zack041 commented Feb 4, 2026

Motivation

Fix #18238

Modifications

test_flashattn_backend.py:

  1. Added kv_cache_dtype, is_hybrid_swa, attention_chunk_size to class attributes
  2. Added is_encoder_decoder, is_local_attention_model to model_config
  3. Fixed type(...) calls missing () — was creating type objects instead of instances
  4. Removed duplicate self.device = self.device

test_flashattn_mla_backend.py:

  1. Added is_encoder_decoder, is_local_attention_model to model_config

Accuracy Tests

WechatIMG953
WechatIMG954

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zack041, 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 an issue with the MockModelRunner used in attention tests, specifically fixing problem #18238. The changes primarily involve enhancing the mock model's configuration to be more comprehensive and accurate, correcting type instantiation logic, and removing redundant code. These updates ensure the attention tests run with a more robust and representative mock environment, improving the reliability of the testing suite.

Highlights

  • MockModelRunner Configuration: The MockModelRunner in test_flashattn_backend.py has been updated with new attributes: kv_cache_dtype, is_hybrid_swa, and attention_chunk_size to better simulate model configurations.
  • Model Configuration Parameters: Both test_flashattn_backend.py and test_flashattn_mla_backend.py now include is_encoder_decoder and is_local_attention_model in their model_config dictionaries, set to False.
  • Type Instantiation Fix: Corrected type(...) calls in test_flashattn_backend.py to type(...)() to ensure proper instantiation of type objects instead of merely referencing the type.
  • Code Redundancy Removal: A redundant self.device = self.device assignment was removed from test_flashattn_backend.py.

🧠 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
  • python/sglang/test/attention/test_flashattn_backend.py
    • Added kv_cache_dtype, is_hybrid_swa, and attention_chunk_size as new instance attributes to the MockModelRunner class.
    • Included is_encoder_decoder and is_local_attention_model with a value of False in the model_config dictionary.
    • Modified type(...) calls to type(...)() to correctly instantiate objects instead of returning type references.
    • Removed a duplicate assignment of self.device = self.device.
  • python/sglang/test/attention/test_flashattn_mla_backend.py
    • Added is_encoder_decoder and is_local_attention_model with a value of False to the model_config dictionary.
Activity
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 correctly fixes several issues in test_flashattn_backend.py where mock objects were not being instantiated correctly, by adding () after type(...) calls. It also adds necessary attributes to the mock configurations. However, I've identified that similar instantiation bugs exist in test_flashattn_mla_backend.py which were not addressed in this PR. I've added a comment to point these out. Additionally, I've suggested a more readable way to create these mock objects using types.SimpleNamespace.

Comment on lines +31 to +32
"is_encoder_decoder": False,
"is_local_attention_model": False,
Copy link
Contributor

Choose a reason for hiding this comment

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

high

While adding these new fields is correct, there are several related bugs in this file where mock objects are not being instantiated. This is the same issue you fixed in test_flashattn_backend.py.

Specifically:

  • self.model_config on line 34 is missing ().
  • self.server_args on line 46 is missing ().
  • self.req_to_token_pool on line 62 is missing ().

These should all be instantiated by adding () at the end of the type(...) call to fix the bugs.

@Kangyan-Zhou Kangyan-Zhou merged commit 2e87c2b into sgl-project:main Feb 4, 2026
54 of 61 checks passed
charlesHsuGG pushed a commit to charlesHsuGG/sglang that referenced this pull request Feb 5, 2026
RubiaCx pushed a commit to RubiaCx/sglang that referenced this pull request Feb 8, 2026
Johnsonms pushed a commit to Johnsonms/sglang that referenced this pull request Feb 14, 2026
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.

[Bug] test_flashattn_backend and test_flashattn_mla_backend failed due to multiple missing parameters

3 participants