fix: optimize InfiniLM paged attention kernels#735
Merged
Conversation
9fd6b5f to
c796425
Compare
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
src/native/cuda/ops/paged_attention_infinilm/kernel.cuhandsrc/native/cuda/ops/paged_attention_prefill_infinilm/kernel.cuh.head_dim=128path, with workspace-backed combine.head_dim=128andblock_size=256, while keeping existing fallback coverage.Motivation
The InfiniOps integration path for InfiniLM paged attention was significantly slower than the previous InfiniCore implementation because it did not use the old fast paged-attention kernels for common InfiniLM shapes.
Before optimization, the integrated InfiniOps path measured about
5427.75 mstotal time for the benchmark below, versus about3069.50 msfor the no-InfiniOps baseline on the same model/shape. This PR restores the decode split-KV CTA path and the pipelined prefill path, bringing the optimized InfiniOps path back to about3096.99 ms.Benchmark setup:
/data-aisoft/mechdancer/models/9g_8b_thinking.bs=1,input_len=256,output_len=256,bfloat16, paged attention + graph enabled.python examples/bench.py --device nvidia --model=/data-aisoft/mechdancer/models/9g_8b_thinking --enable-paged-attn --enable-graph --input-len=256 --output-len=256 --batch-size=1 --warmup.Closes #
Type of Change
feat— new feature / new operator / new platformfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Exact InfiniOps
pytest -m smokewas not run in this workspace. Validation was done through the InfiniCore/InfiniLM integration path that exercises these InfiniLM paged-attention kernels on NVIDIA SM80.Test Results on Supported Platforms
Full `pytest` output (optional)
Benchmark / Performance Impact
Focused benchmark on NVIDIA GPU2 with
9g_8b_thinking,bs=1,input_len=256,output_len=256,bfloat16, paged attention + graph enabled:The optimized InfiniOps path is within about 1% of the measured no-InfiniOps baseline for this focused case.
Notes for Reviewers
kernel.cuhfiles for decode and prefill; there are nolegacyhelper files and no cross-tree includes back into InfiniCore.head_dim=128split-KV CTA and prefillhead_dim=128 && block_size=256pipelined warp-CTA.