Skip to content

feat(ops): add vLLM-aligned paged attention v1 - #893

Open
voltjia wants to merge 1 commit into
masterfrom
feat/add-paged-attention-v1
Open

feat(ops): add vLLM-aligned paged attention v1#893
voltjia wants to merge 1 commit into
masterfrom
feat/add-paged-attention-v1

Conversation

@voltjia

@voltjia voltjia commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add the canonical PagedAttentionV1 operator aligned with the public vLLM v0.6.3 Python wrapper.
  • Add shared CUDA providers for NVIDIA, Iluvatar, MetaX, and Moore while retaining the deprecated PagedAttentionInfinilm interface.
  • Move the reusable decode kernel under paged_attention_v1 so the legacy provider depends on the canonical implementation.

Motivation

PagedAttentionInfinilm exposes an InfiniLM-specific cache layout and cannot serve as the canonical open-source-aligned interface. A public vLLM-aligned operator is needed before compatible consumers can migrate away from the deprecated API.

Type of Change

  • feat - new feature / new operator / new platform
  • fix - bug fix
  • perf - performance improvement (no behavioral change)
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

Validated on ssh nvidia in accelerator-dev/nvidia:latest with a focused CPU + NVIDIA build containing the canonical and legacy operators:

$ python3 -m pip install . --no-build-isolation --no-deps \
    --config-settings=cmake.define.WITH_CPU=ON \
    --config-settings=cmake.define.WITH_NVIDIA=ON \
    --config-settings=cmake.define.INFINI_OPS_OPS=paged_attention_v1,paged_attention_infinilm
Successfully built InfiniOps
Successfully installed InfiniOps-0.1.0

$ python3 -m pytest tests/test_paged_attention_v1.py \
    tests/test_paged_attention_infinilm.py --devices nvidia -q
24 passed in 4.76s

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA Yes focused build passed 12 canonical and 12 legacy tests passed
Iluvatar Yes not run strict provider generation passed; platform hardware unavailable
MetaX Yes not run strict provider generation passed; platform hardware unavailable
Cambricon No N/A N/A - not affected
Moore Yes not run strict provider generation passed; platform hardware unavailable
Ascend No N/A N/A - not affected

Additional checks:

$ python3 scripts/generate_wrappers.py \
    --devices nvidia iluvatar metax moore \
    --ops paged_attention_v1 --strict-ops
passed

$ python3 -m pytest tests/test_generate_wrappers.py -q
23 passed

$ clang-format --dry-run --Werror <changed C++ files>
passed

$ python3 -m ruff check tests/test_paged_attention_v1.py
All checks passed!

$ python3 -m ruff format --check tests/test_paged_attention_v1.py
1 file already formatted

Benchmark / Performance Impact

N/A. This PR exposes an existing decode algorithm through a canonical interface and does not claim a performance change.

Notes for Reviewers

API alignment

InfiniOps API Alignment target Evidence
PagedAttentionV1(query, key_cache, value_cache, block_tables, seq_lens, alibi_slopes, num_kv_heads, scale, block_size, max_seq_len, kv_cache_dtype, k_scale, v_scale, tp_rank, blocksparse_local_blocks, blocksparse_vert_stride, blocksparse_block_size, blocksparse_head_sliding_step, out) vLLM paged_attention_v1(out, query, key_cache, value_cache, num_kv_heads, scale, block_tables, seq_lens, block_size, max_seq_len, alibi_slopes, kv_cache_dtype, k_scale, v_scale, tp_rank=0, blocksparse_local_blocks=0, blocksparse_vert_stride=0, blocksparse_block_size=64, blocksparse_head_sliding_step=0) vLLM v0.6.3 public Python wrapper

InfiniOps applies its C++ input-attribute-output grouping rule: tensor inputs retain their upstream relative order, scalar and string attributes retain their upstream relative order, and the writable out tensor is trailing. The operator has one canonical overload; Python defaults remain explicit C++ arguments.

Current provider scope

The interface represents every vLLM parameter. The current shared CUDA provider supports the existing unquantized dense path: float16/bfloat16 data, head sizes 64 or 128, kv_cache_dtype == "auto", unit K/V scales, and block-sparse attributes disabled. Unsupported values are rejected explicitly rather than removed from the public interface.

PagedAttentionInfinilm remains available and deprecated. Its 4D cache path is covered by the legacy tests, while PagedAttentionV1 uses vLLM's vectorized 5D key-cache and transposed 4D value-cache layouts. No consumer migration or legacy API removal is included in this PR.

@voltjia
voltjia requested a review from a team August 6, 2026 18:50
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