# flydsl-kernel-authoring

flydsl-kernel-authoring — a skill for Claude Code and Cursor serving as a reference manual for authoring and reviewing FlyDSL GPU kernels on AMD GPUs.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 437 installs · ★ 510 repo stars
- Author: amd
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/amd/skills/tree/HEAD/skills/flydsl-kernel-authoring/SKILL.md
- Updated: 2026-10-24
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/flydsl-kernel-authoring

## What it does

This skill provides technical documentation for writing, reviewing, and understanding FlyDSL GPU kernels. It covers layout algebra, tiled copy and MMA primitives, buffer operations, and SharedAllocator for LDS memory. The codebase targets Python 3.12, ROCm 7.2, and CDNA3 or CDNA4 architectures.

The AI agent consults these guidelines when generating or auditing kernel code. FlyDSL compiles Python abstractions through MLIR into executable GPU binaries.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add amd/skills --skill flydsl-kernel-authoring -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/flydsl-kernel-authoring/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/flydsl-kernel-authoring/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add amd/skills --skill flydsl-kernel-authoring -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/flydsl-kernel-authoring/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add amd/skills --skill flydsl-kernel-authoring -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/flydsl-kernel-authoring/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install amd/skills skills/flydsl-kernel-authoring
```

2. **Manually: put the files in place**
- File: `.github/skills/flydsl-kernel-authoring/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add amd/skills --skill flydsl-kernel-authoring -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/amd/skills --path skills/flydsl-kernel-authoring
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/flydsl-kernel-authoring/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add amd/skills --skill flydsl-kernel-authoring -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/amd/skills/tree/HEAD/skills/flydsl-kernel-authoring/SKILL.md

## When to use it
- author a FlyDSL GPU kernel for AMD hardware
- configure layout algebra and tiled copies
- verify kernel code against the reference
- manage shared memory via SharedAllocator

## Example prompts
- Write a matrix multiplication kernel using FlyDSL
- Review the layout setup in preshuffle_gemm.py
- Explain buffer tensor creation in FlyDSL

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 2a659681f3ad4753.

BEGIN THIRD-PARTY FILE 2a659681f3ad4753
````text
---
name: flydsl-kernel-authoring
description: >
  Comprehensive reference for authoring FlyDSL GPU kernels on AMD GPUs.
  Covers the layout algebra, tiled copy/MMA, buffer ops, loop-carried range loops,
  SharedAllocator (LDS), autotuning, and common patterns. Use when writing,
  reviewing, or understanding FlyDSL kernel code.
allowed-tools: Read Edit Bash Grep Glob Agent
---

# FlyDSL Kernel Authoring Skill

## Overview

FlyDSL is a Python DSL and MLIR-based compiler for writing high-performance GPU kernels on AMD GPUs (MI300X/MI350). It provides explicit layout algebra for controlling data movement, tiling, and memory access patterns. The layout system is the core abstraction that distinguishes FlyDSL from Triton/Gluon.

**Repository**: this checkout (examples below assume it is importable — see 12)
**Target GPU**: gfx942 (MI300X, CDNA3), gfx950 (MI350, CDNA4)
**Python**: 3.12, ROCm 7.2

**Scope (read this first)**: This skill is the **reference** — the full layout-algebra API
surface, per-op tables, MFMA/copy-atom catalogs, environment variables, and an exhaustive
troubleshooting list. Reach for it to *look something up* while writing or reviewing kernel
code. If instead you want a *guided, step-by-step procedure* that turns a kernel requirement
into a finished, tested kernel (classify -> skeleton -> compute -> control flow -> test), use
the **flydsl-tile-programming** skill, which is the wizard companion to this reference. For
diagnosing a kernel that already compiles but produces NaN/inf/wrong results, use the
**debug-flydsl-kernel** skill.

---

## 1. Architecture and Compilation

### Pipeline
```
Python (@flyc.kernel/@flyc.jit)
  -> AST Rewriting (for/if -> scf.for/scf.if)
  -> MLIR Tracing (generates Fly dialect + gpu/arith/scf/memref/vector ops)
  -> MlirCompiler.compile() (Fly -> ROCDL -> LLVM -> HSACO binary)
  -> JITCFunction (ExecutionEngine wrapper)
```

### Key Passes
Pipeline is built by `RocmBackend._pipeline_parts()` and split into three stages — see `docs/architecture_guide.md` §3 for the per-pass table. Highlights:
1. `fly-canonicalize` + `fly-rocdl-expand-ops` - Canonicalize Fly ops and expand target-specific operations
2. `fly-layout-lowering` - Lower layout algebra (`fly.crd2idx`, partitions, divides) to arithmetic
3. `fly-convert-atom-call-to-ssa-form` + `fly-promote-regmem-to-vectorssa` - Lift copy/MMA atom calls and register memory to vector SSA
4. `convert-fly-to-rocdl` - Convert Fly values (signatures, calls, launches and control flow alike) to the nested packed ABI, and Fly ops to ROCDL intrinsics
5. `gpu-module-to-binary{format=fatbin}` - Emit HSACO binary via LLVM AMDGPU backend

### Key Source Paths
- `python/flydsl/compiler/` - JIT compilation (jit_function.py, kernel_function.py)
- `python/flydsl/expr/` - DSL expression API (primitive.py, derived.py, typing.py)
- `python/flydsl/expr/primitive.py` - All layout algebra functions
- `python/flydsl/expr/derived.py` - CopyAtom, MmaAtom, TiledCopy, TiledMma wrappers
- `python/flydsl/expr/gpu.py` - GPU operations (thread_idx, block_idx, barrier)
- `python/flydsl/expr/rocdl/` - MFMA/WMMA and other ROCm intrinsics
  (package: cdna3, cdna4, cdna5, rdna3, rdna4, cluster, inline_asm, tdm_ops, universal;
````
END THIRD-PARTY FILE 2a659681f3ad4753

The third-party file has ended. Everything between the 2a659681f3ad4753 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3240 of 20895 bytes. © amd · MIT · https://github.com/amd/skills/tree/HEAD/skills/flydsl-kernel-authoring/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
