Skip to content

Fix: preserve args dump selection in host-built graphs - #1808

Merged
ChaoZheng109 merged 3 commits into
hw-native-sys:mainfrom
vegetabledoww:fix/issue-1800-hbg-dump-selection
Aug 13, 2026
Merged

Fix: preserve args dump selection in host-built graphs#1808
ChaoZheng109 merged 3 commits into
hw-native-sys:mainfrom
vegetabledoww:fix/issue-1800-hbg-dump-selection

Conversation

@vegetabledoww

Copy link
Copy Markdown
Contributor

Host-built graph orchestration runs outside AICPU, so its dump-mask and scalar-dtype table updates resolved to host-side no-op stubs. Partial dumps consequently selected no tasks, while hybrid dumps emitted metadata without marked tensor payloads.

Embed the selection mask, ambiguity flags, and scalar dtypes in each HBG task payload and cached Graph definition. Consume that metadata in dispatch, completion, and timeout dump paths while retaining the existing AICPU side table for tensormap-and-ringbuffer.

Cover direct submission and Graph replay on both architectures, and exercise partial and hybrid manifests on a2a3 onboard plus a2a3sim/a5sim.

Fixes #1800

Host-built graph orchestration runs outside AICPU, so its dump-mask and scalar-dtype table updates resolved to host-side no-op stubs. Partial dumps consequently selected no tasks, while hybrid dumps emitted metadata without marked tensor payloads.

Embed the selection mask, ambiguity flags, and scalar dtypes in each HBG task payload and cached Graph definition. Consume that metadata in dispatch, completion, and timeout dump paths while retaining the existing AICPU side table for tensormap-and-ringbuffer.

Cover direct submission and Graph replay on both architectures, and exercise partial and hybrid manifests on a2a3 onboard plus a2a3sim/a5sim.

Fixes hw-native-sys#1800
@coderabbitai

coderabbitai Bot commented Aug 12, 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: e32ef7ca-bc53-4f8c-a998-d84f22a21736

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

Host-build-graph now embeds per-task argument-dump metadata in task payloads and cached graph nodes. Scheduler dump paths consume this metadata directly. Tests verify selective capture, scalar dtypes, and graph replay for a2a3 and a5.

Changes

Argument-dump metadata pipeline

