Contributor Guide
Build Files
This image has no Dockerfile of its own. CICI: Continuous IntegrationThe practice of building and testing code automatically on every change, usually on a hosted service such as GitHub Actions, so problems show up before the change is merged.WikipediaGlossary builds the upstream vLLMvLLM: virtual Large Language ModelAn open-source inference and serving engine for LLMs, started at UC Berkeley in 2023. Its PagedAttention technique manages the key-value cache in fixed-size blocks, as an OS pages virtual memory, and it batches concurrent requests continuously, so one server can answer many requests at once. It runs on GPUs and CPUs and serves models through an OpenAI-compatible HTTP API.vLLM docsvLLM on GitHubOrigin of the nameGlossary CPUCPU: Central Processing UnitThe general-purpose processor of a computer, which runs the operating system and programs. A CPU has one or more physical cores, and with SMT each core runs two or more hardware threads.WikipediaGlossary
Dockerfile
from a vLLM source tree that the prepare.sh hook clones and
patches. The metadata files of the image folder set the
following:
| File | Value | Effect |
|---|---|---|
CONTEXT | vllm-common/.vllm-src | Build context: the cloned vLLM source tree |
DOCKERFILE | vllm-common/.vllm-src/docker/Dockerfile.cpu | The patched upstream CPU Dockerfile |
TARGET | vllm-openai | The upstream serving stage |
PLATFORMS | amd64 | Only AMD64AMD64The 64-bit version of the x86 instruction set architecture, introduced by AMD in 2003 and also implemented by Intel, which runs most cloud servers. Linux distributions and Docker name it amd64 or x86_64.WikipediaGlossary is built |
BUILD_ARGS | VLLM_CPU_AVX2=true | Passed as a build argument; the upstream Dockerfile of vLLM 0.27.1 declares no such argument, so it has no effect |
ZRAM | true | Compressed swap on the build runner; see CI Builds |
SCCACHE | true | Compiler cache in S3; see Compiler Cache |
CATEGORY | base | Image category label |
The folder has no DEPENDS_ON file. CI finds the folder by its prepare.sh,
because it has no Dockerfile. Git ignores the cloned source tree and the
.cache/ folder that the hook writes.
The build framework of the
sc-images repository describes
the metadata files that all images share.
Pre-Build Hook
When an image folder has a prepare.sh, CICI: Continuous IntegrationThe practice of building and testing code automatically on every change, usually on a hosted service such as GitHub Actions, so problems show up before the change is merged.WikipediaGlossary runs it before the build. The hook
does the following, in order:
- Reads the vLLM version from
vllm-common/VLLM_VERSION, currently0.27.1. - Sizes the compile parallelism (see
Compile Parallelism), and writes the runtime
values of
MAX_JOBS,NVCC_THREADS, andCARGO_BUILD_JOBSto.cache/vllm-parallelism.env, which the build mounts as the BuildKitBuildKitThe build engine of Docker, which builds container images from a Dockerfile. It runs independent build stages in parallel, caches each layer under a key computed from its instruction and inputs, and can export this cache to a registry and import it in a later build. It can also pass secrets to a build step as files that are not stored in the image or its cache.Docker docsGlossary secretvllm_parallelism. - Clones the vLLM tag
v<VLLM_VERSION>with depth 1 intovllm-common/.vllm-src, or fetches and checks out the tag when the tree exists. - Patches
docker/Dockerfile.cpuin that tree withtune-vllm-cpu-dockerfile.sh; see Dockerfile Patches. - Prints
dockerfile_sha256=<hash>of the patched file. - Changes the owner of the source tree to
0:0withsudo -n chown, so that the BuildKit context hash is the same on GitHub-hosted and self-hosted runners. TheCONTEXT_CANONICAL_OWNERenvironment variable (auid:gidpair) overrides the owner. - Prints the
sccachesccacheA compiler cache that wraps C, C++, and Rust compilers and reuses the output of an earlier compilation when the same source is compiled again with the same options. It keeps its cache on a local disk or in remote storage, such as an S3 bucket, so that several build machines can share it.GitHubGlossary lines, the install lines, and theFROMlines of the patched file, in collapsed log groups. - Appends
max_jobs=32and, when the compiler cache is on, its build arguments to.cache/extra-build-args.
Without passwordless sudo, step 6 prints
normalize-context-ownership: WARNING could not chown ... layer cache will not be shared across runner types
and the hook continues.
Dockerfile Patches
The tune-vllm-cpu-dockerfile.sh script makes the following changes to the
upstream Dockerfile, and fails the build when one of them cannot be
applied:
- Adds
.gitto the.dockerignorefile of the build context. - Sets
SETUPTOOLS_SCM_PRETEND_VERSIONto the vLLM version, and prints the resultingENVline. - Sets
ARG max_jobsandENV CARGO_BUILD_JOBSto 32, the values the formula gives a builder with 64 GiB of RAMRAM: Random-Access MemoryThe main memory of a computer, which holds the running programs and their data. It is much faster than disk storage, and its content is lost when the power is off.WikipediaGlossary. Upstream,CARGO_BUILD_JOBSis 4. Fixed values keep theDockerfiletext and its layer cachelayer cacheThe layers of earlier container image builds that BuildKit stores and reuses. Each Dockerfile instruction adds one layer to the image, stored under a key computed from the instruction and its inputs; when a later build reaches an instruction with the same key, it reuses the stored layer instead of running the step again. A build with--no-cacheignores the cache and runs every step.Docker docsGlossary keys the same on every runner. - Makes the
RUNsteps ofsetup.py bdist_wheel,build_rust.sh, andtriton-cpuread the runtime parallelism from thevllm_parallelismsecret, whose content is not part of the layer cache key. - Adds
git submodule update --init --recursiveafter thetriton-cpucheckout, because an emptythird_party/sleeffolder breaks the vLLM build. - Pins both
ubuntu:22.04stages,base-commonandrust-build, to the digestsha256:79676deb51ebb02885b0b9d33788e78a37cf1045ad79d1bb04c6a222c3556b3d(resolved on 2026-08-21), and fails when an unpinnedubuntu:22.04FROMline remains. - Adds the compiler cache to the
vllm-buildandrust-buildstages; see Compiler Cache.
Compile Parallelism
The hook runs
compute-build-parallelism.sh
with the vllm-cpu profile. VLLM_CPU_COMPILE_GIB_PER_SLOT is the memory of
one compile job in GiB (default: 6). MemTotal is the physical RAM, and
effective_GiB is MemTotal + (swap × 0.5), rounded to the nearest GiB.
The script sizes the build as follows:
MAX_JOBS= min((32 ×effective_GiB) / 64,nproc,MemTotal/VLLM_CPU_COMPILE_GIB_PER_SLOT, 32)CARGO_BUILD_JOBS= min((32 ×effective_GiB) / 64,MAX_JOBS, 32)- BuildKitBuildKitThe build engine of Docker, which builds container images from a Dockerfile. It runs independent build stages in parallel, caches each layer under a key computed from its instruction and inputs, and can export this cache to a registry and import it in a later build. It can also pass secrets to a build step as files that are not stored in the image or its cache.Docker docsGlossary
max-parallelism= min(MAX_JOBS, 16) NVCC_THREADS= 1
CICI: Continuous IntegrationThe practice of building and testing code automatically on every change, usually on a hosted service such as GitHub Actions, so problems show up before the change is merged.WikipediaGlossary sets the BuildKit max-parallelism in the builder configuration. The local
build command in Local Build does not.
The memory slots (the third term) count physical RAM only, so the compressed
swap raises the first term but adds no slots. All divisions are integer
divisions, and the effective_GiB terms and the memory slots are at least 1.
A VLLM_CPU_COMPILE_GIB_PER_SLOT of 0 or a value that is not an integer
makes the script fail, and the hook with it. A negative value sets MAX_JOBS
to 1.
The script prints the following three lines to stderrstderrThe standard error stream of a process, one of the three standard streams with stdin and stdout. Programs write logs, progress, and error messages to it, so that they stay separate from the output on stdout when the output is redirected to a file or another program.WikipediaGlossary:
- the memory and CPU inputs, after
Parallelism (vllm-cpu): - the runtime values, after
runtime: - the values written to the
Dockerfile, afterdocker (cache-stable):
On GitHub-hosted runners, the script caps MAX_JOBS, CARGO_BUILD_JOBS, and
the BuildKit parallelism at 2, but CI never builds this image there.
CI Builds
CICI: Continuous IntegrationThe practice of building and testing code automatically on every change, usually on a hosted service such as GitHub Actions, so problems show up before the change is merged.WikipediaGlossary builds this image on every push to main (push.yml),
in the first level of the build plan that
resolve-build-plan.sh
resolves, and then builds
benchmark-vllm-cpu-avx2 on top
of it. The build runs as follows:
- Runner: Always the self-hosted
[self-hosted, Linux, X64, workhorse]runner. The workflow notes that the build is too heavy for GitHub-hosted runners, citing out-of-memory errors, disk pressure, and an unreliable compiler cache. - Compressed swap: CI runs
setup-zram.sh before the build, with the defaultZRAM_PERCENT=125: azramzramA Linux kernel module that creates compressed block devices in memory. It is most often used as swap, so swapped-out pages are compressed in RAM instead of written to disk, trading CPU time for memory.Linux kernel docsGlossary swap of 125% of the RAM, compressed withzstd. When the runner has noapt-getor the kernel has nozrammodule, the script skipszram, keeps the existing swap, and exits with code 0. It exits with code 1 whenzramfails to start orswaponshows nozramdevice. - Build command: CI prints the full
docker buildx buildcommand afterbuild-push-image:, and runs it underrun-with-resource-tracker.sh.
Tags
The build pushes ghcr.io/sparecores/vllm-cpu-base-avx2:main-amd64, and a
merge job then creates the main tag from it. The merge job runs even when
the build fails. When main-amd64 is missing, it skips the main tag and
prints Skipping <tag>: missing <ref>. The package is public.
The image labels give the title, the description from
DESCRIPTION, the documentation URLURL: Uniform Resource LocatorThe address of a resource on the web or a network, such as https://sparecores.com/, made of a scheme, a host, and a path.Glossary, and the category
base. The layers are pushed compressed with zstd, at level 7.
Layer Cache
The build imports its layer cache from the following sources:
ghcr.io/sparecores/vllm-cpu-base-avx2:buildcache-amd64ghcr.io/sparecores/vllm-cpu-base-avx2:main-amd64- the GitHub Actions cache scope
vllm-cpu-base-avx2-amd64-v0.27.1
It exports all layers (mode=max) to the buildcache-amd64 tag and to the
same GitHub Actions cache scope. A new vLLM version starts a new scope.
The first successful build fills both caches. When the buildcache-amd64 tag
does not exist yet, the build skips its import and still runs; see Docker's
registry cache
docs.
A force rebuild
of the resource-trackerresource-trackerAn open-source Spare Cores tool that runs a command and samples resource usage while it runs, such as CPU, memory, disk, network, GPU, and GPU memory use. It can optionally stream the samples to the Spare Cores Sentinel platform, so that a run can be checked to see its aggregated and detailed resource utilization, e.g., whether it used all CPU or GPU cores as intended while running a Navigator benchmark workload.resource-tracker on GitHubGlossary consumers, the default in a manual run, keeps this
image's layer cache, because this image does not depend on resource-tracker.
It rebuilds benchmark-vllm-cpu-avx2
without cache, because that image does.
Compiler Cache
With SCCACHE set to true, CICI: Continuous IntegrationThe practice of building and testing code automatically on every change, usually on a hosted service such as GitHub Actions, so problems show up before the change is merged.WikipediaGlossary runs the hook with SCCACHE_ENABLED=true,
and the build runs its compilers through sccachesccacheA compiler cache that wraps C, C++, and Rust compilers and reuses the output of an earlier compilation when the same source is compiled again with the same options. It keeps its cache on a local disk or in remote storage, such as an S3 bucket, so that several build machines can share it.GitHubGlossary 0.15.0, with an S3 bucket
as its storage. The hook reads the following environment variables:
| Variable | Meaning | Default |
|---|---|---|
SCCACHE_ENABLED | true turns the compiler cache on | Unset; true in CI |
SCCACHE_BUCKET | Name of the S3 bucket; the hook stops with SCCACHE_BUCKET required when SCCACHE is enabled when it is unset | Repository variable in CI |
SCCACHE_REGION | Region of the bucket | us-west-2 |
SCCACHE_PREFIX | Key prefix of this image in the bucket | vllm-cpu-base-avx2/amd64 |
SCCACHE_VERBOSE | 1 turns on the trace logs | Unset |
From these, the hook writes the following build arguments:
| Build argument | Value |
|---|---|
USE_SCCACHE | 1 |
RUSTC_WRAPPER | /usr/local/bin/sc-rust-wrap |
SCCACHE_BUCKET_NAME | The value of SCCACHE_BUCKET |
SCCACHE_REGION_NAME | The value of SCCACHE_REGION |
SCCACHE_S3_NO_CREDENTIALS | 0 |
SCCACHE_S3_KEY_PREFIX | The value of SCCACHE_PREFIX |
SCCACHE_VERBOSE | 1, only when SCCACHE_VERBOSE is 1 |
Without USE_SCCACHE=1, the build skips the sccache install and its
wrappers.
CI writes the AWS credentials of an assumed role to .cache/aws-credentials
and mounts them as an optional BuildKitBuildKitThe build engine of Docker, which builds container images from a Dockerfile. It runs independent build stages in parallel, caches each layer under a key computed from its instruction and inputs, and can export this cache to a registry and import it in a later build. It can also pass secrets to a build step as files that are not stored in the image or its cache.Docker docsGlossary secret. The
patched Dockerfile does the following with the cache:
- It downloads the
x86_64-unknown-linux-muslbuild ofsccache0.15.0 from its GitHub releases, before the RustRustAn open-source programming language that compiles to native code, for fast and reliable software. It checks memory safety when a program is compiled, so its programs need no extra checks for it while they run.Rust websiteGlossary and vLLM builds. - In the
rust-buildstage,cargoruns eachrustccall through the/usr/local/bin/sc-rust-wrapscript (RUSTC_WRAPPER), which runssccache. The script has its own name because a wrapper whose file name stem issccachebreaks theopenssl-sysbuild. The stage also setsCARGO_INCREMENTAL=0,CC=/usr/bin/gcc, andCXX=/usr/bin/g++. - The vLLM build compiles through
/usr/local/bin/sccache-wrapper, which reruns a compile withoutsccachewhensccachefails with one of the infrastructure errors that the wrapper lists, and prints[sccache-wrapper] infrastructure failure rc=..., falling back.
Outside the verbose mode, the build sets SCCACHE_IGNORE_SERVER_IO_ERROR=1,
so errors of the S3 storage do not fail the build, and the log shows only the
output of sccache --show-stats after each compile.
With SCCACHE_VERBOSE=1, the build sets SCCACHE_IGNORE_SERVER_IO_ERROR=0,
and the log also shows [sccache-trace] and [sccache-debug] lines and the
S3 errors. In this mode, the vLLM build still falls back to a plain compile on
the errors that sccache-wrapper lists, but the Rust build has no fallback.
Local Build
The hook runs only on a host with /proc/meminfo, nproc, and sha256sum,
such as Linux; it stops on macOS. It also needs git to clone vLLM, and the
build needs Docker Buildx.
The hook writes vllm-common/.vllm-src and .cache/ relative to the current
folder, so run it from the root of the sc-images repository. To clone and
patch the vLLM source:
bash images/vllm-cpu-base-avx2/prepare.sh
The hook leaves the source tree owned by root when passwordless sudo is
available. Outside CICI: Continuous IntegrationThe practice of building and testing code automatically on every change, usually on a hosted service such as GitHub Actions, so problems show up before the change is merged.WikipediaGlossary, the build gets only the build arguments given with
--build-arg. A local build needs none of the build arguments that CI passes:
VLLM_CPU_AVX2=truehas no effect.max_jobs=32is already the default of the patchedDockerfile.- The hook writes compiler cache arguments only with
SCCACHE_ENABLED=true.
The local command below builds without the compiler cache.
To build the image from the patched source, with the parallelism that the hook computed for this machine:
docker buildx build \
--file vllm-common/.vllm-src/docker/Dockerfile.cpu \
--target vllm-openai \
--platform linux/amd64 \
--secret id=vllm_parallelism,src=.cache/vllm-parallelism.env \
--load \
-t vllm-cpu-base-avx2 \
vllm-common/.vllm-src
To start a vLLM server from the local tag:
docker run --rm vllm-cpu-base-avx2 <owner>/<model>
Version Changes
This image takes its vLLM version from vllm-common/VLLM_VERSION, like the
other vLLM images; see the
Version Changes
of the vLLM benchmarks. The hook clones the tag v<VLLM_VERSION> from the
vLLM repository, and the build fails
when a patch no longer applies to the new Dockerfile.