Skip to content

Support: add l0_swimlane intra-core pipeline profiler#1213

Open
indigo1973 wants to merge 1 commit into
hw-native-sys:mainfrom
indigo1973:l0swim_0629
Open

Support: add l0_swimlane intra-core pipeline profiler#1213
indigo1973 wants to merge 1 commit into
hw-native-sys:mainfrom
indigo1973:l0swim_0629

Conversation

@indigo1973

Copy link
Copy Markdown
Contributor

Dump-driven tool that traces one task's intra-core AICore pipeline under the msprof op simulator (camodel), one level below an L2 task block.

  • Capture a task's real args[] from a JSON-only args dump (Refactor: replace arg_index with positional dump + func_id array #1181 positional model), reconstruct them, and generate a combined replay workspace — zero hand-written shapes or scalars.
  • Mix-together replay: a whole mix task (AIC + AIV0 + AIV1) runs as one msprof op. Two same-source AIV members collapse to a single-AIV include (both lanes run it), covering SPMD mixes whose aiv0 == aiv1.
  • Flags for the manual decisions: --func-id (member set), --set-arg (shrink a scalar / control-tensor loop count without distorting the per-iteration pipeline), --spmd-block-num, --case, --debug-line.
  • docs/dfx/l0-swimlane-profiling.md: usage, fidelity rules, and a Refactor: replace arg_index with positional dump + func_id array #1181-suite coverage table with a runnable command per task shape.
  • .claude/skills/l0-swimlane/SKILL.md: agent-facing operating procedure, centered on how to pick --set-arg / --func-id / --case.

@coderabbitai

coderabbitai Bot commented Jun 30, 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

Run ID: 5b23eed2-1c2d-403f-9006-83e1cc69f21b

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

Adds a new l0_swimlane CLI tool (simpler_setup/tools/l0_swimlane.py) that generates AICore intra-core trace.json traces by reconstructing task args from a dump, synthesizing a CMake/C++/bash replay workspace, running msprof op simulator, and exporting Insight and Perfetto-compatible trace files. Accompanied by a full reference documentation page and an AI skill guide.

Changes

L0 Swimlane Tool and Documentation

Layer / File(s) Summary
l0_swimlane CLI implementation
simpler_setup/tools/l0_swimlane.py
Entire new CLI: load_kernel_meta, get_or_run_dump, reconstruct_task_args, SPMD context synthesis, emit_replay_kernel_combined/emit_replay_host/emit_cmakelists codegen, smoke_build, collect, apply_arg_overrides, _to_perfetto, and main entrypoint with --func-id, --set-arg, --case, --spmd-block-num, --no-collect, and --device flags.
Reference documentation
docs/dfx/l0-swimlane-profiling.md
Full reference page covering concept/scope, feature overview, run modes, internal step flow, flag semantics, output locations, validation findings on a2a3sim, fidelity rules, limitations, FAQ/debug guide, and related links.
AI skill guide
.claude/skills/l0-swimlane/SKILL.md
Skill document defining when to use the tool versus L2/insight-trace, how to select --func-id/--set-arg/--spmd-block-num/--case, post-run self-checks, and coverage pointer.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 A swimlane for tasks, intra-core and precise,
Dumps args, builds replays, exports traces twice—
Perfetto and Insight, both rendered with care,
No hand-authored guesses, just data laid bare.
Hop through the pipes, little rabbit, with glee! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.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 clearly names the main change: adding the l0_swimlane intra-core pipeline profiler.
Description check ✅ Passed The description matches the changeset and summarizes the new tool, docs, flags, and workflow accurately.
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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces the l0_swimlane tool, along with its associated documentation and skill guides, to generate AICore intra-core swimlane traces for tasks. The code review highlights several critical improvements: implementing a stack-based pairing approach for trace events without IDs to prevent trace corruption, passing resolved environment variables to the dump subprocess to avoid execution failures, explicitly specifying UTF-8 encoding and error replacement when reading or writing files to prevent decoding crashes, and generating RAII scopes in the replay host to prevent resource leaks upon API failures.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread simpler_setup/tools/l0_swimlane.py
Comment thread simpler_setup/tools/l0_swimlane.py Outdated
Comment thread simpler_setup/tools/l0_swimlane.py
Comment thread simpler_setup/tools/l0_swimlane.py
Comment thread simpler_setup/tools/l0_swimlane.py
Comment thread simpler_setup/tools/l0_swimlane.py
Comment thread simpler_setup/tools/l0_swimlane.py

