Skip to content

Eliminate AIV_HUB init task in paged_attention_unroll orchestration#318

Closed
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:optimize/pa-unroll-hub
Closed

Eliminate AIV_HUB init task in paged_attention_unroll orchestration#318
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:optimize/pa-unroll-hub

Conversation

@chenshengxin2026
Copy link
Contributor

Summary

  • Remove the standalone FUNC_AIV_HUB task that was submitted solely
    to zero-initialize the online-update accumulators (oi, mi_update,
    li_update) before the paged-attention inner loop.
  • Change the first-iteration buffer semantics in FUNC_ONLINE_UPDATE:
    use add_output (write-only) when is_first == true so the kernel
    initializes the accumulators itself; keep add_inout (read-write)
    for subsequent iterations.
  • Net effect: one fewer AIV task submission per query-head group,
    reducing AICPU scheduling overhead and shortening the critical path.

Motivation

The AIV_HUB initialization task was a separate kernel launch whose
only purpose was to prepare accumulator buffers before the first online-
update iteration. Since the online-update kernel already receives the
is_first flag and can distinguish the initial write from incremental
updates, the initialization can be folded into the first iteration by
switching the buffer direction from inout to output. This avoids
the extra task submission, parameter setup, and synchronization cost.

Remove the separate FUNC_AIV_HUB task that zero-initialized the online-
update accumulators (oi, mi_update, li_update) before the inner loop.
Instead, on the first block iteration (is_first), register these buffers
as outputs rather than inouts in FUNC_ONLINE_UPDATE, letting the kernel
handle initialization inline.

This removes one AIV task submission per query-head group, reducing
orchestration overhead and improving end-to-end pipeline throughput.
@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 optimizes the paged attention unroll orchestration by streamlining the initialization of online-update accumulators. By integrating the initialization logic directly into the first iteration of the FUNC_ONLINE_UPDATE kernel, it eliminates the need for a separate, dedicated AIV_HUB task. This refactoring aims to enhance performance by reducing task submission overhead and improving the efficiency of the critical path in the AICPU scheduling.

Highlights

  • Removed AIV_HUB initialization task: The standalone FUNC_AIV_HUB task, previously used for zero-initializing online-update accumulators (oi, mi_update, li_update) before the paged-attention inner loop, has been eliminated.
  • Modified FUNC_ONLINE_UPDATE buffer semantics: The FUNC_ONLINE_UPDATE kernel now uses add_output when is_first == true to allow the kernel to initialize accumulators itself, and retains add_inout for subsequent iterations.
  • Improved performance and reduced overhead: These changes result in one fewer AIV task submission per query-head group, reducing AICPU scheduling overhead and shortening the critical path for paged attention unroll orchestration.

🧠 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.

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.

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 refactors the paged attention orchestration by removing a separate initialization task for accumulator buffers. The initialization is now efficiently handled within the first iteration of the online update kernel by dynamically changing the buffer direction from inout to output based on whether it's the first block being processed. This change correctly implements the described optimization, reducing overhead by eliminating a kernel launch. The implementation is sound and I found no issues in the proposed changes.

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