Skip to content

feat: add macOS CPU/MPS support alongside CUDA#516

Open
marketswitch wants to merge 1 commit into
karpathy:masterfrom
marketswitch:macos-cpu-support
Open

feat: add macOS CPU/MPS support alongside CUDA#516
marketswitch wants to merge 1 commit into
karpathy:masterfrom
marketswitch:macos-cpu-support

Conversation

@marketswitch
Copy link
Copy Markdown

What changed

pyproject.toml hardcoded torch to the pytorch-cu128 index, which only ships Linux and Windows wheels. This makes the project completely uninstallable on macOS.

This PR adds a platform-conditional torch source:

  • Linux / Windowspytorch-cu128 (existing CUDA 12.8 behaviour, unchanged)
  • macOSpytorch-cpu (resolves a CPU+MPS wheel, uses Apple Silicon GPU via MPS)

The torch pin is also relaxed from ==2.9.1 to >=2.11.0 so the CPU index can resolve a compatible wheel.

Why

Developers on Macs couldn't even run uv sync to get started. With MPS available on Apple Silicon, local experimentation is viable — training is slow vs. H100 but works for iterating on ideas before running overnight jobs on a GPU server.

Testing

uv sync
uv run python -c "import torch; print(torch.__version__); print(torch.backends.mps.is_available())"
# torch: 2.11.0
# MPS available: True

pyproject.toml used a hardcoded CUDA 12.8 torch index which has no
macOS wheels, making the project uninstallable on macOS. This patch
adds a platform-conditional torch source so:

- Linux/Windows → pytorch-cu128 (unchanged CUDA behaviour)
- macOS         → pytorch-cpu  (uses MPS on Apple Silicon)

Also relaxes the torch pin from ==2.9.1 to >=2.11.0 so the CPU index
can resolve a compatible wheel.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@stabgan
Copy link
Copy Markdown

stabgan commented Apr 16, 2026

Is this tested properly ? very interesting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants