Skip to content

fix(a2a3/tensormap): flag alloc-tensor creators so they don't block early-dispatch#1292

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:feat/alloc-creator-default-flag
Jul 8, 2026
Merged

fix(a2a3/tensormap): flag alloc-tensor creators so they don't block early-dispatch#1292
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:feat/alloc-creator-default-flag

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #1285 (direct-only early-dispatch).

Problem

Under the direct-only model, an unflagged producer disqualifies its consumer
from early-dispatch, and a pre-completed producer only seeds dispatch_fanin
when flagged
.

alloc_tensors builds a hidden task that completes INLINE at submit
(pto_orchestrator.cpp), so it is a pre-completed producer — and it carried no
allow_early_resolve flag (defaulted false). Every consumer that reads an
alloc'd buffer therefore had an unflagged pre-completed producer, which
disqualified it from early-dispatch entirely. Because alloc'd buffers are
pervasive inputs, this silently defeats early-dispatch for most real graphs.

A buffer allocation is pure memory whose output is ready at creation — it must
be transparent, never a barrier.

Fix

Flag the creator unconditionally (allow_early_resolve = true) on the
inline-complete path. Unlike a codegen task there is no Arg-driven hint to
honor: an alloc creator should never suppress its consumers' early-dispatch.

This keeps the "unflagged = suppress" invariant clean and deterministic
— a consumer early-dispatches iff every producer is flagged, independent of
which producers happened to race to completion before wiring. Intentional
barriers still use a dummy task, which is scheduled (not inline-completed)
and can be left unflagged to suppress.

Testing

  • WiringTest.FlaggedPrecompletedCreatorTransparentToEarlyDispatch: a flagged
    pre-completed creator + a flagged pending compute producer — the creator is
    seeded (transparent) and the consumer reaches the candidate once the compute
    producer dispatches. cpput WiringTest 19/19 pass.
  • a2a3 tensormap_and_ringbuffer onboard smoke passes; runtime compiles clean.

…arly-dispatch

Follow-up to the direct-only early-dispatch model (hw-native-sys#1285). Under that model an
unflagged producer disqualifies its consumer from early-dispatch, and a
pre-completed producer only seeds dispatch_fanin when flagged.

alloc_tensors builds a hidden task that completes INLINE at submit
(pto_orchestrator.cpp), so it is a pre-completed producer — and it carried no
allow_early_resolve flag (defaulted false). Every consumer that reads an
alloc'd buffer therefore had an unflagged pre-completed producer, which
disqualified it from early-dispatch entirely. Since a buffer allocation is
pure memory whose output is ready at creation, it must be transparent, never a
barrier.

Flag the creator unconditionally (allow_early_resolve = true) on the
inline-complete path. Unlike a codegen task there is no Arg-driven hint to
honor — an alloc creator should never suppress its consumers' early-dispatch.
This keeps the "unflagged = suppress" invariant clean and deterministic
(a consumer early-dispatches iff every producer is flagged, independent of
which producers raced to completion). Intentional barriers still use a dummy
task, which is scheduled (not inline-completed) and can be left unflagged.

Tests: add WiringTest.FlaggedPrecompletedCreatorTransparentToEarlyDispatch —
a flagged pre-completed creator + a flagged pending compute producer: the
creator is seeded (transparent) and the consumer reaches the candidate once
the compute producer dispatches. cpput WiringTest 19/19 pass; a2a3 tensormap
onboard smoke passes; runtime compiles clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 8, 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: f8e08447-4d8a-4c23-b34f-0da2e8ef9818

📥 Commits

Reviewing files that changed from the base of the PR and between 414c778 and 63a8ecb.

📒 Files selected for processing (2)
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp
  • tests/ut/cpp/a2a3/test_wiring.cpp

📝 Walkthrough

Walkthrough

The orchestrator now marks hidden/inline alloc task slot states with allow_early_resolve = true before completion, allowing early-dispatch gating to treat allocation outputs as transparent. A new unit test validates that a flagged pre-completed creator does not block early-dispatch fanin propagation.

Changes

Early Resolve Flag for Alloc Tasks

Layer / File(s) Summary
Set allow_early_resolve for hidden alloc tasks and validate
src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp, tests/ut/cpp/a2a3/test_wiring.cpp
Orchestrator sets slot_state->allow_early_resolve = true for hidden/inline alloc tasks before marking PTO2_TASK_COMPLETED; a new test confirms a pre-completed flagged creator seeds dispatch_fanin transparently and that fanin reaches fanin_actual_count after propagation from a compute producer.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
    participant Orchestrator as PTO2OrchestratorState
    participant SlotState
    participant Consumer

    Orchestrator->>SlotState: allow_early_resolve = true
    Orchestrator->>SlotState: mark PTO2_TASK_COMPLETED
    Consumer->>SlotState: seed dispatch_fanin (transparent creator)
    Consumer->>Consumer: propagate_dispatch_fanin(compute producer)
    Consumer->>Consumer: dispatch_fanin == fanin_actual_count
Loading

Poem

A flag flipped true, so small, so neat,
lets alloc tasks skip the waiting seat.
The creator's done, no need to stall,
dispatch flows on and clears them all.
🐇 hop hop, the fanin's complete!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the change: alloc-tensor creators are flagged to avoid blocking early-dispatch.
Description check ✅ Passed The description directly explains the bug, fix, and tests for alloc-tensor early-dispatch behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@ChaoWao ChaoWao merged commit 3ed75c0 into hw-native-sys:main Jul 8, 2026
30 of 31 checks passed
@ChaoWao ChaoWao deleted the feat/alloc-creator-default-flag branch July 8, 2026 06:00
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