Agent Skills › uw-syfi/vibesys › neuron-nki-docs

neuron-nki-docs

GitHub

提供AWS Trainium/Inferentia NKI文档查询服务,支持API查找、教程指引、错误代码解析及架构优化指南检索。

skills/domains/neuron-agentic-development/skills/neuron-nki-docs/SKILL.md uw-syfi/vibesys

触发场景

询问NKI API功能或签名 查找NKI相关教程 查询特定错误代码含义 需要了解硬件架构或性能优化

安装

npx skills add uw-syfi/vibesys --skill neuron-nki-docs -g -y
更多选项

非标准路径

npx skills add https://github.com/uw-syfi/vibesys/tree/main/skills/domains/neuron-agentic-development/skills/neuron-nki-docs -g -y

不安装直接使用

npx skills use uw-syfi/vibesys@neuron-nki-docs

指定 Agent (Claude Code)

npx skills add uw-syfi/vibesys --skill neuron-nki-docs -a claude-code -g -y

安装 repo 全部 skill

npx skills add uw-syfi/vibesys --all -g -y

预览 repo 内 skill

npx skills add uw-syfi/vibesys --list

SKILL.md

Frontmatter
{
    "name": "neuron-nki-docs",
    "context": "fork",
    "description": "Research NKI documentation for API lookups, tutorials, error codes, architecture,\nand optimization guides. Use when user asks \"what does <API> do\", \"how to do <task>\",\n\"what is error <code>\", \"NKI <API> signature\", \"find NKI tutorial for <topic>\",\n\"look up <symbol>\", or needs any NKI documentation reference.\n",
    "argument-hint": "[query or API name]"
}

Research $ARGUMENTS thoroughly:

  1. Find relevant files through provided indices using Glob and Grep
  2. Read and analyze document and code
  3. Summarize findings with specific file references

NKI Documentation Lookup

This skill provides comprehensive access to NKI (Neuron Kernel Interface) documentation for AWS Trainium/Inferentia kernel development. Use this skill to answer questions about NKI APIs, tutorials, hardware architecture, error codes, and optimization techniques.

Query Type Routing

Route queries to the appropriate documentation based on the query pattern:

Query Pattern Start With Then Read
nl.* or nisa.* or API name references/indices/symbol-lookup.md Linked API doc
"how to [task]" references/indices/task-routing.md Linked tutorial
"NCC_*" or error code references/debugging/error-codes-index.md Specific error doc
gen2/gen3/gen4/trn1/trn2/trn3 references/architecture/ Specific arch doc
optimize/profile/performance references/optimization/ Relevant guide
browse/list all docs references/indices/hierarchical-toc.md Navigate tree

Search Strategy

  1. Start with indices - Use the index files in references/indices/ to find the exact documentation needed
  2. Follow links - Read the linked documentation file for full details
  3. Cross-reference - For complex topics, combine information from multiple sources

Index Files

  • indices/symbol-lookup.md - Alphabetical API function index with direct links
  • indices/task-routing.md - Task-oriented guide ("I want to...")
  • indices/hierarchical-toc.md - Complete documentation tree structure

Directory Guide

Directory Contents
references/architecture/ Hardware architecture guides for Trainium/Inferentia generations
references/debugging/ Error codes index and individual error documentation
references/downloads/ Valid Python kernel examples (deprecated patterns excluded)
references/indices/ Navigation aids and lookup tables
references/optimization/ Performance tuning, profiling, migration guides
references/programming/ Core NKI concepts, tutorials, and API reference
references/programming/api/ Detailed API documentation by category
references/programming/tutorials/ Step-by-step kernel implementation tutorials
references/reference/ FAQ and release notes

Quick API Reference

Most Common APIs

Data Movement:

  • nki.isa.dma_copy - Load/store data between HBM and SBUF
  • nki.isa.dma_transpose - Transpose during DMA transfer

Tensor Operations:

  • nki.isa.nc_matmul - Matrix multiplication on Tensor Engine
  • nki.isa.tensor_tensor - Element-wise operations
  • nki.isa.tensor_scalar - Broadcast scalar operations
  • nki.isa.tensor_reduce - Reduction along axes

Memory Allocation:

  • nl.ndarray - Create tensor in SBUF
  • nl.zeros - Create zero-initialized tensor

