From 0b54201a044c419e07a4bd464adf91e576640977 Mon Sep 17 00:00:00 2001 From: Michael Goin Date: Tue, 14 Jul 2026 15:40:26 -0400 Subject: [PATCH] [CI] Build macOS arm64 CPU wheel natively on the macmini queue (#48289) Signed-off-by: mgoin --- .buildkite/release-pipeline.yaml | 43 +++++++++++++++++++++ .buildkite/scripts/build-macos-wheel.sh | 32 +++++++++++++++ .buildkite/scripts/upload-nightly-wheels.sh | 16 ++++++-- csrc/cpu/torch_bindings.cpp | 5 ++- 4 files changed, 90 insertions(+), 6 deletions(-) create mode 100755 .buildkite/scripts/build-macos-wheel.sh diff --git a/.buildkite/release-pipeline.yaml b/.buildkite/release-pipeline.yaml index 1d3a1d4a53..f29b29ed2a 100644 --- a/.buildkite/release-pipeline.yaml +++ b/.buildkite/release-pipeline.yaml @@ -76,6 +76,49 @@ steps: env: DOCKER_BUILDKIT: "1" + - label: "Build wheel - macOS arm64 - CPU" + depends_on: ~ + id: build-wheel-macos-arm64-cpu + agents: + queue: macmini + timeout_in_minutes: 90 + commands: + - "bash .buildkite/scripts/build-macos-wheel.sh" + - "mkdir -p artifacts/transfer" + - "basename artifacts/dist/*.whl > artifacts/transfer/wheel.name" + - "shasum -a 256 artifacts/dist/*.whl > artifacts/transfer/wheel.sha256" + - "split -b 1m artifacts/dist/*.whl artifacts/transfer/wheel.part." + env: + BUILDKITE_ARTIFACT_UPLOAD_CONCURRENCY: "1" + BUILDKITE_NO_HTTP2: "true" + artifact_paths: + - "artifacts/transfer/*" + + - label: "Upload wheel - macOS arm64 - CPU" + depends_on: build-wheel-macos-arm64-cpu + id: upload-wheel-macos-arm64-cpu + agents: + queue: small_cpu_queue_release + timeout_in_minutes: 15 + commands: + - 'buildkite-agent artifact download "artifacts/transfer/*" .' + - "mkdir -p artifacts/dist artifacts/reassembled" + - 'wheel_name=$$(cat artifacts/transfer/wheel.name)' + - '[[ "$$wheel_name" =~ ^[A-Za-z0-9][A-Za-z0-9._+-]*\.whl$$ && "$$wheel_name" != *..* ]]' + - 'expected_sha=$$(awk ''{print $$1}'' artifacts/transfer/wheel.sha256)' + - '[[ "$$expected_sha" =~ ^[0-9a-f]{64}$$ ]]' + - 'cat artifacts/transfer/wheel.part.* > artifacts/reassembled/wheel' + - 'actual_sha=$$(shasum -a 256 artifacts/reassembled/wheel | awk ''{print $$1}'')' + - '[[ "$$actual_sha" == "$$expected_sha" ]]' + - 'mv artifacts/reassembled/wheel "artifacts/dist/$$wheel_name"' + - "aws sts get-caller-identity" + - "VLLM_WHEEL_PLATFORM=macos bash .buildkite/scripts/upload-nightly-wheels.sh" + - 'bash .buildkite/scripts/annotate-build-artifact.sh "$$BUILDKITE_LABEL" "s3://vllm-wheels/$$BUILDKITE_COMMIT/$(cd artifacts/dist && echo *.whl)"' + plugins: + - aws-assume-role-with-web-identity#v1.6.0: + role-arn: arn:aws:iam::936637512419:role/vllm-release-macos-wheel-uploader + region: us-west-2 + - label: "Build wheel - x86_64 - CUDA 12.9" depends_on: ~ id: build-wheel-x86-cuda-12-9 diff --git a/.buildkite/scripts/build-macos-wheel.sh b/.buildkite/scripts/build-macos-wheel.sh new file mode 100755 index 0000000000..9e1719b793 --- /dev/null +++ b/.buildkite/scripts/build-macos-wheel.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright contributors to the vLLM project +# +# Build the macOS arm64 CPU wheel natively on a macOS agent (the `macmini` +# queue) into artifacts/dist/ for upload-nightly-wheels.sh. + +set -euo pipefail + +# The Rust frontend build needs protoc. +if ! command -v protoc >/dev/null 2>&1; then + brew install protobuf +fi + +# upload-nightly-wheels.sh expects exactly one wheel. +rm -rf artifacts/dist +mkdir -p artifacts/dist + +export VLLM_TARGET_DEVICE=cpu +export VLLM_REQUIRE_RUST_FRONTEND=1 +export MACOSX_DEPLOYMENT_TARGET=11.0 +# uv's CPython is universal2; force an arm64-only build and tag so the wheel +# isn't mislabelled universal2 and installed on Intel Macs where import fails. +export ARCHFLAGS="-arch arm64" +export _PYTHON_HOST_PLATFORM="macosx-11.0-arm64" +export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-4}" + +uv venv --python 3.12 +uv pip install -r requirements/build/cpu.txt --index-strategy unsafe-best-match +uv build --wheel --no-build-isolation -o artifacts/dist + +ls -l artifacts/dist/*.whl diff --git a/.buildkite/scripts/upload-nightly-wheels.sh b/.buildkite/scripts/upload-nightly-wheels.sh index 8cef319088..b9da039607 100644 --- a/.buildkite/scripts/upload-nightly-wheels.sh +++ b/.buildkite/scripts/upload-nightly-wheels.sh @@ -6,8 +6,14 @@ set -ex # manylinux platform tag with auditwheel. # Index generation is handled separately by generate-and-upload-nightly-index.sh. -# shellcheck source=lib/manylinux.sh -source .buildkite/scripts/lib/manylinux.sh +# auditwheel is Linux-only; macOS wheels already carry a valid tag, so skip the +# manylinux retag for them. +WHEEL_PLATFORM="${VLLM_WHEEL_PLATFORM:-linux}" + +if [[ "$WHEEL_PLATFORM" == "linux" ]]; then + # shellcheck source=lib/manylinux.sh + source .buildkite/scripts/lib/manylinux.sh +fi BUCKET="vllm-wheels" SUBPATH=$BUILDKITE_COMMIT @@ -27,8 +33,10 @@ wheel="${wheel_files[0]}" # ========= detect manylinux tag and rename ========== -wheel="$(apply_manylinux_tag "$wheel")" -echo "Renamed wheel to: $wheel" +if [[ "$WHEEL_PLATFORM" == "linux" ]]; then + wheel="$(apply_manylinux_tag "$wheel")" + echo "Renamed wheel to: $wheel" +fi # Extract the version from the wheel version=$(unzip -p "$wheel" '**/METADATA' | grep '^Version: ' | cut -d' ' -f2) diff --git a/csrc/cpu/torch_bindings.cpp b/csrc/cpu/torch_bindings.cpp index 50ce23d89b..88a593725e 100644 --- a/csrc/cpu/torch_bindings.cpp +++ b/csrc/cpu/torch_bindings.cpp @@ -570,7 +570,8 @@ TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) { #endif // fused moe -#if defined(__AVX512F__) || (defined(ARM_BF16_SUPPORT)) +#if defined(__AVX512F__) || \ + (defined(__aarch64__) && !defined(__APPLE__) && defined(ARM_BF16_SUPPORT)) ops.def( "prepack_moe_weight(Tensor weight, Tensor(a1!) packed_weight, str isa) " "-> ()"); @@ -581,7 +582,7 @@ TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) { "bool skip_weighted, " "str act, str isa) -> ()"); ops.impl("cpu_fused_moe", torch::kCPU, &cpu_fused_moe); -#endif // #if defined(__AVX512F__) || (defined(ARM_BF16_SUPPORT)) +#endif ops.def( "mla_decode_kvcache(" " Tensor! out, Tensor query, Tensor kv_cache,"