The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(pm): llama.cpp CUDA on Linux arm64; bundle libgomp for Linux engines
emozilla361963828d71
diff --git a/apps/desktop/electron/feature-flags.test.ts b/apps/desktop/electron/feature-flags.test.tsindex 6e9144051dd..09f9022edaf 100644--- a/apps/desktop/electron/feature-flags.test.ts+++ b/apps/desktop/electron/feature-flags.test.ts@@ -1,6 +1,6 @@// feature-flags.ts is the single resolver for which gated surfaces are on in// this artifact. These tests pin the flag table: local models ship on Windows,-// macOS and Linux x64 on every channel; elsewhere the launch argv opts in with+// macOS and Linux x64/arm64 on every channel; elsewhere the launch argv opts in with// --local.import assert from 'node:assert/strict'@@ -11,7 +11,7 @@ import { isCanaryTag, resolveFeatureFlags } from './feature-flags'const shipsLocalModels: boolean =process.platform === 'win32' ||process.platform === 'darwin' ||- (process.platform === 'linux' && process.arch === 'x64')+ (process.platform === 'linux' && (process.arch === 'x64' || process.arch === 'arm64'))test('without --local, local models follow the platform on every channel', () => {for (const canary of [false, true]) {diff --git a/apps/desktop/electron/feature-flags.ts b/apps/desktop/electron/feature-flags.tsindex a3b80923b25..648f310b1f9 100644--- a/apps/desktop/electron/feature-flags.ts+++ b/apps/desktop/electron/feature-flags.ts@@ -3,7 +3,7 @@ const featureFlags = {localModels: ({ argv }) =>process.platform === 'win32' ||process.platform === 'darwin' ||- (process.platform === 'linux' && process.arch === 'x64') ||+ (process.platform === 'linux' && (process.arch === 'x64' || process.arch === 'arm64')) ||argv.includes('--local')} satisfies Record<string, (args: FeatureFlagInput) => boolean>diff --git a/hermes_cli/local_runtime/binaries.py b/hermes_cli/local_runtime/binaries.pyindex 43b0e73ee02..8a348768a17 100644--- a/hermes_cli/local_runtime/binaries.py+++ b/hermes_cli/local_runtime/binaries.py@@ -153,8 +153,12 @@ def _legacy_installs(backend: str) -> list[tuple[str, Path, dict]]:def _legacy_artifacts(package, version: str, target: str, assets: dict) -> list[str] | None:- """The manifest's archive digests in PM's archive order, or None when one is missing."""- shas = [assets.get(url.rsplit("/", 1)[-1]) for url in package.fetch_urls(version, target)]+ """The manifest's archive digests in PM's archive order, or None when one is missing.++ The pre-PM installer fetched only llama.cpp's own release assets. On Linux PM also pins the+ libgomp .deb, so an adopted engine there records fewer archives than the lock and counts as+ outdated: usable now (its manifest proves it ran against the host's libgomp), update offered."""+ shas = [assets.get(name) for name in package._asset_names(version, target)]if not shas or not all(isinstance(sha, str) and _SHA256.fullmatch(sha) for sha in shas):return Nonereturn shasdiff --git a/pm/lock.json b/pm/lock.jsonindex 65ff7fe9c2e..e1153496786 100644--- a/pm/lock.json+++ b/pm/lock.json@@ -323,14 +323,26 @@"sha256": "305f0e3a17d2c01eb205cd0a62128357f1ec3b55329cb084d94e5ec0115d7a3b","url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-macos-x64.tar.gz"},- "linux-arm64": {- "sha256": "4aeda6fe68831547e49b7fa87607383ca5352b3d72ca5f70d52ed265f58c131f",- "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-arm64.tar.gz"- },- "linux-x64": {- "sha256": "c150306eb16b5ab696f76a8bdf810c35fd98a24e82158742e6fa28f420ff8410",- "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-x64.tar.gz"- },+ "linux-arm64": [+ {+ "sha256": "4aeda6fe68831547e49b7fa87607383ca5352b3d72ca5f70d52ed265f58c131f",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-arm64.tar.gz"+ },+ {+ "sha256": "3f777eac64c87e2db843675b229efd16efe2ac1ae977318d687b39b812747863",+ "url": "https://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_arm64.deb"+ }+ ],+ "linux-x64": [+ {+ "sha256": "c150306eb16b5ab696f76a8bdf810c35fd98a24e82158742e6fa28f420ff8410",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-x64.tar.gz"+ },+ {+ "sha256": "cc2ca1193d2c11d7383bdb03dd333cc621d128237b82dafeb8d7f2bd8302f3dd",+ "url": "https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_amd64.deb"+ }+ ],"win32-arm64": {"sha256": "1727d241f3bf6d27360e984e851cf013928fd655bf89f8628e70da027f377b7d","url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-win-cpu-arm64.zip"@@ -344,6 +356,20 @@},"llamacpp-cuda": {"artifacts": {+ "linux-arm64": [+ {+ "sha256": "4e00496ab6cdee9c00afb11de3cb9d10f9da7e17147d8ed14ca3af05209b400f",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-cuda-13.4-arm64.tar.gz"+ },+ {+ "sha256": "7f46057efcba6338c58ed9f91c06f268c290f3a228fdbdd4bea229dd60b0e094",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/cudart-llama-b11146-bin-ubuntu-cuda-13.4-arm64.tar.gz"+ },+ {+ "sha256": "3f777eac64c87e2db843675b229efd16efe2ac1ae977318d687b39b812747863",+ "url": "https://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_arm64.deb"+ }+ ],"linux-x64": [{"sha256": "1603d9c00a4b6eac8298c5c7868cdb080a3ac31948ab1e457441d71ce274dd7e",@@ -352,6 +378,10 @@{"sha256": "7c2af505f8b26ecd3707ab7723fa985fee1df233b7c1d60e5e17724b536d15bb","url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/cudart-llama-b11146-bin-ubuntu-cuda-13.4-x64.tar.gz"+ },+ {+ "sha256": "cc2ca1193d2c11d7383bdb03dd333cc621d128237b82dafeb8d7f2bd8302f3dd",+ "url": "https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_amd64.deb"}],"win32-arm64": [@@ -379,10 +409,16 @@},"llamacpp-hip": {"artifacts": {- "linux-x64": {- "sha256": "50e79dc559a11af3ea59391d416e9a704a715ac6be94352dbba710782c5dd7d1",- "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-rocm-10.0-x64.tar.gz"- },+ "linux-x64": [+ {+ "sha256": "50e79dc559a11af3ea59391d416e9a704a715ac6be94352dbba710782c5dd7d1",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-rocm-10.0-x64.tar.gz"+ },+ {+ "sha256": "cc2ca1193d2c11d7383bdb03dd333cc621d128237b82dafeb8d7f2bd8302f3dd",+ "url": "https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_amd64.deb"+ }+ ],"win32-x64": {"sha256": "5dee283ec0fd5f38f29df0929769a07266ac6047f74381c153eb54b441e4ef99","url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-win-rocm-10.0-x64.zip"@@ -405,14 +441,26 @@},"llamacpp-vulkan": {"artifacts": {- "linux-arm64": {- "sha256": "5dcebe3ecbcb43a1ed85e3284453f9edf54dcca833e1cb1f54b4022b753c1da5",- "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-vulkan-arm64.tar.gz"- },- "linux-x64": {- "sha256": "d3ce40fce7403cc93bcf5718fc46c6efb61ed9709f8e5d9f10c86bf0e30e8fb3",- "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-vulkan-x64.tar.gz"- },+ "linux-arm64": [+ {+ "sha256": "5dcebe3ecbcb43a1ed85e3284453f9edf54dcca833e1cb1f54b4022b753c1da5",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-vulkan-arm64.tar.gz"+ },+ {+ "sha256": "3f777eac64c87e2db843675b229efd16efe2ac1ae977318d687b39b812747863",+ "url": "https://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_arm64.deb"+ }+ ],+ "linux-x64": [+ {+ "sha256": "d3ce40fce7403cc93bcf5718fc46c6efb61ed9709f8e5d9f10c86bf0e30e8fb3",+ "url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-ubuntu-vulkan-x64.tar.gz"+ },+ {+ "sha256": "cc2ca1193d2c11d7383bdb03dd333cc621d128237b82dafeb8d7f2bd8302f3dd",+ "url": "https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_amd64.deb"+ }+ ],"win32-x64": {"sha256": "55a378aa095b466979d85075234f66d7655c7a7483222af0c006c0e55b4d7bd6","url": "https://github.com/ggml-org/llama.cpp/releases/download/b11146/llama-b11146-bin-win-vulkan-x64.zip"diff --git a/pm/package.py b/pm/package.pyindex 37ff1205af7..a94c0730120 100644--- a/pm/package.py+++ b/pm/package.py@@ -190,74 +190,7 @@ class DebPackage(Package):prefix_rel: str = "data/data/com.termux/files/usr"def unpack(self, archive: Path, staged: Path, target: str) -> None:- raw = archive.read_bytes()- if raw[:8] != b"!<arch>\n":- raise InstallError(self.name, f"not an ar archive: {archive.name}")- payload = None- offset = 8- while offset + 60 <= len(raw):- hdr = raw[offset:offset + 60]- member = hdr[0:16].decode("ascii", "replace").rstrip()- try:- size = int(hdr[48:58].decode("ascii", "replace").strip())- except ValueError:- raise InstallError(self.name, f"bad ar member size in {archive.name}")- start = offset + 60- data = raw[start:start + size]- if member.startswith("data.tar"):- if member.endswith((".zst", ".lzma")):- raise InstallError(- self.name,- f"unsupported data compression {member} in {archive.name}",- )- payload = data- break- offset = start + size + (size % 2)- if payload is None:- raise InstallError(self.name, f"no data.tar member in {archive.name}")- self._untar_payload(payload, staged)-- def _untar_payload(self, payload: bytes, staged: Path) -> None:- import io- import stat as stat_mod- import tarfile-- from pm.store import extract_tar-- try:- extract_tar(io.BytesIO(payload), staged)- except tarfile.FilterError as exc:- member = exc.tarinfo.name if exc.tarinfo is not None else "?"- raise InstallError(self.name, f"unsafe member {member!r}: {exc}") from exc- real_staged = os.path.realpath(staged)- # Termux debs carry owner-only modes across the whole tree (700 on- # binaries n libs, 600 on stdlib .py files) -- postinst would- # normalize on a real phone, but pm extracts without postinst, and- # any uid-hostile mode breaks non-owner consumers: the dynamic- # linker cannot read a 700 lib, the interpreter cannot read a 600- # encoding module. Normalize EVERYTHING: a+r on all regular files,- # a+X on anything that was executable. The deb's bytes are pinned- # by digest; modes are not part of the pin. Symlinks are skipped:- # chmod through one would follow it outside the staged tree.- for root, dirs, files in os.walk(staged):- dirs[:] = [d for d in dirs if not (Path(root) / d).is_symlink()]- for name in files:- f = Path(root) / name- try:- mode = f.lstat().st_mode- except OSError:- continue- if stat_mod.S_ISLNK(mode):- continue- if not os.path.realpath(f).startswith(real_staged + os.sep):- continue- wanted = 0o644 | (0o111 if mode & 0o111 else 0)- try:- f.chmod(wanted)- except OSError:- # Best effort by design: a file we cannot chmod keeps its- # extracted mode, and verify() still judges the tree.- continue+ unpack_deb(self.name, archive, staged)def verify(self, entry: Path, target: str) -> str:"""'' when the staged tree is plausible on target: the expected@@ -272,6 +205,87 @@ class DebPackage(Package):raise NotImplementedError+def deb_data_tar(name: str, archive: Path) -> bytes:+ """A .deb's data.tar, ready for tarfile. Ubuntu compresses it with zstd+ (default since 21.10), decompressed here with the stdlib module PM's+ 3.14 runtime carries; lzma (the pre-xz format) is refused."""+ raw = archive.read_bytes()+ if raw[:8] != b"!<arch>\n":+ raise InstallError(name, f"not an ar archive: {archive.name}")+ offset = 8+ while offset + 60 <= len(raw):+ hdr = raw[offset:offset + 60]+ member = hdr[0:16].decode("ascii", "replace").rstrip()+ try:+ size = int(hdr[48:58].decode("ascii", "replace").strip())+ except ValueError:+ raise InstallError(name, f"bad ar member size in {archive.name}")+ start = offset + 60+ data = raw[start:start + size]+ if member.startswith("data.tar"):+ if member.endswith(".lzma"):+ raise InstallError(name, f"unsupported data compression {member} in {archive.name}")+ if member.endswith(".zst"):+ try:+ from compression import zstd+ except ImportError:+ raise InstallError(name, f"{member} in {archive.name} needs Python 3.14+ (zstd)")+ return zstd.decompress(data)+ return data+ offset = start + size + (size % 2)+ raise InstallError(name, f"no data.tar member in {archive.name}")+++def unpack_deb(name: str, archive: Path, staged: Path) -> None:+ """Stage a .deb by ar+tar extraction: never dpkg, never package scripts.+ The tar goes through pm.store.extract_tar, the one containment policy for+ every PM tarball (symlinks allowed with in-root targets; devices/fifos refused)."""+ _untar_deb_payload(name, deb_data_tar(name, archive), staged)+++def _untar_deb_payload(name: str, payload: bytes, staged: Path) -> None:+ import io+ import stat as stat_mod+ import tarfile++ from pm.store import extract_tar++ try:+ extract_tar(io.BytesIO(payload), staged)+ except tarfile.FilterError as exc:+ member = exc.tarinfo.name if exc.tarinfo is not None else "?"+ raise InstallError(name, f"unsafe member {member!r}: {exc}") from exc+ real_staged = os.path.realpath(staged)+ # Termux debs carry owner-only modes across the whole tree (700 on+ # binaries n libs, 600 on stdlib .py files) -- postinst would+ # normalize on a real phone, but pm extracts without postinst, and+ # any uid-hostile mode breaks non-owner consumers: the dynamic+ # linker cannot read a 700 lib, the interpreter cannot read a 600+ # encoding module. Normalize EVERYTHING: a+r on all regular files,+ # a+X on anything that was executable. The deb's bytes are pinned+ # by digest; modes are not part of the pin. Symlinks are skipped:+ # chmod through one would follow it outside the staged tree.+ for root, dirs, files in os.walk(staged):+ dirs[:] = [d for d in dirs if not (Path(root) / d).is_symlink()]+ for file_name in files:+ f = Path(root) / file_name+ try:+ mode = f.lstat().st_mode+ except OSError:+ continue+ if stat_mod.S_ISLNK(mode):+ continue+ if not os.path.realpath(f).startswith(real_staged + os.sep):+ continue+ wanted = 0o644 | (0o111 if mode & 0o111 else 0)+ try:+ f.chmod(wanted)+ except OSError:+ # Best effort by design: a file we cannot chmod keeps its+ # extracted mode, and verify() still judges the tree.+ continue++class StatePackage(Package):"""A package that is a STATE of this install (the python venv), not astore entry. Verified by comparing a stamp; made true by apply()."""diff --git a/pm/packages.py b/pm/packages.pyindex dd2d943cc36..a8fcfce6c58 100644--- a/pm/packages.py+++ b/pm/packages.py@@ -19,6 +19,7 @@ from pm.package import (StatePackage,_entry_listing,_probe_reason,+ unpack_deb,)from pm.registry import registerfrom pm.store import ALL_TARGETS, MUSL_TARGETS, Store, current_target, flatten_single_dir, merge_tree@@ -1039,10 +1040,10 @@ class Chromium(Package):class LlamaCpp(BinaryPackage):"""One llama.cpp backend build. Backends are dlopen'd plugins, so a- usable engine is one archive per (target, backend) — plus, for Windows- CUDA, the cudart archive: end users have no CUDA toolkit, and Windows- resolves a DLL from the loading executable's own directory, so those- DLLs must land beside llama-server.exe rather than in a second entry.+ usable engine is one archive per (target, backend) — plus, for CUDA, the+ cudart archive (end users have no CUDA toolkit), and on Linux the libgomp+ .deb. Every library lands beside llama-server: Windows resolves DLLs from+ the executable's directory, and the Linux builds' RUNPATH is $ORIGIN.Backend is a HARDWARE choice, not a target, so each backend is its ownoptional package and the runtime asks for the one this machine can@@ -1061,6 +1062,15 @@ class LlamaCpp(BinaryPackage):backend: str = ""# Release-asset infix per target, or absent where upstream ships none.assets: dict[str, str] = {}+ # Upstream's Linux builds (CPU included) link the system OpenMP runtime,+ # which minimal hosts (WSL, containers) lack, and a normal install never+ # touches the system package manager. Ubuntu 24.04's needs glibc 2.38, the+ # floor those builds already set. The release-pocket file stays in the pool+ # until 24.04's EOL; the artifact mirror serves the pinned bytes after that.+ _LIBGOMP = {+ "linux-x64": "https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_amd64.deb",+ "linux-arm64": "https://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-14/libgomp1_14-20240412-0ubuntu1_arm64.deb",+ }@propertydef gaps(self) -> dict[str, str]: # type: ignore[override]@@ -1078,7 +1088,7 @@ class LlamaCpp(BinaryPackage):return [f"https://github.com/ggml-org/llama.cpp/releases/download/b{version}/{asset}"for asset in self._asset_names(version, target)- ]+ ] + ([self._LIBGOMP[target]] if target in self._LIBGOMP else [])def fetch_url(self, version: str, target: str) -> str:return self.fetch_urls(version, target)[0]@@ -1103,15 +1113,29 @@ class LlamaCpp(BinaryPackage):url.rsplit("/", 1)[-1])+ def unpack(self, archive: Path, staged: Path, target: str) -> None:+ if archive.name.endswith(".deb"):+ unpack_deb(self.name, archive, staged)+ else:+ super().unpack(archive, staged, target)+def stage(self, store: Store, staged: Path, version: str, target: str) -> None:"""Some archives nest the binaries under build/bin; hoist them so- binary_rel is one path for every target."""- if (staged / self.binary(staged, target).name).is_file():- return- found = sorted(staged.rglob(self.binary(staged, target).name))- if not found:- raise InstallError(self.name, "archive contains no llama-server")- merge_tree(found[0].parent, staged)+ binary_rel is one path for every target. The libgomp .deb unpacks+ in its filesystem layout (usr/lib/<triplet>/); only the library+ itself moves beside llama-server."""+ server = self.binary(staged, target).name+ if not (staged / server).is_file():+ found = sorted(staged.rglob(server))+ if not found:+ raise InstallError(self.name, "archive contains no llama-server")+ merge_tree(found[0].parent, staged)+ # The pin decides whether the .deb arrives (test_llamacpp_pins); verify()'s --version+ # probe is what proves the libraries resolve.+ libs = sorted((staged / "usr" / "lib").glob("*/libgomp.so.1"))+ if libs:+ shutil.copyfile(libs[0], staged / "libgomp.so.1")+ shutil.rmtree(staged / "usr")def _github_release_digests(repo: str, tag: str) -> dict[str, str]:@@ -1153,6 +1177,7 @@ class LlamaCppCuda(LlamaCpp):"win32-x64": "win-cuda-13.4-x64","win32-arm64": "win-cuda-13.4-arm64","linux-x64": "ubuntu-cuda-13.4-x64",+ "linux-arm64": "ubuntu-cuda-13.4-arm64",}def _asset_names(self, version: str, target: str) -> list[str]:diff --git a/tests/hermes_cli/test_local_legacy_engine.py b/tests/hermes_cli/test_local_legacy_engine.pyindex 585d02c3505..991e16bd41b 100644--- a/tests/hermes_cli/test_local_legacy_engine.py+++ b/tests/hermes_cli/test_local_legacy_engine.py@@ -12,7 +12,8 @@ import pmfrom pm import pathsfrom pm.lock import Facts, Lockfile-PINNED = ("a" * 64, "c" * 64) # CUDA pins the engine archive plus cudart; CPU pins one archive+# The engine archive, cudart (CUDA only), and the libgomp .deb (Linux only), in PM's archive order.+PINNED = ("a" * 64, "c" * 64, "e" * 64)@pytest.fixture(params=["cpu", "cuda"])@@ -40,12 +41,17 @@ def legacy_env(request, tmp_path, monkeypatch):return home, store, package, target, backend, list(PINNED[:len(urls)])+def legacy_digests(package, target, pinned):+ """What a pre-PM manifest records: llama.cpp's own release assets, never PM's extra archives."""+ return pinned[:len(package._asset_names("10964", target))]++def legacy_install(home, package, target, backend, tag, digests, *, verified=True):install = home / "runtimes" / "llamacpp" / tag / backendinstall.mkdir(parents=True)package.binary(install, target).write_bytes(b"engine " + tag.encode())(install / "ggml-base.dll").write_bytes(b"dll")- names = [url.rsplit("/", 1)[-1] for url in package.fetch_urls(tag.removeprefix("b"), target)]+ names = package._asset_names(tag.removeprefix("b"), target)manifest = {"tag": tag, "backend": backend, "assets": dict(zip(names, digests))}if verified:manifest["verified_version"] = f"version: 0.4.1-dev (build {tag[1:]}, commit 0)"@@ -57,23 +63,27 @@ def test_matching_legacy_engine_moves_into_the_store_as_current(legacy_env):from hermes_cli.local_runtime import binarieshome, store, package, target, backend, pinned = legacy_env- install = legacy_install(home, package, target, backend, "b10964", pinned)+ legacy = legacy_digests(package, target, pinned)+ install = legacy_install(home, package, target, backend, "b10964", legacy)- engine = binaries.installed_engine(backend, allow_outdated=False)+ engine = binaries.installed_engine(backend)entry = store / package.store_entry("10964", target)assert engine == binaries.Engine(backend, "b10964", package.binary(entry, target))assert engine.binary.read_bytes() == b"engine b10964"assert not install.exists() and not install.parent.exists()fact = Facts(store / "facts.json").get(package.name)- assert fact["version"] == "10964" and fact["artifacts"] == pinned+ assert fact["version"] == "10964" and fact["artifacts"] == legacy+ # Current exactly when the legacy install carries every archive PM pins.+ assert (binaries.installed_engine(backend, allow_outdated=False) == engine) == (legacy == pinned)def test_older_legacy_engine_counts_as_installed_but_outdated(legacy_env):from hermes_cli.local_runtime import binarieshome, _, package, target, backend, pinned = legacy_env- legacy_install(home, package, target, backend, "b10679", ["d" * 64, *pinned[1:]])+ legacy_install(home, package, target, backend, "b10679",+ ["d" * 64, *legacy_digests(package, target, pinned)[1:]])assert binaries.installed_engine(backend).tag == "b10679"assert pm.installed_package(package.name) is None # the pane offers the update@@ -84,8 +94,9 @@ def test_newest_legacy_engine_wins_and_older_stays(legacy_env):from hermes_cli.local_runtime import binarieshome, _, package, target, backend, pinned = legacy_env- old = legacy_install(home, package, target, backend, "b10679", ["d" * 64, *pinned[1:]])- legacy_install(home, package, target, backend, "b10964", pinned)+ old = legacy_install(home, package, target, backend, "b10679",+ ["d" * 64, *legacy_digests(package, target, pinned)[1:]])+ legacy_install(home, package, target, backend, "b10964", legacy_digests(package, target, pinned))assert binaries.installed_engine(backend).tag == "b10964"assert old.is_dir()@@ -96,8 +107,9 @@ def test_unverified_or_damaged_legacy_engine_is_left_alone(legacy_env, damage):from hermes_cli.local_runtime import binarieshome, store, package, target, backend, pinned = legacy_env+ legacy = legacy_digests(package, target, pinned)install = legacy_install(home, package, target, backend, "b10964",- ["not-a-digest", *pinned[1:]] if damage == "missing_digest" else pinned,+ ["not-a-digest", *legacy[1:]] if damage == "missing_digest" else legacy,verified=damage != "unverified")manifest = json.loads((install / "manifest.json").read_bytes())if damage == "wrong_backend":@@ -115,7 +127,7 @@ def test_engine_that_fails_verification_stays_and_is_not_retried(legacy_env, monfrom hermes_cli.local_runtime import binarieshome, _, package, target, backend, pinned = legacy_env- install = legacy_install(home, package, target, backend, "b10964", pinned)+ install = legacy_install(home, package, target, backend, "b10964", legacy_digests(package, target, pinned))probes = []def failing(self, entry, target):@@ -138,7 +150,7 @@ def test_existing_pm_engine_is_never_replaced(legacy_env):package.binary(entry, target).write_bytes(b"pm engine")Facts(store / "facts.json").record(package.name, "10964", entry.name, {}, store, target=target,artifacts=pinned, digest=tree_digest(entry))- install = legacy_install(home, package, target, backend, "b10964", pinned)+ install = legacy_install(home, package, target, backend, "b10964", legacy_digests(package, target, pinned))assert binaries.installed_engine(backend).binary.read_bytes() == b"pm engine"assert install.is_dir()@@ -149,7 +161,7 @@ def test_busy_store_leaves_the_engine_for_a_later_call(legacy_env):from pm.filesystem import lock_fdhome, store, package, target, backend, pinned = legacy_env- install = legacy_install(home, package, target, backend, "b10964", pinned)+ install = legacy_install(home, package, target, backend, "b10964", legacy_digests(package, target, pinned))store.mkdir(parents=True, exist_ok=True)held, release = threading.Event(), threading.Event()@@ -179,11 +191,12 @@ def test_status_route_reports_the_moved_engine(legacy_env, monkeypatch):from hermes_cli.web_routers import local_models as lmhome, _, package, target, backend, pinned = legacy_env- legacy_install(home, package, target, backend, "b10964", pinned)+ legacy = legacy_digests(package, target, pinned)+ legacy_install(home, package, target, backend, "b10964", legacy)monkeypatch.setattr(lm, "_runtime_section", lambda: {"enabled": True, "backend": backend})monkeypatch.setattr(lm, "_state_endpoint", lambda: None)status = lm.local_models_status()assert status["runtime_installed"] and status["runtime_backend"] == backend- assert status["tag"] == "b10964" and not status["update_available"]+ assert status["tag"] == "b10964" and status["update_available"] == (legacy != pinned)diff --git a/tests/hermes_cli/test_local_runtime_pm.py b/tests/hermes_cli/test_local_runtime_pm.pyindex 54dc0d577a8..8fc786b5e9c 100644--- a/tests/hermes_cli/test_local_runtime_pm.py+++ b/tests/hermes_cli/test_local_runtime_pm.py@@ -10,7 +10,7 @@ from pm.lock import Lockfile@pytest.mark.parametrize("target,vendor,expected", [("linux-x64", "nvidia", "cuda"),- ("linux-arm64", "nvidia", "vulkan"),+ ("linux-arm64", "nvidia", "cuda"),("win32-arm64", "nvidia", "cuda"),("win32-arm64", "AMD Radeon", "cpu"),("win32-x64", "AMD Radeon", "vulkan"),@@ -20,24 +20,32 @@ from pm.lock import Lockfiledef test_auto_backend_uses_only_compatible_pins(target, vendor, expected):assert binaries.resolve_backend("auto", gpu_vendor=vendor, target=target) == expectedwith pytest.raises(binaries.BinaryResolutionError):- binaries.resolve_backend("cuda", target="linux-arm64")+ binaries.resolve_backend("cuda", target="darwin-arm64")def test_linux_cuda_runtime_libraries_land_beside_the_server(tmp_path):- """The engine's RUNPATH is $ORIGIN and its archive carries no CUDA libraries,- so the cudart tarball's own top-level dir must be hoisted next to llama-server."""+ """The engine's RUNPATH is $ORIGIN and its archive carries neither the CUDA+ runtime nor OpenMP, so the cudart tarball's top-level dir and the libgomp+ .deb's usr/lib/<triplet>/ library must both end up next to llama-server."""package = pm.get_package("llamacpp-cuda")staged = tmp_path / "tree"(staged / "llama-b1").mkdir(parents=True)(staged / "llama-b1" / "llama-server").write_bytes(b"engine")(staged / "cudart-llama-b1-bin-ubuntu-cuda-13.4-x64").mkdir()(staged / "cudart-llama-b1-bin-ubuntu-cuda-13.4-x64" / "libcudart.so.13").write_bytes(b"rt")+ gomp = staged / "usr" / "lib" / "x86_64-linux-gnu"+ gomp.mkdir(parents=True)+ (gomp / "libgomp.so.1.0.0").write_bytes(b"omp")+ (gomp / "libgomp.so.1").symlink_to("libgomp.so.1.0.0")package.stage(None, staged, "1", "linux-x64")assert package.binary(staged, "linux-x64").is_file()assert (staged / "libcudart.so.13").is_file()assert not list(staged.glob("cudart-*"))+ assert not (staged / "libgomp.so.1").is_symlink()+ assert (staged / "libgomp.so.1").read_bytes() == b"omp"+ assert not (staged / "usr").exists()def test_missing_pin_is_refused_instead_of_constructing_download_url(tmp_path, monkeypatch):diff --git a/tests/pm/test_deb_safety.py b/tests/pm/test_deb_safety.pyindex 8e00d33d198..576addaa6dd 100644--- a/tests/pm/test_deb_safety.py+++ b/tests/pm/test_deb_safety.py@@ -26,8 +26,8 @@ class _P(DebPackage):-def _build_deb(path: Path, members: list[tarfile.TarInfo | tuple[str, bytes]]) -> None:- """A real ar archive with one data.tar (uncompressed) holding `members`."""+def _build_deb(path: Path, members: list[tarfile.TarInfo | tuple[str, bytes]], *, zstd: bool = False) -> None:+ """A real ar archive with one data.tar (uncompressed, or zstd as Ubuntu ships) holding `members`."""buf = io.BytesIO()with tarfile.open(fileobj=buf, mode="w") as tf:for item in members:@@ -38,10 +38,15 @@ def _build_deb(path: Path, members: list[tarfile.TarInfo | tuple[str, bytes]]) -tf.addfile(info, io.BytesIO(content))else:tf.addfile(item)+ payload, member = buf.getvalue(), "data.tar"+ if zstd:+ from compression import zstd as zstd_codec++ payload, member = zstd_codec.compress(payload), "data.tar.zst"path.write_bytes(b"!<arch>\n"+ _ar_member("debian-binary", b"2.0\n")- + _ar_member("data.tar", buf.getvalue())+ + _ar_member(member, payload))@@ -83,6 +88,22 @@ def test_relative_member_escape_preserves_outside(tmp_path):assert sentinel.read_bytes() == b"outside"+def test_zstd_payload_unpacks_under_the_same_containment(tmp_path):+ """Ubuntu's .debs carry data.tar.zst; it stages like any other and its escapes are refused."""+ deb, staged = tmp_path / "ok.deb", tmp_path / "staged"+ _build_deb(deb, [("usr/lib/x86_64-linux-gnu/libgomp.so.1", b"omp")], zstd=True)+ staged.mkdir()+ _P().unpack(deb, staged, "linux-x64")+ assert (staged / "usr/lib/x86_64-linux-gnu/libgomp.so.1").read_bytes() == b"omp"++ sentinel = tmp_path / "sentinel"+ sentinel.write_bytes(b"outside")+ _build_deb(deb, [("../sentinel", b"escaped")], zstd=True)+ with pytest.raises(InstallError, match="escape|unsafe|outside"):+ _P().unpack(deb, tmp_path / "staged2", "linux-x64")+ assert sentinel.read_bytes() == b"outside"++def test_absolute_symlink_target_rejected(tmp_path: Path):"""A member whose symlink target is ABSOLUTE must be refused outright:the link points outside the staged tree the moment it is created."""diff --git a/tests/pm/test_llamacpp_pins.py b/tests/pm/test_llamacpp_pins.pyindex 913f21f3691..7be2d89bdf2 100644--- a/tests/pm/test_llamacpp_pins.py+++ b/tests/pm/test_llamacpp_pins.py@@ -25,5 +25,7 @@ def test_llamacpp_backends_have_pins_for_their_supported_targets():assert [a["url"] for a in artifacts] == package.fetch_urls(version, target)assert all(len(bytes.fromhex(a["sha256"])) == 32 for a in artifacts)if backend == "cuda":- assert len(artifacts) == 2assert any("cudart-" in a["url"] for a in artifacts)+ # Upstream's Linux builds link the system OpenMP runtime, which minimal hosts lack.+ if target in ("linux-x64", "linux-arm64"):+ assert any("/libgomp1_" in a["url"] and a["url"].endswith(".deb") for a in artifacts)diff --git a/website/docs/user-guide/local-models.md b/website/docs/user-guide/local-models.mdindex c94b59aa72b..b66df317e10 100644--- a/website/docs/user-guide/local-models.md+++ b/website/docs/user-guide/local-models.md@@ -176,7 +176,7 @@ Selecting a local model as your main model uses the standard## Requirements and limits- **Windows:** CUDA on supported NVIDIA targets, Vulkan on x64, or CPU.- **Linux:** CUDA on x64 NVIDIA (needs a CUDA 13 driver), Vulkan, or CPU.+ **Linux:** CUDA on x64 and arm64 NVIDIA (needs a CUDA 13 driver), Vulkan, or CPU.**macOS:** Metal or CPU. HIP/ROCm is an explicit choice on supported x64targets. Unsupported backend/target pairs fail before any download.- A GPU with 8 GB+ of memory runs the small catalog models comfortably;