yzlnew/infra-skills/tilelang-developer
Claude Code and agent skill by yzlnew/infra-skills
- community
Checking that the SKILL.md file is still in the repository.
Write, optimize, and debug high-performance AI compute kernels using TileLang (a Python DSL for GPU programming). Use when the user requests: (1) Writing custom GPU kernels for AI workloads (GEMM, Attention, MLA, etc.), (2) Optimizing existing TileLang code for NVIDIA, AMD, or Ascend hardware, (3) Implementing non-standard operators (like DeepSeek MLA, FlashAttention variants), (4) Debugging TileLang compilation or runtime errors, or (5) Cross-platform kernel development targeting multiple GPU vendors.
Install
npx vskill@latest install yzlnew/infra-skills/tilelang-developerSKILL.md
TileLang Developer
Write high-performance AI compute kernels using TileLang - a tile-based programming model that bridges the gap between CUDA's low-level control and high-level abstractions.
When to Use This Skill
Use this skill when the user needs to:
- Implement custom GPU kernels for AI operations (matrix multiplication, attention mechanisms, etc.)
- Optimize performance-critical operators for modern GPUs (NVIDIA Ampere/Hopper, AMD MI300X, Ascend NPU)
- Debug TileLang code or resolve performance issues
- Port kernels across different hardware platforms
- Understand or modify existing TileLang implementations
Kernel Development Workflow
Follow these steps when writing a TileLang kernel:
Step 1: Analyze Requirements
Gather essential information:
Input/Output Specifications:
- Tensor shapes (M, N, K dimensions)
- Data types (float16, float32, bfloat16, int8)
- Memory layout (row-major, column-major)
Hardware Target:
- NVIDIA GPU (Ampere A100, Hopper H100, etc.)
- AMD GPU (MI300X, etc.)
- Huawei Ascend NPU
Performance Goals:
- Target throughput or latency
- Memory bandwidth constraints
- Comparison baseline (cuBLAS, vendor libraries)
Ask clarifying questions if details are missing.
Step 2: Set Up Kernel Structure
Create the basic kernel scaffold:
Key decisions:
target: "cuda" (NVIDIA), "hip" (AMD), or "cpu"out_idx: List indices of output parameters- Block dimensions: Typical values are 64, 128, or 256
Step 3: Define Grid and Memory Hierarchy
Set up computation grid and allocate memory:
Memory hierarchy:
- Global Memory (HBM): Input/output tensors, slowest
- Shared Memory (L1): Explicitly managed cache, ~164KB on A100
- Registers: Fastest, used for accumulators and temporaries
Critical optimization: Always apply T.make_swizzled_layout to shared memory to eliminate bank conflicts.
Step 4: Implement Computation Logic
Use TileLang primitives for data movement and computation:
Key primitives:
T.copy: Intelligent data transfer (auto-selects cp.async, TMA, etc.)T.gemm: Matrix multiplication using Tensor CoresT.Pipelined: Software pipelining to overlap compute and memory transferT.Parallel: Element-wise parallel operations
Pipeline stages:
num_stages=2: Double bufferingnum_stages=3: Triple buffering (recommended for most workloads)num_stages=4+: Diminishing returns, increases shared memory usage
Step 5: Validate and Test
Generate test code to verify correctness:
Step 6: Optimize Performance
Apply advanced optimizations if performance is suboptimal:
Block Size Tuning:
- A100: Try 128×128×32 or 64×64×32
- H100: Can use larger blocks (256×128×32)
- MI300X: May need smaller blocks due to 64KB shared memory limit
Pipeline Depth:
- Increase
num_stagesif memory-bound - Decrease if shared memory is exhausted
Warp Policy (for advanced cases):
Block-level swizzle:
Common Kernel Patterns
Matrix Multiplication (GEMM)
Most fundamental kernel. See EXAMPLES.md for complete implementation.
Key features:
- 3-stage pipelining
- Swizzle layout for shared memory
- Float32 accumulator for precision
FlashAttention
Memory-efficient attention with online softmax. See EXAMPLES.md for complete implementation.
Key features:
- O(N) memory complexity
- Online softmax statistics
- Fused kernel (no intermediate materialization)
DeepSeek MLA
Multi-Head Latent Attention with KV compression. See EXAMPLES.md for complete implementation.
Key features:
- Split-KV parallelization
- Non-standard dimensions
- FullCol warp policy for narrow matrices
Reference Documentation
When you need specific information:
- API details (parameters, signatures, options): Read API_REFERENCE.md
- Complete code examples (GEMM, Attention, MLA): Read EXAMPLES.md
- Troubleshooting (errors, performance issues): Read DEBUGGING.md
Critical Performance Guidelines
Always include these optimizations:
- Swizzle layout for shared memory:
``python T.annotate_layout({ A_shared: T.make_swizzled_layout(A_shared) }) ``
- Software pipelining:
``python for k in T.Pipelined(num_blocks, num_stages=3): ``
- Float32 accumulators:
``python C_local = T.alloc_fragment((M, N), "float32") # Not float16 ``
- Aligned block_K:
``python block_K = 32 # Or 16, must align for Tensor Core ``
- Initialize accumulators:
``python T.clear(C_local) ``
Hardware-Specific Considerations
NVIDIA GPUs
- Ampere (A100): Use cp.async, num_stages=3, block_K=32
- Hopper (H100): Can use TMA, larger blocks (256×128), num_stages=4
- Shared memory: 164KB (A100), 228KB (H100)
AMD GPUs
- MI300X: Use target="hip", smaller blocks, 64KB shared memory limit
- Test with both HIP and CUDA backends for compatibility
Huawei Ascend
- More experimental backend
- May require specific block sizes
- Consult Ascend-specific documentation
Code Quality Standards
When generating TileLang code:
- Add explanatory comments for non-obvious optimizations
- Specify hardware assumptions (e.g., "optimized for A100")
- Include usage examples showing instantiation
- Document block size choices and tuning rationale
- Provide performance expectations (e.g., "~90% of cuBLAS")
Example Kernel Request Flow
User: "Write a FP16 matrix multiplication kernel for A100"
Response:
- Clarify dimensions (if not specified)
- Generate complete kernel code with:
- Proper structure (@tilelang.jit, @T.prim_func)
- Swizzle layouts
- 3-stage pipelining
- Appropriate block sizes (128×128×32)
- Add usage example
- Explain key optimizations:
- "Swizzle layout eliminates bank conflicts"
- "3-stage pipeline overlaps memory and compute"
- "Float32 accumulator prevents overflow"
- Suggest testing approach
Troubleshooting Quick Reference
Compilation errors:
- Shared memory exceeded → Reduce block size or num_stages
- Shape mismatch → Verify dimension alignment in T.gemm
Runtime errors:
- Results all zeros → Check T.clear() and out_idx in decorator
- NaN/Inf → Use float32 accumulator, add epsilon in division
Performance issues:
- Low throughput → Verify swizzle layout and pipelining enabled
- Low occupancy → Reduce shared memory usage or block size
- Bank conflicts → Apply T.make_swizzled_layout
For detailed solutions, consult DEBUGGING.md.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtilelang-developer/SKILL.md
Popularity
- Repository stars
- 98
- Repository forks
- 6
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 1 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/yzlnew/infra-skills/tilelang-developer)