Repository navigation
macos: serve on the Apple Silicon GPU through vllm-metal - #43
Merged
Merged
Conversation
vllm-helper assumed a Mac runs vLLM's CPU backend. With the vllm-metal plugin installed beside VLLM_BIN it now treats the Mac as a GPU box: - detect vllm_metal and read the Metal working set from MLX - size the budget, KV plan and the 0.9 profile default against the working set, and skip the CPU backend's free-RAM clamp - find the Homebrew and install-script vllm in setup, keep the stable opt path, and follow the symlink to the right python - run system-scope LaunchDaemons as the installing user, so a headless Mac serves at boot without a login session - add 'metal-limit' to raise iogpu.wired_limit_mb and reapply it at boot Tested on an M5 Ultra Mac Studio (256 GB, macOS 27, vllm-metal 0.32.0). Coder Agents generated.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved defects affect Metal memory sizing and reporting, service-scope selection, executable recovery, legacy-daemon migration, and persistence of manually raised wired-memory limits.
7 open issues
Adequate manual wired-memory limits are not persisted across reboots · New Start registers the Metal probe from the wrong executable config · New Repeated setup does not populate a missing VLLM_BIN · New Metal pool usage is calculated against host RAM · New Metal cache planning ignores the fixed KV-cache memory override · New Adopting a daemon with the same label fails to save system scope · New Existing system plists are not migrated to the new identity settings · New
What changed in this PR
Adds Apple Silicon GPU serving through vllm-metal to vllm-helper’s existing profile and service management, while preserving the macOS CPU fallback.
Changes:
- Detects vllm-metal and uses its Metal working set for memory budgets and profile defaults.
- Improves Homebrew discovery and headless LaunchDaemon support.
- Adds persistent GPU wired-memory limits, diagnostics, tests, and documentation.
| File | Description |
|---|---|
| README.md | Advertises Apple Silicon GPU support. |
| internal/vllm/metal.go | Probes plugin availability and Metal memory. |
| internal/vllm/metal_internal_test.go | Tests probe parsing and interpreter discovery. |
| internal/vllm/capabilities.go | Resolves Python beside symlinked vLLM executables. |
| internal/service/service_darwin.go | Adds daemon identity settings and headless diagnostics. |
| internal/service/service_darwin_internal_test.go | Tests daemon user and home settings. |
| internal/profile/profile.go | Selects Metal-specific memory defaults. |
| internal/profile/profile_test.go | Tests Metal profile defaults. |
| internal/detect/process_darwin.go | Detects system-domain launchd services. |
| internal/detect/procargs_darwin_internal_test.go | Tests system-service label parsing. |
| internal/detect/plan.go | Plans cache memory against the Metal working set. |
| internal/detect/metal.go | Registers and caches lazy backend probes. |
| internal/detect/metal_internal_test.go | Tests Metal budgeting, planning, and probe isolation. |
| internal/detect/hardware.go | Exposes Metal backend and memory-pool information. |
| internal/detect/budget.go | Adds Metal-specific model budgeting. |
| internal/control/gguf.go | Reuses shared interpreter discovery. |
| internal/cli/vllmbin.go | Discovers vLLM and preserves stable Homebrew paths. |
| internal/cli/vllmbin_other.go | Supplies non-macOS discovery behavior. |
| internal/cli/vllmbin_internal_test.go | Tests executable-path normalization. |
| internal/cli/vllmbin_darwin.go | Adds macOS install locations and hints. |
| internal/cli/toolchain_darwin.go | Skips source-build checks under Metal. |
| internal/cli/start.go | Waits for the configured wired-memory limit. |
| internal/cli/setup.go | Detects the backend before sizing memory. |
| internal/cli/root.go | Registers backend probes and metal-limit. |
| internal/cli/root_internal_test.go | Updates the expected command set. |
| internal/cli/metallimit.go | Defines limit validation, reporting, and polling. |
| internal/cli/metallimit_other.go | Rejects limit changes outside macOS. |
| internal/cli/metallimit_other_internal_test.go | Tests the platform restriction. |
| internal/cli/metallimit_internal_test.go | Tests limits, reports, plist output, and waiting. |
| internal/cli/metallimit_darwin.go | Applies and persists macOS wired-memory limits. |
| internal/cli/metal_other.go | Leaves backend registration inactive outside macOS. |
| internal/cli/metal_darwin.go | Connects configured vLLM to Metal probes. |
| internal/cli/memfit_darwin.go | Bypasses CPU memory clamping under Metal. |
| internal/cli/memfit_darwin_internal_test.go | Tests preservation of Metal memory settings. |
| internal/cli/detectcmds.go | Displays backend and wired-limit diagnostics. |
| docs/troubleshooting.md | Explains Metal memory behavior and service logs. |
| docs/reference/cli/metal-limit.md | Documents the new command. |
| docs/reference/cli.md | Adds metal-limit to the command index. |
| docs/README.md | Updates the supported-platform overview. |
| docs/profiles.md | Documents backend-specific memory defaults. |
| docs/manifest.json | Updates macOS and command navigation. |
| docs/macos.md | Covers GPU installation, headless serving, and memory limits. |
| docs/install.md | Documents Metal installation and configuration. |
| CHANGELOG.md | Records GPU support and macOS service fixes. |
Review effort: Balanced
- metal-limit --set auto persists a live cap that is already high enough when config.env or the boot-time daemon does not carry it - start registers the vllm-metal probe for the VLLM_BIN it execs, which a profile can override, not config.env's - setup fills in an empty VLLM_BIN on a rerun once a vllm is found - the web panel shows Metal usage as not measured instead of host RAM against the smaller working set - the metal probe reads whether vllm-metal honors --kv-cache-memory-bytes (0.32.0 ignores it); without it the plan leaves the KV cache to vllm-metal and says so - adopt compares the scope as well as the name of the unit it finds - docs: how to replace a LaunchDaemon that an older release installed as root, and which vllm-metal builds honor KV_CACHE_MEMORY_BYTES Coder Agents generated.
This was referenced Oct 30, 2026
Coder Agents generated.
Brings in the providers seam and the llm-helper rename (#46) and AGENTS.md (#49). Resolutions: - setup: lookBin finds vLLM through findVLLM, so the Homebrew opt path and the install-script venv are kept; lookVLLM is gone. The Metal probe and vllmInstallHint apply only to the vllm provider, and fillMissingVLLMBin leaves a config whose PROVIDER names another server alone. - start: only a vllm profile's binary is probed for vllm-metal, so mlx_lm.server and llama-server are never asked; awaitWiredLimit still runs for every provider, since the wired limit is the GPU's. - doctor: the backend line, with its install-vllm-metal hint, shows only when new profiles use vLLM. - root: keeps the Metal probe pre-run, with main's cmdName version template. - docs: #43's text under the llm-helper name, with main's provider rows and entries kept; CLI reference and manifest regenerated.
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.

closes #44
vllm-helper on a Mac assumed vLLM's CPU backend. This makes it serve on the Apple Silicon GPU through vllm-metal (vLLM + MLX), so a Mac Studio works about as well as a DGX Spark does. The CPU backend still works if vllm-metal isn't installed.
What changes
VLLM_BINifvllm_metalis importable, and reads the Metal working set from MLX.setupanddoctorsay which backend is in use.--gpu-memory-utilizationis a share of the Metal working set, not RAM. New profiles default to0.9. The budget and KV plan use the working set. The CPU backend's free-RAM clamp is skipped, since vllm-metal sizes its own cache.vllmeven when it is not onPATH. A Cellar path is saved as the stableoptpath, sobrew upgradedoes not breakVLLM_BIN. The python lookup follows the symlink, so it finds the formula's python and not Homebrew's.SERVICE_SCOPE=systeminstalls a LaunchDaemon. It now runs as the installing user (it used to run as root and read root's config and cache), starts at boot, andstatusreads it without sudo.metal-limit. macOS lets the GPU wire only part of RAM (239 of 256 GiB here).vllm-helper metal-limit --set autoraisesiogpu.wired_limit_mbto RAM minus 16 GiB. It also installs a boot daemon to reapply it, because the sysctl resets on reboot.startwaits up to 60s for the limit before it starts vLLM.doctorshows the limit and suggests a raise.docs/macos.mdrewritten), CHANGELOG and the CLI reference are updated.Tested on the Mac Studio
M5 Ultra, 256 GB, macOS 27, vllm-metal 0.32.0 from Homebrew, system-scope LaunchDaemon:
setupfound/opt/homebrew/opt/vllm-metal/libexec/bin/vllmand reported a 239 GB working set and a ~194 GB budget.vllm-helper new mlx-community/Qwen3-Coder-30B-A3B-Instruct-8bit: served on the GPU (MLX device set to: Device(gpu, 0)), ~85 tok/s single stream. Tool calls work with--tool-call-parser qwen3_coder.metal-limit --set autoraised the working set to 240 GiB. After a reboot with nobody logged in, the limit came back and the server came back healthy.go test ./...passes natively on the Mac.go test -race ./..., bothgo vets, gofmt and prettier pass on Linux.~/bin/vllm-helper.pr43. The Qwen profile still serves through vllm-metal from that build, andllm-helper switchbetween Qwen and DeepSeek took about 20 s each way.DeepSeek V4 Flash does not run on vllm-metal
I tried this first, since the Spark pair runs it. It is blocked upstream, not by vllm-helper:
deepseek_v4. The model file is in the open Add DeepSeek-V4-Flash without MTP (yet) ml-explore/mlx-lm#1797, which has conflicts.mlx-community/DeepSeek-V4-Flash-4bit(151 GB) loads. But the first request fails in vllm-metal's paged attention ('OffsetCache' object has no attribute 'update_and_fetch'). vllm-metal does not handle V4's compressed sparse attention.So I left it out of vllm-helper. A model-specific patch does not belong here. The docs list it as an example of a model vllm-metal must support first, and now also say that llama.cpp runs it.
It does run on the same Mac through llama.cpp, with #46's llama.cpp provider and no code changes there:
unsloth/DeepSeek-V4-Flash-Vision-Exp-GGUF:UD-Q8_K_XLplus its vision file, about 33 tok/s writing and 825 tok/s reading prompts, 161.8 of 240 GiB of GPU memory.Known issues
--api-key <key>tovllm serve, sopsshows the key to every user on the machine. This is how main works today, and this PR doesn't change it. vLLM also readsVLLM_API_KEYfrom its environment, whichstartalready sets, so the fix looks small. providers: serve with vLLM, mlx-lm or llama.cpp, and rename to llm-helper #46 fixes the same leak for llama.cpp.MERGE_SYSTEM_MODELS_JSON). That is live but not yet approved by @bpmct, and it is not part of this PR.Decision log
VLLM_BINlazily, once per process, and only on darwin. On Linux nothing changes. The Spark budget and plan numbers are the same as before.find_specused on everystart. The working set imports MLX, and only budget, plan, doctor andmetal-limituse it. This way a slow MLX import at boot cannot silently sendstartinto the CPU clamp.SERVICE_SCOPE=system.hfvariant labels, and hiding CUDA-only flags from model cards on Metal. Neither blocked an MLX checkpoint in testing.Generated by Coder Agents on behalf of @bpmct.