What Is Metal Performance Shaders (MPS)? Choosing MPS Kernels and MPSGraph
Metal Performance Shaders (MPS) is a library of prepared kernels that lets Metal apps on Apple platforms delegate repeated work such as image filtering and matrix operations to the GPU. An app can connect an MPS operation to existing Metal resources and command buffers without writing a separate shader for every GPU. The right choice depends on whether you need one kernel, a graph of tensor operations, or a custom shader.
What Is Metal Performance Shaders (MPS)? Choosing MPS Kernels and MPSGraph
Metal Performance Shaders (MPS) is a library of prepared kernels that lets Metal apps on Apple platforms delegate repeated work such as image filtering and matrix operations to the GPU. An app can connect an MPS operation to existing Metal resources and command buffers without writing a separate shader for every GPU. The right choice depends on whether you need one kernel, a graph of tensor operations, or a custom shader.
What work does MPS handle?
Metal is a low-level graphics and compute API that gives an app control over GPU work and data flow. MPS is a framework that supplies kernels for common operations. Apple lists image filters and histograms, neural-network operations, matrix factorization and multiplication, and ray–geometry intersection among its capabilities. These kernels work with objects a Metal app already uses, such as MTLTexture, MTLBuffer, and MTLCommandBuffer. Apple’s MPS overview
A kernel is a unit of computation that runs in parallel on a GPU. A blur filter, for example, calculates many pixels using nearby pixels. A hand-written implementation must handle GPU-thread layout, edge pixels, and memory access. With MPS, the app can focus on preparing input and output textures and parameters, then encoding the kernel call into a command buffer. Apple says MPS kernels are tuned for the characteristics of different Metal GPU families, but that does not guarantee that a particular operation will always be faster on every device. Measure the actual device, data format, image size, and surrounding work.
What happens when you blur an image?
Suppose an app needs to blur a camera frame. It first checks whether the Metal device supports MPS by calling MPSSupportsMTLDevice. This function reports framework-level device support. It does not certify every kernel, pixel format, or precision, so also check the individual API documentation and device feature table. MPS device-support function
Record the kernel commands in this order. Using MPS kernels
Prepare an `MTLDevice`, command queue, and command buffer, and check MPS support for that device.
Prepare an input texture containing the pixels and an output texture for the result. Confirm that both textures’ dimensions and pixel formats meet the selected filter’s requirements.
Create a blur kernel with `MPSImageGaussianBlur(device:sigma:)`. The `sigma` value sets the blur strength in the x and y directions.
End any open Metal encoder, then call the kernel’s `encode` method to record its commands. Create a new encoder before adding later GPU work to the same command buffer.
Submit the command buffer and use the output texture after receiving a completion notification. Inspect the image, and compare pixel differences and precision with a reference implementation when needed.
Do not interpret “Gaussian” in the filter name as a guarantee of a mathematically exact Gaussian. Apple describes MPSImageGaussianBlur as a fast approximation intended for common image-processing needs requiring about 10 bits of precision or less. If an analytically clean Gaussian is required, consider MPSImageConvolution with appropriate weights. This distinction can change the choice between a visual blur and an analysis task with stricter error limits. MPSImageGaussianBlur documentation
How do MPS kernels and MPSGraph differ?
An MPS kernel is suited to inserting a prepared operation—such as blur, convolution, or matrix multiplication—into a command buffer. MPSGraph represents a larger computation as a graph: nodes are operations such as addition or convolution, and edges are tensors containing multidimensional data. After building the graph, the app selects inputs (feeds) and outputs (targets), compiles an executable, and can run it on input data. Apple says MPSGraph can use the platform’s compute devices, including the GPU, CPU, and Neural Engine. Actual placement and support depend on the graph, device, and operating system, so do not assume a particular device is guaranteed. MPSGraph overview MPSGraph class and compilation API
For one image blur, an MPS image kernel is a natural fit. For a model made of linked tensor operations—such as resizing, normalization, and several convolutions—consider expressing those relationships in MPSGraph and checking whether graph compilation helps. Write a Metal shader when the required operation is missing or you need direct control over data flow or operation fusion. That choice makes you responsible for thread and memory design, correctness checks, and device-specific profiling.
| Situation | First option to consider | What to check |
|---|---|---|
| A prepared single operation such as an image filter or matrix operation | MPS kernel | Kernel pixel formats, parameters, precision, and device support |
| A computation linking multiple tensor operations from input to output | MPSGraph | Operator support, graph compilation cost, actual execution device, and repeated-run performance |
| Special processing that prepared operations cannot express, or a strong need for fusion | Custom Metal shader | Implementation and maintenance cost, memory access, correctness, and per-device tuning |
| You need to author a custom ML kernel using Metal 4 tensor operations | Also consider Metal Performance Primitives (TensorOps) | Check Metal 4 and target-GPU support. This is not the same layer as the MPS kernel library or MPSGraph |
MPP in the last row is not a new name for MPS. Apple’s 2026 MPP materials describe mpp::tensor_ops as a low-level way to compose tensor operations such as matrix multiplication inside Metal shaders and author custom ML kernels. It targets Metal 4 and newer Apple GPU capabilities, so do not assume the same features exist on older devices. An app that only needs to call an existing image filter is solving a different problem, for which MPS remains relevant. Apple MPP Programming Guide WWDC26: Optimize custom machine-learning operations with Metal tensors
What should you verify before adopting MPS?
First, check the framework and the specific operation on the target operating system and device. MPSSupportsMTLDevice is a starting point; also read Apple’s feature table and the API’s availability and input-format requirements. MPS support does not mean that every MPS class and pixel format is supported under identical conditions.
Second, define the acceptable error before tuning. Input and output formats and reduced-precision options can affect values as well as speed. A visually acceptable blur may be different from a task that requires pixel-level reproducibility or analytical precision; the latter may need a different kernel.
Third, measure the entire app path, not only the kernel’s execution time. Texture creation or copying, temporary buffers, encoder switches, and CPU/GPU waits can cost more than the calculation itself. Apple’s tuning guidance recommends reusing resources and queuing the next commands while the GPU continues its work. MPS tuning guidance
Finally, review how work is encoded concurrently. An MPS kernel object is tied to a Metal device. Multiple threads should not mutate the same kernel object at once or write to the same command buffer concurrently. If several threads encode work, give kernel objects and command buffers clear ownership, and keep resources alive until completion. Compare real models or frame sizes on the target devices before deciding which path—MPS, MPSGraph, or custom Metal—to maintain.
Sources
[Apple, Metal Performance Shaders](https://developer.apple.com/documentation/metalperformanceshaders)
[Apple, The MPSKernel Class](https://developer.apple.com/documentation/metalperformanceshaders/the-mpskernel-class)
[Apple, MPSSupportsMTLDevice(_:)](https://developer.apple.com/documentation/metalperformanceshaders/mpssupportsmtldevice%28_%3A%29)
[Apple, MPSImageGaussianBlur](https://developer.apple.com/documentation/metalperformanceshaders/mpsimagegaussianblur)
[Apple, Metal Performance Shaders Graph](https://developer.apple.com/documentation/metalperformanceshadersgraph)
[Apple, MPSGraph](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraph)
[Apple, Tuning Hints](https://developer.apple.com/documentation/metalperformanceshaders/tuning-hints)
[Apple, Metal Performance Primitives Programming Guide](https://developer.apple.com/download/files/Metal-Performance-Primitives-Programming-Guide.pdf)
[Apple, WWDC26: Optimize custom machine learning operations with Metal tensors](https://developer.apple.com/videos/play/wwdc2026/330/)
References
- Apple Metal Performance Shaders
- Apple The MPSKernel Class
- Apple MPSSupportsMTLDevice
- Apple MPSImageGaussianBlur
- Apple Metal Performance Shaders Graph
- Apple MPSGraph
- Apple Tuning Hints
- Apple Metal Performance Primitives Programming Guide
- Apple WWDC26 Optimize custom machine learning operations with Metal tensors