Skip to content

[BugFix][310p] Align 310P GDN state semantics with vLLM - #7902

Merged
wangxiyuan merged 5 commits into
vllm-project:mainfrom
Tflowers-0129:310p-state-align-vllm
Apr 8, 2026
Merged

wangxiyuan merged 5 commits into
vllm-project:mainfrom
Tflowers-0129:310p-state-align-vllm

Conversation

@Tflowers-0129

@Tflowers-0129 Tflowers-0129 commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

  • I found that the FLA state semantics are not aligned between vllm-ascend and vLLM: in vLLM, the state layout is [N, HV, V, K], while in vllm-ascend it is [N, HV, K, V]. The early 310P implementation was aligned with the mainline vllm-ascend behavior, but the operator team now plans to provide a fused recurrent-gated-delta-rule operator whose semantics will align with vLLM. Therefore, this needs to be adjusted in advance.

  • I also found that L2 normalization can use the operator provided in functional, instead of being fully implemented through manually stitched small ops as it is now.

Does this PR introduce any user-facing change?

NA

How was this patch tested?

ut and the e2e test

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
@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 aligns the 310P GDN state semantics with vLLM by adjusting the state layout and refactoring L2 normalization to use standard library functions. These changes ensure consistency across the codebase and prepare for upcoming operator updates.

Highlights

  • State Layout Alignment: Updated the FLA state semantics layout from [N, HV, K, V] to [N, HV, V, K] to ensure compatibility with vLLM's expected format.
  • L2 Normalization Optimization: Replaced manual L2 normalization implementations with PyTorch's built-in functional operator for improved efficiency and maintainability.

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

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.

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

github-actions Bot commented Apr 1, 2026

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 PR aligns the state layout of Gated Delta Rule (GDN) operations with vLLM by swapping the K and V dimensions in state tensors. Feedback focuses on maintaining numerical stability by avoiding F.normalize in favor of an explicit L2 norm with a larger epsilon for float16 compatibility, and correcting the PR title format.

Suggested PR Title:

[310p][Ops][BugFix] Align 310P GDN state semantics with vLLM

Suggested PR Summary:

### What this PR does / why we need it?
This PR aligns the state layout of Gated Delta Rule (GDN) operations (chunked and fused recurrent) with vLLM's expected semantics by changing state shapes from `[..., K, V]` to `[..., V, K]`. This ensures consistency with reference FLA kernels.

Feedback was provided to revert the change from manual L2 normalization to `torch.nn.functional.normalize`, as the latter's default epsilon (1e-12) is too small for `float16` stability.

### Does this PR introduce _any_ user-facing change?
Yes, the expected shape of the `initial_state` tensor for GDN operations has changed.

### How was this patch tested?
Tested via updated unit tests and new parity tests verifying state layout against vLLM reference values.

Comment thread vllm_ascend/_310p/ops/fla/chunk_gated_delta_rule.py Outdated
Comment thread vllm_ascend/_310p/ops/fla/fused_recurrent_gated_delta_rule.py
Comment thread vllm_ascend/_310p/ops/fla/fused_recurrent_gated_delta_rule.py Outdated
@Tflowers-0129 Tflowers-0129 changed the title [Bugfix][310p] Align 310P GDN state semantics with vLLM [BugFix][310p] Align 310P GDN state semantics with vLLM Apr 1, 2026
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>
@wangxiyuan
wangxiyuan merged commit dbf9f7a into vllm-project:main Apr 8, 2026
38 checks passed
Tflowers-0129 added a commit to pu-zhe/vllm-ascend that referenced this pull request Apr 9, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
(cherry picked from commit dbf9f7a)
guxin108 pushed a commit to guxin108/vllm-ascend that referenced this pull request Apr 24, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: guxin108 <1252896542@qq.com>
chenchuw886 pushed a commit to chenchuw886/vllm-ascend that referenced this pull request Apr 27, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
zouyida2052 pushed a commit to zouyida2052/vllm-ascend that referenced this pull request Apr 28, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: zouyida2052 <zouyida2002@gmail.com>
yangzhe-2026 pushed a commit to yangzhe-2026/vllm-ascend that referenced this pull request May 6, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
nanxingMy pushed a commit to nanxingMy/vllm-ascend that referenced this pull request May 15, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Signed-off-by: nanxing <1014662416@qq.com>
ader47 pushed a commit to ader47/vllm-ascend that referenced this pull request Jun 18, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
CXY-Katrina pushed a commit to CXY-Katrina/vllm-ascend that referenced this pull request Jun 27, 2026
…#7902)

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

- I found that the FLA state semantics are not aligned between
vllm-ascend and vLLM: in vLLM, the state layout is `[N, HV, V, K]`,
while in vllm-ascend it is `[N, HV, K, V]`. The early 310P
implementation was aligned with the mainline vllm-ascend behavior, but
the operator team now plans to provide a ` fused
recurrent-gated-delta-rule` operator whose semantics will align with
vLLM. Therefore, this needs to be adjusted in advance.

- I also found that L2 normalization can use the operator provided in
`functional`, instead of being fully implemented through manually
stitched small ops as it is now.

### Does this PR introduce _any_ user-facing change?
NA

### How was this patch tested?
ut and the e2e test

- vLLM version: v0.18.0
- vLLM main:
vllm-project/vllm@35141a7

---------

Signed-off-by: Tflowers-0129 <2906339855@qq.com>
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.

2 participants