Repository navigation
metal : one backend device per physical GPU, with cross-device copy guard - #28568
Open
brainiac13 wants to merge 1 commit into
Open
brainiac13 wants to merge 1 commit into
brainiac13 wants to merge 1 commit into
Conversation
|
Hi @brainiac13, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
brainiac13
marked this pull request as ready for review
September 7, 2026 17:59
…uard cross-device tensor copies fall back to host staging, since private buffers are only accessible by the device that created them; concurrent dispatch is disabled on non-Apple GPUs (issue ggml-org#25866) Assisted-by: Codex
brainiac13
force-pushed
the
metal-multi-gpu
branch
from
October 26, 2026 21:24
a23ea69 to
70f12ef
Compare
Open
6 tasks
This branch has not been deployed
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.
Overview
This fixes multi-GPU selection in the Metal backend on Macs with more than one physical GPU, for example an Intel Mac with an eGPU.
Previously, all Metal backend devices ended up on the system default GPU, which meant that adding multiple MTL devices didn’t actually allow using multiple physical GPUs.
With this change, backend device indices are mapped to the available physical GPUs, sorted by VRAM (largest first). So MTL0 uses the GPU with the most VRAM, MTL1 the next one, etc.
Existing behavior is kept for GGML_METAL_DEVICES and for device indices that don’t map to a physical GPU. Those continue to use virtual devices on the default GPU.
This also makes it possible to split layers across physical GPUs, for example:
-dev MTL0,MTL1
Tensor copies between different physical GPUs use the host staging path. Metal private buffers can’t be accessed directly from a GPU other than the one that created them.
I also disabled concurrent dispatch on non-Apple GPU families as a workaround for #25866.
Fixes #28565
Additional information
Tested on macOS 26.5.1 on a 2019 Intel MacBook Pro with:
The branch has been rebased onto current master.
Benchmarks with Gemma 4 12B UD-Q4_K_XL (pp / tg, t/s):
There are two limitations I ran into while testing that appear to be unrelated to this change:
Requirements