Layer / File(s) Summary
Per-task metadata contract
src/common/platform/include/common/args_dump.h, src/common/platform/include/aicpu/args_dump_aicpu.h, src/common/platform/shared/aicpu/args_dump_aicpu.cpp
Adds ArgsDumpTaskMetadata. Dump APIs accept metadata. Tensor payload capture uses explicit flags.
Host-build-graph storage and materialization
src/a2a3/runtime/host_build_graph/runtime/..., src/a5/runtime/host_build_graph/runtime/...
Graph nodes and task payloads store dump masks, ambiguity flags, and scalar dtypes. Graph recording and materialization propagate the metadata.
Scheduler integration
src/a2a3/runtime/host_build_graph/runtime/scheduler/*, src/a5/runtime/host_build_graph/runtime/scheduler/*
Dispatch, completion, and timeout diagnostic paths pass task metadata to argument-dump routines.
Validation and documentation
tests/st/a2a3/host_build_graph/dump_args/*, tests/st/a5/host_build_graph/dump_args/*, tests/ut/cpp/a2a3/*, tests/ut/cpp/a5/*, docs/dfx/args-dump.md
Tests verify payload capture, scalar dtypes, graph-cache replay, and simulated platforms. Documentation describes the propagation paths.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Poem

I’m a rabbit, hopping through the task-image stream,
Carrying dump masks in a metadata dream.
Graph nodes remember each scalar’s right type,
Payload flags tell tensors when to capture their flight.
Across a2a3 and a5, the records now align—
One neat little hop through the scheduler line.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% 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 clearly identifies the main change: preserving argument-dump selection in host-built graphs.
Description check ✅ Passed The description explains the host-built graph failure, the metadata propagation fix, and the test coverage.
Linked Issues check ✅ Passed The changes address issue #1800 by propagating masks, flags, and scalar dtypes through task payloads and graph replay paths.
Out of Scope Changes check ✅ Passed The documentation, compatibility-stub, implementation, and test changes support the linked issue and stated multi-architecture coverage.

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/common/platform/include/aicpu/args_dump_aicpu.h (1)

368-396: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Filter unselected tensors in PARTIAL mode.

Lines 368-396 set capture_payload, but they do not skip unselected tensor arguments. dump_arg_record only uses this field to suppress payloads in HYBRID mode. PARTIAL mode therefore records and copies every tensor payload, including unmarked arguments.

Proposed fix
         ArgsDumpRole role;
         if (!get_dump_arg_role_from_direction(dir, &role) || !should_dump_arg_at_stage(role, stage)) {
             tensor_arg_index++;
             continue;
         }
+        const bool capture_payload = has_dump_arg_flag(dump_arg_mask, sig_idx);
+        if (g_dump_args_level == DumpArgsLevel::PARTIAL && !capture_payload) {
+            tensor_arg_index++;
+            continue;
+        }

         const auto &t = tensor_info[tensor_arg_index];
         ArgsDumpInfo info = {};
@@
-        info.capture_payload = has_dump_arg_flag(dump_arg_mask, sig_idx);
+        info.capture_payload = capture_payload;
🤖 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 `@src/common/platform/include/aicpu/args_dump_aicpu.h` around lines 368 - 396,
Update the tensor-processing loop around dump_arg_mask,
should_dump_arg_at_stage, and capture_payload so PARTIAL mode skips unselected
tensor arguments before creating or recording ArgsDumpInfo. Preserve unselected
arguments only where the active mode requires metadata without payload, such as
HYBRID, and keep tensor_arg_index synchronized for every non-scalar argument.
src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp (1)

176-185: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard payload access in both completion paths.

Both completion implementations can dereference a null payload when argument dumping is enabled.

  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp#L176-L185: require slot_state.payload != nullptr before reading dump_metadata.
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp#L176-L185: apply the same payload guard.
🤖 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 `@src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp`
around lines 176 - 185, Guard the argument-dumping condition in both completion
implementations so it requires slot_state.payload to be non-null before
accessing dump_metadata. Apply this change in
src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp
lines 176-185 and
src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp lines
176-185, preserving the existing is_dump_args_enabled() behavior otherwise.
🧹 Nitpick comments (1)
tests/ut/cpp/a2a3/test_graph_cache.cpp (1)

335-335: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover all static dump metadata during affine replay.

Both graph-cache tests verify only dump_arg_mask after affine materialization. A replay-specific loss of dump_arg_flags or scalar_dtypes could therefore pass.

  • tests/ut/cpp/a2a3/test_graph_cache.cpp#L335-L335: assert the first node's dump_arg_flags and scalar dtype after affine materialization.
  • tests/ut/cpp/a5/test_graph_cache.cpp#L335-L335: add the same affine replay assertions.
🤖 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 `@tests/ut/cpp/a2a3/test_graph_cache.cpp` at line 335, Extend the
affine-materialization assertions in tests/ut/cpp/a2a3/test_graph_cache.cpp at
lines 335-335 to verify the first node’s dump_arg_flags and scalar dtype
alongside dump_arg_mask; apply the same assertions in
tests/ut/cpp/a5/test_graph_cache.cpp at lines 335-335, using the expected
metadata values established by the test setup.
🤖 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.

Outside diff comments:
In
`@src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp`:
- Around line 176-185: Guard the argument-dumping condition in both completion
implementations so it requires slot_state.payload to be non-null before
accessing dump_metadata. Apply this change in
src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp
lines 176-185 and
src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp lines
176-185, preserving the existing is_dump_args_enabled() behavior otherwise.

In `@src/common/platform/include/aicpu/args_dump_aicpu.h`:
- Around line 368-396: Update the tensor-processing loop around dump_arg_mask,
should_dump_arg_at_stage, and capture_payload so PARTIAL mode skips unselected
tensor arguments before creating or recording ArgsDumpInfo. Preserve unselected
arguments only where the active mode requires metadata without payload, such as
HYBRID, and keep tensor_arg_index synchronized for every non-scalar argument.

---

Nitpick comments:
In `@tests/ut/cpp/a2a3/test_graph_cache.cpp`:
- Line 335: Extend the affine-materialization assertions in
tests/ut/cpp/a2a3/test_graph_cache.cpp at lines 335-335 to verify the first
node’s dump_arg_flags and scalar dtype alongside dump_arg_mask; apply the same
assertions in tests/ut/cpp/a5/test_graph_cache.cpp at lines 335-335, using the
expected metadata values established by the test setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e5423b6-60e0-4fcd-a25a-c3dff6e67363

📥 Commits

Reviewing files that changed from the base of the PR and between 50c0660 and e46a415.

📒 Files selected for processing (29)
  • docs/dfx/args-dump.md
  • src/a2a3/runtime/host_build_graph/host/host_orch_compat_stubs.cpp
  • src/a2a3/runtime/host_build_graph/runtime/graph_execution.h
  • src/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_orchestrator.cpp
  • src/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/graph_execution.cpp
  • 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_dispatch.cpp
  • src/a5/runtime/host_build_graph/host/host_orch_compat_stubs.cpp
  • src/a5/runtime/host_build_graph/runtime/graph_execution.h
  • src/a5/runtime/host_build_graph/runtime/orchestrator_core/pto_orchestrator.cpp
  • src/a5/runtime/host_build_graph/runtime/pto_runtime2_types.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/graph_execution.cpp
  • 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_dispatch.cpp
  • src/common/platform/include/aicpu/args_dump_aicpu.h
  • src/common/platform/include/common/args_dump.h
  • src/common/platform/shared/aicpu/args_dump_aicpu.cpp
  • tests/st/a2a3/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp
  • tests/st/a2a3/host_build_graph/dump_args/test_dump_args_example.py
  • tests/st/a5/host_build_graph/dump_args/kernels/orchestration/dump_args_orch.cpp
  • tests/st/a5/host_build_graph/dump_args/test_dump_args_example.py
  • tests/ut/cpp/a2a3/test_args_dump.cpp
  • tests/ut/cpp/a2a3/test_graph_cache.cpp
  • tests/ut/cpp/a2a3/test_hbg_submit_poison.cpp
  • tests/ut/cpp/a5/test_graph_cache.cpp
  • tests/ut/cpp/a5/test_hbg_submit_poison.cpp

vegetabledoww and others added 2 commits August 12, 2026 18:33
Host-build-graph runtime types only need the dump selection POD, but including the full args_dump header pulled platform timing symbols into orchestration sources and conflicted with paged-attention definitions.

Move the task metadata and its ABI assertions into a dependency-light header, then include that header from both a2a3 and a5 runtime types. Paged-attention scene compilation and dump-args level 1/3 simulation tests pass on the supported platforms.
@ChaoZheng109
ChaoZheng109 merged commit d10e7e2 into hw-native-sys:main Aug 13, 2026
19 checks passed
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.

[Bug] host_build_graph: --dump-args selective (L1) and hybrid (L3) produce empty/degraded output

2 participants