Repository navigation
perf(ascend): accelerate packed Q/K and strided KV/SwiGLU kernels - #1000
Open
JoeZhang-0x000 wants to merge 1 commit into
Open
JoeZhang-0x000 wants to merge 1 commit into
JoeZhang-0x000 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Motivation
Packed Q/K normalization currently stages individual rows through many device copies; RoPE gathers expanded tables and copies the vendor output back. The strided KV kernel executes all tokens and heads on one block. These costs became bottlenecks while optimizing the non-Attention vLLM path on Ascend 910B4.
The new kernels read the original layouts directly. Unsupported dtypes/shapes/layouts retain the existing ACLNN implementation; the strided KV kernel continues to support NHD/HND caches, padded heads, negative slots and unaligned tails.
Type of Change
perf— performance improvementtest— regression coveragebuild— AscendC source registrationPlatforms Affected
WITH_ASCEND)Smoke Test Result
Ascend 910B4, CANN 9.1, PyTorch/TorchNPU 2.10; InfiniRT
6b256e0ab0853d9e2a7ef059bac22c847bd02251. Built withWITH_ASCEND=ON,BUILD_ASCEND_CUSTOM=ON, and the default smoke allowlist extended byrotary_embedding,reshape_and_cache_flash.Exact BF16 RMSNorm/RoPE comparisons and graph replay after changing input, weights, positions and cache passed. KV checks include 8191/8192 tokens, both cache layouts, padded heads and an 8193-element head exceeding the fixed UB tile. FP16/FP32 fallback cases also passed.
git diff --check, C++ formatting, and Python lint/format checks passed.Test Results on Supported Platforms
Benchmark / Performance Impact
Before: InfiniOps
4c014ca57a0af78bd1501a9b9bfe98647f05b55b. After: this branch. Both packages built against the same InfiniRT/CANN, run serially on device 0 without another experiment or compilation. BF16; five warmups, five synchronized batches of 20 calls, median warm host-plus-device latency. Initialization and graph capture are excluded; these are eager operator measurements.Notes for Reviewers
INFINI_HAS_CUSTOM_KERNELS; existing vendor paths remain available for other layouts. SwiGLU keeps contiguous output on ACLNN because measurements showed the custom kernel's launch overhead was higher there.