Skip to content

[BUG] Ascend C compilation fails because paged attention uses reserved block_idx #1519

Description

@ETOwang

版本

  • InfiniCore commit: 46ca684
  • Hardware: Huawei Ascend 910B3
  • CANN: 8.1.RC1
  • OS: Linux
  • Python: Python 3.10 or later
  • Build command: python scripts/install.py --ascend-npu=y

问题描述

InfiniCore cannot compile the Ascend paged attention kernels because
block_idx is used as a local variable name.

Ascend C defines block_idx as a compiler built-in variable/macro.
As a result, the local variable declaration is expanded by the
preprocessor and rejected by the Ascend C compiler.

复现步骤

  1. git clone --recursive https://github.com/InfiniTensor/InfiniCore.git
  2. cd InfiniCore
  3. source scripts/set_env_linux.sh
  4. python scripts/install.py --ascend-npu=y

实际结果

The build fails with errors :

Image

The errors occur in:

  • src/infiniop/ops/paged_attention/ascend/paged_attention_ascend_kernel.cpp
  • src/infiniop/ops/paged_attention_prefill/ascend/paged_attention_prefill_ascend_kernel.cpp

预期结果

The Ascend paged attention kernels should compile successfully.

根因分析

Ascend C reserves block_idx as a built-in variable.
The affected variables in these kernels represent logical paged
attention block indices, rather than Ascend hardware block IDs.

Therefore, they should not be replaced with AscendC::GetBlockIdx().
They should be renamed to a non-reserved identifier while preserving
the existing indexing logic.

建议修复

Rename the logical page-block variables from block_idx to
page_block_idx in the affected Ascend kernels.

This is a source-level naming fix and does not change the algorithm,
operator interface, memory layout, or output semantics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions