Skip to content

Fix: correct documentation that contradicts the code - #1534

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/stale-doc-claims
Jul 28, 2026
Merged

Fix: correct documentation that contradicts the code#1534
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/stale-doc-claims

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Compiling the capability survey (#1525) surfaced documentation and comments that were true once and now disagree with the code. Every claim was re-verified against current main before being changed here — one item the survey reported turned out to be wrong and is not included (see below).

Comments and prose only: the diff contains no statement or expression changes, verified by filtering the .h/.cpp/CMakeLists.txt diff for non-comment lines.

What was wrong

Location Claimed Actually
docs/hardware/chip-architecture.md AIC_CTRL MMIO is Device-nGnRnE nGnRE, proven from driver source in mmio-performance.md — the distinction is what permits the STR/LDR asymmetry documented there
docs/worker-manager.md (×2) dispatch wait is sleep_for(50us), "not busy-wait" spin-polls and cites codestyle rule 5 for why it must; liveness sampled on a wall clock
docs/dynamic-linking.md AICore ELF registered on every launch_aicore_kernel() lazy, handle cached (device_runner_base.cpp:1101)
docs/dynamic-linking.md flow: AICPU launch → stream sync → AICore, via rtKernelLaunch AICore launches first, via rtKernelLaunchWithHandleV2, no intervening sync
docs/comm-domain.md window = VMM + shareable-handle import a2a3 prefers Fabric V2 with VMM-IPC fallback; a5 uses VMM shareable handles only
docs/comm-domain.md producer CoreCallable declares the SDMA workspace no such API; the demo uses Worker(enable_sdma=True)
docs/a5-sdma-overlay.md a2a3 SDMA "always on" always compiled, provisioning opt-in and default off
investigations/2026-07-a2a3-sdma-fault-teardown.md sdma_async_completion_demo unaffected it sets enable_sdma=True, so it carries the same teardown cost
pto_runtime_c_api.h, sim device_runner_base.h CallConfig carries a block_dim knob call_config.h:22 — "There is no block_dim knob"
aicpu_loader/README.md (×3) one symbol resolved; device_id in per-task KernelArgs; per-runtime dispatcher path loops all declared symbols; device_id arrives once via InitArgs; dispatcher is shared per arch under build/lib/<arch>/dispatcher/
tests/ut/cpp/a5/test_aicore_completion_mailbox.cpp "a5 is counter-only" a5 also registers SDMA event-record and URMA event-handle backends
docs/aicpu-kernel-launch-mechanisms.md PR #537 "attempted Path B" #537 is merged and shipped Path A

Also: seven dangling .docs/ references

.docs/ is gitignored (.gitignore:31) and absent from every checkout, so seven comments pointed at documents no reader could open. The surrounding comments now state the invariant that survives on its own, rather than recording where a decision was taken — comments.md keeps change-rationale and edit history out of code, so a pull-request number is no more appropriate there than the unresolvable path was. Concretely, comm_context.h now states that its layout must stay byte-equivalent with pto-isa's parallel HcclDeviceContext declaration, instead of narrating which paths were deleted and where that was discussed.

PR numbers are kept in docs/aicpu-kernel-launch-mechanisms.md: comments.md names docs as a legitimate home for change-context, and that page is the forensic record of why Path B is unusable, so the issue and PR numbers are its evidence.

Two .docs/ mentions are deliberately kept: docs/ci.md lists it as a member of the CI's NON_CODE path set, and the review-pr skill creates .docs/review/ as its own scratch directory. Both are correct usages.

One survey claim I did not act on

The survey reported that docs/troubleshooting/a2a3-507899-aicpu-shared-so-fault.md repeats the device_id-in-KernelArgs error. On inspection it does not — it refers to DeviceArgs.device_id and the inner-SO filename, both accurate. Left unchanged.

I also left the doc's Path A / Path B labels alone. The survey called them inverted relative to issue #822's wording, but the doc is internally consistent and its technical content matches the code (Path B = KERNEL_TYPE_AICPU_CUSTOM, absent from src/, correctly marked broken). Renaming to match an issue's informal phrasing would be churn.

Testing

  • Comment/prose only — filtering the code diff for non-comment lines returns nothing
  • CMake parenthesis balance checked on both modified CMakeLists.txt; brace/quote balance on the modified cpput file
  • markdownlint-cli2 clean on all 8 changed markdown files (v0.20.0, the version .pre-commit-config.yaml:83 pins)
  • Repo-wide link validation: no new broken links (same 5 pre-existing)
  • Simulation / hardware suites — no functional change, but this PR touches .h/.cpp/CMakeLists.txt so the full CI runs rather than the docs-only path

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f47f525-063d-4941-b34a-b6038b3e3c9a

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Documentation and inline comments were updated to match current SDMA provisioning, kernel-launch caching, worker completion polling, communication backends, ABI details, platform behavior, and review-document references.

Changes

Documentation alignment

Layer / File(s) Summary
Runtime execution and ABI documentation
docs/dynamic-linking.md, docs/worker-manager.md, docs/aicpu-kernel-launch-mechanisms.md, src/common/aicpu_loader/README.md
Documents cached kernel handles, spin-poll completion waiting, dispatcher output locations, and AICPU argument boundaries.
SDMA and communication documentation
docs/a5-sdma-overlay.md, docs/comm-domain.md, docs/investigations/..., src/*/runtime/.../sdma_completion_kernel.h, tests/ut/cpp/a5/...
Updates SDMA provisioning and teardown descriptions, HCCL window-memory behavior, and related comments.
Platform and API contract documentation
docs/hardware/chip-architecture.md, src/common/platform/sim/host/device_runner_base.h, src/common/worker/pto_runtime_c_api.h
Corrects MMIO terminology and documents simulator block-dimension and runtime configuration behavior.
Stale reference cleanup
src/a2a3/platform/..., src/a5/platform/..., src/common/platform/..., src/common/platform_comm/...
Removes obsolete migration-document references and replaces review references without changing executable behavior.

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

Poem

I’m a rabbit with docs in my paws,
Updating paths and runtime laws.
SDMA hops when workers say,
Cached kernels guide the way.
Old links fade into the night—
Every comment now feels right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
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 is concise and accurately summarizes the PR’s main change: correcting documentation and comments that conflict with code.
Description check ✅ Passed The description is clearly related to the changeset and explains the documentation-only corrections in sufficient detail.

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

🤖 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/worker-manager.md`:
- Around line 174-180: Update the comments describing next_liveness_check and
the related liveness polling logic to call the timing source a “steady clock” or
“monotonic clock” instead of a “wall clock,” matching steady_clock::now()
behavior; leave the implementation unchanged.
- Around line 176-183: Update the pseudocode loop around next_liveness_check to
invoke check_child_death() when the poll interval expires, and return the
endpoint failure or otherwise terminate the wait when the child is detected
dead. Preserve the existing TASK_DONE polling and next-check scheduling behavior
so the example reflects the WorkerManager liveness logic.
🪄 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 Plus

Run ID: 8fb41aae-dac4-4a8b-b340-05f85ed442c2

📥 Commits

Reviewing files that changed from the base of the PR and between a53cc16 and 839a9e2.

📒 Files selected for processing (22)
  • docs/a5-sdma-overlay.md
  • docs/aicpu-kernel-launch-mechanisms.md
  • docs/comm-domain.md
  • docs/dynamic-linking.md
  • docs/hardware/chip-architecture.md
  • docs/investigations/2026-07-a2a3-sdma-fault-teardown.md
  • docs/worker-manager.md
  • src/a2a3/platform/onboard/host/CMakeLists.txt
  • src/a2a3/platform/onboard/host/comm_hccl.cpp
  • src/a2a3/platform/sim/host/CMakeLists.txt
  • src/a2a3/runtime/host_build_graph/runtime/backend/sdma/sdma_completion_kernel.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/backend/sdma/sdma_completion_kernel.h
  • src/a5/platform/onboard/host/CMakeLists.txt
  • src/a5/platform/onboard/host/comm_hccl.cpp
  • src/a5/platform/sim/host/CMakeLists.txt
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/backend/sdma/sdma_completion_kernel.h
  • src/common/aicpu_loader/README.md
  • src/common/platform/onboard/host/device_runner_helpers.h
  • src/common/platform/sim/host/device_runner_base.h
  • src/common/platform_comm/comm_context.h
  • src/common/worker/pto_runtime_c_api.h
  • tests/ut/cpp/a5/test_aicore_completion_mailbox.cpp
💤 Files with no reviewable changes (2)
  • src/a5/platform/onboard/host/CMakeLists.txt
  • src/a2a3/platform/onboard/host/CMakeLists.txt

Comment thread docs/worker-manager.md Outdated
Comment thread docs/worker-manager.md
@ChaoWao
ChaoWao force-pushed the fix/stale-doc-claims branch 2 times, most recently from 9d6ca86 to 157162d Compare July 28, 2026 00:46
Compiling the capability survey turned up documentation and comments
that
were true once and now disagree with what the code does. Each was
re-verified against the current source before being changed here;
several
were load-bearing enough to send a reader the wrong way.

Claims corrected:

- docs/hardware/chip-architecture.md called the AIC_CTRL MMIO window
  Device-nGnRnE. It is nGnRE, proven from driver source in
  docs/hardware/mmio-performance.md, and the distinction is what makes
  the
  STR/LDR asymmetry there possible.
- docs/worker-manager.md showed the dispatch wait as sleep_for(50us) and
  called it "not busy-wait". The code spin-polls and cites codestyle
  rule 5 for why it must, sampling child liveness on a steady-clock
  period. Its pseudocode also dropped the check_child_death() call that
  ends the wait with ENDPOINT_FAILURE, so as written the loop would have
  spun forever on a dead child.
- docs/dynamic-linking.md claimed the AICore ELF is registered on every
  launch_aicore_kernel() call; registration is lazy and the handle
  cached.
  Its flow diagram also had the launch order backwards: AICore launches
  before the AICPU Run task, via rtKernelLaunchWithHandleV2, with no
  intervening stream sync.
- docs/comm-domain.md described the window as VMM plus shareable-handle
  import. a2a3 prefers Fabric V2 handles and falls back to VMM IPC; a5
  uses VMM shareable handles only. Peer access via
  aclrtDeviceEnablePeerAccess is still accurate and stays.
- docs/comm-domain.md said a producer CoreCallable declares the SDMA
  workspace requirement. No such API exists; the demo provisions SDMA
  with
  Worker(enable_sdma=True).
- docs/a5-sdma-overlay.md called the a2a3 SDMA path "always on". The
  provider is always compiled; provisioning is opt-in and defaults off.
- The a2a3 SDMA fault-teardown investigation called
  sdma_async_completion_demo unaffected by that change, but the demo
  sets
  enable_sdma=True and so carries the same teardown cost.
- src/common/worker/pto_runtime_c_api.h and the sim device_runner_base.h
  both documented a CallConfig block_dim knob. CallConfig has no such
  field and says so explicitly.
- src/common/aicpu_loader/README.md resolved one symbol rather than
  every
  declared one, put device_id in the per-task KernelArgs when it reaches
  the device once via InitArgs, and gave a per-runtime dispatcher path
  when the SO is shared per arch under build/lib/<arch>/dispatcher/.
- A cpput comment claimed a5 is counter-only; a5 registers SDMA
  event-record and URMA event-handle backends too.
- docs/aicpu-kernel-launch-mechanisms.md credited PR hw-native-sys#537 with
  attempting
  Path B. It is merged and shipped Path A.

Also removes seven references to files under .docs/, which is gitignored
and absent from every checkout, so no reader could follow them. The
surrounding comments now state the invariant that survives on its own
rather than recording where a decision was taken: comments.md keeps
change-rationale and edit history out of code, so a pull-request number
is no more appropriate there than the unresolvable path was. The two
remaining .docs/ mentions are left alone: docs/ci.md lists it as a
NON_CODE path set member, and the review-pr skill creates .docs/review/
as its own scratch directory.

Comments and prose only — no statement or expression changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ChaoWao

ChaoWao commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai Both inline findings addressed and resolved:

  • steady vs wall clock — both mentions now read "steady-clock period". The implementation is steady_clock::now(), so "wall clock" wrongly implied sensitivity to system-time changes.
  • missing liveness check in the pseudocode — the snippet now calls check_child_death() and returns ENDPOINT_FAILURE, and the cost bullet names that outcome.

The review body only enumerated those two threads, so no separate action; the walkthrough comment needs none.

Both fixes are folded into the existing single commit rather than appended.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@ChaoWao Thanks for the precise follow-up. The corrected steady-clock terminology and the restored check_child_death() / ENDPOINT_FAILURE path address both inline findings. Noted that the walkthrough needs no change.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@ChaoWao
ChaoWao merged commit cdcbb71 into hw-native-sys:main Jul 28, 2026
16 checks passed
@ChaoWao
ChaoWao deleted the fix/stale-doc-claims branch July 28, 2026 01:04
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