Skip to content
Back to skills

Pypto General Debug

ASecurity

PyPTO debugging router for stuck or opaque failures, including tile-shape/L0/L1/alignment/set_cube_tile_shapes issues; route through DEBUG_GUIDEBOOK.md to the matching topic reference or sub-skill. Use when a PyPTO kernel development session is stuck or hits opaque failures and needs routing to the right debug reference.

  • 21 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 7, 2026
documentationpythongobashdebugginggitapidocumentation

Works with

  • api

Security analysis

A100/100

Pro scans all 17 files and shows the line behind each finding

Scanned November 7, 2026

npx -y skills add hicann/cannbot-skills --skill pypto-general-debug --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pypto General Debug?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pypto General Debug
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hicann-pypto-general-debug/badge)](https://www.skillsdirectory.com/skills/hicann-pypto-general-debug)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pypto-general-debug
description: PyPTO debugging router for stuck or opaque failures, including tile-shape/L0/L1/alignment/set_cube_tile_shapes issues; route through DEBUG_GUIDEBOOK.md to the matching topic reference or sub-skill. Use when a PyPTO kernel development session is stuck or hits opaque failures and needs routing to the right debug reference.
---

# PyPTO Complex Kernel — Debugging

This skill covers what to do when the agent is stuck. The full playbook is split into focused topic files under `references/`. **Route symptoms through `references/DEBUG_GUIDEBOOK.md` first, then open only the leaf file it names — do NOT read every reference file.** The full section→file map (preserved old `§X.Y` numbering for any external references) and symptom→leaf map live in `references/DEBUG_GUIDEBOOK.md`.

Tile-shape failures (`L0A/L0B/L0C/L1` exceeded, tile alignment, missing tile shape, `enable_split_k`, or `set_cube_tile_shapes` validation errors) are handled by this skill. Follow `references/DEBUG_GUIDEBOOK.md` to the tile-shape reference instead of using a separate tile-shape skill.

## Contents at a glance

| Document | What it covers |
|----------|---------------|
| **This file (SKILL.md)** | Failure history logging, strategy switching rules, op-by-op check protocol, sub-skill fallback policy |
| **`references/DEBUG_GUIDEBOOK.md`** | The authoritative routing index. It maps old `§X.Y` references and current failure situations to the one leaf file to read next. |
| **`references/*.md` leaf files** | Focused debug references. Open one only after `DEBUG_GUIDEBOOK.md` selects it, or when an external instruction already names that exact leaf. |

---

## Failure History

Every iteration must log:
- hypothesis,
- exact changed location,
- result,
- next action,
- whether rollback occurred.

This is mandatory.

---

## Strategy Switching Rules

These rules are mandatory.

- repeated compile error → check the post-edit lint hook output (OL01-OL54 covers JIT structure, interface, shapes, dtypes); re-check kernel structure
- repeated runtime error → run `diagnose_error(error_log=..., kernel_code=...)`; if no match, follow `references/error-codes.md`
- repeated accuracy mismatch → check the post-edit lint hook output to rule out write-back bugs (OL02/OL51)
- repeated same failure after three evidence-based attempts → revisit module boundaries or architecture
- integrated graph memory-conflict / copy-pass failure → stop assuming a local line fix; use staged fallback or create a minimal repro
- opaque PyPTO error after the above → run `extract_pypto_calls.py`, then follow the op-by-op check protocol below

---

## PyPTO op-by-op check protocol (when the agent is stuck)

**Goal:** When hitting PyPTO-specific failures not resolved by the post-edit lint hook, `diagnose_error`, or docs, use this mechanical sequence so debugging converges.

### Step 0 — Enumerate every `pypto` call (mandatory checklist)

Run on the failing kernel file:

```bash
python3 <path-to-pypto-op-review>/scripts/extract_pypto_calls.py custom/<operator_name>/<kernel_or_impl>.py
```

- Output is an ordered, numbered list: line number + call shape.
- Use this list as the single source of truth for "which PyPTO op comes next."
- Optional: `--json` for machine consumption or to paste into the memory.

### Step 1 — Verify each call site against documentation (in order)

For call sites in the suspected region (or from index 1 upward if the fault is unknown):

1. Map `pypto.<name>` → `https://raw.gitcode.com/cann/pypto/raw/master/docs/zh/api/operation/pypto-<name>.md` or `https://raw.gitcode.com/cann/pypto/raw/master/docs/zh/api/config/...`.
2. Confirm dtype, shape/axes, tile config, transpose flags, and write-back rules match the doc for that line.
3. Record mismatches in the memory with line number from Step 0.

### Step 2 — Wrong numeric result: checkpoint bisection (not random edits)

If the graph runs but outputs are wrong:
- Use `pypto-precision-compare` / checkpoint saves so golden and kernel dump tensors at aligned logical points.
- Binary-search which checkpoint index diverges first; map that index back to the call-site range from Step 0.

### Step 3 — Do **not** "comment out half the file"

Disabling arbitrary `pypto` lines inside one fused `@jit` usually invalidates the graph or hides the real bug.

- Prefer module-at-a-time stubs (see skill `pypto-orchestration-manual`'s `../pypto-orchestration-manual/references/rules.md` → Module-at-a-time enforcement): shrink the live region, then re-run Step 0 on the smaller file.
- If you must bisect inside one module, insert one intermediate checkpoint between call sites k and k+1 and binary-search k using the numbered list — do not remove ops unless the minimal repro requires it.

### Step 4 — Plan file log (handoff-safe)

Append to `custom/<operator_name>/MEMORY.md`:
- Path to `extract_pypto_calls.py` output (or paste the table),
- First doc mismatch or first diverging checkpoint index,
- Hypothesis and patch; re-run validation.

This protocol is compatible with fully autonomous runs: the agent applies it without waiting for the user when stuck, unless stop conditions apply.

---

## Before writing or debugging PyPTO code

Open `references/DEBUG_GUIDEBOOK.md` and use its **Quick map: situation → leaf file** table to choose the one focused reference for the current operation or failure. Keep the routing table in the guidebook, not in this `SKILL.md`, so all callers share one source of truth.

---

## Subskill fallback decision tree (router policy)

This skill is the **router** for all debug sub-skills. When dispatched by
the pypto-op-debugger, load **exactly one** sub-skill per failure, and
unload it before handling the next failure. This keeps the active-skill
count ≤ 4.

**Dispatch order — evaluate top to bottom; stop at the first match:**

1. **Precision / accuracy mismatch**
   *Signal:* `detailed_tensor_compare` returns `all_close: false`; build and
   layout succeed; no crash, no aicore error in logs.
   → Load skill `pypto-precision-debug` (SKILL.md auto-loads)
   (code-level workarounds: inplace, unroll, `+0.0`).

2. **Precision bisection needed**
   *Signal:* precision still fails after (1), or the diverging checkpoint is
   not yet localized; multiple modules in scope.
   → Load skill `pypto-precision-compare` (SKILL.md auto-loads)
   (`pass_verify_save` or checkpoint tensors; binary-search the first
   diverging checkpoint index).

**Router rules (mandatory):**

- Do **not** load more than one sub-skill at once. If a new failure class
  appears, unload the current sub-skill first.
- Do **not** pre-load sub-skills speculatively.
- If no row matches, stay in this SKILL.md + the leaf selected by `references/DEBUG_GUIDEBOOK.md`. Do not escalate.
- skill `pypto-orchestration-manual`'s `../pypto-orchestration-manual/references/rules.md` takes precedence over any sub-skill guidance on conflict.
- Log the dispatch decision to `custom/<op>/MEMORY.md` under **Development &
  debug log** (which row matched, which sub-skill was loaded, outcome).

Files in this skill

  • SKILL.md7 KB
  • evals/evals.json5.9 KB
  • references/DEBUG_GUIDEBOOK.md5.1 KB
  • references/checklist-and-api.md2.4 KB
  • references/common-patterns.md2.7 KB
  • references/dynamic-shapes.md5.5 KB
  • references/error-codes.md12.4 KB
  • references/examples-debug.md5.5 KB
  • references/jit-signature.md4.3 KB
  • references/matmul.md11.5 KB
  • references/npu-launch-failures.md3.6 KB
  • references/pypto-view.md2.3 KB
  • references/python-operators.md1.4 KB
  • references/scan-and-reduction.md3.8 KB
  • references/sim-mode.md1.3 KB
  • references/tensor-ops.md2 KB
  • references/tile-shapes.md13.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in documentation →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.