Skip to content

Refactor: migrate legacy tests to @scene_test format - #548

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
doraemonmj:reuse_fix
Apr 14, 2026
Merged

ChaoWao merged 1 commit into
hw-native-sys:mainfrom
doraemonmj:reuse_fix

Conversation

@doraemonmj

@doraemonmj doraemonmj commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Migrate all legacy golden.py + kernel_config.py tests under a2a3/tensormap_and_ringbuffer/ to the unified @scene_test / SceneTestCase format (single test_*.py per example).

  • 10 synthetic examples moved from examples/ → tests/st/ with new test_*.py
  • 3 tests/st/ tests converted in-place (benchmark_bgemm, paged_attention_unroll, explicit_fatal kernels)
  • 2 dual-directory merges (batch_paged_attention, paged_attention): small-scale sim cases + production-scale hardware cases → single test_*.py
  • batch_paged_attention kernels unified: C++ typename T template parameter + 3-way runtime dispatch (fp16/bf16)
  • Include path fix: kernel_compiler.py adds runtime_common_dir to resolve intrinsic.h
  • Zero legacy files remaining: all golden.py / kernel_config.py deleted

Migration Table

Location Changes

# Case Before After Type
1 spmd_basic examples/ tests/st/ synthetic → st
2 spmd_multiblock_aiv examples/ tests/st/ synthetic → st
3 spmd_multiblock_mix examples/ tests/st/ synthetic → st
4 spmd_starvation examples/ tests/st/ synthetic → st
5 spmd_sync_start examples/ tests/st/ synthetic → st
6 spmd_sync_start_aiv examples/ tests/st/ synthetic → st
7 spmd_sync_start_edge examples/ tests/st/ synthetic → st
8 spmd_sync_start_stress examples/ tests/st/ synthetic → st
9 mixed_example examples/ tests/st/ synthetic → st
10 multi_round_paged_attention examples/ tests/st/ synthetic → st
11 benchmark_bgemm tests/st/ tests/st/ in-place convert
12 paged_attention_unroll tests/st/ tests/st/ in-place convert
13 batch_paged_attention examples/ + tests/st/ examples/ dual-dir merge
14 paged_attention examples/ + tests/st/ examples/ dual-dir merge
15 bgemm examples/ examples/ in-place convert
16 paged_attention_ringbuffer examples/ examples/ in-place adjust

Parameters (all unchanged)

# Case RTOL/ATOL thread_num block_dim Cases
1 spmd_basic 0/0 4 24 Case1: {}
2 spmd_multiblock_aiv 0/0 4 24 Case1: {}
3 spmd_multiblock_mix 0/0 4 24 Case1: {}
4 spmd_starvation 0/0 4 24 Case1: {}
5 spmd_sync_start 0/0 4 24 Case1: {}
6 spmd_sync_start_aiv 0/0 4 24 Case1: {}
7 spmd_sync_start_edge 0/0 4 24 Case1: {}
8 spmd_sync_start_stress 0/0 4 24 Case1: {}
9 mixed_example 1e-3/1e-3 4 3 case1: {num_iters:4}, case2: {num_iters:1}
10 multi_round_paged_attention 1e-2/1e-2 4 24 Case1: {batch:1, ...} manual=True
11 benchmark_bgemm 1e-3/1e-3 4 24 Case0-4 (5 cases)
12 paged_attention_unroll 1e-3/1e-3 4 24 Case1-3: prod bf16, manual=True
13 batch_paged_attention (small) 1e-2/1e-2 4 24 Case1-3+VarSeq2+VarSeq4: fp16
13 batch_paged_attention (large) 1e-3/1e-3 4 24 Case1-3: bf16, manual=True, RING_HEAP=1GB
14 paged_attention 1e-2/1e-2 4 24 Case1-2+VarSeq2+VarSeq4: bf16
15 bgemm 1e-3/1e-3 4 3 default: {4x4x4 grid}
16 paged_attention_ringbuffer 1e-3/1e-3 4 24 ringbuffer_stress: {batch:32, bf16}, env vars

