Skip to content

Commit a7fec9a

Browse files
localai-botmudler
andauthored
feat(backends): add darwin/metal (MPS) build for trl (#10487)
* feat(backends): add darwin/metal (MPS) build for trl Authors backend/python/trl/requirements-mps.txt and wires trl into the darwin CI matrix and gallery so the MPS training path can be built and validated on Apple Silicon. The MPS variant installs plain PyPI torch wheels (MPS-capable on macOS arm64) and the trl training stack; bitsandbytes is omitted as it is a CUDA-only dependency with poor Apple Silicon support. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:opus-4.8 [Claude Code] * fix(trl): guard uv-only --index-strategy for the pip/darwin path The darwin/MPS build installs with pip (USE_PIP=true), which rejects the uv-only --index-strategy flag and failed the darwin backend build. Add it only on the uv path; Linux/CUDA resolution is unchanged. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:opus-4.8 [Claude Code] --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
1 parent c678530 commit a7fec9a

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/backend-matrix.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4974,6 +4974,9 @@ includeDarwin:
49744974
- backend: "kitten-tts"
49754975
tag-suffix: "-metal-darwin-arm64-kitten-tts"
49764976
build-type: "mps"
4977+
- backend: "trl"
4978+
tag-suffix: "-metal-darwin-arm64-trl"
4979+
build-type: "mps"
49774980
- backend: "liquid-audio"
49784981
tag-suffix: "-metal-darwin-arm64-liquid-audio"
49794982
build-type: "mps"

backend/index.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5295,6 +5295,7 @@
52955295
nvidia: "cuda12-trl"
52965296
nvidia-cuda-12: "cuda12-trl"
52975297
nvidia-cuda-13: "cuda13-trl"
5298+
metal: "metal-trl"
52985299
## TRL backend images
52995300
- !!merge <<: *trl
53005301
name: "cpu-trl"
@@ -5326,6 +5327,16 @@
53265327
uri: "quay.io/go-skynet/local-ai-backends:master-gpu-nvidia-cuda-13-trl"
53275328
mirrors:
53285329
- localai/localai-backends:master-gpu-nvidia-cuda-13-trl
5330+
- !!merge <<: *trl
5331+
name: "metal-trl"
5332+
uri: "quay.io/go-skynet/local-ai-backends:latest-metal-darwin-arm64-trl"
5333+
mirrors:
5334+
- localai/localai-backends:latest-metal-darwin-arm64-trl
5335+
- !!merge <<: *trl
5336+
name: "metal-trl-development"
5337+
uri: "quay.io/go-skynet/local-ai-backends:master-metal-darwin-arm64-trl"
5338+
mirrors:
5339+
- localai/localai-backends:master-metal-darwin-arm64-trl
53295340
## llama.cpp quantization backend
53305341
- &llama-cpp-quantization
53315342
name: "llama-cpp-quantization"

backend/python/trl/install.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ else
88
source $backend_dir/../common/libbackend.sh
99
fi
1010

11-
EXTRA_PIP_INSTALL_FLAGS+=" --upgrade --index-strategy=unsafe-first-match"
11+
EXTRA_PIP_INSTALL_FLAGS+=" --upgrade"
12+
# --index-strategy is a uv-only flag. The darwin/MPS build installs with pip
13+
# (USE_PIP=true in scripts/build/python-darwin.sh), which rejects it. Only add
14+
# it when uv is the installer, keeping the Linux/CUDA resolution unchanged.
15+
if [ "x${USE_PIP:-}" != "xtrue" ]; then
16+
EXTRA_PIP_INSTALL_FLAGS+=" --index-strategy=unsafe-first-match"
17+
fi
1218
installRequirements
1319

1420
# Fetch convert_hf_to_gguf.py and gguf package from the same llama.cpp version
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
torch==2.10.0
2+
trl
3+
peft
4+
datasets>=3.0.0
5+
transformers>=4.56.2
6+
accelerate>=1.4.0
7+
huggingface-hub>=1.3.0
8+
sentencepiece
9+
# Note: bitsandbytes is intentionally omitted on MPS. It is only used by the
10+
# CUDA (cublas) variants for 8-bit/4-bit quantization and has poor support on
11+
# Apple Silicon. torch here uses the plain PyPI wheels, which ship MPS support
12+
# on macOS arm64.

0 commit comments

Comments
 (0)