Refactor aicpu_build_graph: ring buffers, explicit deps, scope-end publish#333
Conversation
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 significantly overhauls the Highlights
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 is a significant and impressive refactoring of the aicpu_build_graph runtime. It replaces the old implementation with the new PTO2 ring buffer infrastructure, introducing explicit dependency management, scope-based batch publishing of tasks, and a register-based dispatch protocol. This eliminates the overhead of TensorMap lookups, leading to performance improvements as shown in the benchmarks. The code is well-structured, introducing new components like a decoupled orchestrator and scheduler, a lock-free MPMC ready queue, and robust ring buffer implementations with deadlock detection. The changes are extensive, touching everything from example orchestration logic and kernels to the core runtime implementation on host, AICPU, and AICore. The addition of a new, complex paged_attention_unroll test case demonstrates the capabilities of the new runtime. My review found a few minor areas for improvement, mainly related to code clarity and cleanup.
src/a2a3/runtime/aicpu_build_graph/host/runtime_compile_info.cpp
Outdated
Show resolved
Hide resolved
examples/a2a3/aicpu_build_graph/vector_example/kernels/orchestration/orchestration.cpp
Outdated
Show resolved
Hide resolved
examples/a2a3/aicpu_build_graph/vector_example/kernels/orchestration/orchestration.cpp
Outdated
Show resolved
Hide resolved
examples/a2a3/aicpu_build_graph/vector_example/kernels/orchestration/orchestration.cpp
Outdated
Show resolved
Hide resolved
278420b to
d5c7387
Compare
…blish Replace the old aicpu_build_graph runtime (fixed Task array, mutex scheduling, handshake dispatch, raw uint64_t args) with PTO2's ring buffer infrastructure while keeping explicit dependency management (no TensorMap). - Ring buffers: HeapRing, TaskRing, DepListPool for concurrent build+execute - Register-based dispatch: DATA_MAIN_BASE/COND protocol - Scope-end batch publish: tasks invisible until scope_end - Explicit add_dependency: no TensorMap lookup/insert overhead - PTOParam/Tensor args: typed tensor args with HeapRing output allocation - dep_pool reclaim: periodic reclamation prevents pool exhaustion Examples migrated: vector_example, bgemm New tests: paged_attention, paged_attention_unroll Benchmark: added -r/--runtime flag to benchmark_rounds.sh Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d5c7387 to
01ada96
Compare
Summary
Replace the old
aicpu_build_graphruntime (fixed Task array, mutex scheduling, handshake dispatch, rawuint64_targs) with PTO2's ring buffer infrastructure while keeping explicit dependency management (no TensorMap).scope_end, enabling non-atomic dep wiringadd_dependency: No TensorMap lookup/insert overheadNew API
Examples migrated
New tests
Benchmark updated
tools/benchmark_rounds.sh: added-r/--runtimeflag for runtime selectionbenchmark-prskill: auto-detects affected runtimesPerformance (Paged Attention Unroll, 10 rounds, Ascend 910)
The improvement comes from eliminating TensorMap lookup/insert in the orchestration submit path.
Test plan
vector_examplesimulation test PASSbgemmsimulation test PASSpaged_attentionhardware test PASS (batch=256, all 524288 elements matched)paged_attention_unrollCase1+Case2 hardware test PASStensormap_and_ringbufferexamples unaffected (no regression)./ci.sh -p a2a3sim— 12/12 PASS./ci.sh -p a2a3 -d 4-7 --parallel— 21/21 PASS🤖 Generated with Claude Code