Skip to content

[BugFix][Mamba] Fix PtrOffsetInfo AxisInfo assertion failure - #15032

Merged
weijinqian0 merged 7 commits into
vllm-project:mainfrom
Lethobenthos20:mamba_triton_v2
Aug 27, 2026
Merged

weijinqian0 merged 7 commits into
vllm-project:mainfrom
Lethobenthos20:mamba_triton_v2

Conversation

@Lethobenthos20

@Lethobenthos20 Lethobenthos20 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

This PR fixes the following Triton Ascend assertion failure in the Mamba state pre-copy kernel:

PtrOffsetInfo::AxisInfo::operator[]: Assertion `idx < size()` failed

This issue was also observed in #7103 and #10888 .
This PR also:

After these changes, V2 Runner inference works correctly.
Below is the accuracy of Qwen3.5-27B on the GPQA benchmark.
image

Signed-off-by: Lethobenthos20 <3205604419@qq.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation module:tests module:ops labels Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [BugFix] tag, indicating a bug fix or new feature.

Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:

  • Fixes #<issue_number>
  • Closes #<issue_number>
  • Resolves #<issue_number>
  • Refs #<rfc_or_issue_number> (for RFCs)

🙏 Thanks for helping us keep the project well-organized!

@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 a critical Triton Ascend assertion failure in the Mamba state pre-copy kernel, which previously hindered V2 Runner inference. The changes include a refactored kernel implementation to resolve the assertion error, the addition of a robust end-to-end test suite to ensure future stability, and the inclusion of detailed documentation to clarify kernel parameters and constraints.

Highlights

  • Bug Fix: Resolved the PtrOffsetInfo::AxisInfo assertion failure in the Mamba state pre-copy kernel by improving memory handling and kernel logic.
  • Testing: Added a comprehensive end-to-end test suite to verify the kernel across various layouts and execution modes.
  • Documentation: Added detailed documentation covering kernel behavior, parameters, constraints, and usage examples.
  • Refactoring: Refactored the kernel implementation to improve stability and ensure compatibility with V2 Runner inference.
New Features

🧠 You can now enable Memory (public preview) 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.

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 the 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 counterproductive. 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.

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

Suggested PR Title:

[Ops][Feature] Support multi-tile parallelization for Mamba precopy kernel in v2

Suggested PR Summary:

### What this PR does / why we need it?
This pull request migrates the `precopy_mamba_align_fused_kernel` to the v2 Triton path and introduces support for multi-tile parallelization (`TEMPORAL_TILES`) to optimize temporal state copying. It also adds documentation and unit tests for the precopy kernel.

Feedback:
A review comment identifies a workload imbalance issue in the temporal state copy logic due to `per_tile_u64` alignment, which can defeat the purpose of parallelization. A more balanced work distribution is suggested.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Tested using the newly added unit test: `tests/e2e/nightly/single_node/ops/singlecard_ops/triton/test_precopy.py`.

Comment on lines +94 to +96
per_tile_u64 = tl.cdiv(tl.cdiv(copy_size_u64, TEMPORAL_TILES), COPY_BLOCK_SIZE) * COPY_BLOCK_SIZE
tile_start = tile_idx.to(tl.int64) * per_tile_u64
tile_end = tl.minimum(tile_start + per_tile_u64, copy_size_u64)

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.

high

The current workload distribution for temporal state copy can be inefficient. per_tile_u64 is aligned up to COPY_BLOCK_SIZE, which can cause significant load imbalance among tiles. For instance, with copy_size_u64 = 130, TEMPORAL_TILES = 4, and COPY_BLOCK_SIZE = 128, per_tile_u64 becomes 128. This results in:

  • Tile 0 processing 128 elements.
  • Tile 1 processing 2 elements.
  • Tiles 2 and 3 processing 0 elements.

This largely defeats the purpose of parallelization. A more balanced distribution can be achieved by dividing the work more evenly.

Suggested change
per_tile_u64 = tl.cdiv(tl.cdiv(copy_size_u64, TEMPORAL_TILES), COPY_BLOCK_SIZE) * COPY_BLOCK_SIZE
tile_start = tile_idx.to(tl.int64) * per_tile_u64
tile_end = tl.minimum(tile_start + per_tile_u64, copy_size_u64)
work_per_tile = tl.cdiv(copy_size_u64, TEMPORAL_TILES)
tile_start = tile_idx.to(tl.int64) * work_per_tile
tile_end = tl.minimum(tile_start + work_per_tile, copy_size_u64)

Signed-off-by: Lethobenthos20 <3205604419@qq.com>
Signed-off-by: Lethobenthos20 <3205604419@qq.com>
Signed-off-by: Lethobenthos20 <3205604419@qq.com>
@LoganJane LoganJane added the ready-precise run selected e2e test for pr label Aug 26, 2026
Signed-off-by: Lethobenthos20 <3205604419@qq.com>
Signed-off-by: Lethobenthos20 <3205604419@qq.com>
Signed-off-by: Lethobenthos20 <3205604419@qq.com>

@lijiahang226 lijiahang226 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@weijinqian0
weijinqian0 merged commit 8091873 into vllm-project:main Aug 27, 2026
48 checks passed
ASH-XING pushed a commit to ASH-XING/vllm-ascend that referenced this pull request Aug 28, 2026
…oject#15032)

### What this PR does / why we need it?

This PR fixes the following Triton Ascend assertion failure in the Mamba
state pre-copy kernel:

```text
PtrOffsetInfo::AxisInfo::operator[]: Assertion `idx < size()` failed
```
This issue was also observed in vllm-project#7103 and vllm-project#10888 .
This PR also:
- Adds an end-to-end test covering the supported layouts and execution
modes.
- Adds documentation for the kernel behavior, parameters, constraints,
and usage.
This is a follow-up to vllm-project#14649.

After these changes, V2 Runner inference works correctly.

- vLLM version: v0.27.1
- vLLM main:
vllm-project/vllm@ba07e4a

---------

Signed-off-by: Lethobenthos20 <3205604419@qq.com>
Signed-off-by: d30086105 <denghaojie1@h-partners.com>
Lethobenthos20 added a commit to Lethobenthos20/vllm-ascend that referenced this pull request Sep 4, 2026
…oject#15032)

### What this PR does / why we need it?

This PR fixes the following Triton Ascend assertion failure in the Mamba
state pre-copy kernel:

```text
PtrOffsetInfo::AxisInfo::operator[]: Assertion `idx < size()` failed
```
This issue was also observed in vllm-project#7103 and vllm-project#10888 .
This PR also:
- Adds an end-to-end test covering the supported layouts and execution
modes.
- Adds documentation for the kernel behavior, parameters, constraints,
and usage.
This is a follow-up to vllm-project#14649.

After these changes, V2 Runner inference works correctly. 

- vLLM version: v0.27.1
- vLLM main:
vllm-project/vllm@ba07e4a

---------

Signed-off-by: Lethobenthos20 <3205604419@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation module:ops module:tests ready-precise run selected e2e test for pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants