Skip to content

Fast local LLM inference on plain CPUs. No GPU, 8 GB of RAM. OpenAI-compatible server.

Prebuilt engine on every release, and ./install.sh --prebuilt (#137)

0xaron19d09a1887be
diff --git a/.github/workflows/package-portable.yml b/.github/workflows/package-portable.yml
index 99f9454..8b1187e 100644
--- a/.github/workflows/package-portable.yml
+++ b/.github/workflows/package-portable.yml
@@ -1,6 +1,12 @@
name: package-portable
+# Builds the portable x86-64 engine (every kernel variant, chosen at run time; no model weights) and packs it for
+# ./install.sh --prebuilt and --bin-url. Runs when a release is published, and attaches the tarball and its checksum
+# to that release. It can also be started by hand; then the tarball is only kept as a workflow artifact.
+
on:
+ release:
+ types: [published]
workflow_dispatch:
inputs:
tarball_name:
@@ -11,11 +17,15 @@ on:
permissions:
contents: read
+env:
+ TARBALL_NAME: ${{ inputs.tarball_name || 'openset-llm-linux-x86_64.tar.gz' }}
+
jobs:
build-portable-linux:
+ # the oldest runner image: the binaries need its glibc or newer
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- name: Install build dependencies
run: |
@@ -38,12 +48,16 @@ jobs:
cmake --build /tmp/llama.cpp/build -j"$(nproc)"
mkdir -p "$HOME/.openset-llm/bin"
cp -a /tmp/llama.cpp/build/bin/llama-server /tmp/llama.cpp/build/bin/*.so* "$HOME/.openset-llm/bin/"
+ # the same extra tools ./install.sh --portable installs (bench/jobs.sh uses llama-bench)
+ for tool in llama-bench llama-cli; do
+ if [ -e "/tmp/llama.cpp/build/bin/$tool" ]; then cp -a "/tmp/llama.cpp/build/bin/$tool" "$HOME/.openset-llm/bin/"; fi
+ done
+ LD_LIBRARY_PATH="$HOME/.openset-llm/bin" "$HOME/.openset-llm/bin/llama-server" --version
- name: Pack tarball and SHA256SUMS
run: |
- OUT="${{ inputs.tarball_name }}"
- bash scripts/package.sh "$OUT"
- sha256sum "$OUT" > SHA256SUMS
+ bash scripts/package.sh "$TARBALL_NAME"
+ sha256sum "$TARBALL_NAME" > SHA256SUMS
cat SHA256SUMS
- name: Upload portable artifact
@@ -51,6 +65,23 @@ jobs:
with:
name: openset-llm-portable-linux-x86_64
path: |
- ${{ inputs.tarball_name }}
+ ${{ env.TARBALL_NAME }}
SHA256SUMS
retention-days: 14
+
+ attach-to-release:
+ # only this job may write to the repository, and only to add the two files to the release that triggered it
+ if: github.event_name == 'release'
+ needs: build-portable-linux
+ runs-on: ubuntu-24.04
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ name: openset-llm-portable-linux-x86_64
+ - name: Attach the tarball and its checksum to the release
+ env:
+ GH_TOKEN: ${{ github.token }}
+ TAG: ${{ github.event.release.tag_name }}
+ run: gh release upload "$TAG" "$TARBALL_NAME" SHA256SUMS --repo "$GITHUB_REPOSITORY" --clobber
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 933058e..15dacfa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,20 @@ All notable changes to openset-llm. Dates are YYYY-MM-DD.
## Unreleased
+Added
+
+- Prebuilt engine on every release: publishing a release now builds the portable x86-64 engine and attaches
+ `openset-llm-linux-x86_64.tar.gz` and `SHA256SUMS` to it. `./install.sh --prebuilt` installs it without a compiler:
+ it verifies the checksum and refuses an engine built from other patches or kernels than the checkout. Builds on
+ the packaging workflow contributed in #22.
+- `docs`: the README and CONTRIBUTING point to the smoke test, the deployment guide and how to run the tests (#136).
+
+Changed
+
+- `install.sh` changed, so the next `./install.sh` rebuilds the engine once.
+
+Thank you to @cioffivictor for the packaging workflow.
+
## 0.3.2 (2026-11-27)
A small bug-fix release. Speed and the model file are unchanged.
diff --git a/README.md b/README.md
index a3d98b5..fc8318b 100644
--- a/README.md
+++ b/README.md
@@ -466,7 +466,11 @@ To keep the server running in the background as a systemd service, see [docs/dep
- **Any Linux VM or container host** with 8 vCPU / 8 GB: the Linux recipe or the Docker image above (AVX-512 for the
speeds on this page; AVX2-only hosts such as AMD Zen 2 / Zen 3 instances run on the 256-bit kernels).
-- **Prebuilt binaries:** `./install.sh --bin-url <tarball>` skips the build (tarballs come from `scripts/package.sh`).
+- **Prebuilt binaries:** `./install.sh --prebuilt` fetches the engine attached to the latest release instead of
+ building it (x86-64 Linux with glibc 2.35 or newer, such as Ubuntu 22.04 or Debian 12; no compiler needed). It
+ checks the download against the release's `SHA256SUMS` and refuses an engine built from other patches or kernels
+ than your checkout, so use it on a checkout of the latest release tag. Releases from 0.3.3 on carry one.
+ `./install.sh --bin-url <tarball>` does the same with a tarball of your own (made by `scripts/package.sh`).
A tarball runs on the Linux distribution it was built on or a newer one, so build it on the oldest one you want to
support; `install.sh` checks that it starts before it downloads the model.
diff --git a/SECURITY.md b/SECURITY.md
index c0991c6..4694ebb 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -14,7 +14,9 @@ attacker gains. You will get an answer within a week.
- **No rate limiting.** One client can occupy the engine.
- At install, the script clones llama.cpp from GitHub, downloads the model weights from Hugging Face over HTTPS, and
may install build tools with apt or pip. `--bin-url` downloads and runs a prebuilt binary: only use a tarball you
- trust. Nothing is fetched after install.
+ trust. `--prebuilt` downloads the engine attached to the latest release of this repository and checks it against
+ that release's `SHA256SUMS`; the checksum comes from the same release, so it detects a damaged download, not a
+ tampered release. Nothing is fetched after install.
- **Prompt states on disk.** With resume on (the default), the server keeps up to 8 prefix states built from your
prompts in `~/.openset-llm/state`. Delete the folder to clear them, or run `./serve --no-resume`.
- Until the first tagged release, only the latest commit on `main` is supported with fixes.
diff --git a/install.sh b/install.sh
index 52adba4..4b5f4df 100755
--- a/install.sh
+++ b/install.sh
@@ -4,6 +4,8 @@
# ./install.sh # CPU check, build for this machine, download + prepare the model
# ./install.sh --portable # build one binary set for every x86-64 CPU (picks the best kernel at run time:
# # AVX-512 where the CPU has it, the 256-bit AVX2 / AVX-VNNI kernels where it does not)
+# ./install.sh --prebuilt # fetch the engine built for the latest release instead of building (no compiler
+# # needed; checksum verified; must match this checkout's engine sources)
# ./install.sh --bin-url URL # fetch a prebuilt tarball (made by scripts/package.sh) instead of building
# ./install.sh --no-mtp # skip the speculative-decoding head (saves 1.4 GB of download; 1.4-1.9x slower)
# ./install.sh --check # only print what this machine will get, then exit
@@ -22,15 +24,19 @@ MTP_REPO=unsloth/Qwen3.8-27B-GGUF; MTP_FILE=MTP/mtp-Qwen3.8-27B-Q4_0
MIN_RAM_KB=7600000 # an "8 GB" machine reports ~7.6-8.1 GB; the server's resident set is ~7.0 GB
MIN_DISK_GB=15 # base 6.0 + MTP sidecar 1.4 + grafted model 6.2 at peak, + the build
-PORTABLE=0; BIN_URL=${OPENSET_LLM_BIN_URL:-}; MTP=1; CHECK_ONLY=0; MODEL_ONLY=0
+PORTABLE=0; BIN_URL=${OPENSET_LLM_BIN_URL:-}; MTP=1; CHECK_ONLY=0; MODEL_ONLY=0; PREBUILT=0; ENGINE_ID_ONLY=0
+RELEASE_URL=${OPENSET_LLM_RELEASE_URL:-https://github.com/opensetlabs/openset-llm/releases/latest/download}
+RELEASE_TARBALL=openset-llm-linux-x86_64.tar.gz
while [ $# -gt 0 ]; do
case $1 in
--portable) PORTABLE=1 ;;
+ --prebuilt) PREBUILT=1 ;;
+ --engine-id) ENGINE_ID_ONLY=1 ;; # for scripts/package.sh: print what identifies the engine sources, then exit
--bin-url) [ $# -ge 2 ] || { echo "--bin-url needs a URL" >&2; exit 2; }; BIN_URL=$2; shift ;;
--no-mtp) MTP=0 ;;
--check) CHECK_ONLY=1 ;;
--model-only) MODEL_ONLY=1 ;;
- -h|--help) sed -n '2,12p' "$0"; exit 0 ;;
+ -h|--help) sed -n '2,14p' "$0"; exit 0 ;;
*) echo "unknown option: $1" >&2; exit 2 ;;
esac
shift
@@ -39,6 +45,16 @@ done
say() { printf '\033[1m==> %s\033[0m\n' "$*"; }
die() { printf '\033[31merror:\033[0m %s\n' "$*" >&2; exit 1; }
+# What the engine is built from: the pinned fork commit, the patches and the kernels. Not this script, not the docs.
+engine_id() { echo "$FORK_SHA $(cat "$HERE/patches/apply.sh" "$HERE"/patches/*.patch "$HERE"/kernels/* | cksum | cut -d' ' -f1)"; }
+if [ "$ENGINE_ID_ONLY" = 1 ]; then engine_id; exit 0; fi
+if [ "$PREBUILT" = 1 ]; then
+ [ -z "$BIN_URL" ] || die "--prebuilt and --bin-url cannot be used together"
+ [ "$PORTABLE" = 0 ] || die "--prebuilt and --portable cannot be used together"
+ case $(uname -m) in x86_64|amd64) ;; *) die "prebuilt engines exist for x86-64 Linux only; run plain ./install.sh to build here" ;; esac
+ BIN_URL=$RELEASE_URL/$RELEASE_TARBALL
+fi
+
# ---------------------------------------------------------------- CPU check
cpu_path() {
local arch flags; arch=$(uname -m)
@@ -172,8 +188,25 @@ if [ "$MODEL_ONLY" = 1 ]; then
elif [ -n "$BIN_URL" ]; then
say "Fetching prebuilt binaries: $BIN_URL"
begin_bin_update
- curl -fSL --retry 3 "$BIN_URL" | tar -xz -C "$BIN_STAGE" --strip-components=1 \
- || die "could not download or unpack $BIN_URL"
+ if [ "$PREBUILT" = 1 ]; then
+ # download to a file first: the checksum is checked before anything is unpacked or run
+ curl -fSL --retry 3 -o "$BIN_STAGE/.download" "$BIN_URL" \
+ || die "could not download $BIN_URL
+ Releases before 0.3.3 carry no prebuilt engine. Run plain ./install.sh to build the engine here instead."
+ sums=$(curl -fsSL --retry 3 "$RELEASE_URL/SHA256SUMS") || die "could not download $RELEASE_URL/SHA256SUMS"
+ want=$(printf '%s\n' "$sums" | awk -v f="$RELEASE_TARBALL" '$2 == f || $2 == "*" f {print $1; exit}')
+ got=$(sha256sum "$BIN_STAGE/.download" | cut -d' ' -f1)
+ [ -n "$want" ] && [ "$want" = "$got" ] || die "checksum mismatch for $RELEASE_TARBALL (expected ${want:-no entry in SHA256SUMS}, got $got); nothing was installed"
+ tar -xzf "$BIN_STAGE/.download" -C "$BIN_STAGE" --strip-components=1 || die "could not unpack $BIN_URL"
+ rm -f "$BIN_STAGE/.download"
+ if [ "$(cat "$BIN_STAGE/.engine-id" 2>/dev/null)" != "$(engine_id)" ]; then
+ die "the latest release's engine was built from different engine sources than this checkout (patches or kernels differ).
+ Check out the latest release tag, or run plain ./install.sh to build the engine here."
+ fi
+ else
+ curl -fSL --retry 3 "$BIN_URL" | tar -xz -C "$BIN_STAGE" --strip-components=1 \
+ || die "could not download or unpack $BIN_URL"
+ fi
# a prebuilt engine only runs on the distribution it was built on or a newer one: find out now, before the download
engine_starts() { ver=$(LD_LIBRARY_PATH="$BIN_STAGE" "$BIN_STAGE/llama-server" --version 2>&1); }
if ! engine_starts && case $ver in *libgomp.so.1*) true ;; *) false ;; esac; then
diff --git a/scripts/package.sh b/scripts/package.sh
index f5ab1af..58884d7 100755
--- a/scripts/package.sh
+++ b/scripts/package.sh
@@ -7,5 +7,7 @@ set -euo pipefail
PREFIX=${OPENSET_LLM_HOME:-$HOME/.openset-llm}
OUT=${1:-openset-llm-linux-$(uname -m).tar.gz}
ls "$PREFIX"/bin/libggml-cpu-*.so >/dev/null 2>&1 || { echo "not a portable build: run ./install.sh --portable" >&2; exit 1; }
+# what the engine was built from, so ./install.sh --prebuilt can refuse an engine that does not match a checkout
+bash "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/install.sh" --engine-id > "$PREFIX/bin/.engine-id"
tar -czf "$OUT" -C "$PREFIX" --transform 's#^bin#openset-llm#' bin
echo "$OUT ($(du -h "$OUT" | cut -f1))"
diff --git a/tests/test_install_prebuilt_release.py b/tests/test_install_prebuilt_release.py
new file mode 100644
index 0000000..e23f334
--- /dev/null
+++ b/tests/test_install_prebuilt_release.py
@@ -0,0 +1,140 @@
+import hashlib
+import io
+import os
+from pathlib import Path
+import shutil
+import subprocess
+import tarfile
+import tempfile
+import unittest
+
+ROOT = Path(__file__).resolve().parents[1]
+TARBALL = 'openset-llm-linux-x86_64.tar.gz'
+
+
+class PrebuiltRelease(unittest.TestCase):
+ """./install.sh --prebuilt: the release tarball is installed only if its checksum matches SHA256SUMS and it was
+ built from the same engine sources as this checkout. Otherwise the working engine stays as it was."""
+
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.work = Path(self.temp.name)
+ self.prefix = self.work / 'installation'
+ self.tools = self.work / 'tools'
+ self.tools.mkdir()
+ (self.prefix / 'bin').mkdir(parents=True)
+ (self.prefix / 'models').mkdir()
+ (self.prefix / 'models/model.gguf').write_bytes(b'cached')
+ self.command(self.prefix / 'bin/llama-server', '#!/bin/sh\nexit 0\n')
+ self.before = (self.prefix / 'bin/llama-server').read_bytes()
+ for name in ('dirname', 'uname', 'grep', 'cut', 'sed', 'awk', 'cat', 'mkdir', 'id', 'mv', 'rm', 'touch',
+ 'tar', 'gzip', 'head', 'mktemp', 'basename', 'flock', 'sha256sum', 'cksum', 'cp'):
+ executable = shutil.which(name)
+ if executable:
+ (self.tools / name).symlink_to(executable)
+ self.command(self.tools / 'df', "#!/bin/sh\nprintf 'Filesystem 1024-blocks Used Available Capacity Mounted\nfixture 999999999 0 999999999 0%% /\n'\n")
+ self.command(self.tools / 'du', "#!/bin/sh\nprintf '0 fixture\n'\n")
+ self.command(self.tools / 'python3', '#!/bin/sh\nexit 0\n')
+ # the release: -o FILE URL writes the tarball, a URL ending in SHA256SUMS prints the checksum file
+ self.command(self.tools / 'curl', '#!/bin/sh\n'
+ 'out=; url=\n'
+ 'while [ "$#" -gt 0 ]; do case $1 in -o) out=$2; shift ;; --retry) shift ;; -*) ;; *) url=$1 ;; esac; shift; done\n'
+ 'printf \'%s\\n\' "$url" >> "$URL_LOG"\n'
+ 'case $url in\n'
+ ' */SHA256SUMS) [ -f "$SUMS" ] || exit 22; cat "$SUMS" ;;\n'
+ ' *) [ -f "$ARCHIVE" ] || exit 22; if [ -n "$out" ]; then cp "$ARCHIVE" "$out"; else cat "$ARCHIVE"; fi ;;\n'
+ 'esac\n')
+ self.archive = self.work / TARBALL
+ self.sums = self.work / 'SHA256SUMS'
+ self.env = {**os.environ, 'OPENSET_LLM_HOME': str(self.prefix), 'PATH': str(self.tools),
+ 'OPENSET_LLM_RELEASE_URL': 'https://example.invalid/release',
+ 'ARCHIVE': str(self.archive), 'SUMS': str(self.sums), 'URL_LOG': str(self.work / 'urls')}
+ self.env.pop('OPENSET_LLM_BIN_URL', None)
+ self.env.pop('HF_TOKEN', None)
+ self.engine_id = subprocess.run(['/bin/bash', str(ROOT / 'install.sh'), '--engine-id'],
+ text=True, capture_output=True, check=True).stdout
+
+ def command(self, path, content):
+ path.write_text(content)
+ path.chmod(0o755)
+
+ def release(self, engine_id=None, checksum=None, listed=True):
+ payload = b'#!/bin/sh\nexit 0\n# release engine\n'
+ stream = io.BytesIO()
+ with tarfile.open(fileobj=stream, mode='w:gz') as tar:
+ members = [('openset-llm/llama-server', payload, 0o755)]
+ if engine_id is not None:
+ members.append(('openset-llm/.engine-id', engine_id.encode(), 0o644))
+ for name, data, mode in members:
+ entry = tarfile.TarInfo(name)
+ entry.mode = mode
+ entry.size = len(data)
+ tar.addfile(entry, io.BytesIO(data))
+ self.archive.write_bytes(stream.getvalue())
+ digest = checksum or hashlib.sha256(stream.getvalue()).hexdigest()
+ self.sums.write_text(f'{digest} {TARBALL if listed else "another-file.tar.gz"}\n')
+ return payload
+
+ def install(self, *args):
+ return subprocess.run(['/bin/bash', str(ROOT / 'install.sh'), *args, '--no-mtp'],
+ env=self.env, text=True, capture_output=True, timeout=15)
+
+ def assert_untouched(self, result, message):
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn(message, result.stderr)
+ self.assertEqual((self.prefix / 'bin/llama-server').read_bytes(), self.before)
+ self.assertEqual(list(self.prefix.glob('.bin.*')), [])
+
+ def test_matching_release_is_installed(self):
+ payload = self.release(engine_id=self.engine_id)
+ result = self.install('--prebuilt')
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual((self.prefix / 'bin/llama-server').read_bytes(), payload)
+ self.assertFalse((self.prefix / 'bin/.download').exists())
+ self.assertEqual(list(self.prefix.glob('.bin.*')), [])
+ self.assertEqual((self.work / 'urls').read_text().split(),
+ [f'https://example.invalid/release/{TARBALL}', 'https://example.invalid/release/SHA256SUMS'])
+
+ def test_wrong_checksum_installs_nothing(self):
+ self.release(engine_id=self.engine_id, checksum='0' * 64)
+ self.assert_untouched(self.install('--prebuilt'), 'checksum mismatch')
+
+ def test_tarball_missing_from_the_checksum_file_installs_nothing(self):
+ self.release(engine_id=self.engine_id, listed=False)
+ self.assert_untouched(self.install('--prebuilt'), 'checksum mismatch')
+
+ def test_missing_checksum_file_installs_nothing(self):
+ self.release(engine_id=self.engine_id)
+ self.sums.unlink()
+ self.assert_untouched(self.install('--prebuilt'), 'SHA256SUMS')
+
+ def test_engine_from_other_sources_installs_nothing(self):
+ self.release(engine_id='0000000000000000000000000000000000000000 1\n')
+ self.assert_untouched(self.install('--prebuilt'), 'different engine sources')
+
+ def test_engine_without_an_id_installs_nothing(self):
+ self.release(engine_id=None)
+ self.assert_untouched(self.install('--prebuilt'), 'different engine sources')
+
+ def test_release_without_a_prebuilt_engine_says_how_to_build(self):
+ result = self.install('--prebuilt') # no tarball on the release
+ self.assert_untouched(result, 'Run plain ./install.sh')
+
+ def test_prebuilt_excludes_bin_url_and_portable(self):
+ for other in (('--bin-url', 'https://example.invalid/engine.tar.gz'), ('--portable',)):
+ with self.subTest(other=other[0]):
+ result = self.install('--prebuilt', *other)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn('cannot be used together', result.stderr)
+ self.assertEqual((self.prefix / 'bin/llama-server').read_bytes(), self.before)
+
+ def test_engine_id_names_the_fork_commit_and_ignores_the_installer(self):
+ fork = [line.split('=', 1)[1] for line in (ROOT / 'install.sh').read_text().splitlines()
+ if line.startswith('FORK_SHA=')][0]
+ self.assertEqual(self.engine_id.split()[0], fork)
+ self.assertEqual(len(self.engine_id.split()), 2)
+
+
+if __name__ == '__main__':
+ unittest.main()