Skip to content

[WIP] Fix: add PTOStride alias and remove pipe_barrier for A5#229

Closed
ChaoZheng109 wants to merge 1 commit intohw-native-sys:mainfrom
ChaoZheng109:examples-a5
Closed

[WIP] Fix: add PTOStride alias and remove pipe_barrier for A5#229
ChaoZheng109 wants to merge 1 commit intohw-native-sys:mainfrom
ChaoZheng109:examples-a5

Conversation

@ChaoZheng109
Copy link
Collaborator

@ChaoZheng109 ChaoZheng109 commented Mar 10, 2026

  • Define PTOStride template alias (wrapping pto::Stride) in each kernel
    file to resolve naming conflict with the global enum class Stride
    defined in ccec's __clang_cce_vector_intrinsics.h on A5 platform
  • Remove pipe_barrier(PIPE_V) calls in aiv_online_update as A5 hardware
    provides ordering guarantees natively

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two key issues: a naming conflict with the Stride type in kernel files and an incompatibility with pipe_barrier usage on A5 hardware. By introducing a PTOStride alias, the naming clash is resolved, and by updating barrier types, the kernels are made compatible with A5, ensuring broader hardware support and correct execution.

Highlights

  • Naming Conflict Resolution: Defined a PTOStride template alias in various kernel files to resolve a naming conflict with a global enum class Stride.
  • A5 Compatibility for Barriers: Replaced pipe_barrier(PIPE_V) with pipe_barrier(PIPE_ALL) in aiv_online_update kernels to ensure correct functionality on A5 AIV hardware, as PIPE_V was outside the valid range.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • examples/host_build_graph/bgemm/kernels/aic/kernel_gemm_tile.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/bgemm/kernels/aiv/kernel_tile_add.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/matmul/kernels/aic/kernel_matmul.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/matmul/kernels/aiv/kernel_add_exp.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/matmul/kernels/aiv/kernel_log_sqrt.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/paged_attention/kernels/aic/aic_pv_matmul.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/paged_attention/kernels/aic/aic_qk_matmul.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/paged_attention/kernels/aiv/aiv_online_update.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
    • Replaced pipe_barrier(PIPE_V) with pipe_barrier(PIPE_ALL) for A5 compatibility.
    • Updated comments reflecting the change from PIPE_V to PIPE_ALL.
  • examples/host_build_graph/paged_attention/kernels/aiv/aiv_softmax_prepare.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/vector_example/kernels/aiv/kernel_add.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/vector_example/kernels/aiv/kernel_add_scalar.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • examples/host_build_graph/vector_example/kernels/aiv/kernel_mul.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • tests/device_tests/host_build_graph/paged_attention/kernels/aic/aic_pv_matmul.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • tests/device_tests/host_build_graph/paged_attention/kernels/aic/aic_qk_matmul.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
  • tests/device_tests/host_build_graph/paged_attention/kernels/aiv/aiv_online_update.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
    • Replaced pipe_barrier(PIPE_V) with pipe_barrier(PIPE_ALL) for A5 compatibility.
    • Updated comments reflecting the change from PIPE_V to PIPE_ALL.
  • tests/device_tests/host_build_graph/paged_attention/kernels/aiv/aiv_softmax_prepare.cpp
    • Defined PTOStride template alias to resolve naming conflicts.
    • Updated GlobalTensor definitions to use PTOStride alias.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two main changes: adding a PTOStride alias to work around a naming conflict and updating pipe_barrier calls from PIPE_V to PIPE_ALL for A5 hardware compatibility. The changes appear correct and address the intended issues. However, the PTOStride alias is duplicated across many files. I've suggested moving it to a common header to improve maintainability. I also noted a minor inconsistency in an updated comment.

Comment on lines +14 to +16
template <int64_t SN1 = DYNAMIC, int64_t SN2 = DYNAMIC, int64_t SN3 = DYNAMIC,
int64_t SN4 = DYNAMIC, int64_t SN5 = DYNAMIC>
using PTOStride = pto::Stride<SN1, SN2, SN3, SN4, SN5>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This PTOStride template alias is defined in multiple files across this pull request, leading to significant code duplication. To improve maintainability and reduce redundancy, please consider defining this alias in a single common header file (e.g., a new header in pto/common/ or an existing one if appropriate) and including it where needed. This would apply to all other kernel files modified in this PR.


// Phase 2: Scalar arithmetic in RowMajor (kScalarRows, kScalarCols)
// pipe_barrier(PIPE_V) required between each dependent vector operation
// pipe_barrier(ALL) required between each dependent vector operation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment was updated to (ALL), but the code uses PIPE_ALL. For consistency with the code and the corresponding change in examples/host_build_graph/paged_attention/kernels/aiv/aiv_online_update.cpp, please update this comment to use (PIPE_ALL).

        // pipe_barrier(PIPE_ALL) required between each dependent vector operation

- Define PTOStride template alias (wrapping pto::Stride) in each kernel
  file to resolve naming conflict with the global enum class Stride
  defined in ccec's __clang_cce_vector_intrinsics.h on A5 platform
- Remove pipe_barrier(PIPE_V) calls in aiv_online_update as A5 hardware
  provides ordering guarantees natively
@ChaoZheng109 ChaoZheng109 changed the title Fix: add PTOStride alias and replace PIPE_V barriers for A5 [WIP] Fix: add PTOStride alias and remove pipe_barrier for A5 Mar 10, 2026
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