Skip to content

Fix: pass pin-resolved PTO_ISA_ROOT by value and -D - #1418

Merged
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
yanghaoran29:fix/issue-1403-pto-isa-root-by-value
Jul 22, 2026
Merged

Fix: pass pin-resolved PTO_ISA_ROOT by value and -D#1418
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
yanghaoran29:fix/issue-1403-pto-isa-root-by-value

Conversation

@yanghaoran29

Copy link
Copy Markdown
Contributor

Summary

  • Stop smuggling the managed pto-isa checkout through os.environ["PTO_ISA_ROOT"] / $ENV{PTO_ISA_ROOT}. ensure_pto_isa_root() remains the pin source of truth; host CMake gets -DPTO_ISA_ROOT= (a2a3 always; a5 when an async overlay is ON).
  • Drop ambient env exports in runtime_compiler, build_runtimes, conftest, scene_test, runtime_fatal_codes, and bake the path in l0_swimlane.
  • Update docs/a5-sdma-overlay.md with the 2026-07-21 CANN 9.1.T500 repro (libopapi.so probe, 507018 / 0x715002a), mark [Code Health] Extend PTO-ISA build/run version guard to a5 onboard SDMA overlay (missed after #1179) #1351 done, and keep SDMA default OFF (no Option B on broken CANN).

Fixes #1403
Related to #1315

@coderabbitai

coderabbitai Bot commented Jul 21, 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: 7fc50599-37eb-4c4b-9685-2e88b358fa1a

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

The PR replaces ambient PTO_ISA_ROOT transport with pin-resolved explicit paths, validates checkout pins and runtime metadata, makes compile caches pin-aware, and updates host CMake wiring, tooling, tests, and documentation.

Changes

PTO-ISA pin validation and runtime wiring

Layer / File(s) Summary
Pin and metadata validation
simpler_setup/pto_isa.py, simpler_setup/kernel_compiler.py, tests/ut/py/test_pto_isa.py
Adds checkout-pin validation, makes missing runtime metadata fatal, and validates PTO-ISA roots before kernel compilation.
Runtime host build integration
simpler_setup/runtime_compiler.py, simpler_setup/runtime_builder.py, simpler_setup/build_runtimes.py, src/*/platform/onboard/host/CMakeLists.txt, tests/ut/py/test_runtime_builder.py
Stores resolved roots on runtime compiler instances and passes them to host CMake through -DPTO_ISA_ROOT.
L0 workspace transport
simpler_setup/tools/l0_swimlane.py
Bakes the resolved root into generated collection scripts and requires it as a CMake definition rather than an environment variable.
Scene-test cache and execution
simpler_setup/scene_test.py, tests/ut/py/test_scene_test_cache.py, conftest.py, tests/st/runtime_fatal_codes/test_runtime_fatal_codes.py
Adds the PTO-ISA pin to compile-cache keys and removes environment exports during standalone and test setup.
Documentation and setup guidance
docs/*, .claude/skills/*
Documents required runtime metadata, explicit host CMake wiring, updated pin rebuild commands, and a5 overlay verification steps.

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

Possibly related PRs

Poem

A rabbit hops where pin paths flow,
No ambient roots are left to grow.
CMake gets its checkout clear,
Cache keys guard each revision dear.
Metadata speaks, stale builds flee—
Hoppy builds for you and me!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 Concise and specific; it matches the main change of passing PTO_ISA_ROOT explicitly via value and -D.
Description check ✅ Passed The summary is clearly about the PTO_ISA_ROOT transport refactor and related docs/tests.
Linked Issues check ✅ Passed The changes align with #1403: env transport is removed, explicit -D/path passing is added, and related docs/tests are updated.
Out of Scope Changes check ✅ Passed I don't see unrelated code changes; the extra docs, tests, and skill updates all support the same PTO_ISA_ROOT refactor.

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 refactors how the PTO_ISA_ROOT path is propagated and validated across the build and test systems. Instead of relying on the ambient environment variable os.environ["PTO_ISA_ROOT"] (or $ENV{PTO_ISA_ROOT} in CMake), the pin-resolved path is now explicitly passed to CMake as a definition (-DPTO_ISA_ROOT=) and to compilers directly. Additionally, it introduces strict validation to ensure the resolved PTO_ISA_ROOT matches the current pto_isa.pin commit, raises errors for missing build metadata, and incorporates the pin SHA into session compile-cache keys to prevent stale kernel reuse during mid-session pin bumps. I have no feedback to provide as there are no review comments.

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.

@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)
tests/ut/py/test_pto_isa.py (1)

360-365: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Escape the regex metacharacter in the match string.

pytest.raises treats the match string as a regular expression. The unescaped . in pto_isa.pin will match any character. Escaping it ensures an exact match and resolves the static analysis warning.

♻️ Proposed fix
-    with pytest.raises(RuntimeError, match="does not match pto_isa.pin"):
+    with pytest.raises(RuntimeError, match=r"does not match pto_isa\.pin"):
🤖 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/py/test_pto_isa.py` around lines 360 - 365, Update the pytest.raises
match pattern in test_assert_pto_isa_root_matches_pin_rejects_mismatch to escape
the dot in “pto_isa.pin”, ensuring the assertion matches the literal error text
rather than any character.

Source: Linters/SAST tools

🤖 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/multi-repo-qwen-setup/SKILL.md:
- Around line 267-270: Remove the PTO_ISA_ROOT export from the simpler
managed-checkout instructions. Update the surrounding guidance to rely on
ensure_pto_isa_root() and automatic pin resolution, or document the external
script’s explicit supported argument/configuration instead; do not teach users
to set an ambient root that can override the pinned checkout.

---

Nitpick comments:
In `@tests/ut/py/test_pto_isa.py`:
- Around line 360-365: Update the pytest.raises match pattern in
test_assert_pto_isa_root_matches_pin_rejects_mismatch to escape the dot in
“pto_isa.pin”, ensuring the assertion matches the literal error text rather than
any character.
🪄 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: 476eae82-7bde-412b-a4be-66220bf39d6a

📥 Commits

Reviewing files that changed from the base of the PR and between 0a0262c and d9ffe33.

📒 Files selected for processing (18)
  • .claude/skills/multi-repo-qwen-setup/SKILL.md
  • .claude/skills/review-pr/SKILL.md
  • conftest.py
  • docs/a5-sdma-overlay.md
  • docs/getting-started.md
  • simpler_setup/build_runtimes.py
  • simpler_setup/kernel_compiler.py
  • simpler_setup/pto_isa.py
  • simpler_setup/runtime_builder.py
  • simpler_setup/runtime_compiler.py
  • simpler_setup/scene_test.py
  • simpler_setup/tools/l0_swimlane.py
  • src/a2a3/platform/onboard/host/CMakeLists.txt
  • src/a5/platform/onboard/host/CMakeLists.txt
  • tests/st/runtime_fatal_codes/test_runtime_fatal_codes.py
  • tests/ut/py/test_pto_isa.py
  • tests/ut/py/test_runtime_builder.py
  • tests/ut/py/test_scene_test_cache.py

Comment thread .claude/skills/multi-repo-qwen-setup/SKILL.md Outdated
@yanghaoran29
yanghaoran29 force-pushed the fix/issue-1403-pto-isa-root-by-value branch 6 times, most recently from 9fb25ac to 8b19b0f Compare July 21, 2026 12:50
Stop smuggling the managed pto-isa checkout through os.environ /
$ENV{PTO_ISA_ROOT}. ensure_pto_isa_root() remains the pin source of
truth; RuntimeBuilder passes -DPTO_ISA_ROOT= to host CMake (a2a3 always,
a5 when an async overlay is ON).

- Drop ambient env writes in runtime_compiler, build_runtimes, conftest,
  scene_test, and runtime_fatal_codes
- a2a3/a5 host CMakeLists require -DPTO_ISA_ROOT= instead of $ENV
- l0_swimlane resolves the pin once and threads it by value into
  workspace generation (run_collect.sh) and smoke_build (-DPTO_ISA_ROOT=);
  it no longer injects PTO_ISA_ROOT into the subprocess environment
- Scene-test compile cache keys include the pin SHA
- Embedding platforms fail closed when pto_isa_build.json is missing
- KernelCompiler rejects pto_isa_root that does not match pto_isa.pin
- docs/skills: fail-closed metadata, SIMPLER_PTO_ISA_BUILD_COMMIT naming,
  drop ambient-export guidance (incl. the qwen decode_fwd path); MD060
  table align
- docs/a5-sdma-overlay.md: libopapi probe, 2026-07-21 9.1.T500 repro,
  no Option B on broken CANN; hw-native-sys#1351 marked done

Fixes hw-native-sys#1403
Related to hw-native-sys#1315
@ChaoZheng109
ChaoZheng109 merged commit cd2f52c into hw-native-sys:main Jul 22, 2026
16 checks passed
@yanghaoran29
yanghaoran29 deleted the fix/issue-1403-pto-isa-root-by-value branch July 25, 2026 08: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.

[Code Health] Stop transporting PTO_ISA_ROOT via the environment; pass the pin-resolved path by value / -D

2 participants