Skip to main content

MPS Conv3D

3D Convolution for Apple Silicon (M1/M2/M3/M4).

Drop-in replacement for torch.nn.functional.conv3d on MPS.

Why?

3D convolutions are essential for video models:

  • Synchformer: Audio-visual synchronization
  • I3D: Video classification
  • SlowFast: Action recognition
  • C3D: Video feature extraction
  • MMAudio: Audio generation from video

But PyTorch's MPS backend doesn't support 3D convolutions:

NotImplementedError: aten::slow_conv3d_forward is not implemented for MPS

This package provides a native Metal implementation.

Installation

pip install mps-conv3d

Or from source:

git clone https://github.com/mpsops/mps-conv3d
cd mps-conv3d
pip install -e .

Quick Start

from mps_conv3d import patch_conv3d

# Patch at the start of your script
patch_conv3d()

# Now all conv3d operations use MPS!
import torch
import torch.nn.functional as F

x = torch.randn(1, 3, 16, 112, 112, device='mps')
w = torch.randn(64, 3, 3, 7, 7, device='mps')
out = F.conv3d(x, w, padding=(1, 3, 3))  # Uses MPS!

Direct Usage

import torch
from mps_conv3d import conv3d

x = torch.randn(1, 3, 16, 112, 112, device='mps')
w = torch.randn(64, 3, 3, 7, 7, device='mps')

out = conv3d(x, w, stride=1, padding=(1, 3, 3))

Conv3d Module

from mps_conv3d import Conv3d

conv = Conv3d(
    in_channels=3,
    out_channels=64,
    kernel_size=(3, 7, 7),
    stride=(1, 2, 2),
    padding=(1, 3, 3)
).to('mps')

x = torch.randn(1, 3, 16, 112, 112, device='mps')
out = conv(x)

API Reference

conv3d(input, weight, bias, stride, padding, dilation, groups)

Same signature as torch.nn.functional.conv3d.

Parameter Type Description
input Tensor Input tensor (N, C_in, D, H, W)
weight Tensor Weight tensor (C_out, C_in/groups, kD, kH, kW)
bias Tensor Optional bias (C_out,)
stride int/tuple Stride of convolution
padding int/tuple Padding added to input
dilation int/tuple Dilation of kernel
groups int Number of groups

patch_conv3d()

Monkey-patches torch.nn.functional.conv3d to use MPS implementation for MPS tensors.

unpatch_conv3d()

Restores original torch.nn.functional.conv3d.

Compatibility

  • PyTorch: 2.0+
  • macOS: 12.0+ (Monterey)
  • Hardware: Apple Silicon (M1/M2/M3/M4)

Features

  • Full forward and backward pass (training supported)
  • fp32 and fp16 supported
  • Groups and dilation supported
  • Drop-in compatible with PyTorch API

License

MIT

Metadata

Release files for mps-conv3d 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mps-conv3d 0.2.1
File Size Uploaded Provenance Actions
mps_conv3d-0.2.1.tar.gz 13.6 kB Without provenance Details for mps_conv3d-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mps-conv3d 0.2.1
File Interpreter ABI Platform Actions
mps_conv3d-0.2.1-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details for mps_conv3d-0.2.1-cp314-cp314-macosx_15_0_arm64.whl

Total release size: 106.6 kB

Release files / mps_conv3d-0.2.1.tar.gz

Download URL mps_conv3d-0.2.1.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
46e384b5683742d1cac968e1ae515adb90f4205a61303af281763d730e24d6a5
BLAKE2b-256 checksum
How to use checksums
ac8155edad21c1f90eaa69b4975505b271e0403b6e53e388b5098113228621c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / mps_conv3d-0.2.1-cp314-cp314-macosx_15_0_arm64.whl

Download URL mps_conv3d-0.2.1-cp314-cp314-macosx_15_0_arm64.whl
Size 93.0 kB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
cfbbade8e158bf006bc6020d37cb8b34980f58f83134350fd1f899594e2f4521
BLAKE2b-256 checksum
How to use checksums
4186fcb930f89a914c0afe3f125e8d20ae1594d346edc50d5611d979b7b9f27a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for mps-conv3d 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page