Skip to content

[Performance][310p] use recurrent gdn custom op with aclgraph - #9106

Closed
Tflowers-0129 wants to merge 9 commits into
vllm-project:mainfrom
Tflowers-0129:512-310p-gdn-recurrent-graph
Closed

Tflowers-0129 wants to merge 9 commits into
vllm-project:mainfrom
Tflowers-0129:512-310p-gdn-recurrent-graph

Conversation

@Tflowers-0129

@Tflowers-0129 Tflowers-0129 commented May 12, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

[310P] Fix linear attention graph capture and dtype issues

  • Fix graph capture issue for causal-conv1d operator.
  • Fix dtype handling issue in recurrent-gated-delta-rule-310.
  • Integrate fused operators for the 310P linear attention path.

Does this PR introduce any user-facing change?

NA

How was this patch tested?

some UT and local test

@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 introduces performance optimizations for the 310P platform by integrating a custom recurrent GDN operator with ACLGraph. The changes involve updating core operator signatures to use optional tensors, replacing fallback PyTorch implementations with specialized NPU kernels for decode and spec-decode operations, and cleaning up test code to align with these API updates.

Highlights

  • Custom Kernel Integration: Integrated the recurrent GDN custom operator with ACLGraph for improved performance on 310P hardware.
  • API Refactoring: Updated the npu_causal_conv1d_310 operator signature to accept optional tensors instead of IntArrayRef, enhancing flexibility.
  • Kernel Replacement: Replaced the generic fused_recurrent_gated_delta_rule_pytorch with the optimized npu_recurrent_gated_delta_rule_310 for decode and spec-decode workflows.
  • Test Cleanup: Refactored test utilities to remove redundant conversion functions and updated test cases to support the new operator signature.
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. ↩

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

@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 a custom recurrent Gated Delta Net (GDN) operator for Ascend 310P to optimize performance and support graph capture, replacing the previous PyTorch-based implementation. It also updates the npu_causal_conv1d_310 operator to accept Tensors instead of array references for metadata, facilitating aclgraph compatibility. Feedback from the reviewer indicates that the PR title and summary do not adhere to the repository's style guide. Furthermore, a high-severity issue was identified regarding a missing in-place marker for the conv_states tensor in the operator registration, which could lead to incorrect behavior during graph capture.

Comment thread csrc/torch_binding.cpp
Comment on lines 998 to 1007
" Tensor weight, "
" Tensor? bias, "
" Tensor conv_states, "
" int[] query_start_loc, "
" int[] cache_indices, "
" int[] initial_state_mode, "
" int[] num_accepted_tokens, "
" Tensor? query_start_loc, "
" Tensor? cache_indices, "
" Tensor? initial_state_mode, "
" Tensor? num_accepted_tokens, "
" int activation_mode, "
" int pad_slot_id, "
" int run_mode) -> (Tensor output)");

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

Suggested PR Title:

[310p][Ops][Feature] use recurrent gdn custom op with aclgraph

Suggested PR Summary:

### What this PR does / why we need it?
This PR introduces a custom recurrent GDN operator for Ascend 310P to improve performance and support `aclgraph` capture. It replaces the existing PyTorch-based recurrent rule with a fused kernel (`npu_recurrent_gated_delta_rule_310`) and updates the `causal_conv1d_310` operator to use tensors for metadata instead of array refs, facilitating graph capture.

### Does this PR introduce _any_ user-facing change?
No. This is an internal performance optimization for Ascend 310P.

### How was this patch tested?
Tested with existing E2E nightly tests for `causal_conv1d_310` and GDN attention.

The current PR title and summary do not follow the required format specified in the repository style guide. I have provided a suggested title and summary above.

Additionally, the schema for npu_causal_conv1d_310 is missing the in-place marker for the conv_states tensor. Since this operator updates the convolution states in-place (as verified by the tests), the schema should use Tensor! conv_states to ensure correct behavior with the PyTorch dispatcher and graph capture mechanisms.

        "                         Tensor weight, "
        "                         Tensor? bias, "
        "                         Tensor! conv_states, "
        "                         Tensor? query_start_loc, "
        "                         Tensor? cache_indices, "
        "                         Tensor? initial_state_mode, "
        "                         Tensor? num_accepted_tokens, "
        "                         int activation_mode, "
        "                         int pad_slot_id, "
        "                         int run_mode) -> (Tensor output)");
References
  1. The PR title and summary must follow the specific format: [Branch][Module][Action] Title, and include sections for 'What this PR does', 'User-facing change', and 'How was this patch tested'. (link)

@Tflowers-0129
Tflowers-0129 force-pushed the 512-310p-gdn-recurrent-graph branch 5 times, most recently from 315e9a5 to 59f4378 Compare May 18, 2026 07:31
…r ops

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
@Tflowers-0129
Tflowers-0129 force-pushed the 512-310p-gdn-recurrent-graph branch from fc55af2 to 1f8438e Compare May 19, 2026 05:00
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: Tflowers-0129 <2906339855@qq.com>
@Tflowers-0129

Copy link
Copy Markdown
Collaborator Author

我调试不出来了,causal-conv1d一直出现bad-alloc,先关闭吧,重头开始弄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant