refactor(ops): migrate paged attention to canonical InfiniOps - #1481
Open
voltjia wants to merge 2 commits into
Open
refactor(ops): migrate paged attention to canonical InfiniOps#1481voltjia wants to merge 2 commits into
voltjia wants to merge 2 commits into
Conversation
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.
What
FlashAttnWithKvcacheAPI.mha_varlenpaged-prefill calls through the canonical InfiniOpsFlashAttnVarlenFuncAPI.21b07ebcfdb0f993d2f3b672a4e38788e489fb80to the merged [2025秋季][T1-1-49]zili2004 #911 revision1c865aea58a6af8bbfdc67b76a4ed0ea8d1c167d.Alignment
paged_attentiondecodeFlashAttnWithKvcache(q, k_cache, v_cache, k=nullopt, v=nullopt, rotary_cos=nullopt, rotary_sin=nullopt, cache_seqlens, cache_batch_idx=nullopt, cache_leftpad=nullopt, block_table, alibi_slopes, softmax_scale, causal=true, window_size=(-1, -1), softcap=0, rotary_interleaved=true, num_splits=0, return_softmax_lse=false, out, softmax_lse=nullopt)flash_attn_with_kvcache, InfiniOps API, linked provider #894mha_varlenpaged prefillFlashAttnVarlenFunc(q, k, v, cu_seqlens_q, cu_seqlens_k, alibi_slopes, block_table, max_seqlen_q, max_seqlen_k, dropout_p=0, softmax_scale=scale, causal=true, window_size=(-1, -1), softcap=0, deterministic=false, return_attn_probs=false, out, softmax_lse=nullopt, s_dmask=nullopt)flash_attn_varlen_func, InfiniOps API, linked provider #911The adapters use metadata-only views to match the public FlashAttention layouts. InfiniOps orders tensor inputs before attributes and outputs last according to its contribution rules.
Scope
No public InfiniCore Python or C++ API changes are introduced. Unsupported decode layouts continue to use
PagedAttentionInfinilm; unsupportedmha_varlenlayouts continue to use the existing ATen path. No native provider is added because both canonical implementations are loaded from the existing linked FlashAttention library.This PR does not remove every InfiniLM-suffixed call from InfiniCore. The remaining call sites are tracked separately and include the paged-attention decode fallback plus the legacy KV caching, paged-attention prefill, random sampling, and rotary-embedding adapters.
Screenshots: N/A (backend adapter migration only).
Validation
Run on
ssh nvidiainaccelerator-dev/nvidia:lateston NVIDIA A100 GPUs:scripts/format.py --check --c clang-format-16 --py ruffpassed with clang-format 16.0.6 and CI-pinned ruff 0.15.20 for the decode change; clang-format 16.0.6 also passed for the prefill source.git diff --checkpassed for the combined branch._infinicorebuilds passed with canonical and fallback wrappers enabled together.python test/infinicore/ops/mha_varlen.py --nvidia --verbose: 22/22 passed, covering 20 FP16/BF16 paged cases and 2 dense MLA fallback cases.