mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-25 09:09:07 -04:00
* 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>
44 lines
1.8 KiB
Bash
44 lines
1.8 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
backend_dir=$(dirname $0)
|
|
if [ -d $backend_dir/common ]; then
|
|
source $backend_dir/common/libbackend.sh
|
|
else
|
|
source $backend_dir/../common/libbackend.sh
|
|
fi
|
|
|
|
EXTRA_PIP_INSTALL_FLAGS+=" --upgrade"
|
|
# --index-strategy is a uv-only flag. The darwin/MPS build installs with pip
|
|
# (USE_PIP=true in scripts/build/python-darwin.sh), which rejects it. Only add
|
|
# it when uv is the installer, keeping the Linux/CUDA resolution unchanged.
|
|
if [ "x${USE_PIP:-}" != "xtrue" ]; then
|
|
EXTRA_PIP_INSTALL_FLAGS+=" --index-strategy=unsafe-first-match"
|
|
fi
|
|
installRequirements
|
|
|
|
# Fetch convert_hf_to_gguf.py and gguf package from the same llama.cpp version
|
|
LLAMA_CPP_CONVERT_VERSION="${LLAMA_CPP_CONVERT_VERSION:-master}"
|
|
CONVERT_SCRIPT="${EDIR}/convert_hf_to_gguf.py"
|
|
if [ ! -f "${CONVERT_SCRIPT}" ]; then
|
|
echo "Downloading convert_hf_to_gguf.py from llama.cpp (${LLAMA_CPP_CONVERT_VERSION})..."
|
|
curl -L --fail --retry 3 \
|
|
"https://raw.githubusercontent.com/ggml-org/llama.cpp/${LLAMA_CPP_CONVERT_VERSION}/convert_hf_to_gguf.py" \
|
|
-o "${CONVERT_SCRIPT}" || echo "Warning: Failed to download convert_hf_to_gguf.py. GGUF export will not be available."
|
|
fi
|
|
|
|
# Install gguf package from the same llama.cpp commit to keep them in sync
|
|
GGUF_PIP_SPEC="gguf @ git+https://github.com/ggml-org/llama.cpp@${LLAMA_CPP_CONVERT_VERSION}#subdirectory=gguf-py"
|
|
echo "Installing gguf package from llama.cpp (${LLAMA_CPP_CONVERT_VERSION})..."
|
|
if [ "x${USE_PIP:-}" == "xtrue" ]; then
|
|
pip install "${GGUF_PIP_SPEC}" || {
|
|
echo "Warning: Failed to install gguf from llama.cpp commit, falling back to PyPI..."
|
|
pip install "gguf>=0.16.0"
|
|
}
|
|
else
|
|
uv pip install "${GGUF_PIP_SPEC}" || {
|
|
echo "Warning: Failed to install gguf from llama.cpp commit, falling back to PyPI..."
|
|
uv pip install "gguf>=0.16.0"
|
|
}
|
|
fi
|