Skip to content

Refactor: retire five PTO2 identifiers, one per commit - #1969

Merged
ChaoWao merged 5 commits into
hw-native-sys:mainfrom
ChaoWao:refactor/retire-pto2-identifiers
Aug 24, 2026
Merged

Refactor: retire five PTO2 identifiers, one per commit#1969
ChaoWao merged 5 commits into
hw-native-sys:mainfrom
ChaoWao:refactor/retire-pto2-identifiers

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Five commits, each retiring one PTO2 identifier (or one coherent macro/type cluster) across every occurrence, in the order the user asked for. .claude/rules/codestyle.md rule 10 requires one identifier per commit — a rename that leaves both spellings alive is worse than no rename — and rule 9 requires "clear names or a namespace" where the prefix was actually disambiguating something.

# Identifier Becomes Occurrences Files
1 PTO2OrchestrationConfig OrchestrationConfig 308 156
2 PTO2TaskSlotState ChipTaskSlotState 856 109
3 PTO2_SCOPE + guard/concat cluster SIMPLER_SCOPE 265 77
4 PTO2Runtime + 3 satellites RuntimeContext 758 69
5 PTO2_MAX_RING_DEPTH CHIP_MAX_RING_DEPTH 484 55

Only #1 was a plain prefix strip. Three of the five could not take the bare name, and all three for the same reason: the name is already held by the host L3+ hierarchical orchestrator, which models the same concept one tier up.

  • TaskSlotStatesrc/common/hierarchical/types.h is the host orchestrator's per-task bookkeeping (std::mutex, std::vector); the renamed one is the chip runtime's 64-byte shared-memory slot with a spinlock and refcounts.
  • Runtimeruntime.h already has a class Runtime for AICPU↔AICore handshake, whose own docstring drew the line: "Task graph construction is handled by PTO2Runtime; this class only handles execution control."
  • MAX_RING_DEPTHhierarchical/types.h defines the host's = 4 heap-slab count and worker_bind.h exports it to Python. docs/orchestrator.md says the host count "matches L2's PTO2_MAX_RING_DEPTH", i.e. two deliberately equal but distinct constants.

So the PTO2 prefix was doing real work in exactly the places where the chip runtime and the host orchestrator name the same idea. Rule 13 says which side keeps the bare name — L3+ does, the chip runtime takes Chip — so this branch spells them ChipTaskSlotState and CHIP_MAX_RING_DEPTH, matching the existing ChipWorker / ChipTensor / ChipTaskArgs, and names the context struct for what its docstring already called it.

