Skip to content

Retire the PTO brand names, and hold the line with a hook - #2021

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:retire-pto-brand-banners
Aug 26, 2026
Merged

ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:retire-pto-brand-banners

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

.claude/rules/codestyle.md rule 10 said the retirement was complete and that "there is no backlog to work through". Two of its three claims held. The third was false — the rule's own grep, PTO Runtime2?|PTO2|pto2_|pto_runtime2, found 38 brand banners across 36 files in src/.

The claim had been measured with PTO2|pto2_, which cannot see a brand name with a space in it. #1980's title was "finish the PTO2 retirement" and it finished exactly that, verifiably — 62 remaining under its own pattern, reproducible today. The sentence it added generalised from "PTO2 identifiers" to "the retirement".

What changed

The 38 banners

Following the style already in the tree — orchestrator_core/orchestrator.cpp opens * host_build_graph orchestrator implementation, so the runtime's directory name leads, subsystem words are lower case, type names keep their case:

* PTO Runtime2 - TensorMap Interface       ->  * host_build_graph TensorMap interface
* PTO Runtime2 - Ring Buffer Data Struct…  ->  * tensormap_and_ringbuffer ring buffer data structures

The four PTO Runtime C API banners are in the platform layer, which serves both runtimes, so they take the name the canonical header already uses for itself: simpler host-runtime C API.

Eighteen comments naming a pto_* that does not exist

doc-consistency.md §3 defects rather than naming preferences — a reader who greps the name finds nothing:

stale actual uses
pto_submit_task rt_submit_task, in orchestration/orchestration_api.h 16
pto_runtime_c_api runtime_c_api, the file name 2

git grep -w <name> returning only comments is what established each was absent.

Six mentions that named a retired variable only for history

