Apple Silicon hardware acceleration backends for GoMLX / github.com/gomlx/compute.
| Backend Name | Package | Framework | Hardware |
|---|---|---|---|
mps |
github.com/gomlx/go-darwinml/compute/mps |
Metal Performance Shaders Graph (MPSGraph) |
Apple GPU (Metal) |
(Future planned backend: mlx using Apple's MLX framework.)
- macOS 13.0+ (Ventura or later; macOS 14.0+ Sonoma for
BFloat16and nativescaledDotProductAttention) - Xcode Command Line Tools (
xcode-select --install) for CGo + Metal/MPSGraph frameworks - Go 1.27+
go get github.com/gomlx/go-darwinmlOn Darwin (macOS) machines, the "mps" backend is included by default when importing GoMLX's default backends package (_ "github.com/gomlx/gomlx/backends/default"), or it can be explicitly imported with _ "github.com/gomlx/go-darwinml/compute/mps":
import (
"github.com/gomlx/compute"
_ "github.com/gomlx/gomlx/backends/default" // Includes "mps" by default on Darwin; or use:
// _ "github.com/gomlx/go-darwinml/compute/mps"
)
func main() {
backend, err := compute.NewWithConfig("mps")
if err != nil {
panic(err)
}
defer backend.Finalize()
}Or select it at runtime via the GOMLX_BACKEND=mps environment variable when calling compute.New() / compute.MustNew().
See docs/MPSGraph.md for detailed architecture and buffer management documentation.
- Unsupported DTypes: Apple Metal /
MPSGraphdoes not support 64-bit floats (Float64), complex numbers (Complex64,Complex128), or sub-byte integer types (Int2,Int4,Uint2,Uint4). - Unsupported Operations:
- Complex & FFT ops:
Complex,Real,Imag,Conj,FFT. - Bit-level & bitwise reduction ops:
Bitcast,BitCount,Clz,ReduceBitwiseAnd,ReduceBitwiseOr,ReduceBitwiseXor,ReduceLogicalXor. - Pooling scatter variants:
SelectAndScatterSum,SelectAndScatterMin(SelectAndScatterMaxis supported). - Dynamic shape ops:
DynamicBroadcastInDim,DynamicIota,DynamicPad,DynamicReshape,DynamicShape,DynamicDimensionSize. - Collective / distributed ops:
AllReduce,AllGather,CollectiveBroadcast. - Barriers & quantized fused ops:
OptimizationBarrier,SchedulingBarrier,FusedQuantizedDense,QuantizedEmbeddingLookup. - (Note: Operations with GoMLX graph decompositions, such as
CumSumandCumMax, automatically fall back to their decomposed implementations).
- Complex & FFT ops:
go-darwinml/
├── compute/
│ └── mps/ # GoMLX compute.Backend implementation ("mps")
└── internal/
└── bridge/ # CGo / Objective-C bridge to Metal & MPSGraph
# Run unit and backend compliance tests
go test ./...Apache 2.0 - see LICENSE file.