Skip to content

[Triton/Gluon] Accept strided leading dimensions in GDN L2Norm - #5624

Merged
azaidy merged 1 commit into
ROCm:mainfrom
vorapolsiloai:fix/gdn-l2norm-strided-reshape
Oct 12, 2026
Merged

azaidy merged 1 commit into
ROCm:mainfrom
vorapolsiloai:fix/gdn-l2norm-strided-reshape

Conversation

@vorapolsiloai

Copy link
Copy Markdown
Contributor

Summary

  • Replace view() with reshape() when flattening leading dimensions for the Triton GDN L2Norm wrapper.
  • Preserve the zero-copy view for compatible contiguous inputs while allowing valid strided tensors to materialize safely when required.
  • Add focused coverage for non-contiguous leading dimensions against an FP32 reference.

Context

Qwen3.8 TP1 can pass Q/K tensors whose last dimension is contiguous but whose leading dimensions cannot be flattened with view(). The kernel supports this layout after flattening; the wrapper currently rejects it before launch.

This is a correctness and integration-enabling change. It does not claim an independent serving-throughput uplift.

Test plan

  • Run the Triton GDN L2Norm test with transposed BF16 inputs at short and multi-tile token counts on MI355.
  • Compare normalized output against the FP32 PyTorch reference.
  • Verify output shape and the no-rstd inference contract.
  • Run syntax, formatting, and whitespace checks.

@vorapolsiloai
vorapolsiloai requested a review from a team September 17, 2026 06:05
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5624 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

@github-actions github-actions Bot changed the title [Triton] Accept strided leading dimensions in GDN L2Norm [Triton/Gluon] Accept strided leading dimensions in GDN L2Norm Sep 17, 2026
@Boss2002n
Boss2002n requested a lite review from Copilot September 17, 2026 09:33

Copilot AI 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.

🟢 Approval recommended

No blocking issues were identified; one non-blocking test-structure nit remains.

Pull request overview

Updates GDN L2 normalization to support valid strided leading dimensions using reshape(), with BF16 correctness coverage.

Changes:

  • Preserve compatible views while safely materializing incompatible layouts.
  • Add transposed-input tests against an FP32 reference.
File summaries
File Summary
op_tests/triton_tests/normalization/test_gdn_l2norm.py Adds strided-input correctness tests.
aiter/ops/triton/_triton_kernels/gated_delta_rule/utils/l2norm.py Uses reshape() to support non-contiguous leading dimensions.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zufayu
zufayu requested review from a team and azaidy September 18, 2026 01:17

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

Left one comment.

@vorapolsiloai
vorapolsiloai force-pushed the fix/gdn-l2norm-strided-reshape branch from 8babab8 to 6f7037f Compare September 29, 2026 14:12
@azaidy
azaidy requested a review from amd-jrosas October 7, 2026 15:43
@azaidy

azaidy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@vorapolsiloai can you rebase and resolve conflicts

@vorapolsiloai

Copy link
Copy Markdown
Contributor Author

@amd-jrosas @azaidy Thanks for reviewing this. I realized the PR description omitted the related downstream context. This change was created while the strided GDN Q/K integration was evolving in SGLang #38806 and SGLang #39595.

Both SGLang branches have since evolved. SGLang #38806 now handles the strided packed input in its fused prefill preparation, writes normalized contiguous Q/K, and disables downstream Q/K normalization. SGLang #39595 creates contiguous Q/K before calling AITER L2Norm. Therefore, neither current path depends on this AITER change, and I have not found another active caller that requires it.

This PR now appears to provide only general support for hypothetical strided callers, while reshape() may silently materialize a copy. Would you prefer that I close it as no longer needed? I can rebase it if AITER intentionally wants strided leading dimensions to be part of the supported API contract; otherwise, keeping layout handling explicit at the SGLang/framework boundary seems preferable.

@azaidy

azaidy commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@amd-jrosas @azaidy Thanks for reviewing this. I realized the PR description omitted the related downstream context. This change was created while the strided GDN Q/K integration was evolving in SGLang #38806 and SGLang #39595.

Both SGLang branches have since evolved. SGLang #38806 now handles the strided packed input in its fused prefill preparation, writes normalized contiguous Q/K, and disables downstream Q/K normalization. SGLang #39595 creates contiguous Q/K before calling AITER L2Norm. Therefore, neither current path depends on this AITER change, and I have not found another active caller that requires it.

This PR now appears to provide only general support for hypothetical strided callers, while reshape() may silently materialize a copy. Would you prefer that I close it as no longer needed? I can rebase it if AITER intentionally wants strided leading dimensions to be part of the supported API contract; otherwise, keeping layout handling explicit at the SGLang/framework boundary seems preferable.

@vorapolsiloai do you see any future need for strided callers? Is there a performance hit to having the reshape - I assume not but confirming? My take is the contribution solidifies the kernel so unless there are other issues lets rebase and try to get it merged into aiter.

Qwen3.8 TP1 can pass Q/K views whose leading dimensions cannot be flattened with `view()`. Use `reshape()` so contiguous inputs retain the zero-copy path while valid strided inputs materialize safely.

- Cover strided Q/K parity through the public GDN wrapper
@vorapolsiloai
vorapolsiloai force-pushed the fix/gdn-l2norm-strided-reshape branch from 6f7037f to e2c361f Compare October 9, 2026 20:43
@vorapolsiloai

Copy link
Copy Markdown
Contributor Author

I couldn't find a current strided caller. SGLang and vLLM disable AITER-side Q/K normalization because they already normalize Q/K during fused preparation, not because this path is broken. I see this mainly as defensive hardening for a future caller that enables AITER-side normalization and passes tensor views.

I checked on MI355X: for contiguous inputs, reshape() remained zero-copy and added about 9 ns versus view(), so there is no meaningful impact to the existing path. For incompatible strided inputs, it materializes a copy instead of raising an error.

I've rebased the PR, and the regression test passes (2 tests).

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

LGTM!

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.

5 participants