Apple Silicon native run manager#646
Open
clockworksquirrel wants to merge 11 commits into
Open
Conversation
Reformat the MPS and CUDA compatibility-layer docs with the repo's configured prettier (tabs, no-semi, single-quote, trailing-comma es5), matching the treefmt markdown formatter. Content is unchanged; this only fixes table alignment, line wrapping, and stray tabs that were left non-canonical in the earlier commits.
…/HfAuto Split the modeling `parallelism` Cargo feature into `parallelism-core` (Apple-safe, no NCCL/CUDA) and `cuda-parallelism` (NCCL/CUDA) so the native Apple Silicon client builds without CUDA-only bindings. Propagate the split through psyche-client, the centralized/decentralized client and testing crates, and the python extension, and update the `#[cfg]` gates in shared/modeling accordingly. Native compute path: - factory.py only redirects CUDA-shaped device intent to MPS for the validated HfAuto architecture; others reject instead of silently running. - HfTransformersAuto forward runs inside mps_compat_context. - sidecar requires an explicit --device, enforces gloo + single rank on MPS, stages distributed collectives on CPU then moves to the device, and is import-safe (main only runs under __main__). - build-native-silicon.sh sets the Apple Silicon Python/libtorch env and embeds rpaths at link time. - Add scripts/check-hfauto-mps-redirect.py and scripts/check-sidecar-mps-device.py and document the native flow. Formatting/verification: - taplo, black, prettier, and beautysh are clean on all touched files. - Nightly rustfmt --check is clean on all authored Rust lines. The lone remaining nightly-rustfmt diff (shared/modeling/src/distro.rs:702 import ordering) is pre-existing on HEAD (reproduced via `rustfmt --check` on the committed blob) and is intentionally left untouched to keep this diff to authored lines; the only change here is a commented-out cfg label. - mdbook build of psyche-book succeeds (exit 0). - Verified locally: build-native-silicon.sh --python, cargo build -p psyche-modeling --examples, cargo test -p run-manager native, and the fallback-disabled HfAuto/MPS + sidecar smokes. Caveat: the `cuda-parallelism` (NCCL/CUDA) path cannot be compiled on Apple Silicon and was NOT built here. A CUDA host must `cargo build --features cuda-parallelism` before that lane is assumed good upstream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an experimental native compute-provider path for macOS Apple Silicon, plus documentation and guardrails for using a native client when the standard Linux/NVIDIA CUDA Docker path cannot expose the local Apple Silicon MPS accelerator.
The main experimental target in this PR is Apple Silicon on macOS using PyTorch MPS. It also adds an experimental Windows ARM64 helper for CPU-only smoke/development runs. Windows DirectML, NPU, and GPU acceleration are not wired in here.
What changed
psyche-solana-clientbinary through--native-client.scripts/build-native-silicon.shrun-managerandpsyche-solana-clientscripts/build-native-windows-arm64.ps1aarch64-pc-windows-msvctorchimporttorch.compileon non-CUDA devicesflash_attention_2tosdpaon non-CUDA devicesPSYCHE_MPS_BF16=1forces BF16PSYCHE_MPS_BF16=0forces float16HfAutorepo-file checkpoint loading:state_dictstate_dictinputstikv-jemallocatoroff on Windows so the Solana client can build on Windows/MSVC targets.Platform support in this PR
run-manager/client binaries with PyTorch MPS for local acceleration. Single local rank only. Sustained runs require burn-in on the exact model, sequence length, batch shape, dtype, and coordinator configuration.--device cpu. DirectML, NPUs, and Windows GPU acceleration are not implemented.Apple Silicon sizing note
Single-rank means one local worker process, not an automatic short-duration cap. On high-memory Apple Silicon systems, some 12B-class Hugging Face checkpoints may load and may complete limited local train/verify steps when the exact run uses modest sequence lengths, small micro-batches, gradient checkpointing, and BF16 or float16 weights. This is not a general 12B support guarantee.
Loading larger 20B-30B checkpoints on the same machine is not evidence that live training or verification will fit. Sustained runs also use memory for activations, gradients, optimizer state, logits, allocator overhead, and any unsupported MPS operations that fall back to CPU.
Documentation
New primary doc:
psyche-book/src/enduser/native-silicon.mdAlso touched:
The docs include:
Validation
Local checks run on macOS Apple Silicon:
A focused Python helper smoke test also covered safetensors indexing, tied-alias helper behavior, and shape-mismatch error reporting.
The Windows ARM64 helper has been statically reviewed and mechanically checked where possible, but still needs target-host validation on a real Windows ARM64 machine before treating that path as proven.
Caveats
--native-client-versionshould only be used after the run administrator confirms the accepted version; it should not be used just to bypass the compatibility gate.