@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: 4

🤖 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 @.claude/skills/l0-swimlane/SKILL.md:
- Around line 95-106: Update the `--case NAME` guidance in `SKILL.md` to remove
the claim that the replay defaults to the first matching case; instead explain
that `--case` must be passed explicitly to pin a specific case, and that
omitting it leaves the dump/run unscoped so the test may use default cases or
the wrong/newest dump. Keep the wording tied to the `--case`, `--set-arg`, and
replay behavior described in the `CASES[*]` section so readers understand when
case pinning is required.

In `@docs/dfx/l0-swimlane-profiling.md`:
- Around line 175-182: The workspace naming docs omit the `_mix...` segment,
which causes the example path to point to the wrong output directory. Update the
wording around the workspace location and trace filenames to use the actual
label format from the profiling flow, including the
`<Class>_<Case>_<platform>_<kernel>_mix<members>` segment in the referenced
workspace name and copied trace names. Keep the same structure in the section
that mentions the final traces so readers can map the generated workspace
correctly.

In `@simpler_setup/tools/l0_swimlane.py`:
- Around line 1140-1150: The task-submit --run payload in swimlane collection is
building a shell string with unquoted interpolated values, so update the command
construction in the code that assembles cmd to shell-quote every injected
path/value before embedding it. Use shlex.quote for CANN_HOME, PTO_ISA_ROOT,
REPO_ROOT, and ws in the run string so the task-submit invocation remains safe
and the script path is resolved correctly even when values contain spaces or
shell metacharacters.
- Around line 163-172: The default block width in _case_block_dim() is being
derived from the first platform-matching entry in CASES, which ignores the
user-selected dump case. Update the logic that feeds the synthesized slot-48
block_num so it resolves block_dim from the selected case via args.case or the
recovered manifest case instead of the current platform-first ordering. Make
sure the change is applied consistently where _case_block_dim() is used so
replay_host.cpp gets the block width for the pinned case, not an arbitrary
matching CASES entry.
🪄 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: b9cc59f5-0006-4463-9e6b-870f7566af86

📥 Commits

Reviewing files that changed from the base of the PR and between 11d03d9 and e2c0acd.

📒 Files selected for processing (3)
  • .claude/skills/l0-swimlane/SKILL.md
  • docs/dfx/l0-swimlane-profiling.md
  • simpler_setup/tools/l0_swimlane.py

Comment thread .claude/skills/l0-swimlane/SKILL.md Outdated
Comment thread docs/dfx/l0-swimlane-profiling.md
Comment thread simpler_setup/tools/l0_swimlane.py Outdated
Comment thread simpler_setup/tools/l0_swimlane.py
Dump-driven tool that traces one task's intra-core AICore pipeline under
the msprof op simulator (camodel), one level below an L2 task block.

- Capture a task's real args[] from a JSON-only args dump (hw-native-sys#1181 positional
  model), reconstruct them, and generate a combined replay workspace —
  zero hand-written shapes or scalars.
- Mix-together replay: a whole mix task (AIC + AIV0 + AIV1) runs as one
  msprof op. Two same-source AIV members collapse to a single-AIV include
  (both lanes run it), covering SPMD mixes whose aiv0 == aiv1.
- Flags for the manual decisions: --func-id (member set), --set-arg
  (shrink a scalar / control-tensor loop count without distorting the
  per-iteration pipeline), --spmd-block-num, --case, --debug-line.
- docs/dfx/l0-swimlane-profiling.md: usage, fidelity rules, and a
  hw-native-sys#1181-suite coverage table with a runnable command per task shape.
- .claude/skills/l0-swimlane/SKILL.md: agent-facing operating procedure,
  centered on how to pick --set-arg / --func-id / --case.
@indigo1973

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

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