Eliminate AIV_HUB init task in paged_attention_unroll orchestration#318
Eliminate AIV_HUB init task in paged_attention_unroll orchestration#318chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
Conversation
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.
Summary of ChangesHello, 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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
Summary
FUNC_AIV_HUBtask that was submitted solelyto zero-initialize the online-update accumulators (
oi,mi_update,li_update) before the paged-attention inner loop.FUNC_ONLINE_UPDATE:use
add_output(write-only) whenis_first == trueso the kernelinitializes the accumulators itself; keep
add_inout(read-write)for subsequent iterations.
reducing AICPU scheduling overhead and shortening the critical path.
Motivation
The
AIV_HUBinitialization task was a separate kernel launch whoseonly purpose was to prepare accumulator buffers before the first online-
update iteration. Since the online-update kernel already receives the
is_firstflag and can distinguish the initial write from incrementalupdates, the initialization can be folded into the first iteration by
switching the buffer direction from
inouttooutput. This avoidsthe extra task submission, parameter setup, and synchronization cost.