Merged
refactor(panko): share the PyPTO search and campaign core #922
refactor(panko): share the PyPTO search and campaign core #922
Merged
Tomomasa YamasakiAdd on 28 days ago
Tomomasa Yamasaki
Tomomasa YamasakiCollaborators
28 days ago

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

  1. AI Agent: Claude; OpenAI Codex
  2. AI Model: Claude Opus 5; GPT-6; GPT-6.2 Astra
  3. Prompt: Add multi-objective PANKO support for PyPTO-Pro, validate initialization and tile search, support multi-file kernels, address applicable review feedback from PRs #629 and #808, reduce orchestration overhead while preserving optimization evidence and gates, add generic catalog transformations and concise contract-preserving search procedures, consolidate the shared PANKO core, and validate Pro behavior before and after consolidation on NPU.

The final scope agreed during review is the shared-core refactoring only.

Claude (Claude Opus 5) assisted the initial implementation. OpenAI Codex (GPT-6 and GPT-6.2 Astra) assisted subsequent fixes, review, and validation.

What this PR does / why we need it:

PANKO tunes a kernel by trying changes, measuring candidates and keeping improvements. This PR refactors the optimizer already shipped for PyPTO (Classic) so another frontend can use the same search and campaign rules. Classic users keep their existing CLI and installation procedure.

Area What is shared What a frontend supplies
Tile search The Optuna TPE loop, warm starts, trial accounting and best-candidate selection Legal tile shapes, candidate construction and evaluation
Campaign Action selection, Pareto acceptance, source restoration and stopping rules Source semantics, configuration and artifact operations
Final verification Scheduling repeated measurements in ABBA order and advancing through the Pareto front How to validate the staged program and interpret its readings

All changes are under cannbot-skills/ops/pypto-op-perf-panko-manual/scripts/. This first PR can be reviewed and tested with Classic alone.

Which issue this PR relates to

Related to #326.

Change Type / 改动类型

Testing / 测试信息

All 816 PANKO host tests passed in 95.73 seconds at 32da86c9. This includes the 811 existing Classic tests and five frontend contract tests. The registered-backend test runs the CLI with synthetic latency samples. It checks that a faster candidate is accepted, a slower candidate triggers source rollback, the evaluation budget triggers STOP, and ABBA verification restores the accepted source for delivery.

Run the full suite from the repository root with a Python 3.12 virtual environment active and pytest==8.4.2 and optuna==4.9.0 installed.

suite=cannbot-skills/ops/pypto-op-perf-panko-manual/scripts/tests
python -m pytest -q -s --confcutdir="$suite" "$suite"

A fresh project installation also passed Classic CLI initialization and action selection at 9f22b59e.

Checklist / 检查清单

Planned optimization features after PR922 merges

The PyPTO-Pro frontend will be delivered in two dependent PRs:

  1. Single-file PyPTO-Pro tuning. Install and route the Pro autotuner and coder. Tune kernels whose JIT functions live in one source file, measure latency on the NPU, derive on-chip memory use from the source, and verify and deliver the selected candidates. The correctness test may live in a separate file.
  2. Multi-file JIT packages. Extend the single-file frontend to kernels whose JIT functions span modules. Restore each candidate to its original file layout and export each Pareto point with a runtime manifest. Verify that the exported package can be measured independently of the original source tree.

Other planned optimizations:

  • Action selection from measured outcomes. Update action weights from measurements within a campaign and reuse chip-specific outcome histories to initialize later campaigns. Evaluate the effect against fixed catalog weights.
  • Hypothesis and experiment ledger. Record each proposal’s prediction and measured outcome so the next proposal can use that evidence.
  • Diagonal scaling in contractions. Move scaling to the operand that requires less work or temporary storage.
  • Deferred state updates. When a recurrence has no additive contribution, accumulate its scale factors and apply them when the state is next needed.
  • Lower-precision reads of recurrent state. Keep state updates at the required precision and provide a lower-precision copy to eligible read-only consumers.

Follow-up PRs will evaluate these changes against the existing accuracy, latency and memory criteria.

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for Tomomasa Yamasaki's contribution.)
Tomomasa YamasakiTomomasa YamasakiCollaborators
28 days ago Created pull request, commit 7be7b8cd
Tomomasa YamasakiTomomasa YamasakiCollaborators
28 days ago Associated issue: [Feature]: PANKO for PyPTO-Pro — a multi-objective search-based Stage 5 auto-tuner for Pro kernels
CANN-robotCANN-robotCollaborators
28 days ago Added label: ai-co-authored
CANN-robotCANN-robotCollaborators
28 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
28 days ago Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/pypto-gym ✅ wangzheng97, lim-jiunnbin (2/2) ✅ lim-jiunnbin (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

tomomasayamasaki, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
1050 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
4 days ago Added label: approved
lim-jiunnbinlim-jiunnbinCollaborators
4 days ago Approval passed
wangzheng97
wangzheng97Collaborators
4 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
4 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
4 days ago Merged pull request