Open
[Feature]: PANKO for PyPTO-Pro — a multi-objective search-based Stage 5 auto-tuner for Pro kernels #326
Tomomasa YamasakiAdd on 28 days ago
28 days ago Associated pull request
28 days ago Added label: Agent
宋乐
28 days ago Comments:
28 days ago Comments:
感谢贡献,请跟踪闭环


23 days ago Associated pull request
10 days ago Associated pull request
10 days ago Associated pull request
10 days ago Associated pull request
10 days ago Associated pull request
5 days ago Associated pull request
Feature Description / 功能描述
Add
pypto-pro-panko-manual, a search-based Stage 5 performance tuner forPyPTO-Pro kernels, together with the
pypto-pro-op-orchestratorgate thatrecords which Stage 5 optimizer ran.
This repository already has PANKO for classic PyPTO
(
cannbot-skills/ops/pypto-op-perf-panko-manual). That tuner does not transferto PyPTO-Pro, because the two languages place on-chip buffers differently:
In classic PyPTO a tile is
set_vec_tile_shapes(32, 512)and the compilerplaces the buffers.
In PyPTO-Pro the kernel writes both the shape and the address:
t_vf = pl.make_tile_group( type=pl.TileType(shape=[HC, V], dtype=pl.DT_FP32, target_memory=pl.MemorySpace.Vec), addrs=UB_VF, mutex_ids=[1])so changing one tile's extent invalidates every address after it, and the
classic tuner's knobs and measurements have no Pro equivalent.
The proposed addition is a deterministic harness plus an agent, with a strict
split of ownership:
snapshots, accounting and stop decisions. It is a CLI over a persisted
optimization/search_state.json, so a campaign survives interruption and canbe audited after the fact.
TileType.shapecoordinates only. Shapematerialization then updates the required address map deterministically through
an allocator; replacement addresses are never hand-written, and proven
author-owned overlays are preserved.
buffer depth and mutex rotation, pipeline/preload, synchronization, launch
configuration and case specialization.
It is multi-objective: latency and on-chip workspace bytes are both carried on a
Pareto front, rather than optimizing latency and discovering the capacity cost
afterwards.
Two properties of real Pro kernels drove most of the work:
@pl.jit; thekernel is built inside a factory that computes its extents. The editable
region is therefore defined as the call-graph closure of the jit entries, not
as a decorator list at module top level.
spread over several local modules. A version-2
program_manifestgives all ofthem one namespaced analysis view, one candidate hash and package-wide
checkpoints, while the runtime modules keep their original imports and bytes.
The change is additive. It does not modify
pypto-op-perf-panko-manualorpypto-pro-op-perf-tune.Use Case / 应用场景
Stage 5 performance tuning of a PyPTO-Pro kernel that has already passed
correctness verification, when the remaining gains depend on choices a human
would otherwise explore by hand: tile extents, buffer depth and mutex rotation,
preload and pipeline arrangement, and per-case specialization.
Concretely:
factory arguments or a declared tiling-key field, so there is no number in the
file to tune. INIT exposes the declaration, and TPE then searches the resolved
shape domain.
where one candidate changes three modules together. The campaign stages,
evaluates and rolls back the whole program as one unit, and the test command
stays the original import-based one.
records which action was selected and why, what was measured, what was
accepted, and which budget remains, so a long tuning run can be interrupted,
inspected and continued without re-measuring.
search". INIT states the program it analyzed and whether the tile space can
be drawn at all, so an empty search is visible before the budget is spent
rather than after.
The intended caller is the
pypto-pro-op-autotunersubagent under the existingorchestration flow. It is not a replacement for
pypto-pro-op-perf-tune, whoseknowledge cards and general methods remain the source of structural optimization
items; this is the search and measurement machinery around such changes.
Expected Behavior / 期望行为
Command surface.
python scripts/panko_harness.py <command>over a persistedcampaign:
status,init,normalize,select,block,feasible,record,probe,evolve,close,stop,verify,pareto,report.statusreadsstored facts without importing the optimization or device stack, and without
selecting, stopping, migrating state or restoring source.
Initialization.
Recorded case bindings with unchanged runtime bytes are preferred.
and latency equivalence.
not hidden in order to start a campaign. Chip capacities are derived from the
platform configuration and refused when they cannot be derived; they are never
guessed or copied from another device.
diagnosis; its result returns to ordinary INIT, which must accept the candidate
before any search begins.
Search.
couple source and destination tile parameters, so
pl.movepairs are drawntogether rather than independently.
allocator. Author-owned overlays that tile shapes cannot re-derive keep their
written addresses.
"fastest-only" rule.
delivered program restored at STOP.
Measurement contract. Device, architecture, case, interpreter, test command,
objectives, warmup/runs, thresholds and budget are frozen for the campaign. The
latency objective is in-kernel AICore time attributed to exactly one op name, and
host code outside the kernel is frozen so that readings stay comparable across
candidates. A reading whose launch structure or op name disagrees with the pinned
campaign values is refused rather than recorded.
Reporting. Static coverage, actual TPE and device trial counts, final
verification and remaining gaps are reported separately. An empty or
single-anchor shape block is reported as such, not as successful shape tuning.
Additional Information / 附加信息
Where it lives
cannbot-skills/ops/pypto-pro-panko-manual/— the skill: entry document, phasereferences, action catalog, and
scripts/(harness, source analysis, allocator,program bundle, measurement, chip profile, and the test suite).
cannbot-skills/plugins-official/pypto-pro-op-orchestrator/— records whichStage 5 optimizer ran and gates on it.
Validation status (CPU only)
readiness, shape-domain construction and real Optuna TPE sampling, and each
passed a further TPE block after a real loop-structure edit. A six-file
attention package exposed 57 declarations / 114 shape parameters, with one
candidate changing three modules together and complete restoration after every
trial.
rehashed before and after; zero original-source changes.
references/validation_*.md, with their own stated limits.Known limits, stated deliberately
capacity or speedup evidence; correctness and timing callbacks returned
synthetic observations, and CPU tests ran with an empty hardware envelope.
sources with statically resolvable acyclic local imports. Dynamic or escaping
module access, local-scope or cyclic imports, star imports and unsupported
class construction need explicit INIT repair.
refused by name rather than approximated with the single-file helper.
failure does not by itself demonstrate meaningful TPE exploration.
Relationship to existing assets
pypto-op-perf-panko-manual(classic PyPTO PANKO) is unchanged, and no classicPyPTO knob or measurement is imported into a Pro campaign.
pypto-pro-op-perf-tuneis unchanged.Happy to split this into smaller reviewable pieces if the maintainers prefer —
for example the harness and skill first, and the multi-file package support as a
follow-up.