Key Changes

Change Description
Format conversion golden.py + kernel_config.py → single test_*.py (SceneTestCase)
Explicit platforms sim-compatible: ["a2a3sim", "a2a3"], hardware-only: ["a2a3"]
batch_paged_attention kernel merge Two kernel sets → one with typename T + 3-way runtime dispatch
batch_paged_attention class merge examples/ small(fp16) + tests/st/ large(bf16) → two classes in one file
paged_attention dual-dir merge examples/ small + tests/st/ large → examples/ small only
paged_attention_ringbuffer Kernel path → ../batch_paged_attention/kernels (reuse merged kernels)
PA generate_args Removed .flatten(), keep original tensor shapes
PA compute_golden Generic args.specs traversal instead of manual reshape
Include path fix kernel_compiler.py adds src/{arch}/runtime/{rt}/common/ for intrinsic.h
Legacy cleanup All golden.py / kernel_config.py deleted, zero remaining

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the Batch Paged Attention implementation and its test suite, introducing production-scale chunked batching and runtime dispatch for multiple tile configurations and data types. It consolidates test logic into SceneTestCase classes and adds extensive functional and stress tests for SPMD, BGEMM, and mixed AIC/AIV operations. Feedback points out an unnecessary .flatten() call in the multi-round paged attention test, which is inconsistent with the PR's objective of maintaining original tensor shapes and complicates the golden result computation.

…est format

- Move 10 synthetic examples to tests/st/ as SceneTestCase tests:
  spmd_basic, spmd_multiblock_aiv, spmd_multiblock_mix, spmd_starvation,
  spmd_sync_start, spmd_sync_start_aiv, spmd_sync_start_edge,
  spmd_sync_start_stress, mixed_example, multi_round_paged_attention
- Merge batch_paged_attention (examples + tests/st) into single example
  with unified runtime-dispatch kernels (typename T template parameter)
- Merge paged_attention into examples/ with sim-compatible cases
- Convert bgemm, benchmark_bgemm, paged_attention_unroll to @scene_test
- Remove all golden.py and kernel_config.py legacy files
- Delete original example dirs after migration to tests/st/

Fix: add runtime common/ to incore kernel include path

The SPMD kernel sources #include "intrinsic.h" which lives in
src/{arch}/runtime/{runtime}/common/. This directory was implicitly
available via the legacy run_example.py pipeline but missing from
the SceneTestCase kernel compiler include dirs.
@ChaoWao
ChaoWao merged commit 2e598d6 into hw-native-sys:main Apr 14, 2026
13 checks passed
nalinaly pushed a commit to nalinaly/simpler that referenced this pull request Jul 31, 2026
…est format (hw-native-sys#548)

- Move 10 synthetic examples to tests/st/ as SceneTestCase tests:
  spmd_basic, spmd_multiblock_aiv, spmd_multiblock_mix, spmd_starvation,
  spmd_sync_start, spmd_sync_start_aiv, spmd_sync_start_edge,
  spmd_sync_start_stress, mixed_example, multi_round_paged_attention
- Merge batch_paged_attention (examples + tests/st) into single example
  with unified runtime-dispatch kernels (typename T template parameter)
- Merge paged_attention into examples/ with sim-compatible cases
- Convert bgemm, benchmark_bgemm, paged_attention_unroll to @scene_test
- Remove all golden.py and kernel_config.py legacy files
- Delete original example dirs after migration to tests/st/

Fix: add runtime common/ to incore kernel include path

The SPMD kernel sources #include "intrinsic.h" which lives in
src/{arch}/runtime/{runtime}/common/. This directory was implicitly
available via the legacy run_example.py pipeline but missing from
the SceneTestCase kernel compiler include dirs.

Co-authored-by: majin0824 <majin15@huawei.com>
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