Agent skill

Phase 5 Decode Optimization

by Xilinx in Xilinx/mlir-air

Phase 5 of LLM deployment — apply the shared optimization skillset to a Phase-4-correct decode pipeline (multi-launch merge with N-way extern rename, static weight BOs, on-device layout).

MITAuto-check passedDevOps & Cloud

Install Phase 5 Decode Optimization

skills CLI
$ npx skills add Xilinx/mlir-air --skill phase-5-decode-optimization -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Xilinx/mlir-air phase-5-decode-optimization --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Xilinx/mlir-air.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/phase-5-decode-optimization .claude/skills/phase-5-decode-optimization && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
phase-5-decode-optimization
GitHub stars
150
Token cost
~2.3k tokens
SKILL.md length
1,032 words
Files
1
Skills in repo
15
Repo updated
First seen
Licence
MIT

At a glance

Phase 5 of LLM deployment — apply the shared optimization skillset to a Phase-4-correct decode pipeline (multi-launch merge with N-way extern rename, static weight BOs, on-device layout).

  • DevOps & Cloud work in your project
  • SKILL.md covers Purpose, Phase 5 PASS criteria (HARD…, Knowledge base references and Workflow, plus 2 more sections
  • Calls make

What it does

Phase 5 Decode Optimization is an agent skill from Xilinx/mlir-air. Phase 5 of LLM deployment — apply the shared optimization skillset to a Phase-4-correct decode pipeline (multi-launch merge with N-way extern rename, static weight BOs, on-device layout). Thin orchestrator that dispatches opt-merge-multi-launch-kernels, opt-buffer-object-reuse, and opt-layout-alignment. Each step preserves correctness by re-running the Phase 3 gate — make verify (token-set vs HF bf16) is the PASS/FAIL gate; make diagnosis per-layer cosine is the informational lens used to localize a regression…

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in DevOps & Cloud. The licence is MIT.

When your agent uses it

  • DevOps & Cloud work in your project

Example prompts

  • “/phase-5-decode-optimization”

What it can do on your machine

Read from SKILL.md and the folder at commit 6e81ce1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Phase 5 Decode Optimization loads about 2.3k tokens when it runs. Until then it costs about 146 tokens; SKILL.md has 1,032 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~146
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Xilinx/mlir-air at commit 6e81ce1, republished under its MIT licence (© Xilinx). 1,032 words, ~2,302 tokens.

Download SKILL.mdSave it as .claude/skills/phase-5-decode-optimization/SKILL.md (or your agent's skills folder).
name
phase-5-decode-optimization
description
Phase 5 of LLM deployment — apply the shared optimization skillset to a Phase-4-correct decode pipeline (multi-launch merge with N-way extern rename, static weight BOs, on-device layout). Thin orchestrator that dispatches `opt-merge-multi-launch-kernels`, `opt-buffer-object-reuse`, and `opt-layout-alignment`. Each step preserves correctness by re-running the Phase 3 gate — `make verify` (token-set vs HF bf16) is the PASS/FAIL gate; `make diagnosis` per-layer cosine is the informational lens used to localize a regression. Invoked after Phase 4 PASS.

Purpose

Phase 4 optimized prefill while preserving Phase 3 correctness. Phase 5 does the same for decode — but the dominant optimizations differ because decode runs at M=1 per token, calling all N layers once per generated token. This phase is a thin orchestrator: it dispatches the same shared optimization skillset as Phase 4 — opt-merge-multi-launch-kernels (ELF-merging), opt-buffer-object-reuse (host↔NPU runtime-overhead reduction), and opt-layout-alignment (host-side layout) — each of which owns its own recipe and failure modes. Decode amplifies the value of static weight BOs (weights are loaded once but read on every token). These wins are things you compose from the kernels, not behaviors inherited from a reference; the reference's builders are worked examples. Every optimization is an experiment: apply, re-measure, re-run Phase 3 gate; revert if correctness regresses.

For scale, the reference deployment llama3.2-1B took decode from ~500 ms/token → 92 ms/token (5.4×) by composing these optimizations — an illustrative datapoint for what they buy on one model, not a target every deployment must hit.

Phase 5 PASS criteria (HARD GATES)

  1. Correctness preserved: after every applied optimization, make verify (the token-set gate vs HF bf16) still PASSES — this is the Phase 3 correctness gate, re-run between optimization skills. make diagnosis per-layer cosine is NOT a gate (the verify subsystem retired threshold-based diagnosis; compare_pair reports cosine with no pass/fail), and note it only probes prefill — decode regressions (KV cache, per-token BO reuse) surface in make verify's 32-token generation, not in diagnosis. If make verify regresses to FAIL, revert the change and document why.
  2. Decode time/token strictly < Phase 4 baseline, measured with make profile at the same canonical prompt.
  3. Per-skill outcome documented in <model>/docs/development_progress/phase5_decode.md: for each optimization skill it invoked, record applied / skipped / reverted, the latency delta, and a one-line reason.

The "≥ N optimization skills applied" check is NOT a gate — some models legitimately need only merge + static weight BOs. The gate is the outcome (decode time improved + correctness preserved), not the process count.

Knowledge base references

PRIMARY:

  • programming_examples/llms/llama32_1b/docs/profile.md — the reference deployment's profiling breakdown; the reference for what "good" looks like
  • programming_examples/llms/<model>/docs/development_progress/phase4_prefill.md — Phase 4 baseline (prefill numbers + the integration path used)
  • programming_examples/llms/llama32_1b/multi_launch_builder/o_gemv_ffn_multi.py — decode-specific merge pattern + 2-K extern kernel rename, in code
  • programming_examples/kernel_registry/details/GEMV_bf16.md — per-kernel constraints / placeability notes (the authority for that kernel's hard limits): K_max=8160, combined channel reads ≤ 255, L2 cap — relevant when GEMV K > 8160 or M is large

REFERENCE EXEMPLARS (read/mirror to compose your own decode ELFs; import directly only on a bit-for-bit kernel-sequence match):

  • programming_examples/llms/llama32_1b/multi_launch_builder/rms_gemv_rope_multi.py — fused 6-launch decode ELF for RMSNorm + Q/K/V GEMV + RoPE Q/K
  • programming_examples/llms/llama32_1b/multi_launch_builder/o_gemv_ffn_multi.py — fused 8-launch decode ELF (with 2-K extern rename for K=8192 Down)
  • programming_examples/llms/llama32_1b/multi_launch_builder/lm_head_gemv_multi.py — vocab-partitioned LM Head GEMV (part of the model's decode assembly, built in Phase 3/finalize; profiled here, not a separate optimization)
  • programming_examples/llms/llama_kernel_builder/ — the shared toolkit every decode-ELF build uses (KernelCache, stitching, external_kernels).

Workflow

Step 1: Measure Phase 4 baseline

Capture the decode time/token before invoking any optimization skill — this is the number every skill must beat:

bash
cd programming_examples/llms/<model>
flock -x -w 1800 /tmp/mlir-air-npu.lock make profile

Record: ms/token + per-layer + LM head time breakdown (where the budget goes today) as the baseline. These numbers gate every optimization below.

Step 2: Apply optimization skills

decode draws on the same shared optimization skillset; the dominant patterns differ because decode runs at M=1 per token, calling all N layers per token.

Optimization skillWhen it applies to decodeWhat it does (decode flavor)
opt-merge-multi-launch-kernelsalmost alwaysstitch decode kernel groups (GEMV instead of GEMM) into fused ELFs (10 launches/layer/token → 2–3). Build the model's multi_launch_builder/ (kernel-first) or reuse llama's fused decode ELFs (bit-for-bit inheritance — the verdict made in phase-2-single-block-validation Step 1). Decode specifics handled by the skill: N-way extern kernel rename when multiple GEMV K values co-link in one ELF (2-K for llama: mv.o K=2048 + mv_k8192.o; add a 3rd renamed .o when n_heads·head_dim ≠ emb_dim), and K-split (down_k_split) for K > 8160 (details/GEMV_bf16.md).
opt-buffer-object-reusealways — biggest decode winstatic weight BOs: weights allocated once, bo.map() zero-copy, static_input_indices skips re-write on every token. With 16+ layers × ~7 weights × 100 tokens, this is the dominant pre-optimization decode host cost.
opt-layout-alignmentusually N/Aonly if decode introduced a transpose Phase 4 didn't already fix.

Each skill owns its recipe + success self-check + failure modes. The LM Head GEMV (vocab-partitioned) is part of the model's decode assembly built in Phase 3/finalize, profiled here — not a separate optimization skill.

Show full SKILL.md (330 more words)Show less
Step 3: Re-run Phase 3 gate after each optimization skill

After every applied (or attempted) optimization skill, re-run the gate:

bash
flock -x -w 1800 /tmp/mlir-air-npu.lock make verify      # GATE: token-set, exit 1 on FAIL

make verify PASS is the correctness gate (its 32-token generation is what catches decode-only bugs — KV cache, per-token static-BO reuse). If it regresses to FAIL, revert the change and document why. diagnosis only probes prefill, so it cannot localize a decode regression — bisect by reverting optimization skills instead.

Failure modes

SymptomLikely causeWhere to look
Multi-launch merge compile fails (BD exhaustion, channel routing, herd shape conflict, bare-herd, DMA stride, IR/compile blowup)BD/placeability limit or wrong stitching boundaryInvoke debug-multi-launch-merge — it discriminates the 6 known compile blockers
Extern kernel rename collision (link error, symbol redefined)Two .o files exporting same symbolCheck -D mapping uniqueness; each .o must export distinct <group>_matvec_* names
'aiex.npu.push_queue' op Repeat count exceeds [0:255] (opt-merge-multi-launch-kernels)GEMV K > 8160, or combined channel reads > 255 (see details/GEMV_bf16.md)For K > 8160 → set k_split / down_k_split; for large M → set tile_m == m_input and grow tile_m × herd_m
L2 capacity exceeded (matvec.py builder assert)GEMV staged buffer K × herd_m × tile_m × 2 > 512 KiB (see details/GEMV_bf16.md)Reduce tile_m (e.g., 8 → 2 for K=8192)
Output corruption after static weight BO conversion (correct first call, NaN/garbage on subsequent)Per-layer BO key collision OR static_input_indices wrongInvoke debug-bo-corruption
Cosine drops after an optimization skillthe skill has a layout/type assumption this model violatesRevert the change; check the assumption (e.g., decode already seq-first, weights already pre-transposed)
ms/token unchanged after opt-merge-multi-launch-kernelsPer-call XRT overhead dominates; fusion alone insufficientopt-buffer-object-reuse (static weight BOs) is likely the missing piece — apply it next

For any failure not in the table, invoke superpowers:systematic-debugging.

Update protocol

On Phase 5 PASS:

  • <model>/docs/development_progress/phase5_decode.md: per-skill table with applied / skipped / reverted, latency delta, reason
  • <model>/TODO.md: mark Phase 5, append final ms/token + speedup vs Phase 4 baseline
  • If a new fused decode ELF was built (kernel-first path of opt-merge-multi-launch-kernels), surface to Phase 6 for potential promotion to a shared location if a second deployment validates the same pattern

© Xilinx, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/phase-5-decode-optimization of Xilinx/mlir-air.

Open the folder on GitHubat commit 6e81ce1

Compare with similar skills

Phase 5 Decode Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Phase 5 Decode Optimization compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Phase 5 Decode Optimization this skillXilinx/mlir-air150—~2.3kAutomated safety check: PassMIT
Monitor CInrwl/nx29k6 repos~4.7kAutomated safety check: PassMIT
Terraform and OpenTofu Guideagentscope-ai/QwenPaw35k6 repos~4.2kAutomated safety check: PassApache-2.0
Vercel Optimize Auditvercel-labs/agent-skills32k9 repos~4.3kAutomated safety check: PassNone
Openclaw Live Updateropenclaw/openclaw392k—~3.7kAutomated safety check: PassMIT
Analyze GitHub Action Logswithastro/astro63k1 repos~1.3kAutomated safety check: PassCustom licence

Similar skills

  • Monitor CI

    nrwl/nx

    Monitor Nx Cloud CI pipeline and handle self-healing fixes. An agent skill from nrwl/nx.

    29k GitHub starsUsed in 6 repos~4.7k tokens
    DevOps & CloudAuto-check passed
  • Terraform and OpenTofu Guide

    agentscope-ai/QwenPaw

    Guidance for writing and testing Terraform and OpenTofu code: module structure, naming, test approaches, CI/CD workflows, state handling and security scanning.

    35k GitHub starsUsed in 6 repos~4.2k tokens
    DevOps & CloudAuto-check passed
  • Vercel Optimize Audit

    vercel-labs/agent-skills

    Official

    Runs a metrics-first audit of a deployed Vercel project, gating investigations on real signals to produce ranked, citation-backed cost and performance recommendations.

    32k GitHub starsUsed in 9 repos~4.3k tokens
    DevOps & CloudAuto-check passed
  • Openclaw Live Updater

    openclaw/openclaw

    Maintain the canonical live OpenClaw main checkout, macOS LaunchAgent-managed Gateway, local macOS app, exact-head main CI, and recurring full release validation.

    392k GitHub stars~3.7k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Official

    Analyze recent GitHub Actions workflow runs to identify patterns, mistakes, and improvements.

    63k GitHub starsUsed in 1 repo~1.3k tokens
    DevOps & CloudAuto-check passed
  • Creates and queries KubeSphere users, workspaces and projects and assigns built-in roles, defaulting to least privilege and never deleting anything.

    17k GitHub starsUsed in 1 repo~3.1k tokens
    DevOps & CloudAuto-check passed

More from Xilinx/mlir-air

All 15 skills in this repo
  • Debug Bo Corruption

    Xilinx/mlir-air

    A skill your agent uses when an NPU kernel passes its standalone shape test but produces NaN, garbage, or stale values when invoked as part of a larger pipeline.

    150 GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • A skill your agent uses when NPU FlashAttention hangs (ERTCMDSTATETIMEOUT) or produces NaN at headdim ≥ 128.

    150 GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • A skill your agent uses when stitching kernels into a multi-launch ELF and the AIE compiler rejects the merged module (BD exhaustion, channel routing, herd shape conflict, IR validation error, DMA…

    150 GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Deploy New LLM

    Xilinx/mlir-air

    Entry point for deploying a new decoder-only LLM on AMD NPU2.

    150 GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Optimization skill — reuse NPU BufferObjects across calls instead of re-allocating/re-writing them.

    150 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Opt Layout Alignment

    Xilinx/mlir-air

    Optimization skill — choose activation layouts so consecutive kernels hand off on-device without a host-side transpose.

    150 GitHub stars~1k tokensUpdated today
    Auto-check passed

Categories

Questions about Phase 5 Decode Optimization

What does Phase 5 Decode Optimization do?

Phase 5 of LLM deployment — apply the shared optimization skillset to a Phase-4-correct decode pipeline (multi-launch merge with N-way extern rename, static weight BOs, on-device layout). Phase 5 Decode Optimization is an agent skill from Xilinx/mlir-air. Phase 5 of LLM deployment — apply the shared optimization skillset to a Phase-4-correct decode pipeline (multi-launch merge with N-way extern rename, static weight BOs, on-device layout).

When should I use Phase 5 Decode Optimization?

Phase 5 Decode Optimization fits situations like: devOps & Cloud work in your project.

How do I install Phase 5 Decode Optimization in Claude Code?

Run `npx skills add Xilinx/mlir-air --skill phase-5-decode-optimization -a claude-code`. Or copy the skill folder (.claude/skills/phase-5-decode-optimization in Xilinx/mlir-air) into .claude/skills/phase-5-decode-optimization in your project. Claude Code loads it when a task matches its description.

How do I install Phase 5 Decode Optimization in Codex?

Run `npx skills add Xilinx/mlir-air --skill phase-5-decode-optimization -a codex`. Or copy the skill folder (.claude/skills/phase-5-decode-optimization in Xilinx/mlir-air) into .agents/skills/phase-5-decode-optimization in your project. Codex loads it when a task matches its description.

Can I use Phase 5 Decode Optimization in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Xilinx/mlir-air --skill phase-5-decode-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/phase-5-decode-optimization, .gemini/skills/phase-5-decode-optimization, .github/skills/phase-5-decode-optimization and .opencode/skills/phase-5-decode-optimization in your project.

What does Phase 5 Decode Optimization need to run?

Going by SKILL.md and its folder, Phase 5 Decode Optimization needs the command-line tools its instructions call (make).

Does Phase 5 Decode Optimization access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Phase 5 Decode Optimization safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Phase 5 Decode Optimization use?

Phase 5 Decode Optimization is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Phase 5 Decode Optimization use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Phase 5 Decode Optimization?

Skills that share tags, products or a category with Phase 5 Decode Optimization: Monitor CI (nrwl/nx, 29k stars), Terraform and OpenTofu Guide (agentscope-ai/QwenPaw, 35k stars), Vercel Optimize Audit (vercel-labs/agent-skills, 32k stars) and Openclaw Live Updater (openclaw/openclaw, 392k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Phase 5 Decode Optimization?

Xilinx (a GitHub organization) maintains it in Xilinx/mlir-air, which has 150 GitHub stars. The repository holds 15 skills in this directory. The repository was last updated on October 8, 2026.

Source: Xilinx/mlir-air on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.