Skip to content

Refactor: consolidate per-task markers into one TaskAttrs byte (a5/tmr)#1433

Closed
ChaoZheng109 wants to merge 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:refactor/issue-1402-a5-tmr-task-attrs
Closed

Refactor: consolidate per-task markers into one TaskAttrs byte (a5/tmr)#1433
ChaoZheng109 wants to merge 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:refactor/issue-1402-a5-tmr-task-attrs

Conversation

@ChaoZheng109

Copy link
Copy Markdown
Collaborator

Summary

Mirrors the a2a3/tmr consolidation (#1402) to the a5 tensormap_and_ringbuffer runtime. Folds the four scattered per-task markers into a single TaskAttrs byte on PTO2TaskSlotState and reverts active_mask to a pure subtask-slot mask. a5/tmr was structurally identical to the a2a3 baseline, so this is a 1:1 port with the same settled design.

Changes

  • New TaskAttrs (pto_submit_types.h) — one byte: bit0 allow_early_resolve, bit1 sync_start, bit2 has_predicate, bit3 is_timed, bits4-7 timing_tag (0..15).
  • ActiveMask reverts to pure subtask-slot mask — dropped SYNC_START/HAS_PREDICATE bits/accessors; only core_mask (bits 0-2) remains.
  • task_timing_slot removed from PTO2TaskDescriptor — tag now rides the hot slot_state line. Descriptor 40B / packed_buffer_base offset unchanged (ABI preserved). PTO2TaskSlotState stays 64B.
  • Attributes written once per submit in prepare_task; all scheduler read sites updated. static_assert couples the 4-bit tag to NUM_TASK_TIMING_SLOTS <= 16 / TASK_TIMING_SLOT_NONE == -1.
  • Accessor naming matches the a2a3 baseline: predicate getters (allow_early_resolve/requires_sync_start/has_predicate/is_timed), set_<concept> setters.

Testing

  • test_a5_wiring (cpput)
  • a5sim st: predicated_dispatch, spmd_sync_start{,_early_dispatch,_stress,_mix_spill}, mixed_example, dummy_task, spmd_multiblock_mix
  • a5 hardware — deferred (this box is Ascend910/a2a3)

Relation to #1402

a5/tmr mirror of the a2a3/tmr baseline. Remaining: a2a3 host_build_graph, a5 host_build_graph (legacy path). Part of #1402.

Mirror of the a2a3/tmr consolidation (hw-native-sys#1402) to the a5
tensormap_and_ringbuffer runtime: fold the four scattered per-task
markers into a single TaskAttrs byte on PTO2TaskSlotState, and revert
active_mask to a pure subtask-slot mask.

- Add TaskAttrs (pto_submit_types.h): bit0 allow_early_resolve,
  bit1 sync_start, bit2 has_predicate, bit3 is_timed, bits4-7 timing_tag.
- Drop SYNC_START/HAS_PREDICATE flag bits and accessors from ActiveMask;
  it now carries only core_mask (bits 0-2).
- Remove task_timing_slot from PTO2TaskDescriptor; the tag now rides the
  scheduler's hot slot_state line. Descriptor size/ABI (40B,
  packed_buffer_base offset) unchanged; PTO2TaskSlotState stays 64B
  (task_attrs reuses the byte allow_early_resolve occupied, alongside the
  atomic lifecycle_flags).
- prepare_task writes task_attrs per submit alongside active_mask;
  attributes are assembled at each submit entry point (submit_task,
  submit_dummy_task, alloc_tensors).
- Update all scheduler read sites (dispatch/completion/scheduler.h) to
  read the attributes off slot_state.
- Static-assert NUM_TASK_TIMING_SLOTS <= 16 and TASK_TIMING_SLOT_NONE
  == -1 so the 4-bit tag field and the untagged sentinel stay coupled.

Accessor naming matches the settled a2a3/tmr baseline: getters are
predicates (allow_early_resolve / requires_sync_start / has_predicate /
is_timed), setters are set_<concept> (set_early_resolve / set_sync_start /
set_predicate / set_timing_slot).

Behavior-neutral refactor. Verified: test_a5_wiring (cpput) plus a5sim st
(predicated_dispatch, spmd_sync_start{,_early_dispatch,_stress,_mix_spill},
mixed_example, dummy_task, spmd_multiblock_mix). Part of hw-native-sys#1402.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f5447c67-05d3-4ef4-a982-4aeab1680e99

📥 Commits

Reviewing files that changed from the base of the PR and between a7a29ee and 2e9fc68.

📒 Files selected for processing (8)
  • src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_submit_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_completion.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp

📝 Walkthrough

Walkthrough

Changes

Task attribute scheduling migration

Layer / File(s) Summary
Define packed task attributes
src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_submit_types.h, src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_types.h, src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_runtime2_types.h
TaskAttrs stores early-resolve, sync-start, predicate, and timing metadata, while ActiveMask retains only subtask-mask state and slot layouts enforce the updated ABI.
Thread attributes through task submission
src/a5/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp
Submission, dummy tasks, allocation tasks, and fan-in wiring construct or consume TaskAttrs through prepared slot state.
Apply attributes to ready and early-dispatch routing
src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.h, src/a5/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
Ready-queue placement, predicate filtering, early-resolution checks, fan-in propagation, and sync-start routing use task_attrs.
Use attributes during dispatch and completion
src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp, src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_completion.cpp
Dispatch synchronization, timing publication and completion, pending gating, and promotion logic read timing and sync-start state from task_attrs.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

Poem

A rabbit packed flags in a byte neat and bright,
Sync-start and timing now hop through the night.
Predicates leave masks, early resolve takes flight,
Slots carry attributes, dispatch feels right.
“One hop at a time!” says the rabbit in glee.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% 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
Title check ✅ Passed The title accurately summarizes the main change: consolidating per-task markers into a TaskAttrs byte in a5/tmr.
Description check ✅ Passed The description is directly related and matches the task-attribute consolidation and scheduler updates in the diff.
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.

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.

@ChaoZheng109

Copy link
Copy Markdown
Collaborator Author

Folding the a5/tmr change into #1410 instead of a standalone PR, per request.

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