Skip to content

[KMCompiler][ttx]opt for rope#368

Open
YangLong114514 wants to merge 3 commits into
XPU-Forces:masterfrom
YangLong114514:KMCompiler-Rope
Open

[KMCompiler][ttx]opt for rope#368
YangLong114514 wants to merge 3 commits into
XPU-Forces:masterfrom
YangLong114514:KMCompiler-Rope

Conversation

@YangLong114514

Copy link
Copy Markdown

Description

The rope operator has been optimized for the ascend platform.

Changes

  1. Modified the block_size calculation method to dynamically adjust the block_size value based on the UB upper limit of 192KB.

Performance

Using Ascend 910B and Triton 3.2.x of FlagTree:

shape before after speedup= before/after
(1,4,32,64) 32.8846 27.9724 1.18
(2,8,1,32) 3.916 3.0602 1.28
(1,32,1024,32) 70.8734 67.5576 1.05
(2,16,512,128) 86.5778 76.9256 1.13
(1,32,4096,128) 342.8748 320.2106 1.07
(2,16,4096,128) 350.215 319.8304 1.10

Test

Correctness verified against baseline implementation across all shapes and dtypes listed above.

@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 optimizations and safety checks for the RoPE kernel on the NPU backend, including dynamic token block size estimation to prevent compile-time Unified Buffer (UB) overflow, simplified masking, and improved Triton loading and casting. The review feedback suggests replacing an iterative loop with an O(1) mathematical calculation to optimize block size limiting, and removing commented-out code to maintain codebase cleanliness.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread mojo_opset/backends/ttx/kernels/npu/rope.py Outdated
Comment thread mojo_opset/backends/ttx/kernels/npu/rope.py
YangLong114514 and others added 2 commits June 15, 2026 17:55
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant