Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

Build and publish container images from GitHub Actions

Benson Wong34a9a4f23c2b
diff --git a/.dockerignore b/.dockerignore
index dfe932d..0eb999b 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -5,3 +5,7 @@ build
*.st
__pycache__
doc/container.md
+
+# Built in the image; a host build must not overwrite it
+exllamav3_ext*.so
+.rebuild.*
diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml
new file mode 100644
index 0000000..ddfc594
--- /dev/null
+++ b/.github/workflows/container.yml
@@ -0,0 +1,157 @@
+name: Build & Publish Container Images
+run-name: Build & Publish Container Images (${{ inputs.tag || github.ref_name }})
+
+# Builds docker/Dockerfile once per model and pushes ghcr.io/<owner>/kyojin-<model>, the images
+# doc/container.md tells people to pull. Runs on a version tag push. workflow_dispatch builds the
+# given tag (to rebuild a release), or the selected branch when the tag is empty, and only pushes
+# when asked. A tag build writes the tag into exllamav3/version.py first.
+#
+# amd64 only: the image targets Strix Halo (gfx1151), so there is no multi-arch manifest to join.
+# All models build in ONE job on purpose. Only the last layer (ARG MODEL) differs between them, so
+# the first build pays for the hours-long torch/SDK/extension layer and the others are seconds.
+# A matrix would put each model on its own runner and compile everything again.
+
+on:
+ push:
+ tags:
+ - 'v*'
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: 'Tag to build, e.g. v1.5.5. Empty builds the selected branch'
+ default: ''
+ required: false
+ type: string
+ push:
+ description: 'Push the images to ghcr.io'
+ default: false
+ required: true
+ type: boolean
+
+permissions:
+ contents: read
+ packages: write
+
+env:
+ # Models to publish, see docker/kyojin_args.py. mimo is left out like in doc/container.md.
+ MODELS: qwen glm
+
+jobs:
+ build:
+ name: build and push
+ runs-on: ubuntu-latest
+ # GitHub's hard cap is 360m; stop short of it so an overrun is reported as a timeout
+ timeout-minutes: 330
+ steps:
+ # The build layer peaks well above the free space of a stock runner (about 14 GB of wheels
+ # plus the unpruned ROCm SDK tree)
+ # Skipped under act (local testing), where it would only strip the act container
+ - name: Free Disk Space
+ if: ${{ !env.ACT }}
+ uses: jlumbroso/[email protected]
+ with:
+ tool-cache: true
+ android: true
+ dotnet: true
+ haskell: true
+ large-packages: false
+ swap-storage: true
+
+ # Two steps rather than `ref: ${{ inputs.tag }}`: act only uses the local working copy when
+ # checkout has no ref at all, so a plain checkout keeps tag pushes testable locally
+ - name: Checkout
+ if: ${{ !inputs.tag }}
+ uses: actions/checkout@v4
+
+ - name: Checkout ${{ inputs.tag }}
+ if: ${{ inputs.tag }}
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.tag }}
+
+ # Tag builds (pushed, or given to workflow_dispatch) stamp the tag into exllamav3/version.py
+ # before the image is built, so the package inside reports the version the image is tagged
+ # with. Branch builds keep the file as it is.
+ - name: Resolve version
+ id: version
+ env:
+ INPUT_TAG: ${{ inputs.tag }}
+ run: |
+ tag="$INPUT_TAG"
+ if [[ -z "$tag" && "$GITHUB_REF_TYPE" == "tag" ]]; then
+ tag="$GITHUB_REF_NAME"
+ fi
+ if [[ -n "$tag" ]]; then
+ version="${tag#v}"
+ # The version lands in Python source and in image tags: digits first, no quotes
+ if [[ ! "$version" =~ ^[0-9][0-9A-Za-z.-]*$ ]]; then
+ echo "::error file=container.yml::Tag $tag is not a version (expected v1.2.3 or 1.2.3)"
+ exit 1
+ fi
+ printf '__version__ = "%s"' "$version" > exllamav3/version.py
+ fi
+ version=$(sed -nE 's/^__version__ = "([^"]+)"/\1/p' exllamav3/version.py)
+ if [[ -z "$version" ]]; then
+ echo "::error file=container.yml::Could not parse version from exllamav3/version.py"
+ exit 1
+ fi
+ echo "::notice file=container.yml,title=Image Version::$version"
+ echo "version=$version" >> "$GITHUB_OUTPUT"
+ echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log in to GitHub Container Registry
+ if: ${{ !env.ACT }}
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ github.token }}
+
+ # Tags: <version> always; <major.minor> and latest only for plain X.Y.Z releases, so a
+ # pre-release tag never moves them. Never pushes under act.
+ # Layer cache lives in ghcr.io/<owner>/kyojin-buildcache: a fresh runner has no local cache, and
+ # without it every release recompiles the dependency and extension layers even when only the
+ # Python source changed. Read on every build; written only by pushing builds, and only for the
+ # first model, since the others differ from it in the last layer alone.
+ - name: Build and push images
+ env:
+ VERSION: ${{ steps.version.outputs.version }}
+ OWNER: ${{ steps.version.outputs.owner }}
+ PUSH: ${{ !env.ACT && (github.event_name == 'push' || inputs.push) }}
+ run: |
+ push_flag=""
+ [[ "$PUSH" == "true" ]] && push_flag="--push"
+ cache="ghcr.io/${OWNER}/kyojin-buildcache:latest"
+ cache_to=()
+ [[ "$PUSH" == "true" ]] && cache_to=(--cache-to "type=registry,ref=${cache},mode=max")
+
+ for model in $MODELS; do
+ image="ghcr.io/${OWNER}/kyojin-${model}"
+ tags=(-t "${image}:${VERSION}")
+ if [[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\.[0-9]+$ ]]; then
+ tags+=(-t "${image}:${BASH_REMATCH[1]}" -t "${image}:latest")
+ fi
+
+ echo "::group::${model}: ${tags[*]}"
+ docker buildx build \
+ -f docker/Dockerfile \
+ --platform linux/amd64 \
+ --build-arg "MODEL=${model}" \
+ "${tags[@]}" \
+ --label "org.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
+ --label "org.opencontainers.image.version=${VERSION}" \
+ --label "org.opencontainers.image.revision=${GITHUB_SHA}" \
+ --cache-from "type=registry,ref=${cache}" \
+ "${cache_to[@]}" \
+ ${push_flag} \
+ .
+ echo "::endgroup::"
+ cache_to=()
+ done
+
+ - name: Disk usage
+ if: always()
+ run: df -h