From 237ac976982e3efa4ae4339b1fe9344c81316b28 Mon Sep 17 00:00:00 2001 From: Artur Skowronski Date: Tue, 7 Apr 2026 23:20:30 +0200 Subject: [PATCH] feat: add Apple Metal backend support to llama-tornado launcher Add --metal flag to enable running GPULlama3 with TornadoVM's Metal backend on macOS. This requires TornadoVM 4.0+ which ships the Metal driver (tornado.drivers.metal). Tested on Apple M1 Pro with TornadoVM 4.0.0-jdk21 Metal SDK. --- llama-tornado | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/llama-tornado b/llama-tornado index 57a50f1c..a49542f7 100755 --- a/llama-tornado +++ b/llama-tornado @@ -19,6 +19,7 @@ from enum import Enum class Backend(Enum): OPENCL = "opencl" PTX = "ptx" + METAL = "metal" class LlamaRunner: @@ -168,6 +169,14 @@ class LlamaRunner: "ALL-SYSTEM,jdk.incubator.vector,tornado.runtime,tornado.annotation,tornado.drivers.common,tornado.drivers.ptx", ] ) + elif args.backend == Backend.METAL: + module_config.extend( + [ + f"@{self.tornado_sdk}/etc/exportLists/metal-exports", + "--add-modules", + "ALL-SYSTEM,jdk.incubator.vector,tornado.runtime,tornado.annotation,tornado.drivers.common,tornado.drivers.metal", + ] + ) module_config.extend( [ @@ -410,6 +419,13 @@ def create_parser() -> argparse.ArgumentParser: const=Backend.PTX, help="Use PTX/CUDA backend", ) + hw_group.add_argument( + "--metal", + dest="backend", + action="store_const", + const=Backend.METAL, + help="Use Apple Metal backend (macOS only, requires TornadoVM 4.0+)", + ) hw_group.add_argument("--gpu-memory", default="14GB", help="GPU memory allocation") hw_group.add_argument("--heap-min", default="20g", help="Minimum JVM heap size") hw_group.add_argument("--heap-max", default="20g", help="Maximum JVM heap size")