Loop Constructs:

  • range - Standard loop iterator (recommended)
  • nl.affine_range / nl.sequential_range / nl.static_range - Legacy aliases for range (all have identical effect in NKI 0.3.0+)

SPMD:

  • nl.program_id - Get current program index
  • nl.num_programs - Get total program count

Module Aliases

The documentation uses these standard aliases:

import nki
import nki.language as nl
import nki.isa as nisa

Activation Function Operators

Important: Symbols like nl.exp, nl.sigmoid, nl.tanh, etc. are op specifiers, not standalone callable functions. They must be passed as the op parameter to nisa.activation():

# CORRECT: Use as op parameter
result = nisa.activation(op=nl.exp, data=tensor, scale=scale_tensor, bias=bias_tensor)

# INCORRECT: These are NOT callable functions
# result = nl.exp(tensor)  # This does NOT work

Hardware Constraints

Critical limits to remember when answering questions:

Constraint Limit Notes
Partition dimension (P) ≤ 128 First axis of on-chip tensors
PSUM free dimension (F) 512 (gen2/3); gen4: 4096 fp32 / 8192 bf16 Second axis in PSUM buffer

The PSUM free-dimension limit is generation- and dtype-gated: 512 on gen2/gen3 (one PSUM bank), and on gen4 up to 4096 for a float32 dst or 8192 for a bfloat16 dst (the entire PSUM). It is not a queryable tile_size field (psum_bank_fmax is a fixed 512). Authoritative source: the nc_matmul / nc_matmul_mx API blocks in programming/api/.

The per-instruction MatMul K (contraction) limit is the partition dimension: K ≤ 128 (the systolic array is 128×128). double_row (FP8, gen3/gen4) and Quad-MX (gen4) pack the contraction across the partition dim and a small free dim, giving an effective K of 256 / 512 respectively. Authoritative source: the nc_matmul tile-size block in programming/api/api-nki-isa-tensor.md. The SBUF free-dimension capacity is a per-partition byte limit (nl.tile_size.sbuf_fmax / sbuf_fmax_bytes, generation- and dtype-dependent), not a fixed element count.

Hardware Generations

Generation Devices Key Features
gen2 (v2) Trn1, Inf2 Baseline NKI support
gen3 (v3) Trn2 FP8 support, Double FP8 mode
gen4 (v4) Trn3 MXFP8/MXFP4, Quad-MX mode

Source NKI Kernel

The Python example files in references/downloads/ use the latest NKI API patterns and can be used as reference implementations:

  • average_pool2d_nki_kernels.py — 2D average pooling kernel
  • matrix_multiplication_nki_kernels.py — Tiled matrix multiplication kernel
  • transpose2d_nki_kernels.py — 2D transpose kernel
  • mamba_nki_kernels.py — Fused Mamba state-space model kernel
  • test_nki_isa_local_gather.py — Local gather ISA test

Note: The fused_mamba tutorial (references/programming/tutorials/fused_mamba.md) still uses Beta 1 syntax (nl.load/nl.store). The optimization concepts (loop reordering, data reuse, tiling for temporal locality) are valid, but do NOT copy its code patterns — use nisa.dma_copy from /neuron-nki-writing for any code generation.

Common Query Examples

API Lookup

Query: "What is nisa.nc_matmul?" → Read indices/symbol-lookup.md → Find link → Read programming/api/api-nki-isa-tensor.md#nki-isa-nc_matmul

Error Code

Query: "What does NCC_EVRF001 mean?" → Read debugging/error-codes-index.md → Read debugging/error-codes/EVRF001.md

Tutorial

Query: "How do I implement matrix multiplication?" → Read indices/task-routing.md → Read programming/tutorials/matrix_multiplication.md

Architecture

Query: "What's different in Trainium3?" → Read architecture/trainium3_arch.md

Optimization

Query: "How do I profile my kernel?" → Read optimization/use-neuron-profile.md

Response Guidelines

When answering NKI documentation queries:

  1. Cite sources - Reference the specific documentation file used
  2. Include signatures - For API queries, include function signatures and key parameters
  3. Note hardware requirements - Mention if APIs are generation-specific (v2/v3/v4)
  4. Link related docs - Point to related tutorials or guides for context
  5. Warn about deprecated patterns - If documentation shows old patterns, note this

