Skip to content

feat(mps): Apple Silicon MPS port — Flash Attention 3 → PyTorch SDPA - #582

Open
Rensp wants to merge 4 commits into
karpathy:masterfrom
Rensp:autoresearch/may10
Open

feat(mps): Apple Silicon MPS port — Flash Attention 3 → PyTorch SDPA#582
Rensp wants to merge 4 commits into
karpathy:masterfrom
Rensp:autoresearch/may10

Conversation

@Rensp

@Rensp Rensp commented May 10, 2026

Copy link
Copy Markdown

Summary

Port autoresearch to run fully on Apple Silicon (MPS) — no CUDA required.

  • Replace Flash Attention 3 (CUDA/Hopper-only) with PyTorch F.scaled_dot_product_attention
  • Remove kernels dependency; switch torch source from CUDA 12.8 index to standard PyPI
  • Port prepare.py: MPS device detection, remove unsupported pin_memory=True
  • Rewrite MuonAdamW: Python float scalars instead of CPU tensors (fixes MPS cross-device errors); disable torch.compile (not stable on MPS)
  • Add read_result.py: helper to parse run.log with \r carriage returns
  • Add program.md: MPS-specific experiment loop instructions for autonomous Claude Code research

Motivation

This port enables overnight autonomous ML experiments on Apple M-series hardware. The 5-minute training budget maps well to MPS throughput (~11.5M param model, batch=4).

Baseline result (Apple M-series, MPS)

config val_bpb params steps
depth=4, SDPA, batch=4 1.5258 11.5M 318

Test plan

  • uv run python prepare.py --num-shards 2 completes on MPS
  • uv run python train.py runs 300s and prints val_bpb:
  • No CUDA or kernels imports needed

🤖 Generated with Claude Code

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.

1 participant