Skip to content

test(a5/tmr): port a2a3-only tensormap_and_ringbuffer scene/L3 tests to a5 - #1450

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
yanghaoran29:port-a2a3-tmr-tests-to-a5
Aug 5, 2026
Merged

test(a5/tmr): port a2a3-only tensormap_and_ringbuffer scene/L3 tests to a5#1450
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
yanghaoran29:port-a2a3-tmr-tests-to-a5

Conversation

@yanghaoran29

@yanghaoran29 yanghaoran29 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Port the remaining single-device a2a3-only tensormap_and_ringbuffer scene/L3 coverage onto a5 for differential validation.
  • Cover L3 dependency and host-buffer behavior, dynamic registration, batch/multi-round/4D-unrolled paged attention, alternating matmul/add, fan-in lookup, empty-ring heap rebase, and SPMD batch-dispatch bounds.
  • Add the scalar-data, paged-attention ringbuffer, and merge-pipeline-barrier examples with architecture-specific READMEs, plus the a5 InCore orchestration guide.
  • Adapt the ports to current a5 launch, logging, stride, and runtime APIs; make scene compile-cache keys module-aware as preventative isolation for same-named test classes in different modules.
  • Exclude multi-device coverage and spmd_paged_attention; spmd_paged_attention_highperf also remains out of scope pending a dedicated dav-c310 port.

Test plan

  • A5Sim: all applicable newly added cases pass; the four scenes affected by review fixes were rerun locally.
  • A5 single-device onboard: applicable cases passed in the previous CI run; the rebased revision will rerun the self-hosted A5 lane.
  • Cache regression unit tests: 3 passed after rebase.
  • Full commit-stage pre-commit passed, including pyright.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d8b748fe-313a-454a-ad44-603679e7ffd8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds multiple TensorMap and ringbuffer scene implementations: tiled matmul/add, batched and SPMD paged attention, fan-in and dispatch regression scenarios, plus runtime registration, dependency, host-buffer, and prewarm tests.

Changes

Alternating matmul and add

Layer / File(s) Summary
Tiled kernels and interleaved orchestration
tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/...
Adds AIC matmul and AIV add kernels, per-group tensor views, interleaved task submission, and golden-output validation.

Batched paged attention

Layer / File(s) Summary
Attention kernels and scheduling
tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/...
Adds QK matmul, softmax preparation, PV matmul, online update, and chunked orchestration across batches and heads.
Scene validation
tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/test_batch_paged_attention.py
Adds parameterized execution cases and shared paged-attention golden comparison.

Four-dimensional paged attention

Layer / File(s) Summary
Unrolled kernels and task pipeline
tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/...
Adds pipelined QK, SplitK PV, softmax, online update, and four-stage unrolled orchestration.
Scene validation
tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/test_paged_attention_unroll_4dims.py
Adds 4D query/output handling and reshaping around the shared golden computation.

SPMD TPUSH/TPOP attention

Layer / File(s) Summary
Mixed FIFO kernel and launch
tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/...
Adds cooperative AIC/AIV FIFO processing, fixed 24-block launch configuration, and runtime tile dispatch.
Scene validation
tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/test_spmd_paged_attention.py
Adds callable wiring, parameterized cases, argument construction, and golden-output checks.

Runtime lifecycle and L3 behavior

Layer / File(s) Summary
Dynamic registration
tests/st/a5/tensormap_and_ringbuffer/dynamic_register/test_dynamic_register.py
Adds post-start registration tests covering broadcast, capacity, duplicate handles, unregistering, and re-preparation.
L3 dependencies and grouping
tests/st/a5/tensormap_and_ringbuffer/test_l3_dependency.py, tests/st/a5/tensormap_and_ringbuffer/test_l3_group.py
Adds dependent subtasks and grouped chip-worker execution scenarios.
Host buffers and prewarm
tests/st/a5/tensormap_and_ringbuffer/test_l3_host_buffer_registration.py, tests/st/a5/tensormap_and_ringbuffer/test_prewarm_config.py
Adds host-buffer zero-copy execution and ring-task-window prewarm initialization tests.

Fan-in and dispatch regression coverage

Layer / File(s) Summary
Fan-in lookup performance
tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/...
Adds explicit producer-to-consumer fan-in dependencies, optional real kernels, and benchmark validation.
SPMD batch dispatch bounds
tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/...
Adds two-task dispatch reproduction kernels and cache-line-position output checks.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Poem

A rabbit hops through tiles of light,
Matmuls bloom and queues take flight.
FIFOs hum from left to right,
Softmax settles sums just right.
Tests guard each path with care—
“Carrots for kernels everywhere!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: porting a2a3-only tensormap_and_ringbuffer scene and L3 tests to a5.
Description check ✅ Passed The description directly explains the a5 port, covered test areas, API adaptations, exclusions, and validation plan.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (4)
tests/st/a5/tensormap_and_ringbuffer/multi_round_paged_attention/test_multi_round_paged_attention.py (1)

30-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document that scene CALLABLE and CASES metadata must remain read-only.

These mutable class attributes are shared across test cases; any recursive update during path resolution or validation may leak between cases. Mark them read-only/read-only-convention-compliant with typing.ClassVar or a narrow RUF012 suppression if mutation is never intended.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/st/a5/tensormap_and_ringbuffer/multi_round_paged_attention/test_multi_round_paged_attention.py`
around lines 30 - 66, Mark the shared class attributes CALLABLE and CASES as
read-only metadata by annotating them with typing.ClassVar, or apply a narrow
RUF012 suppression if they must remain mutable by convention. Update both
affected declarations in
tests/st/a5/tensormap_and_ringbuffer/multi_round_paged_attention/test_multi_round_paged_attention.py:30-66
and :68-134, without changing their contents or runtime behavior.

Source: Linters/SAST tools

tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/test_fanin_lookup_perf.py (1)

30-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Annotate shared class configuration with ClassVar.

Ruff RUF012 flags both mutable class attributes. These are intentionally class-level scene metadata, so annotate them as ClassVar to make the ownership explicit and clear the warning without changing runtime behavior.

Proposed fix
 import ctypes
+from typing import ClassVar

 ...

-    CALLABLE = {
+    CALLABLE: ClassVar = {
         ...
     }

-    CASES = [
+    CASES: ClassVar = [
         ...
     ]

Also applies to: 48-61

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/test_fanin_lookup_perf.py`
around lines 30 - 46, Annotate the mutable class-level scene metadata containing
CALLABLE and the corresponding configuration at the other flagged location with
typing.ClassVar. Preserve their existing values and class-level behavior while
clearing Ruff RUF012.

Source: Linters/SAST tools

tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/test_spmd_batch_dispatch_oob.py (1)

38-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Annotate mutable class configuration as ClassVar.

CALLABLE and CASES are intentionally class-level configuration, but their mutable types trigger Ruff RUF012. Add ClassVar annotations to clear the warning without moving them to instance state.

