Skip to content

fix: support HybridLinearAttnBackend in TboAttnBackend - #20114

Merged
Qiaolin-Yu merged 5 commits into
sgl-project:mainfrom
lawrence-harmonic:fix/tbo_linear
Apr 30, 2026
Merged

fix: support HybridLinearAttnBackend in TboAttnBackend#20114
Qiaolin-Yu merged 5 commits into
sgl-project:mainfrom
lawrence-harmonic:fix/tbo_linear

Conversation

@lawrence-harmonic

Copy link
Copy Markdown
Contributor

Motivation

Fix #20109

Modifications

  • Add missing forward method to TboAttnBackend
  • Handle mrope_positions in TboForwardBatchPreparer.filter_batch()

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 by enhancing the TboAttnBackend to properly support HybridLinearAttnBackend. The changes ensure that attention-related position data (mrope_positions) is correctly processed during batch preparation and that the TboAttnBackend can correctly forward calls to its underlying primary attention mechanism, thereby improving the robustness and compatibility of the attention system.

Highlights

  • TboAttnBackend Functionality: Added a missing forward method to TboAttnBackend to ensure proper delegation to its primary attention backend.
  • Batch Preparation: Implemented explicit handling and slicing of mrope_positions within the TboForwardBatchPreparer.filter_batch() method, improving compatibility for specific attention backends.

🧠 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/srt/batch_overlap/two_batch_overlap.py
    • Removed mrope_positions from the default list of attributes copied directly to the output dictionary.
    • Added a new block of code to explicitly retrieve and slice mrope_positions from the batch if they exist, or set them to None.
  • python/sglang/srt/layers/attention/tbo_backend.py
    • Introduced a forward method that passes all arguments and keyword arguments to the forward method of the self.primary object.
Activity
  • No human activity 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 fixes to enhance support for specific model backends and features. First, it correctly handles mrope_positions within the two-batch overlap mechanism by properly slicing the tensor for sub-batches, which was previously overlooked. Second, it adds a forward method to TboAttnBackend to ensure proper delegation to the primary attention backend, a necessary change for compatibility with backends like HybridLinearAttnBackend that may have custom forward implementations. The changes are logical, well-implemented, and address the intended issues.

Comment thread python/sglang/srt/batch_overlap/two_batch_overlap.py
@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

voipmonitor pushed a commit to voipmonitor/sglang that referenced this pull request Apr 12, 2026
@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

/rerun-test test/srt/ep/test_deepep_small.py test/srt/ep/test_mooncake_ep_small.py test/srt/ep/test_deepep_large.py

@github-actions

Copy link
Copy Markdown
Contributor

test/srt/ep/test_deepep_small.py: File not found: test/srt/ep/test_deepep_small.py

test/srt/ep/test_mooncake_ep_small.py: File not found: test/srt/ep/test_mooncake_ep_small.py

test/srt/ep/test_deepep_large.py: File not found: test/srt/ep/test_deepep_large.py

@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

/rerun-test test/registered/ep/test_deepep_small.py test/registered/ep/test_mooncake_ep_small.py test/registered/ep/test_deepep_large.py

@github-actions

Copy link
Copy Markdown
Contributor

4-gpu-h100 (2 tests): View workflow run

cd test/ && python3 registered/ep/test_deepep_small.py
cd test/ && python3 registered/ep/test_mooncake_ep_small.py

8-gpu-h200 (1 test): View workflow run

cd test/ && python3 registered/ep/test_deepep_large.py

@Qiaolin-Yu

Copy link
Copy Markdown
Collaborator

I believe there are no other registered tests related to this pr. so it should be ok to merge it.

@Qiaolin-Yu
Qiaolin-Yu merged commit f75a8b6 into sgl-project:main Apr 30, 2026
106 of 134 checks passed
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [Qwen3.5] TboAttnBackend crashes with linear attention: forward() missing 3 required positional arguments: 'q', 'k', and 'v'

4 participants