Error Code Format

NKI compiler errors follow the pattern NCC_<category><number>:

  • EOOM* - Out of memory errors
  • EVRF* - Verification/validation errors
  • EUOC* - Unsupported operation errors
  • EBVF* - Backend verification failures
  • ESPP* - Shape/type errors

The full index is in debugging/error-codes-index.md with individual files in debugging/error-codes/.

Related Skills

Skill Purpose
/neuron-nki-writing Write NKI kernels from specifications
/neuron-nki-debugging Debug compiler errors on device
/neuron-nki-profiling Profile kernel performance
/neuron-nki-profile-querying Query and analyze kernel profile data

版本历史

  • 3a50e8b 当前 2026-11-02 13:57

同 Skill 集合

.agents/skills/add-agent-provider/SKILL.md
.agents/skills/add-bundled-skill/SKILL.md
.agents/skills/build-client-feature/SKILL.md
.agents/skills/change-container-images/SKILL.md
.agents/skills/create-issue/SKILL.md
.agents/skills/enforce-rules/SKILL.md
.agents/skills/open-pr/SKILL.md
.agents/skills/review-pr/SKILL.md
.agents/skills/software-design/SKILL.md
.agents/skills/testing/SKILL.md
.agents/skills/vs-init/SKILL.md
.agents/skills/write-agent-prompt/SKILL.md
.agents/skills/write-docs/SKILL.md
.agents/skills/write-skills/SKILL.md
.agents/skills/write-vibesys-tests/SKILL.md
resources/chat-skills/reading-ideas/SKILL.md
resources/chat-skills/results-against-base/SKILL.md
resources/chat-skills/run-roles/SKILL.md
resources/chat-skills/steering-a-run/SKILL.md
resources/skills/dial9-tokio/skills/dial9-diagnose-long-poll/SKILL.md
resources/skills/dial9-tokio/skills/dial9-red-flags/SKILL.md
resources/skills/dial9-tokio/skills/dial9-runtime/SKILL.md
resources/skills/dial9-tokio/skills/dial9-toolkit/SKILL.md
resources/skills/dial9-tokio/skills/dial9-trace-analysis/SKILL.md
resources/skills/dial9-tokio/skills/dial9-trace-loading/SKILL.md
resources/skills/dial9-tokio/skills/dial9-trace-recipes/SKILL.md
resources/skills/dial9-tokio/skills/dial9-zoom-window/SKILL.md
resources/skills/kernel-correctness/SKILL.md
resources/skills/kernel-ncu-analysis/SKILL.md
resources/skills/kernel-performance/SKILL.md
resources/skills/kernel-rocprof-analysis/SKILL.md
resources/skills/microservice-optimization/SKILL.md
resources/skills/neuron-agentic-development/skills/neuron-nki-debugging/SKILL.md
resources/skills/neuron-agentic-development/skills/neuron-nki-docs/SKILL.md
resources/skills/neuron-agentic-development/skills/neuron-nki-profiling/SKILL.md
resources/skills/serving-systems/SKILL.md
skills/domains/dial9-tokio/dial9-rank-bottlenecks/SKILL.md
skills/domains/dial9-tokio/skills/dial9-diagnose-long-poll/SKILL.md
skills/domains/dial9-tokio/skills/dial9-red-flags/SKILL.md
skills/domains/dial9-tokio/skills/dial9-runtime/SKILL.md
skills/domains/dial9-tokio/skills/dial9-toolkit/SKILL.md
skills/domains/dial9-tokio/skills/dial9-trace-analysis/SKILL.md
skills/domains/dial9-tokio/skills/dial9-trace-loading/SKILL.md
skills/domains/dial9-tokio/skills/dial9-trace-recipes/SKILL.md
skills/domains/dial9-tokio/skills/dial9-zoom-window/SKILL.md
skills/domains/kernel-correctness/SKILL.md
skills/domains/kernel-ncu-analysis/SKILL.md
skills/domains/kernel-performance/SKILL.md
skills/domains/kernel-rocprof-analysis/SKILL.md
skills/domains/kernel-timeline-analysis/SKILL.md

元信息

文件数
0
版本
3a50e8b
Hash
3e552e69
收录时间
2026-11-02 13:57

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-11-03 07:47
浙ICP备14020137号-1