Closed
[WIP] feat(cannbot): add Stage-5 NPU-measure optimization loop and its measurement-confirmed KB #472
hid22900163Add on Aug 12Closed at Aug 24
[WIP] feat(cannbot): add Stage-5 NPU-measure optimization loop and its measurement-confirmed KB #472
Closed
hid22900163Add on Aug 12Closed at Aug 24
hid22900163
hid22900163Collaborators
Aug 12

Was This PR authored or co-authored using generative AI tooling?

[ ] No
[x] Yes
__1. AI Agent : Claude Code, driving the pypto-pro-op-orchestrator skills in this repo
__2. AI Model : claude-opus-5
__3. Prompt : "Add a Stage-5 performance-optimization stage after Stage 4's correctness gate, tune
rms_norm on Ascend950PR with it, and write back only what measurement confirmed." Each tuning run
got a brief naming its lever, a pre-registered per-case cohort and an accept/reject rule fixed before
measuring.

What this PR does / why we need it:

Adds Stage 5, an NPU-measure optimization loop that runs after Stage 4's correctness gate, plus
the knowledge base it produced.

  • 3 new skills — pypto-pl-vector-kernel, pypto-pl-cube-bound, pypto-pl-pipe-roofline
  • optimizer + verifier agents, a Stage-4 speed gate, DEFAULT_MAX_STAGE 4 → 5
  • KB patterns/constraints/playbooks where every claim names the instrument that produced it
  • the rms_norm artifact those claims were measured on

On rms_norm it moved the hidden-set (80-case) score 86.2283 → 87.4026 (+1.17), taking the
operator from 8th to 2nd on the official leaderboard:

step hidden Δ
Stages 1–4 baseline 86.2283 —
narrow-D PACK-N (D | 64) 86.9338 +0.7055
compile-time register unroll 87.0346 +0.1008
Rows growth/floor rules 87.2669 +0.2323
Rows clamp at the measured rung optimum 87.4026 +0.1357

Every step was accepted on a pre-registered per-case cohort against a byte-identical control, never
on a whole-set delta.

Which issue this PR fixes: fixes

Special notes for your reviewer:

1. This stacks on #444 — base is cd7ed46, the tip of cann-bench-a5-all, not master. The
shared cannbot-skills/kb/ tree this PR edits is #444's contribution; master has 0 files under it
today. Merge after #444.

2. 🔴 PL10 will fail every Stage-5 run and needs a one-line fix that is not in this PR.
hooks/pypto-pro-op-lint/.../checks/d2_artifact.py:100 hardcodes the stage cap:

-    if max_stage != 4:
+    if max_stage not in (4, 5):

The lint arrived on master in 18d77c6, after this branch's base, so the file does not exist
here and editing it would create an add/add conflict. It should be applied when this branch is
rebased onto post-#444 master.

3. Conflict surface this PR owns: 11 files. state-transition-core.ts (master rewrote it with
DEFAULT_MAX_STAGE = 4; this sets 5 — a one-line semantic re-apply, plus its test and hook) and 8
doc/registration files. Master's other 226 changed files are #444's to resolve.

Change Type / 改动类型

Testing / 测试信息

Measured on Ascend950PR via the official cann-bench harness; scores above are grader results, not
local numbers. Kernel is bit-identical to the submission that scored 87.4026.

Checklist / 检查清单

likedislike
The current Pull Request has been closed by hid22900163.
hid22900163hid22900163Collaborators
Aug 12 Created pull request, commit 25318cc8
hid22900163hid22900163Collaborators
Aug 12 Set as a draft.
hid22900163hid22900163Collaborators
Aug 12 Change title to "[WIP] feat(cannbot): add Stage-5 NPU-measure optimization loop and its measurement-confirmed KB", originally titled "feat(cannbot): add Stage-5 NPU-measure optimization loop and its measurement-confirmed KB".
hid22900163hid22900163Collaborators
Aug 24 Close pull request