Skip to content

Refactor: L3-L2 orch comm data path redesign#1291

Open
ccyywwen wants to merge 5 commits into
hw-native-sys:mainfrom
ccyywwen:l3-l2-comm-data-path-refactor
Open

Refactor: L3-L2 orch comm data path redesign#1291
ccyywwen wants to merge 5 commits into
hw-native-sys:mainfrom
ccyywwen:l3-l2-comm-data-path-refactor

Conversation

@ccyywwen

@ccyywwen ccyywwen commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is based on PR #1236 / l3-l2-message-queue-input-window.
That base is intentional: PR #1236 restructures the L3-L2 message queue and
primitive payload-transfer layering, so the mapped-region data path here is
implemented against that newer primitive-layer shape rather than the older queue
staging structure.

This PR implements the first production slice of the L3-L2 communication data
path refactor. It adds lifecycle create/release controls for L3-L2 regions and
switches simulation platforms to an L3 Host mapped-region data path. In sim,
payload and counter operations now execute from the L3 Host through private
mapped-region helpers, while the six-scalar descriptor remains unchanged and
continues to carry L2-side addresses for the L2 AICPU endpoint.

On onboard platforms, the public API remains supported through the existing
L2 Host-mediated path. No public primitive or message queue API changes are
introduced.

Changes

  • Add region create/release mailbox controls, fixed wire structs, bindings, and
    Python encode/decode support.
  • Allocate one L2 Host-owned sim backing region and partition it into payload
    and counter ranges.
  • Initialize counter bytes to zero before publishing create replies.
  • Add private L3 Host mapped-region helpers for sim import/close, payload
    read/write, and counter notify/test/wait.
  • Store mapped-region metadata privately on the L3 Host side; it is not exposed
    through descriptor_scalars().
  • Route sim payload_write, payload_read, SIGNAL_NOTIFY, SIGNAL_TEST,
    and SIGNAL_WAIT through the mapped-region path.
  • Preserve live/released/poison semantics, create rollback, and post-drain
    cleanup ordering.
  • Keep queue staging behavior behind primitive payload transfer.
  • Update user-facing docs for the current API and platform behavior.
  • Remove the non-main design/implementation planning docs from this branch.

@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

📝 Walkthrough

Walkthrough

Adds two new documentation files describing a refactor of the L3↔L2 orchestrator communication data path: a design document and a detailed implementation plan. Both specify removing the dedicated child-side shared-memory service, shifting steady-state payload/counter execution to the L3 parent, and preserving existing descriptor/queue ABI.

Changes

L3-L2 Data Path Refactor Documentation

Layer / File(s) Summary
Design goals and target architecture
docs/l3-l2-comm-data-path-refactor-design.md
States design goals/non-goals and describes the target architecture split between child-owned allocation and parent-owned execution.
Lifecycle control and backend semantics
docs/l3-l2-comm-data-path-refactor-design.md
Specifies mailbox-based lifecycle control flow and onboard/simulation backend payload/counter execution rules.
Ordering, error semantics, migration plan
docs/l3-l2-comm-data-path-refactor-design.md
Documents ordering/cache maintenance, error/poison rules, queue behavior, and migration/acceptance criteria.
Implementation scope and lifecycle encoding
docs/l3-l2-comm-data-path-refactor-impl.md
Defines implementation goals and typed lifecycle mailbox controls with create/release payload validation.
Child allocation and transport backends
docs/l3-l2-comm-data-path-refactor-impl.md
Specifies child region allocation/registry and onboard/simulation transport export/import flows.
Parent-private metadata and operation contracts
docs/l3-l2-comm-data-path-refactor-impl.md
Defines parent-private metadata classes and payload/counter execution and signal semantics.
Cache/ordering rules and ownership boundaries
docs/l3-l2-comm-data-path-refactor-impl.md
Reassigns cache/ordering responsibility and defines live/released/poison state ownership and cleanup rules.
Affected files, migration plan, validation
docs/l3-l2-comm-data-path-refactor-impl.md
Lists affected files, presents a two-PR migration plan, and defines validation/acceptance criteria.

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

Possibly related PRs

  • hw-native-sys/simpler#1015: Original design for the dedicated L3-L2 shared-memory service that this PR's refactor plan supersedes.
  • hw-native-sys/simpler#1130: Adds message queue transport design that overlaps with the message-queue protocol semantics preserved in this refactor.

Poem

A rabbit hopped through docs so wide,
Parent and child now redefined,
No more shuttle service in between,
Just direct paths, swift and clean.
Descriptors stay the same six-fold,
A new design, refactor told. 🐇📄

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly matches the PR's L3-L2 communication data path refactor and redesign work.
Description check ✅ Passed The description is detailed and directly describes the documented refactor, lifecycle controls, and sim/onboard behavior.

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: 1

🧹 Nitpick comments (1)
docs/l3-l2-comm-data-path-refactor-impl.md (1)

386-396: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Keep the buffer failure contract explicit. If parent-contiguous spans are added here, preserve the current pre-submit ValueError behavior and no-poison path for unsupported, non-contiguous, and non-writable inputs so the API stays stable.

🤖 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 `@docs/l3-l2-comm-data-path-refactor-impl.md` around lines 386 - 396, The
buffer-input expansion in this section should keep the existing failure contract
intact. Update the primitive/buffer resolution path so any newly accepted
parent-contiguous span still raises ValueError before submit for unsupported,
non-contiguous, or non-writable inputs, and ensure the no-poison behavior
remains unchanged. Use the existing primitive staging/resolution flow described
here to gate acceptance, and preserve the current runtime Tensor path while
broadening only when the buffer checks are explicit and stable.
🤖 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 `@docs/l3-l2-comm-data-path-refactor-impl.md`:
- Around line 416-420: Clarify the SIGNAL_NOTIFY.Add overflow behavior in the
comm data path spec, since the current description only says to load, add, and
store an int32_t result. Update the SIGNAL_NOTIFY section to explicitly state
whether the addition should wrap, saturate, or fail on overflow, and make the
wording consistent with the parent implementation behavior so readers can
implement the add operation unambiguously.

---

Nitpick comments:
In `@docs/l3-l2-comm-data-path-refactor-impl.md`:
- Around line 386-396: The buffer-input expansion in this section should keep
the existing failure contract intact. Update the primitive/buffer resolution
path so any newly accepted parent-contiguous span still raises ValueError before
submit for unsupported, non-contiguous, or non-writable inputs, and ensure the
no-poison behavior remains unchanged. Use the existing primitive
staging/resolution flow described here to gate acceptance, and preserve the
current runtime Tensor path while broadening only when the buffer checks are
explicit and stable.
🪄 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

Run ID: b9bbdc22-c02b-4476-a419-652417357517

📥 Commits

Reviewing files that changed from the base of the PR and between f5330d4 and 5315c0c.

📒 Files selected for processing (2)
  • docs/l3-l2-comm-data-path-refactor-design.md
  • docs/l3-l2-comm-data-path-refactor-impl.md

Comment on lines +416 to +420
`SIGNAL_NOTIFY`:

- `Set`: store the operand as `int32_t`.
- `Add`: load current `int32_t`, add operand, store result.
- Apply release/publish ordering before the store becomes visible.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "NotifyOp\.Add|SIGNAL_NOTIFY|counter_operand|int32_t" python src tests docs

Repository: hw-native-sys/simpler

Length of output: 50378


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the target section with line numbers
sed -n '400,435p' docs/l3-l2-comm-data-path-refactor-impl.md

# Find the upstream implementation/contract for SIGNAL_NOTIFY semantics
rg -n "SIGNAL_NOTIFY|NotifyOp\.Add|Add: load current|store the operand as int32_t|release/publish ordering|poison|exception" \
  python src docs tests

Repository: hw-native-sys/simpler

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- docs/l3-l2-comm-data-path-refactor-design.md (around NotifyOp.Add) ---'
sed -n '288,312p' docs/l3-l2-comm-data-path-refactor-design.md

echo '--- docs/l3-l2-orch-comm.md (counter notify semantics) ---'
sed -n '300,330p' docs/l3-l2-orch-comm.md

echo '--- python/simpler/l3_l2_orch_comm.py (SIGNAL_NOTIFY path) ---'
sed -n '200,250p' python/simpler/l3_l2_orch_comm.py

echo '--- src/common/platform/shared/host/l3_l2_orch_comm_service.cpp (SIGNAL_NOTIFY handler) ---'
sed -n '181,330p' src/common/platform/shared/host/l3_l2_orch_comm_service.cpp

echo '--- tests around NotifyOp.Add and counter behavior ---'
sed -n '280,340p' tests/ut/py/test_worker/test_l3_l2_orch_comm.py
sed -n '100,140p' tests/ut/py/test_worker/test_l3_l2_message_queue.py

Repository: hw-native-sys/simpler

Length of output: 15045


Define SIGNAL_NOTIFY.Add overflow behavior. The current parent implementation does observed + request.counter_operand on int32_t, so overflow is undefined unless you specify wrap, saturate, or error semantics here.

🤖 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 `@docs/l3-l2-comm-data-path-refactor-impl.md` around lines 416 - 420, Clarify
the SIGNAL_NOTIFY.Add overflow behavior in the comm data path spec, since the
current description only says to load, add, and store an int32_t result. Update
the SIGNAL_NOTIFY section to explicitly state whether the addition should wrap,
saturate, or fail on overflow, and make the wording consistent with the parent
implementation behavior so readers can implement the add operation
unambiguously.

@ccyywwen ccyywwen force-pushed the l3-l2-comm-data-path-refactor branch 2 times, most recently from 7ef64f9 to 0d0988f Compare July 9, 2026 03:33
jvjhfhg and others added 5 commits July 9, 2026 11:49
- Template L3L2QueueEndpoint on MaxInflight and remove runtime config
- Move active input tracking to a fixed ring with STOP extra capacity
- Unify L3-L2 helper namespaces, error metadata, cache, and time helpers
- Link public AICPU helper sources into JIT orchestration builds
- Update docs, examples, and C++ UT coverage
- Add the direct parent data path design for L3-L2 orch comm
- Add an implementation plan with lifecycle controls, sim/onboard migration split, cleanup ordering, and validation scope
- Add lifecycle create/release controls and fixed create wire structs
- Implement sim L2 Host owned region allocation with L3 Host mapping helpers
- Route sim payload and counter operations through mapped-region helpers
- Keep queue staging behavior behind primitive payload transfer
- Add focused Python and C++ coverage for lifecycle and mapped access
- Describe L3 Host mapped-region behavior for simulation platforms
- Clarify onboard payload buffers and L2 Host-mediated operations
- Move queue payload-transfer staging wording to the primitive backend
@ccyywwen ccyywwen force-pushed the l3-l2-comm-data-path-refactor branch from 0d0988f to eccc8ef Compare July 9, 2026 03:57
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