Proposed fix
+from typing import ClassVar
+
...
-    CALLABLE = {
+    CALLABLE: ClassVar[dict] = {
...
-    CASES = [
+    CASES: ClassVar[list] = [

Also applies to: 66-73

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/test_spmd_batch_dispatch_oob.py`
around lines 38 - 64, Annotate the class-level mutable configuration attributes
CALLABLE and CASES with typing.ClassVar, preserving their existing values and
keeping them on the class rather than moving them to instance state.

Source: Linters/SAST tools

tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp (1)

64-64: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

Align the SPMD paged-attention orchestration entry with the existing AICPU entry convention. All other orchestration kernels under tests/st/a5/tensormap_and_ringbuffer export aicpu_orchestration_entry, but the graph-based multi_round_paged_attention port uses build_paged_attention_graph; pick one entry ABI for this test and keep the kernel export and function_name matching it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp`
at line 64, Align the SPMD paged-attention entry ABI across the orchestration
kernel and test configuration: choose either aicpu_orchestration_entry or
build_paged_attention_graph, then make the exported function in
spmd_paged_attention_orch.cpp and the function_name in
test_spmd_paged_attention.py use the same symbol, matching the convention
selected for this test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp`:
- Around line 70-121: Validate matmul_batch and add_batch before the group-count
divisions in the orchestration setup, rejecting zero values and any
configuration where total_matmul_tasks or total_add_tasks is not evenly
divisible by its corresponding batch size. Use the existing runtime assertion or
validation mechanism, and only compute num_matmul_groups and num_add_groups
after these checks so no tasks are silently dropped.

In
`@tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_qk_matmul.cpp`:
- Around line 128-143: Case3 dispatches head_dim=256 but the q_tile-64 kernels
only support 128-wide data. Add matching head_dim=256 template dispatches in
aic_qk_matmul.cpp (qk_matmul_batch_impl), aic_pv_matmul.cpp (PV implementation),
and aiv_online_update.cpp (online update), preserving the existing 128 paths for
other inputs; update test_batch_paged_attention.py only if the wide-head-dim
kernels are not implemented, by removing or guarding Case3.

In
`@tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/test_paged_attention_unroll_4dims.py`:
- Around line 98-113: Disable or remove the manual Case3 configuration in the
test definition, unless the paged-attention orchestration and its q_tile=64 QK,
PV, softmax, and update branches are updated to support head_dim=256. Do not
leave Case3 enabled while only head_dim=128 templates process the workload.

In `@tests/st/a5/tensormap_and_ringbuffer/test_l3_host_buffer_registration.py`:
- Around line 25-28: Update the documentation in the host-buffer registration
test to replace stale a2a3/a2a3sim references with a5/a5sim, including the
statement about vector_example kernels, so it accurately matches the test’s
a5sim runtime and KERNELS_BASE configuration.

---

Nitpick comments:
In
`@tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/test_fanin_lookup_perf.py`:
- Around line 30-46: Annotate the mutable class-level scene metadata containing
CALLABLE and the corresponding configuration at the other flagged location with
typing.ClassVar. Preserve their existing values and class-level behavior while
clearing Ruff RUF012.

In
`@tests/st/a5/tensormap_and_ringbuffer/multi_round_paged_attention/test_multi_round_paged_attention.py`:
- Around line 30-66: Mark the shared class attributes CALLABLE and CASES as
read-only metadata by annotating them with typing.ClassVar, or apply a narrow
RUF012 suppression if they must remain mutable by convention. Update both
affected declarations in
tests/st/a5/tensormap_and_ringbuffer/multi_round_paged_attention/test_multi_round_paged_attention.py:30-66
and :68-134, without changing their contents or runtime behavior.

In
`@tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/test_spmd_batch_dispatch_oob.py`:
- Around line 38-64: Annotate the class-level mutable configuration attributes
CALLABLE and CASES with typing.ClassVar, preserving their existing values and
keeping them on the class rather than moving them to instance state.

In
`@tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp`:
- Line 64: Align the SPMD paged-attention entry ABI across the orchestration
kernel and test configuration: choose either aicpu_orchestration_entry or
build_paged_attention_graph, then make the exported function in
spmd_paged_attention_orch.cpp and the function_name in
test_spmd_paged_attention.py use the same symbol, matching the convention
selected for this test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4306e68d-14ef-46f2-a446-2e70cba34302

📥 Commits

Reviewing files that changed from the base of the PR and between c032e07 and 67e6bfa.

📒 Files selected for processing (32)
  • tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/kernels/aic/kernel_matmul.cpp
  • tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/kernels/aiv/kernel_add.cpp
  • tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/test_alternating_matmul_add.py
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_pv_matmul.cpp
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/aic/aic_qk_matmul.cpp
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_online_update.cpp
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/aiv/aiv_softmax_prepare.cpp
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/test_batch_paged_attention.py
  • tests/st/a5/tensormap_and_ringbuffer/dynamic_register/test_dynamic_register.py
  • tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/kernels/aic/kernel_write_const_visible.cpp
  • tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/kernels/orchestration/fanin_lookup_perf_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/test_fanin_lookup_perf.py
  • tests/st/a5/tensormap_and_ringbuffer/multi_round_paged_attention/test_multi_round_paged_attention.py
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/aic/aic_pv_matmul.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/aic/aic_qk_matmul.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/aiv/aiv_online_update.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/aiv/aiv_softmax_prepare.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/test_paged_attention_unroll_4dims.py
  • tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/aic/kernel_write.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/aiv/kernel_write.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/test_spmd_batch_dispatch_oob.py
  • tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/mix/paged_attention_parallel.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/test_spmd_paged_attention.py
  • tests/st/a5/tensormap_and_ringbuffer/test_l3_dependency.py
  • tests/st/a5/tensormap_and_ringbuffer/test_l3_group.py
  • tests/st/a5/tensormap_and_ringbuffer/test_l3_host_buffer_registration.py
  • tests/st/a5/tensormap_and_ringbuffer/test_prewarm_config.py

Comment thread tests/st/a5/tensormap_and_ringbuffer/test_l3_host_buffer_registration.py Outdated
@yanghaoran29
yanghaoran29 force-pushed the port-a2a3-tmr-tests-to-a5 branch 2 times, most recently from 92d57d9 to 56b05a5 Compare July 23, 2026 07:18
yanghaoran29 added a commit to yanghaoran29/simpler that referenced this pull request Jul 23, 2026
Two CI failures on PR hw-native-sys#1450 (st-sim-a5 / st-onboard-a5), both arch-drift
from copying a2a3 sources verbatim:

- Kernel compile "reference to 'Stride' is ambiguous" on a5 (Incore
  compile exit 1): a5 kernel headers put another Stride in scope, so bare
  Stride<...> is ambiguous. Qualify to pto::Stride<...> (a5 convention) in
  alternating_matmul_add, batch_paged_attention, paged_attention_unroll_4dims,
  spmd_paged_attention kernels.
- L3 TypeError "missing required keyword-only argument": upstream main made
  Orchestrator.submit_next_level(worker=) / submit_next_level_group(workers=)
  required. Pass worker=0 / workers=[0, 1], matching the a2a3 originals.

Verified: both L3 tests pass on a5sim; all 4 scenes' kernels compile clean
for a5 (device-independent compile check).
@yanghaoran29
yanghaoran29 force-pushed the port-a2a3-tmr-tests-to-a5 branch 8 times, most recently from 8cbef18 to f706ef1 Compare July 28, 2026 08:29
@yanghaoran29
yanghaoran29 force-pushed the port-a2a3-tmr-tests-to-a5 branch 10 times, most recently from 84ea9e5 to 2189dde Compare August 5, 2026 02:17
@ChaoWao

ChaoWao commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Reviewed at 041b69279 (merge-base b7141748, #1673). The two findings from the previous revision — the out-of-scope a2a3 edit and the dead block_dim config keys in 7 new files — are both fixed, thanks.

The port itself is careful. I verified each of the three adaptations that looked suspicious and all three are correct:

  • set_block_numset_core_num is required, not cosmetic: src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_submit_types.h:262 exposes only set_core_num, a2a3 only set_block_num.
  • Barrier elision in the paged-attention AIV kernels follows existing a5 precedent — the pre-existing tests/st/a5/.../paged_attention_unroll/kernels/aiv/aiv_softmax_prepare.cpp has 0 pipe_barrier(PIPE_V) where its a2a3 twin has 13.
  • function_name: "build_paged_attention_graph" in multi_round_paged_attention matches the symbol actually exported by the a5 source it references (examples/a5/.../paged_attention_orch.cpp:71), and the a5 example's own test uses the same name.

Five things I'd like changed before merge, plus three notes that need no code change.


1. Unreachable guards in the a5 orchestration

tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp:72-84

In the previous revision these two LOG_ERROR guards were added to the a2a3 file; this revision moves them into the a5 copy rather than dropping them, so the divergence between the two arch copies is still there — just on the other side.

No case can reach them. I computed all three: 1 % 1 = 0, 2000 % 4 = 0, 1024 % 4 = 0 and 2560 % 5 = 0. The scalars come from the test's own params, not from external input, so neither division-by-zero nor a non-even split is structurally reachable.

This matters because the PR's stated purpose is 1:1 differential validation. That only works if the two arch copies are logically identical — otherwise a future behavioral difference can't be attributed to silicon vs. a branch this port added.

Either delete them (restores parity with a2a3), or add a case that actually trips one and asserts the failure — in which case please also state "add input validation" as an explicit goal in the PR body, since nothing in the current description covers it.

2. Half-qualified pto:: in 12 new kernels

Each of these opens with using namespace pto; and then qualifies only Stride, leaving Shape, Tile, and GlobalTensor bare:

using DynShapeDim5 = Shape<1, 1, 1, ROWS, COLS>;
using DynStridDim5 = pto::Stride<1, 1, 1, COLS, 1>;

That is verbatim the counter-example in .claude/rules/codestyle.md §11, which says a half-qualified file is a defect where a fully bare one is not, and requires "qualify a file completely or not at all."

I checked whether the qualification was forced by an ambiguity and could not find one — the only Stride reachable here is pto::Stride (pto-isa/include/pto/common/pto_tile.hpp:139); there is no competing declaration on a5.

Mitigating: roughly 20 pre-existing a5 kernels this PR doesn't touch already have this shape, so you were following local precedent rather than inventing it. But §11 makes new files the place to stop propagating it. Either fully qualify these 12, or drop the pto:: and stay bare.

Files: merge_pipeline.cpp, scalar_data_test/kernel_add.cpp, alternating_matmul_add/{kernel_matmul,kernel_add}.cpp, and the four kernels each under batch_paged_attention/ and paged_attention_unroll_4dims/.

3. Stale cluster count in ported prose

  • spmd_batch_dispatch_oob/test_spmd_batch_dispatch_oob.py:12 — "block_num=48 (>> 24 clusters)"
  • spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp:55 — "(2x cluster count)"

Both numbers are a2a3's. PLATFORM_MAX_BLOCKDIM is 24 on a2a3 but 36 on a5 (src/a5/platform/include/common/platform_config.h:38), so on a5 48 is 1.33× the cluster count, not 2×.

The test still exercises what it should (48 > 36), but the comment now misstates the margin.

4. scalar_data_test directory name

Every other example directory under examples/a5/tensormap_and_ringbuffer/ — and all of examples/a2a3/tensormap_and_ringbuffer/ — uses the bare feature name; the a2a3 original is scalar_data. This is the only _test-suffixed example directory in the repo. Suggest renaming to scalar_data unless there's a collision I'm missing.

5. All three ported examples dropped their README.md

scalar_data, merge_pipeline_barrier, and paged_attention_ringbuffer each have a README on the a2a3 side that did not come across. The scalar_data one is 74 lines and carries the point of the example — "when the orchestration writes a tensor a kernel is using, who waits?" — which isn't derivable from the code.

Three of the 13 a5 examples do carry READMEs, so this isn't an a5-tree convention. Either port them (a path-substituted copy, as was done for INCORE_ORCHESTRATION_GUIDE.md), or note in the PR body that a5 examples intentionally defer to the a2a3 prose.


Notes — no code change needed

6. The compile-cache key change prevents no collision that exists today. I enumerated every (class name, platform, runtime) triple across tests/st and examples: zero are reachable from more than one module. There are 43 duplicate scene-class names (TestScalarData, TestL3Dependency, …), but they all differ on platform or runtime, which the key already carried.

The change is sound — widening a key can only cause a redundant compile, never a false hit, and all four construction sites moved together. But the PR body's "to prevent same-named test classes from sharing binaries" reads as though it fixes an active defect. Worth one clause marking it preventative, so someone later debugging a stale-binary problem doesn't assume this was the cause.

7. The commit message drops the cache-key half of goal 4. The body mentions it; the commit says only "architecture-derived launch defaults." git log is the durable record — worth folding back in.

8. CI reach for the three new examples is onboard-only. All three are platforms: ["a5"], so they never run in st-sim-a5. Not a regression — their a2a3 originals are ["a2a3"]-only too. Flagging only because "A5Sim: all applicable newly added cases pass" is true but "applicable" carries weight: 21 of 40 non-manual cases are sim-reachable.


Also worth confirming: pto_isa.pin is at 83d01313 and untouched. The new kernels add <pto/pto-inst.hpp>, <pto/common/constants.hpp>, and <pto/common/pto_tile.hpp>, but all three are already used on the merge base (209 / 9 / 8 files), so no pin bump appears necessary.

Port the remaining single-device a2a3 tensormap_and_ringbuffer coverage to A5 for differential validation across architectures.

Add scenes for alternating matmul/add, batch and multi-round paged attention, 4D unroll, dynamic registration, fanin lookup, empty-ring heap rebase, SPMD batch dispatch, and L3 dependency and host-buffer behavior.

Add scalar-data, paged-attention ringbuffer, and merge-pipeline-barrier examples with architecture-specific READMEs plus the A5 InCore orchestration guide. Adapt the ports to current A5 APIs and architecture-derived launch defaults.

Make scene compile-cache keys module-aware as preventative isolation for same-named test classes in different modules.

Exclude multi-device coverage and spmd_paged_attention from this port.
@yanghaoran29
yanghaoran29 force-pushed the port-a2a3-tmr-tests-to-a5 branch from 2189dde to 713cec6 Compare August 5, 2026 03:21
@yanghaoran29

Copy link
Copy Markdown
Contributor Author

@ChaoWao Addressed all five requested changes:

  1. Removed the unreachable A5-only batch guards so the alternating orchestration matches the a2a3 port.
  2. Removed the broad using namespace pto; directives and fully qualified PTO types throughout the 12 half-qualified kernels; also removed the unused directive from the scalar no-op kernel.
  3. Corrected the SPMD batch-dispatch prose to describe 48 blocks against A5’s 36-cluster limit.
  4. Renamed the A5 example directory from scalar_data_test to scalar_data.
  5. Ported the three example READMEs and adapted their platform names, paths, launch API, and A5 launch capacity.

Also clarified in the PR body that the module-aware compile-cache key is preventative, folded that behavior into the commit message, and kept the simulation applicability note explicit in the test plan. Thanks for the careful review.

@ChaoWao
ChaoWao merged commit 0a4898b into hw-native-sys:main Aug 5, 2026
18 checks passed
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.

2 participants