Skip to content

Commit eced528

Browse files
simbasimba
authored andcommitted
feat: localize MLX frameworks to write C++ turboquant and ssd streamer scaffolds
1 parent 7d23eba commit eced528

1,814 files changed

Lines changed: 569562 additions & 24 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Create a report about an issue you've encountered
4+
title: "[BUG] "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
15+
Include code snippet
16+
```swift
17+
18+
```
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Desktop (please complete the following information):**
24+
- OS Version: [e.g. MacOS 14.1.2]
25+
- Device: [e.g. iPhone 16, M2 MacBook Pro]
26+
- Version [e.g. 0.29.1]
27+
28+
**Additional context**
29+
Add any other context about the problem here.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Proposed changes
2+
3+
Please include a description of the problem or feature this PR is addressing. If there is a corresponding issue, include the issue #.
4+
5+
## Checklist
6+
7+
Put an `x` in the boxes that apply.
8+
9+
- [ ] I have read the [CONTRIBUTING](https://github.com/ml-explore/mlx/blob/main/CONTRIBUTING.md) document
10+
- [ ] I have run `pre-commit run --all-files` to format my code / installed pre-commit prior to committing changes
11+
- [ ] I have added tests that prove my fix is effective or that my feature works
12+
- [ ] I have updated the necessary documentation (if needed)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
# [Pre-setup] Check required env variables.
5+
: "${TOOLKIT_VERSION:?Error: TOOLKIT_VERSION is not set. Please define it in the GitHub Actions workflow.}"
6+
CUDA_BIN_PATH="/usr/local/${TOOLKIT_VERSION}/bin"
7+
export PATH="$CUDA_BIN_PATH:$PATH"
8+
9+
# [CMake] CI Build Sanity Check: Verifies code compilation, not for release.
10+
export CMAKE_ARGS="-DCMAKE_COMPILE_WARNING_AS_ERROR=ON"
11+
export DEBUG=1
12+
export CMAKE_C_COMPILER=/usr/bin/clang
13+
export CMAKE_CXX_COMPILER=/usr/bin/clang++
14+
15+
rm -rf build
16+
mkdir -p build
17+
pushd build
18+
cmake -DMLX_BUILD_METAL=OFF -DMLX_BUILD_CUDA=ON -DMLX_C_BUILD_EXAMPLES=OFF .. -G Ninja
19+
ninja
20+
./example1 --device gpu
21+
./tutorial --device gpu
22+
popd
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
BUILD_DIR=`xcodebuild -configuration Debug -showBuildSettings -scheme MLX | grep 'BUILT_PRODUCTS_DIR = /' | sed -e 's/^[^=]*= //g' | head -1`
4+
5+
# rpath points to PackageFrameworks so link it to the built products
6+
(cd $BUILD_DIR/PackageFrameworks; ln -s ../*.framework .)
7+
8+
xcrun xctest "$BUILD_DIR/MLXTests.xctest"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
# [Setup] Install dependencies inside the container.
5+
if command -v apt-get >/dev/null 2>&1; then
6+
apt-get update -y
7+
apt-get install -y \
8+
build-essential \
9+
cmake \
10+
ninja-build \
11+
libblas-dev \
12+
liblapacke-dev \
13+
libopenblas-dev
14+
15+
elif command -v dnf >/dev/null 2>&1; then
16+
dnf update -y
17+
dnf install -y \
18+
blas-devel \
19+
lapack-devel \
20+
openblas-devel \
21+
make \
22+
cmake \
23+
clang \
24+
ninja-build
25+
26+
else
27+
echo "No supported package manager found (apt-get, dnf)"
28+
exit 1
29+
fi
30+
31+
# [CMake] CI Build Sanity Check: Verifies code compilation, not for release.
32+
export CMAKE_ARGS="-DCMAKE_COMPILE_WARNING_AS_ERROR=ON"
33+
export DEBUG=1
34+
export CMAKE_C_COMPILER=/usr/bin/clang
35+
export CMAKE_CXX_COMPILER=/usr/bin/clang++
36+
37+
rm -rf build
38+
mkdir -p build
39+
pushd build
40+
cmake -DMLX_BUILD_METAL=OFF .. -G Ninja
41+
ninja
42+
./example1
43+
./tutorial
44+
popd
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
# [Pre-setup] Check required env variables.
5+
: "${TOOLKIT_VERSION:?Error: TOOLKIT_VERSION is not set. Please define it in the GitHub Actions workflow.}"
6+
: "${SWIFT_VERSION:?Error: SWIFT_VERSION is not set. Please define it in the GitHub Actions workflow.}"
7+
: "${SWIFT_SIGNING_KEY:?Error: SWIFT_SIGNING_KEY is not set. Please define it in the GitHub Actions workflow.}"
8+
9+
# [Pre-setup] System compatibility checks.
10+
if [[ "$(uname -s)" != "Linux" ]]; then
11+
echo "Error: This script is intended for Linux only."
12+
echo "Detected OS: $(uname -s)"
13+
exit 1
14+
fi
15+
export ARCH=$(uname -m)
16+
if [[ "$ARCH" != "x86_64" ]]; then
17+
echo "Error: This script is intended for x86_64 arch only."
18+
echo "Detected arch: $(uname -m)"
19+
exit 1
20+
fi
21+
ID=$(grep '^ID=' /etc/os-release | cut -d'=' -f2 || true)
22+
VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"' || true)
23+
if [[ "$ID" != "ubuntu" || "$VERSION_ID" != "24.04" ]]; then
24+
PRETTY_NAME=$(grep '^PRETTY_NAME=' /etc/os-release | cut -d'=' -f2 | tr -d '"' || true)
25+
echo "Error: This script is intended for Ubuntu 24.04 only."
26+
echo "Detected OS: ${PRETTY_NAME:-"Unknown Linux"}"
27+
exit 1
28+
fi
29+
SWIFT_PLATFORM=ubuntu24.04
30+
31+
# [Setup] Install dependencies.
32+
## Common deps.
33+
export DEBIAN_FRONTEND=noninteractive
34+
sudo apt-get update
35+
sudo apt-get install -y \
36+
binutils \
37+
build-essential \
38+
cmake \
39+
curl \
40+
dkms \
41+
git \
42+
gnupg2 \
43+
libblas-dev \
44+
libc6-dev \
45+
libcurl4-openssl-dev \
46+
libedit2 \
47+
libgcc-13-dev \
48+
liblapacke-dev \
49+
libncurses-dev \
50+
libopenblas-dev \
51+
libpython3-dev \
52+
libsqlite3-0 \
53+
libstdc++-13-dev \
54+
libxml2-dev \
55+
libz3-dev \
56+
ninja-build \
57+
pkg-config \
58+
python3-lldb \
59+
tzdata \
60+
ubuntu-drivers-common \
61+
unzip \
62+
zip \
63+
zlib1g-dev
64+
65+
## Install MPI.
66+
sudo apt-get install -y \
67+
openmpi-bin \
68+
openmpi-common \
69+
libopenmpi-dev
70+
71+
## Install CUDA toolkit + NCCL.
72+
CUDA_MAJOR_VERSION=${TOOLKIT_VERSION%.*}
73+
CUDA_TOOLKIT_PKG="cuda-toolkit-${TOOLKIT_VERSION#cuda-}"
74+
CUDNN_PKG="libcudnn9-dev-${CUDA_MAJOR_VERSION}"
75+
CUDA_PACKAGES="$CUDNN_PKG $CUDA_TOOLKIT_PKG"
76+
77+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/$ARCH/cuda-keyring_1.1-1_all.deb
78+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
79+
sudo apt-get update
80+
sudo apt-get install -y \
81+
libnccl2 \
82+
libnccl-dev \
83+
$CUDA_PACKAGES
84+
CUDA_BIN_PATH="/usr/local/${TOOLKIT_VERSION}/bin"
85+
export PATH="$CUDA_BIN_PATH:$PATH"
86+
rm cuda-keyring_1.1-1_all.deb
87+
88+
## Sanity checks - system requirements.
89+
echo "NVIDIA Driver Packages Available:"
90+
sudo ubuntu-drivers list --gpgpu
91+
echo "NVIDIA Driver Version:"
92+
cat /proc/driver/nvidia/version || echo "nvidia driver not found"
93+
echo "Installed NVIDIA and CUDA packages:"
94+
dpkg -l | egrep "cuda|nvidia" -i
95+
echo "DKMS Status:"
96+
dkms status || echo "dkms not found"
97+
echo "NVIDIA-SMI Status:"
98+
nvidia-smi || echo "nvidia-smi not found"
99+
100+
## Install Swift toolchain manually (status 12/18/2025: no official swiftlang ubuntu package available yet).
101+
# See for example https://github.com/swiftlang/swift-docker/blob/main/6.2/ubuntu/24.04/Dockerfile
102+
SWIFT_WEBROOT="https://download.swift.org"
103+
case "$ARCH" in
104+
x86_64)
105+
OS_ARCH_SUFFIX=""
106+
;;
107+
aarch64|arm64)
108+
OS_ARCH_SUFFIX="-aarch64"
109+
;;
110+
*)
111+
echo "Error: Unsupported architecture: ${ARCH}" >&2
112+
exit 1
113+
;;
114+
esac
115+
SWIFT_BRANCH=$(echo "$SWIFT_VERSION" | tr '[:upper:]' '[:lower:]')
116+
SWIFT_WEBDIR="$SWIFT_WEBROOT/$SWIFT_BRANCH/$(echo $SWIFT_PLATFORM | tr -d .)$OS_ARCH_SUFFIX"
117+
SWIFT_BIN_URL="$SWIFT_WEBDIR/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM$OS_ARCH_SUFFIX.tar.gz"
118+
SWIFT_SIG_URL="$SWIFT_BIN_URL.sig"
119+
GNUPGHOME="$(mktemp -d)"
120+
curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_SIG_URL" -o swift.tar.gz.sig
121+
gpg --batch --quiet --keyserver keyserver.ubuntu.com --recv-keys "$SWIFT_SIGNING_KEY"
122+
gpg --batch --verify swift.tar.gz.sig swift.tar.gz
123+
# - Unpack the toolchain, set libs permissions, and clean up.
124+
sudo tar -xzf swift.tar.gz --directory / --strip-components=1
125+
sudo chmod -R o+r /usr/lib/swift
126+
rm -rf "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz
127+
swift --version

0 commit comments

Comments
 (0)