"the now-retired PTO2_RING_* environment variables", "the process-wide PTO2_RING_* env, since retired" — these explained a design by contrast with something the reader cannot find. They now state the current mechanism and what it enables. (per_task_runtime_env/README.md also carried "shared the process-wide process-wide", a duplicated line from #1980's edit.)

tests/lint/check_retired_names.py, wired into pre-commit

Rule 10 already demanded that "the count only goes down"; nothing enforced it, and a count written into prose cannot stay true — that is how this rotted. The hook fails on any new PTO Runtime, PTO Runtime2, or bare Runtime2, so the rule can point at it and drop the number it could not keep current.

Rule 10 itself

  • The "no backlog" claim is replaced by a pointer to the hook, plus "do not put a number here again — put it in the hook".
  • Tier A is split in two, because it had been lumping populations with opposite risk: A1 brand prose (mechanically safe, no Tier-C name can hide in a file banner) and A2 dangling pto_* references (grep first — it is a §3 defect, and the namespace is shared with Tier C).
  • Tier C now names the dlsym trap explicitly.

What is deliberately untouched, and why

Every live pto_cpu_sim_* / pto_sim_* hook — 33 occurrences, all left alone. cpu_sim_context.cpp exports them for "pto-isa via dlsym(RTLD_DEFAULT)", and device_runner_base.cpp:863 fetches pto_sim_register_hooks by dlsym. Renaming one produces no compile error — just a hook that is never found at run time.

That is the "handful of Tier-C names hiding in it" rule 10's no-sweep ban was written to protect, and it is real. It just hides in the lowercase pto_* namespace, not in the banner namespace — which is exactly why the hook checks only the brand spellings and why Tier A had to be split.

PTO2_* is out of the hook's scope, because what remains of that spelling is load-bearing in two ways a regex cannot distinguish:

  • Twelve occurrences belong to warn_on_retired_ring_env() in each host/runtime_maker.cpp — a kRetired[] array of env names plus the comment explaining it — and three doc sites that tell a reader what the warning they just saw means. The names cannot leave without the warning leaving, and that warning is one day old (Refactor: finish the PTO2 retirement, one identifier per commit #1980, 2026-08-25); rule 10 holds it up as the model for retiring a knob rather than silently falling back.
  • Eight are PTO2_MANUAL_MAX_SEQ, pypto-lib's own variable, which the qwen READMEs tell a user to export literally.

So banning the spelling would either delete a live diagnostic or break working instructions. Happy to remove the warning and its 15 mentions in a follow-up if the transition is considered over — that is a behaviour change, so it wants its own decision.

Testing

Comments, docs, and one new lint script. No declaration, signature or expression changed.

  • Full product build — both arches, sim and onboard, all four runtimes
  • ctest cpput — 119/119
  • Per-PR sim gate (--manual exclude) — green on a2a3sim and a5sim
  • clang-format --dry-run --Werror clean on all 42 changed C++ files; every one is a matched a2a3/a5 pair
  • markdownlint-cli2 clean on every changed doc

The hook's own behaviour, verified four ways: 0 over all 2294 tracked files; 1 on a probe containing PTO Runtime2 - Something; 1 on a bare Runtime2; 0 on codestyle.md, which is exempt because a rule has to spell what it bans.

🤖 Generated with Claude Code

`.claude/rules/codestyle.md` rule 10 said the retirement was complete and that
"there is no backlog to work through". Two of its three claims held: no `PTO2`
*identifier* is left, and a new one is a defect. The third was false — the rule's
own grep, `PTO Runtime2?|PTO2|pto2_|pto_runtime2`, found 38 brand banners across
36 files in `src/`.

The claim had been measured with `PTO2|pto2_`, which cannot see a brand name with
a space in it. hw-native-sys#1980's title was "finish the PTO2 retirement" and it finished
exactly that, verifiably — 62 remaining under its own pattern, reproducible today.
The sentence generalised from "PTO2 identifiers" to "the retirement".

## What changed

**The 38 banners**, following the style already in the tree —
`orchestrator_core/orchestrator.cpp` opens `* host_build_graph orchestrator
implementation`, so the runtime's directory name leads and the subsystem words are
lower case, with type names keeping their case:

    * PTO Runtime2 - TensorMap Interface   ->  * host_build_graph TensorMap interface
    * PTO Runtime2 - Ring Buffer Data …    ->  * tensormap_and_ringbuffer ring buffer data …

The four `PTO Runtime C API` banners are in the platform layer, which serves both
runtimes, so they take the name the canonical header already uses for itself:
`simpler host-runtime C API`.

**Eighteen comments naming a `pto_*` that does not exist.** These are
`doc-consistency.md` §3 defects rather than naming preferences — a reader who
greps the name finds nothing:

  - `pto_submit_task` x16 -> `rt_submit_task`, the actual orchestration entry in
    `orchestration/orchestration_api.h`.
  - `pto_runtime_c_api` x2 -> `runtime_c_api`, the actual file name.

`git grep -w` returning only comments is what established each was absent.

**`tests/lint/check_retired_names.py`**, wired into pre-commit. Rule 10 already
demanded that "the count only goes down"; nothing enforced it, and a count written
into prose cannot stay true. The hook fails on any new `PTO Runtime`,
`PTO Runtime2`, or bare `Runtime2`, so the rule can now point at it and drop the
number it could not keep current.

The hook is deliberately narrow, and the reason is the third population rule 10
lumped into one Tier A row.

## What is deliberately untouched

**Every live `pto_cpu_sim_*` / `pto_sim_*` hook** — 33 occurrences, all left
alone. `cpu_sim_context.cpp` exports them for "pto-isa via
`dlsym(RTLD_DEFAULT)`", and `device_runner_base.cpp` fetches
`pto_sim_register_hooks` by `dlsym`. Renaming one produces **no compile error** —
just a hook that is never found at run time. That is the "handful of Tier-C names
hiding in it" rule 10's no-sweep ban was written to protect, and it is real; it
just hides in the lowercase `pto_*` namespace, not in the banner namespace. So the
hook checks only the brand spellings, and rule 10's Tier A is split into A1
(brand prose, mechanically safe) and A2 (dangling `pto_*` references, grep first),
with the `dlsym` trap named in Tier C.

**Six mentions that named a retired variable only for history** — "the
now-retired `PTO2_RING_*` environment variables", "the process-wide `PTO2_RING_*`
env, since retired" — now state the current mechanism and what it enables
instead. They explained a design by contrast with something the reader cannot
find. (`per_task_runtime_env/README.md` also had "shared the process-wide
process-wide", a duplicated line from hw-native-sys#1980's edit.)

`PTO2_*` is deliberately left out of the hook, because what remains of that
spelling is load-bearing in two ways the hook cannot distinguish:

  - Twelve occurrences belong to `warn_on_retired_ring_env()` in each
    `host/runtime_maker.cpp` — a `kRetired[]` array of env names and the comment
    explaining it — plus three doc sites that tell a reader what the warning they
    just saw means. The names cannot leave without the warning leaving, and that
    warning is one day old (hw-native-sys#1980, 2026-08-25); rule 10 holds it up as the model
    for retiring a knob rather than silently falling back.
  - Eight are `PTO2_MANUAL_MAX_SEQ`, pypto-lib's own variable, which the qwen
    READMEs tell a user to `export` literally.

So banning the spelling would either delete a live diagnostic or break working
instructions.

## Verification

Comments and one new lint script; no declaration, signature or expression changes.

  - Full product build — both arches, sim and onboard, all four runtimes.
  - cpput 119/119.
  - The hook returns 0 over all 2294 tracked files, 1 on a probe containing
    `PTO Runtime2 - Something`, 1 on a bare `Runtime2`, and 0 on
    `codestyle.md` itself, which is exempt because a rule has to spell what it bans.
  - `clang-format --dry-run --Werror` clean on all 42 changed C++ files; every one
    of them is a matched a2a3/a5 pair.

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

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 2 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 61e1385f-8e2f-41ed-bb65-a30663467b30

📥 Commits

Reviewing files that changed from the base of the PR and between 32e3ee0 and d349cd5.

📒 Files selected for processing (51)
  • .claude/rules/codestyle.md
  • .pre-commit-config.yaml
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention_ringbuffer/README.md
  • examples/a2a3/tensormap_and_ringbuffer/paged_attention_ringbuffer/test_paged_attention_ringbuffer.py
  • examples/a5/tensormap_and_ringbuffer/paged_attention_ringbuffer/README.md
  • examples/a5/tensormap_and_ringbuffer/paged_attention_ringbuffer/test_paged_attention_ringbuffer.py
  • examples/workers/l3/per_task_runtime_env/README.md
  • examples/workers/l3/per_task_runtime_env/main.py
  • src/a2a3/platform/onboard/host/runtime_c_api.cpp
  • src/a2a3/platform/sim/host/runtime_c_api.cpp
  • src/a2a3/runtime/host_build_graph/runtime/runtime_types.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler.h
  • src/a2a3/runtime/host_build_graph/runtime/shared/shared_memory.cpp
  • src/a2a3/runtime/host_build_graph/runtime/shared/tensormap.cpp
  • src/a2a3/runtime/host_build_graph/runtime/tensormap.h
  • src/a2a3/runtime/host_build_graph/runtime/types.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/orchestrator.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/orchestrator.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/shared_memory.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared/tensormap.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/shared_memory.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/tensormap.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/types.h
  • src/a5/platform/onboard/host/runtime_c_api.cpp
  • src/a5/platform/sim/host/runtime_c_api.cpp
  • src/a5/runtime/host_build_graph/runtime/runtime_types.h
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler.cpp
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler.h
  • src/a5/runtime/host_build_graph/runtime/shared/shared_memory.cpp
  • src/a5/runtime/host_build_graph/runtime/shared/tensormap.cpp
  • src/a5/runtime/host_build_graph/runtime/tensormap.h
  • src/a5/runtime/host_build_graph/runtime/types.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/orchestrator.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/orchestrator.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/ring_buffer.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared/shared_memory.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared/tensormap.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/shared_memory.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/tensormap.h
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/types.h
  • src/common/platform/onboard/host/c_api_shared.cpp
  • src/common/platform/onboard/host/device_runner_base.h
  • tests/lint/check_retired_names.py

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.

@ChaoWao
ChaoWao merged commit 37b9b82 into hw-native-sys:main Aug 26, 2026
20 checks passed
@ChaoWao
ChaoWao deleted the retire-pto-brand-banners branch August 26, 2026 04:32
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