metal-kernel
SKILL.md
Metal Kernel Writing Guide
This skill guides you through implementing Metal kernels for PyTorch operators on Apple Silicon.
Important: The goal of this skill is to use native Metal capabilities via the c10/metal/ infrastructure, NOT MPSGraph. Native Metal kernels provide better control, performance, and maintainability.
Overview
There are two workflows covered by this skill:
- Adding new MPS support - Implementing a new operator from scratch
- Migrating from MPSGraph - Converting existing MPSGraph-based operators to native Metal
Both workflows involve:
- Update dispatch in
aten/src/ATen/native/native_functions.yaml - Write Metal kernel in
aten/src/ATen/native/mps/kernels/ - Implement host-side stub in
aten/src/ATen/native/mps/operations/