SIMPLER_SCOPE is the one that gets a macro-shaped answer rather than a role. A bare SCOPE does in fact compile — it is function-like, so it only expands at SCOPE(, and neither this tree nor the CANN headers nor pto-isa spells that token (all four runtimes build and the a2a3sim sweep passes with it applied; measured, not assumed). It is rejected on cost, not feasibility: a macro obeys no namespace, so naming it SCOPE claims an English word followed by ( in every translation unit that includes orchestration_api.h, in this repo and in the orchestration sources of every consumer repo, forever. It also stops being greppable — git grep -w SCOPE today returns 7 hits and all of them are === SCOPE STACK === comment banners. RT_ is not available either (CANN owns it: RT_ERROR_NONE, consumed by device_runner_helpers.cpp), and SIMPLER_ is what the status codes took in #1963, so the orchestration macro surface now spells its owner the same way the error codes do.

Two clusters move as a unit rather than one identifier at a time, because splitting them would leave the two spellings on adjacent lines of the same declaration: SIMPLER_SCOPE with its ScopeGuard / _SIMPLER_CONCATENATE implementation, and RuntimeContext with the RuntimeOps table it carries as its first field (plus RuntimeMode, RuntimeArenaLayout).

Two of the new names were already in the tree as prose: RuntimeArenaLayout was the gtest suite name in both test_shared_memory.cpp copies, and the shared-memory layout diagrams have long written the slot arrays with the prefix stripped. The diagrams stay as they are for now — they strip it from all three arrays uniformly, so they move as one piece when PTO2TaskDescriptor / PTO2TaskPayload land.

Tier-A brand prose in the touched files goes with commit 4: the PTO Runtime2 - Main Interface / - Orchestrator Interface / - Main Implementation banners, two static_assert messages, and the title and overview of both tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md copies, which now name the runtime the way the host_build_graph copies already do. Those two copies had drifted apart on a (PTO2) heading suffix; they agree again.

Base

Rebased onto #1968 / #1925, and before that onto #1965. That last merge is why commit 5 is here at all: PTO2_MAX_RING_DEPTH had 148 lines of overlap with it while it was open, and after it landed the macro is defined only in the two tensormap_and_ringbuffer copies — host_build_graph carries no ring dimension — so the rename is smaller and no longer collides with in-flight work. Both rebases conflicted (the scheduler_cold_path.cpp / shared_memory.cpp / runtime_core.h / runtime_init.cpp / runtime_maker.cpp pairs against #1965; orchestrator.cpp / scheduler.h / types.h and one troubleshooting doc against #1968). Every one was resolved the same way — discard our side of the file, take upstream's, re-run the rename over it — so no upstream restructuring is dropped and the resolution is not hand-authored. #1968 also introduced two new PTO2Runtime / PTO2_SCOPE mentions in a runtime_core.h comment after this branch was cut; they are absorbed into the commit that owns each identifier, so the count still only goes down.

Remaining surface

5862 occurrences across 319 files, led by PTO2ResourceShape (368), PTO2TaskPayload (309), PTO2SchedulerState (305), PTO2TensorMapEntry (224), PTO2_ALIGN_SIZE (216). Given what this PR found, expect more of the collisions above rather than fewer as the chip-runtime structs get closer to the host orchestrator's vocabulary — each needs a name decided, not a prefix deleted.

Cross-repo

Every identifier here is reachable from orchestration sources outside this repo — SIMPLER_SCOPE is typed directly in orchestration code and RuntimeContext *rt is the handle every entry point takes. This lands without compatibility aliases by the same explicit decision as #1963 and #1966; the matching renames and the merge order are coordinated outside this PR.

⚠️ At 323 files this is past the bot reviewer's 100-file limit, so expect it to skip the review as it did on #1963. That is a real cost of mechanical renames at this scale and the reason each commit is separately reviewable.

Testing

All on this box, at the final commit, after pip install --no-build-isolation -e .:

  • all four runtime variants build
  • a2a3sim scene sweep — 59 passed, 8 skipped
  • a5sim scene sweep — 52 passed
  • a2a3 onboard sweep (-m "not sdma" --exclude-level 4) — 153 passed, 1 skipped
  • a2a3 quarantined SDMA step — 2 passed
  • cpput — 117/117; hardware-labelled test_comm_lifecycle — 1/1
  • pyut — 1897 passed, 14 skipped, plus one pre-existing failure: test_second_child_failure_reaps_first is the open flake in [Bug] SIGTERM during INIT_FAILED publication can escape forked child main #1948 (a SIGTERM-vs-os._exit race in _forked_child_main). It passes alone, reproduces 2/2 in the full sweep here, and the whole path it exercises — python/simpler/worker.py, the test, conftest.py — is byte-identical to upstream/main on this branch. Two more occurrences appended to that issue.
  • clang-format --dry-run --Werror, ruff, markdownlint-cli2 clean over all 323 changed files

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 323 files, which is 223 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

Usage-priced reviews support at most 300 files.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e70e3b2-1f86-4f96-b9cd-db2050549866

📥 Commits

Reviewing files that changed from the base of the PR and between 969c6a6 and 1c2d11f.

📒 Files selected for processing (323)
  • .github/ISSUE_TEMPLATE/feature_request.yml
  • docs/callable-identity-registration.md
  • docs/dfx/device-phases.md
  • docs/dfx/profiling-config-naming.md
  • docs/dfx/scope-stats.md
  • docs/dynamic-linking.md
  • docs/manual-scope.md
  • docs/orchestrator.md
  • docs/task-flow.md
  • docs/troubleshooting/device-error-codes/capacity.md
  • docs/troubleshooting/device-error-codes/untested.md
  • examples/a2a3/host_build_graph/deepseek_v4_flash_decode/kernels/orchestration/decode_fwd_graph.cpp
  • examples/a2a3/host_build_graph/qwen3_14b_decode/kernels/orchestration/decode_fwd_layers.cpp
  • examples/a2a3/tensormap_and_ringbuffer/benchmark_bgemm/kernels/orchestration/bgemm_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/deepseek_v4_flash_decode/kernels/orchestration/decode_fwd.cpp
  • examples/a2a3/tensormap_and_ringbuffer/docs/INCORE_ORCHESTRATION_GUIDE.md
  • examples/a2a3/tensormap_and_ringbuffer/merge_pipeline_barrier/kernels/orchestration/merge_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention/README.md
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention_manual_scope/README.md
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/README.md
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/prefetch_async_demo/kernels/orchestration/prefetch_async_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/qwen3_14b_decode/kernels/orchestration/decode_fwd_layers.cpp
  • examples/a2a3/tensormap_and_ringbuffer/scalar_data/kernels/orchestration/scalar_data_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/sdma_async_completion_demo/kernels/orchestration/sdma_async_completion_orch.cpp
  • examples/a2a3/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp
  • examples/a5/host_build_graph/qwen3_14b_decode/kernels/orchestration/decode_fwd_layers.cpp
  • examples/a5/tensormap_and_ringbuffer/benchmark_bgemm/kernels/orchestration/bgemm_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/bgemm/kernels/orchestration/bgemm_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/docs/INCORE_ORCHESTRATION_GUIDE.md
  • examples/a5/tensormap_and_ringbuffer/merge_pipeline_barrier/kernels/orchestration/merge_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/paged_attention_manual_scope/kernels/orchestration/paged_attention_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/paged_attention_unroll_manual_scope/kernels/orchestration/paged_attention_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/qwen3_14b_decode/kernels/orchestration/decode_fwd_layers.cpp
  • examples/a5/tensormap_and_ringbuffer/scalar_data/kernels/orchestration/scalar_data_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/sdma_async_completion_demo/kernels/orchestration/sdma_async_completion_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/urma_deferred_completion_demo/kernels/orchestration/urma_deferred_completion_orch.cpp
  • examples/a5/tensormap_and_ringbuffer/vector_example/kernels/orchestration/example_orchestration.cpp
  • examples/workers/l2/vector_add/kernels/orchestration/vector_add_orch.cpp
  • examples/workers/l3/allreduce/kernels/orchestration/allreduce_onephase_orch.cpp
  • examples/workers/l3/dual_domain_overlap/kernels/orchestration/affine_orch.cpp
  • examples/workers/l3/dual_domain_overlap/kernels/orchestration/domain_allreduce_orch.cpp
  • examples/workers/l3/ep_dispatch_combine/kernels/orchestration/ep_dispatch_combine_orch.cpp
  • examples/workers/l3/ffn_tp_parallel/kernels/orchestration/allreduce_sum_orch.cpp
  • examples/workers/l3/ffn_tp_parallel/kernels/orchestration/ffn_local_orch.cpp
  • examples/workers/l3/multi_chip_dispatch/kernels/orchestration/vector_add_orch.cpp
  • examples/workers/l3/worker_chip_message_queue/kernels/orchestration/worker_chip_message_queue_orch.cpp
  • examples/workers/l3/worker_chip_orch_comm_stream/kernels/orchestration/worker_chip_orch_comm_orch.cpp
  • examples/workers/l4/compute_then_tload_mixed_l3/kernels/orchestration/global_tload_orch.cpp
  • examples/workers/l4/compute_then_tload_mixed_l3/kernels/orchestration/local_add_orch.cpp
  • examples/workers/l4/global_tload_mixed_l3/kernels/orchestration/global_tload_orch.cpp
  • examples/workers/l4/vector_add_mixed_l3/kernels/orchestration/vector_add_mixed_l3_orchestration.cpp
  • src/a2a3/runtime/host_build_graph/aicpu/aicpu_executor.cpp
  • src/a2a3/runtime/host_build_graph/docs/RUNTIME_LOGIC.md
  • src/a2a3/runtime/host_build_graph/docs/SUBMIT_BY_CLUSTER.md
  • src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp
  • src/a2a3/runtime/host_build_graph/orchestration/common.cpp
  • src/a2a3/runtime/host_build_graph/orchestration/orchestration_api.h
  • src/a2a3/runtime/host_build_graph/runtime/aicore_completion_mailbox.h
  • src/a2a3/runtime/host_build_graph/runtime/async_wait.h
  • src/a2a3/runtime/host_build_graph/runtime/common.h
  • src/a2a3/runtime/host_build_graph/runtime/orchestrator.h
  • src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/orchestrator.cpp
  • src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/runtime_core.cpp
  • src/a2a3/runtime/host_build_graph/runtime/runtime.h
  • src/a2a3/runtime/host_build_graph/runtime/runtime_core.h
  • src/a2a3/runtime/host_build_graph/runtime/runtime_types.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_context.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_types.h
  • src/a2a3/runtime/host_build_graph/runtime/shared/runtime.cpp
  • src/a2a3/runtime/host_build_graph/runtime/shared/runtime_init.cpp
  • src/a2a3/runtime/host_build_graph/runtime/shared/shared_memory.cpp
  • src/a2a3/runtime/host_build_graph/runtime/shared_memory.h
  • src/a2a3/runtime/host_build_graph/runtime/submit_types.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/docs/MULTI_RING.md
  • src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
  • src/a2a3/runtime/tensormap_and_ringbuffer/docs/SUBMIT_BY_CLUSTER.md
  • src/a2a3/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/common.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/orchestration/orchestration_api.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/aicore_completion_mailbox.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/async_wait.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/common.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/orchestrator.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/orchestrator.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime_core.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime_core.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime_types.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_completion.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_context.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_types.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/runtime.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/runtime_init.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/shared_memory.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/tensormap.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared_memory.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/submit_types.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/tensormap.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/types.h
  • src/a5/runtime/host_build_graph/aicpu/aicpu_executor.cpp
  • src/a5/runtime/host_build_graph/docs/RUNTIME_LOGIC.md
  • src/a5/runtime/host_build_graph/docs/SUBMIT_BY_CLUSTER.md
  • src/a5/runtime/host_build_graph/host/runtime_maker.cpp
  • src/a5/runtime/host_build_graph/orchestration/common.cpp
  • src/a5/runtime/host_build_graph/orchestration/orchestration_api.h
  • src/a5/runtime/host_build_graph/runtime/aicore_completion_mailbox.h
  • src/a5/runtime/host_build_graph/runtime/async_wait.h
  • src/a5/runtime/host_build_graph/runtime/common.h
  • src/a5/runtime/host_build_graph/runtime/orchestrator.h
  • src/a5/runtime/host_build_graph/runtime/orchestrator_core/orchestrator.cpp
  • src/a5/runtime/host_build_graph/runtime/orchestrator_core/runtime_core.cpp
  • src/a5/runtime/host_build_graph/runtime/runtime.h
  • src/a5/runtime/host_build_graph/runtime/runtime_core.h
  • src/a5/runtime/host_build_graph/runtime/runtime_types.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_context.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_types.h
  • src/a5/runtime/host_build_graph/runtime/shared/runtime.cpp
  • src/a5/runtime/host_build_graph/runtime/shared/runtime_init.cpp
  • src/a5/runtime/host_build_graph/runtime/shared/shared_memory.cpp
  • src/a5/runtime/host_build_graph/runtime/shared_memory.h
  • src/a5/runtime/host_build_graph/runtime/submit_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/docs/MULTI_RING.md
  • src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
  • src/a5/runtime/tensormap_and_ringbuffer/docs/SUBMIT_BY_CLUSTER.md
  • src/a5/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/orchestration/common.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/orchestration/orchestration_api.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/aicore_completion_mailbox.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/async_wait.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/common.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/orchestrator.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/orchestrator.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime_core.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime_core.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_cold_path.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_completion.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_context.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared/runtime.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared/runtime_init.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared/shared_memory.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared/tensormap.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared_memory.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/submit_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/tensormap.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/types.h
  • src/common/hierarchical/ring.h
  • src/common/hierarchical/types.h
  • src/common/host_build_graph/graph_execution.cpp
  • src/common/host_build_graph/graph_execution.h
  • src/common/host_build_graph/graph_host_state.h
  • src/common/platform/include/common/scope_stats.h
  • src/common/task_interface/task_id.h
  • tests/st/a2a3/host_build_graph/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp
  • tests/st/a2a3/host_build_graph/bgemm/kernels/orchestration/bgemm_orch.cpp
  • tests/st/a2a3/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp
  • tests/st/a2a3/host_build_graph/graph_execution/kernels/orchestration/graph_execution_aic_aiv_orch.cpp
  • tests/st/a2a3/host_build_graph/graph_execution/kernels/orchestration/graph_execution_mix_spmd_orch.cpp
  • tests/st/a2a3/host_build_graph/graph_execution/kernels/orchestration/graph_execution_orch.cpp
  • tests/st/a2a3/host_build_graph/graph_predicated_dispatch/kernels/orchestration/graph_predicated_dispatch_orch.cpp
  • tests/st/a2a3/host_build_graph/matmul/kernels/orchestration/matmul_orch.cpp
  • tests/st/a2a3/host_build_graph/native_run_lifecycle/kernels/orchestration/long_vector_orch.cpp
  • tests/st/a2a3/host_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a2a3/host_build_graph/predicated_dispatch/kernels/orchestration/predicated_dispatch_orch.cpp
  • tests/st/a2a3/host_build_graph/vector_example/kernels/orchestration/example_orch.cpp
  • tests/st/a2a3/host_build_graph/worker_async_endpoint/kernels/orchestration/long_vector_orch.cpp
  • tests/st/a2a3/host_build_graph/worker_async_fifo/kernels/orchestration/pipelined_vector_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/dfx/args_dump/kernels/orchestration/partial_dump_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/dfx/chip_swimlane/kernels/orchestration/chained_mix_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/dfx/chip_swimlane/kernels/orchestration/sync_start_early_local_owner_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/dfx/dep_gen/kernels/orchestration/chain_barrier_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/dfx/scope_stats/test_scope_stats.py
  • tests/st/a2a3/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/fanin_lookup_perf/kernels/orchestration/fanin_lookup_perf_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/heap_empty_ring_rebase/kernels/orchestration/heap_empty_ring_rebase_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/predicated_dispatch/kernels/orchestration/predicated_dispatch_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_batch_dispatch_oob/kernels/orchestration/spmd_batch_dispatch_oob_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_paged_attention_highperf/kernels/orchestration/paged_attention_highperf_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp
  • tests/st/a2a3/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp
  • tests/st/a5/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp
  • tests/st/a5/host_build_graph/graph_execution/kernels/orchestration/graph_execution_aic_aiv_orch.cpp
  • tests/st/a5/host_build_graph/graph_execution/kernels/orchestration/graph_execution_mix_spmd_orch.cpp
  • tests/st/a5/host_build_graph/graph_execution/kernels/orchestration/graph_execution_orch.cpp
  • tests/st/a5/host_build_graph/graph_predicated_dispatch/kernels/orchestration/graph_predicated_dispatch_orch.cpp
  • tests/st/a5/host_build_graph/paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a5/host_build_graph/predicated_dispatch/kernels/orchestration/predicated_dispatch_orch.cpp
  • tests/st/a5/host_build_graph/vector_example/kernels/orchestration/example_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/alternating_matmul_add/kernels/orchestration/alternating_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/available_aicore_counts/kernels/orchestration/available_aicore_counts_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/batch_paged_attention/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/dfx/args_dump/kernels/orchestration/partial_dump_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/dfx/chip_swimlane/kernels/orchestration/chained_mix_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/dfx/chip_swimlane/kernels/orchestration/sync_start_early_local_owner_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/dfx/dep_gen/kernels/orchestration/chain_barrier_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/dfx/scope_stats/test_scope_stats.py
  • tests/st/a5/tensormap_and_ringbuffer/dummy_task/kernels/orchestration/dummy_task_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/fanin_lookup_perf/kernels/orchestration/fanin_lookup_perf_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/heap_empty_ring_rebase/kernels/orchestration/heap_empty_ring_rebase_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/mixed_example/kernels/orchestration/mixed_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/mx_fp_gemm/kernels/orchestration/mx_fp_gemm_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/paged_attention_unroll_4dims/kernels/orchestration/paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/predicated_dispatch/kernels/orchestration/predicated_dispatch_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/simt_basic/kernels/orchestration/simt_basic_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_basic/kernels/orchestration/spmd_basic_orch.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_multiblock_aiv/kernels/orchestration/spmd_multiblock_aiv_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_multiblock_mix/kernels/orchestration/spmd_multiblock_mix_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_paged_attention/kernels/orchestration/spmd_paged_attention_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_starvation/kernels/orchestration/spmd_starvation_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start/kernels/orchestration/spmd_sync_start_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_aiv/kernels/orchestration/spmd_sync_start_aiv_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_early_dispatch/kernels/orchestration/spmd_sync_start_early_dispatch_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_edge/kernels/orchestration/spmd_sync_start_edge_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_mix_spill/kernels/orchestration/spmd_sync_start_mix_spill_orch.cpp
  • tests/st/a5/tensormap_and_ringbuffer/spmd_sync_start_stress/kernels/orchestration/spmd_sync_start_stress_orch.cpp
  • tests/st/aicore_op_timeout/kernels/orchestration/aicore_op_timeout_orch.cpp
  • tests/st/host_build_graph_validation/kernels/orchestration/validation_orch.cpp
  • tests/st/host_build_graph_wide_dispatch/kernels/orchestration/host_build_graph_wide_dispatch_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/aicore_hang_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/async_error_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/dep_pool_overflow_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/explicit_fatal_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/flow_control_deadlock_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/heap_ring_deadlock_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/invalid_args_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/require_sync_start_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/scope_deadlock_orch.cpp
  • tests/st/runtime_fatal_codes/kernels/orchestration/tensor_wait_timeout_orch.cpp
  • tests/st/runtime_fatal_codes/test_runtime_fatal_codes.py
  • tests/st/task_timing/task_timing_slots/kernels/orchestration/task_timing_orch.cpp
  • tests/st/worker/collectives/all_to_all/kernels/orchestration/all_to_all_orch.cpp
  • tests/st/worker/collectives/allgather/kernels/orchestration/allgather_orch.cpp
  • tests/st/worker/collectives/allreduce/kernels/orchestration/allreduce_bidirectional_ring_orch.cpp
  • tests/st/worker/collectives/allreduce/kernels/orchestration/allreduce_ibing_orch.cpp
  • tests/st/worker/collectives/allreduce/kernels/orchestration/allreduce_onephase_orch.cpp
  • tests/st/worker/collectives/allreduce/kernels/orchestration/allreduce_ring_orch.cpp
  • tests/st/worker/collectives/allreduce/kernels/orchestration/allreduce_twophase_orch.cpp
  • tests/st/worker/collectives/broadcast/kernels/orchestration/broadcast_orch.cpp
  • tests/st/worker/collectives/group_reservation/kernels/orchestration/group_reservation_orch.cpp
  • tests/st/worker/collectives/reduce_scatter/kernels/orchestration/reduce_scatter_orch.cpp
  • tests/st/worker/comm_domain/async_notify/kernels/orchestration/async_notify_orchestration.cpp
  • tests/st/worker/comm_domain/deferred_notify/kernels/orchestration/deferred_notify_orch.cpp
  • tests/ut/cpp/a2a3/test_a2a3_fatal.cpp
  • tests/ut/cpp/a2a3/test_aicore_completion_mailbox.cpp
  • tests/ut/cpp/a2a3/test_dep_list_pool.cpp
  • tests/ut/cpp/a2a3/test_fanin_pool.cpp
  • tests/ut/cpp/a2a3/test_graph_activation.cpp
  • tests/ut/cpp/a2a3/test_hbg_submit_poison.cpp
  • tests/ut/cpp/a2a3/test_orchestrator_fanin.cpp
  • tests/ut/cpp/a2a3/test_ready_queue.cpp
  • tests/ut/cpp/a2a3/test_scheduler_state.cpp
  • tests/ut/cpp/a2a3/test_shared_memory.cpp
  • tests/ut/cpp/a2a3/test_task_state.cpp
  • tests/ut/cpp/a2a3/test_tensormap.cpp
  • tests/ut/cpp/a2a3/test_wiring.cpp
  • tests/ut/cpp/a5/test_a5_fatal.cpp
  • tests/ut/cpp/a5/test_aicore_completion_mailbox.cpp
  • tests/ut/cpp/a5/test_dep_list_pool.cpp
  • tests/ut/cpp/a5/test_fanin_pool.cpp
  • tests/ut/cpp/a5/test_graph_activation.cpp
  • tests/ut/cpp/a5/test_hbg_submit_poison.cpp
  • tests/ut/cpp/a5/test_orchestrator_fanin.cpp
  • tests/ut/cpp/a5/test_ready_queue.cpp
  • tests/ut/cpp/a5/test_scheduler_state.cpp
  • tests/ut/cpp/a5/test_shared_memory.cpp
  • tests/ut/cpp/a5/test_task_state.cpp
  • tests/ut/cpp/a5/test_tensormap.cpp
  • tests/ut/cpp/a5/test_wiring.cpp
  • tests/ut/cpp/common/test_hbg_graph_async_submit.cpp
  • tests/ut/cpp/common/test_hbg_graph_cache.cpp
  • tests/ut/cpp/common/test_hbg_ready_queue_seed.cpp
  • tests/ut/cpp/common/test_hbg_scheduler_drain.cpp
  • tests/ut/cpp/common/test_hbg_self_relative_ptr.cpp
  • tests/ut/cpp/common/test_hbg_slot_claim.cpp
  • tests/ut/cpp/common/test_hbg_sm_compaction.cpp
  • tests/ut/cpp/common/test_scope_deadlock_detection.cpp
  • tests/ut/cpp/common/test_trb_runtime_temp_buffer.cpp

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


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.

ChaoWao and others added 5 commits August 23, 2026 19:49
`PTO2OrchestrationConfig` becomes `OrchestrationConfig`. The name was free —
nothing else in the tree spells it — so this is a plain prefix strip, 308
occurrences across 156 files, one identifier in one commit
(`.claude/rules/codestyle.md` rule 10).

The shorter return type lets clang-format rejoin 110 orchestration-entry
signatures onto one line, which is the rest of the diff.

The type is named in orchestration sources outside this repo, so this lands
without a compatibility alias by the same explicit decision as hw-native-sys#1963.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`PTO2TaskSlotState` becomes `ChipTaskSlotState` — not `TaskSlotState`, because
that name is taken by a different type: `src/common/hierarchical/types.h` holds
the host orchestrator's per-task bookkeeping, built out of `std::mutex`,
`std::vector` and `std::atomic`. This one is the chip runtime's 64-byte slot in
the shared-memory task window, carrying a spinlock and refcounts the AICPU
scheduler touches. Two types, two contexts, so the prefix `PTO2` was providing
real disambiguation here and stripping it alone would have merged them.

`.claude/rules/codestyle.md` rule 13 says which context keeps the bare name:
the L3+ recursive scheduler does, and the chip runtime takes the `Chip` prefix,
as `ChipWorker` / `ChipTensor` / `ChipTaskArgs` already do.

856 occurrences across 109 files. The name is the same length, so every changed
line is the identifier and nothing re-flowed.

The shared-memory layout diagrams in `runtime/shared_memory.h` and
`docs/RUNTIME_LOGIC.md` keep spelling the three slot arrays `TaskDescriptor[]` /
`TaskPayload[]` / `TaskSlotState[]` — they strip the prefix from all three
uniformly and name no type that exists under that exact spelling, so they move
as one piece when the sibling types are renamed rather than half now.

The type is named in orchestration sources outside this repo, so this lands
without a compatibility alias by the same explicit decision as hw-native-sys#1963.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The orchestration API's scoped-block macro becomes `SIMPLER_SCOPE`, and its
sibling `SIMPLER_SCOPE_GUARD`. Not a bare `SCOPE`: a macro has no namespace, and
every translation unit that includes `orchestration_api.h` would inherit a
four-letter object-like collision magnet. `RT_` is not available either — CANN
owns that prefix for its runtime macros (`RT_ERROR_NONE` and friends, consumed
by `device_runner_helpers.cpp`). `SIMPLER_` is the prefix the status codes took
in hw-native-sys#1963, so the macro surface now spells its owner the same way throughout.

The RAII type the macro expands to (`PTO2ScopeGuard` -> `ScopeGuard`) and the
token-pasting helpers (`_PTO2_CONCATENATE`, `_PTO2_CONCATENATE_IMPL`) move in
the same commit. They exist only to implement these two macros and sit within
twenty lines of them in the same header, so splitting them out would leave
`SIMPLER_SCOPE` expanding to a `PTO2ScopeGuard` on the adjacent line.

265 occurrences across 77 files. `PTO2_SCOPE_TASKS_CAP` and the
`PTO2_SCOPE_STATS_*` capacity constants are untouched — they are separate
identifiers that only share a spelling prefix, not part of this macro.

`SIMPLER_SCOPE` is typed by orchestration sources outside this repo, so this
lands without a compatibility alias by the same explicit decision as hw-native-sys#1963.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`PTO2Runtime` becomes `RuntimeContext` — not `Runtime`, because that name is
taken, in the same header tree, by the AICPU/AICore handshake class whose own
docstring already draws the line: "Task graph construction is handled by
PTO2Runtime; this class only handles execution control and device orchestration
state." The struct being renamed is the context the orchestration `.so` receives
— ops table, shared-memory handle, orchestrator, scheduler, mailbox, heap, mode,
statistics — and "context" is what its docstring called it all along, under a
brand name (`PTO Runtime2 context`) rather than a role.

Its three satellites move with it, in one commit, because they are the same
cluster and splitting them would put `RuntimeContext` and `PTO2RuntimeOps` on
adjacent lines of one struct:

- `PTO2RuntimeOps` -> `RuntimeOps` (the ops table, first field)
- `PTO2RuntimeMode` -> `RuntimeMode`
- `PTO2RuntimeArenaLayout` -> `RuntimeArenaLayout`

The last one had already converged: the only occurrences of the bare name in the
tree were the gtest suite names in `tests/ut/cpp/{a2a3,a5}/test_shared_memory.cpp`,
which is what the type is now spelled.

758 occurrences across 69 files. The longer name re-wraps some multi-line
signatures, which is the rest of the diff.

Tier-A brand prose in the same files goes too (rule 10 fixes it on sight): the
`PTO Runtime2 - Main Interface` / `- Orchestrator Interface` /
`- Main Implementation` banners, the two `static_assert` messages that said
"PTO2 runtime ring depth", and the title and overview of both
`tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md` copies, which now name the
runtime the way the `host_build_graph` copies already do. The a2a3 and a5 copies
of that doc had drifted apart on the `(PTO2)` heading suffix; they agree again.

`RuntimeContext` is the handle every orchestration entry point takes, including
in sources outside this repo, so this lands without a compatibility alias by the
same explicit decision as hw-native-sys#1963.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`PTO2_MAX_RING_DEPTH` becomes `CHIP_MAX_RING_DEPTH` — not `MAX_RING_DEPTH`,
because that name is taken by a constant this one is deliberately equal to but
distinct from: `src/common/hierarchical/types.h` defines the host orchestrator's
`MAX_RING_DEPTH = 4` heap-slab count, which `python/bindings/worker_bind.h`
exports to Python. `docs/orchestrator.md` states the relationship outright —
the host slab count "matches L2's `PTO2_MAX_RING_DEPTH`" — so collapsing the two
spellings into one would have turned a documented coincidence into an apparent
identity.

`.claude/rules/codestyle.md` rule 13 assigns the bare name to the L3+ context and
the `Chip` prefix to the chip runtime, the same split this branch already applied
to `ChipTaskSlotState`.

484 occurrences across 55 files. After hw-native-sys#1965 the macro is defined only in the two
`tensormap_and_ringbuffer/runtime/runtime_types.h` copies — host_build_graph
carries no ring dimension at all — so this is now a single-runtime constant.

`PTO2_SCOPE_STATS_MAX_RING_DEPTH` in `src/common/platform/include/common/scope_stats.h`
is untouched: it is a separate identifier that bounds the scope-stats collector's
own per-ring arrays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ChaoWao
ChaoWao force-pushed the refactor/retire-pto2-identifiers branch from c04d398 to 1c2d11f Compare August 24, 2026 03:23
@ChaoWao
ChaoWao merged commit e60dbbf into hw-native-sys:main Aug 24, 2026
19 checks passed
@ChaoWao
ChaoWao deleted the refactor/retire-pto2-identifiers branch August 24, 2026 04:55
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