Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]
include:
# Apple silicon: the Metal device detection and macOS paths.
- os: macos-latest
python-version: "3.12"
steps:
- uses: actions/checkout@v4

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ omni model's components count as the run's own models; anything else loaded
makes the run invalid, as for every other run. Results go to
`results/<profile>/omni/`.

## Apple silicon

Lemonade reports an Apple GPU as a `metal` device. It shares memory with the
CPU, so LemonMatrix treats it as an integrated GPU: use `--engine igpu` with a
`-metal` backend (`llamacpp-metal`, `whispercpp-metal`, `sd-cpp-metal`):

```bash
lemonmatrix run --profile my-mac \
--model Qwen3-1.7B-GGUF --model-class dense --quant Q4_0 \
--context-length 4096 --engine igpu --backend llamacpp-metal \
--power-state plugged
```

## Ryzen AI NPU and hybrid runs

Lemonade's `ryzenai-llm` recipe has one backend, `ryzenai-llm-npu`, and the
Expand Down
5 changes: 4 additions & 1 deletion src/lemonmatrix/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,11 @@ def available_compute_engines(system_info: dict) -> list[str]:
has_igpu = any(g.get("available") and is_integrated_gpu(g) for g in amd_gpus)
has_amd_dgpu = any(g.get("available") and not is_integrated_gpu(g) for g in amd_gpus)
has_nvidia_dgpu = any(g.get("available") for g in _as_list(devices.get("nvidia_gpu")))
# Apple silicon: Lemonade reports the GPU under "metal". It shares memory
# with the CPU, so it counts as an integrated GPU.
has_metal_igpu = any(g.get("available") for g in _as_list(devices.get("metal")))

if has_igpu:
if has_igpu or has_metal_igpu:
engines.append("igpu")
if has_amd_dgpu or has_nvidia_dgpu:
engines.append("dgpu")
Expand Down
14 changes: 14 additions & 0 deletions src/lemonmatrix/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
rather than crashing. Callers can override anything discovery got wrong via
CLI flags. Each amd_gpu entry carries an "integrated" flag (seen on 11.6 and
on 2026.47); see is_integrated_gpu below for the fallback when it is absent.
On Apple silicon (Lemonade 2026.47.1, macOS 26) the GPU is a "metal" entry
under "devices"; it is treated as an integrated GPU.
"""

from __future__ import annotations
Expand Down Expand Up @@ -121,6 +123,18 @@ def _classify_gpus(devices: dict) -> tuple[str | None, str | None, str | None, s
igpu_families.append(family)
driver_version = driver_version or gpu.get("driver_version")

# Apple silicon reports its GPU under "metal". It shares memory with the
# CPU, so it is an integrated GPU.
metal_gpus = devices.get("metal") or []
if isinstance(metal_gpus, dict):
metal_gpus = [metal_gpus]
for gpu in metal_gpus:
name = gpu.get("name")
if not gpu.get("available", True) or not name:
continue
igpu_names.append(name)
driver_version = driver_version or gpu.get("driver_version")

nvidia_gpus = devices.get("nvidia_gpu") or []
if isinstance(nvidia_gpus, dict):
nvidia_gpus = [nvidia_gpus]
Expand Down
27 changes: 27 additions & 0 deletions tests/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,30 @@ def test_parse_quantization_keeps_plain_and_custom_variants():

def test_parse_quantization_returns_nothing_for_onnx_npu_checkpoints():
assert parse_quantization("AMD-OLMo-1B-SFT-DPO-Hybrid", "amd/AMD-OLMo-1B-SFT-DPO-onnx-ryzenai-1.7-hybrid") == ""


# Real devices block from Lemonade 2026.47.1 on a MacBook with an Apple M5.
APPLE_SYSTEM_INFO = {
"devices": {
"amd_gpu": [],
"amd_npu": {"available": False, "name": "Apple M5"},
"cpu": {"available": True, "name": "Apple M5", "family": "arm64"},
"metal": {
"available": True,
"driver_version": "Metal",
"family": "metal",
"name": "Apple M5",
"vram_gb": 24.96,
},
"nvidia_gpu": [{"available": False, "name": ""}],
},
}


def test_available_compute_engines_treats_apple_metal_as_igpu():
assert available_compute_engines(APPLE_SYSTEM_INFO) == ["cpu", "igpu"]


def test_available_compute_engines_ignores_unavailable_metal():
info = {"devices": {"cpu": {"available": True}, "metal": {"available": False, "name": ""}}}
assert available_compute_engines(info) == ["cpu"]
36 changes: 36 additions & 0 deletions tests/test_profile_real_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,39 @@ def test_discover_environment_ignores_unavailable_npu_with_bogus_name():
# field with the CPU name -- must not be mistaken for a real NPU.
environment, _ = discover_environment(_StubClient(REAL_SYSTEM_INFO, REAL_HEALTH))
assert "npu" not in environment


APPLE_SYSTEM_INFO = {
"OS Version": "macOS 26.7.3 Darwin Kernel Version 25.6.0",
"Physical Memory": "32 GB",
"Processor": "Apple M5",
"devices": {
"amd_gpu": [],
"amd_npu": {
"available": False,
"error": "NPU not supported on macOS (Ryzen AI NPUs are Windows/Linux only)",
"family": "",
"name": "Apple M5",
"utilization": 0.0,
},
"cpu": {"available": True, "cores": 10, "family": "arm64", "name": "Apple M5", "threads": 10},
"metal": {
"available": True,
"driver_version": "Metal",
"family": "metal",
"name": "Apple M5",
"vram_gb": 24.96,
},
"nvidia_gpu": [{"available": False, "error": "NVIDIA GPUs not detected on macOS", "name": ""}],
},
}

APPLE_HEALTH = {"status": "ok", "version": "2026.47.1", "model_loaded": None, "all_models_loaded": []}


def test_discover_environment_reports_apple_metal_gpu_as_igpu():
environment, _ = discover_environment(_StubClient(APPLE_SYSTEM_INFO, APPLE_HEALTH))
assert environment["igpu"] == "Apple M5"
assert "dgpu" not in environment
assert environment["driver_version"] == "Metal"
assert environment["lemonade_version"] == "2026.47.1"
Loading