Production-grade guide to llm versioning strategies covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.
Llm versioning is the practice of assigning a durable, reproducible identity to every model artifact that enters a production pipeline. It matters whenever a model update is deployed, a security patch is applied, an architecture experiment is promoted, or an incident requires an immediate rollback. Without an explicit versioning strategy, a model change can silently alter output semantics, break downstream prompt logic, or make it impossible to trace which version generated a given response. The patterns below are agnostic of any particular serving platform; they map to git, docker, and Kubernetes primitives that most engineering teams already operate.
The most immediate control point is making sure a specific model artifact is what actually runs. Several orthogonal mechanisms can achieve this, and they are often combined.
Git-based provenance
git tag -a v1.3.2 -m "LLM model release"
git push origin v1.3.2
After the tag is pushed, the associated Docker image (built from that commit) can be referenced by the tag name. The tag itself is a lightweight human‑readable pointer; the immutable SHA‑1/256 behind it is the only guaranteed identity.
Docker image tagging
docker build -t my-registry/my-llm:v1.3.2 .
docker push my-registry/my-llm:v1.3.2
The tag v1.3.2 is stored in the image manifest. If the same tag is later re‑pointed to a different digest (e.g., via a force push), the behavioral effect depends on the downstream pull policy.
Kubernetes image promotion
kubectl set image deployment/app-service my-llm=my-registry/my-llm:v1.3.2
kubectl rollout status deployment/app-service --timeout=120s
This updates the container spec to pull the tagged image on the next restart (or immediately if imagePullPolicy: Always is set). The command works across any OCI‑compatible registry.
Environment‑variable pinning Many serving processes read a MODEL_VERSION environment variable at startup. Adding it to the pod spec or the container’s entrypoint ensures the process self‑identifies the version it loads:
env:
- name: MODEL_VERSION
value: "v1.3.2"
The variable’s name is convention‑level; individual frameworks may use MODEL_TAG, LLM_VERSION, or similar, but the pattern—a single string that the runtime resolves to a concrete artifact—is widespread.
HTTP‑header versioning Inference APIs frequently accept a version‑bearing header so that a single endpoint can route to different model back‑ends without DNS or service‑mesh changes. The exact header name is implementation‑specific, but the request format follows the same structure as Authorization or Accept headers:
curl -s -H "Authorization: Bearer $TOKEN" -H "Model-Version: v1.3.2" -d '{"prompt":"hello"}' https://<your-endpoint>/v1/infer
The URL placeholder represents any compliant endpoint; the flag -H Model-Version: v1.3.2 is the concrete mechanism.
Knowing which versions exist is the prerequisite for pinning or promoting.
Listing local Docker images
docker images --filter=reference='my-llm*'
The output shows the repository, tag, and digest. The digest (@sha256:…) is the immutable identifier; tags may move.
Listing git‑based tags
git tag --list 'v*'
Annotated tags carry the release message; lightweight tags only store the commit reference. Verifying the commit that a tag points to is a good practice before relying on it:
git rev-parse v1.3.2
Inspecting the immutable digest
docker inspect my-registry/my-llm:v1.3.2 --format='{{index .RepoDigests 0}}'
The digest is guaranteed to refer to the exact layer bundle that was pushed. Using @sha256:… in deployment specs prevents silent upgrades when a tag is re‑pointed.
Kubernetes label query (if applicable)
kubectl get pods -l model-version=v1.3.2
Some teams annotate pods with the model version at creation time. This query is only useful if the label‑setting process is part of the deployment pipeline, not a manual step.
Version promotion is where the gap between “available” and “in production” is closed. The goal is a deterministic, auditable transition.
Typical pipeline flow
onnxruntime bundle or a fine‑tuned weights file). docker build -t my-registry/my-llm:$CI_COMMIT_SHA .
docker push my-registry/my-llm:$CI_COMMIT_SHA
git tag -a v1.3.3 -m "Release with improved safety filters"
git push origin v1.3.3
kubectl set image deployment/app-service my-llm=my-registry/my-llm:v1.3.3
GitOps declarative promotion Instead of imperative kubectl set image calls, teams often keep a deployment.yaml (or equivalent Helm chart, Kustomize overlay, etc.) that references the desired tag:
spec:
template:
spec:
containers:
- name: my-llm
image: my-registry/my-llm:v1.3.3
Applying the manifest then becomes the promotion step:
kubectl apply -f deployment.yaml
Because the manifest is version‑controlled, the diff between v1.3.2 and v1.3.3 is a single image tag change, which can be reviewed before merge.
Automation script pattern A minimal shell helper can bump the version tag and restart the pod, useful for quick hot‑patches or internal tooling:
#!/usr/bin/env bash
set -euo pipefail
NEW_TAG=$(git describe --tags --abbrev=0)
kubectl set image deployment/app-service my-llm=my-registry/my-llm:$NEW_TAG
The script assumes the repository already has an annotated tag that matches the intended model artifact. It does not perform validation beyond what git describe returns, so teams typically embed additional checks (e.g., “tag must end in -rc for release candidates”) in their CI gates.
Adopting a consistent version‑naming scheme reduces the cognitive load of pinning and rolling back.
MAJOR.MINOR.PATCH convention
Pinning strategy
export MODEL_VERSION=v1.3.2
Pinning to v1.3 (major only) is permissible only when the team has confirmed that all minor‑level changes within the 1.x series are backward‑compatible. Pinning to the triplet eliminates the risk of a new v1.3.3 being pulled silently.
Compatibility documentation Adjacent to each released tag, maintain a brief compatibility note. Example format (stored in the repo, not vendor‑specific):
v1.3.0 — output field `citations` now includes URI scheme; update prompt templates to reference `citations.uri`.
v1.2.1 — fixed token‑count overflow for prompts > 8 k tokens.
These notes are plain‑text or Markdown files in the same repository as the model artifacts, ensuring they travel with the version.
Adapter shim when upgrading major versions If a MAJOR bump is unavoidable and downstream consumers cannot be updated immediately, deploy a thin adapter layer that translates the new output shape into the legacy format. The shim is a small code module, not a configuration toggle, and its existence should be documented alongside the version bump.
When a production run misbehaves, the ability to revert to a known‑good version is the safety net that makes versioning worthwhile.
Kubernetes‑based rollback
kubectl set image deployment/app-service my-llm=my-registry/my-llm:v1.2.3
kubectl rollout status deployment/app-service --timeout=180s
The command re‑images the pod with the earlier tag. If the pod was already running v1.3.2, Kubernetes will pull v1.2.3 on the next restart respecting the imagePullPolicy. With Always, the change takes effect immediately.
Git‑driven redeployment
git checkout v1.2.3
# Re‑build from the checked‑out commit (if the Docker build is part of the same repo)
docker build -t my-registry/my-llm:v1.2.3 .
docker push my-registry/my-llm:v1.2.3
kubectl set image deployment/app-service my-llm=my-registry/my-llm:v1.2.3
Checking out the commit ensures the exact source that produced the original image is what gets rebuilt. If the image was built in a separate CI job, the tag v1.2.3 already points to the correct digest, and the docker push step may be skipped.
Preferring digests over tags When the serving layer supports it, reference models by their OCI digest:
kubectl set image deployment/app-service my-llm=my-registry/my-llm@sha256:3a7bd4e245214590069d4d1e0f06d9438b9d5c45e2a60e9e7f7b19b39f3d7441
Digest references are immutable; even if a tag is re‑pointed, the pod continues pulling the exact same layers. This pattern is especially valuable for audit trails and long‑running production clusters where tag drift would otherwise cause silent version shifts.
Avoiding the latest trap Never allow a deployment to reference my-llm:latest in production. The latest tag is by definition the most recently pushed image, which may correspond to a version that has not undergone the full promotion pipeline. If a cluster is observed running latest, the first remediation step is to replace the image tag with an explicit version and adjust the pull policy accordingly.
Even with a disciplined versioning scheme, failure modes that are easy to overlook can surface in production.
The latest tag silently follows the newest push If a deployment’s image tag is latest and the CI pipeline pushes a new build without a corresponding version bump, the cluster will pull the new image on the next pod restart or respecting the pull policy. Rollback then requires either changing the tag to a specific version or re‑setting the image with a known digest.
Tag‑format mismatches between build and serve layers Some serving frameworks accept 1.3.0 while others require v1.3.0 or v1.3.0-rc1. When the version string passed via MODEL_VERSION or an HTTP header does not match the expected format, the serving process typically returns 400 Bad Request or 422 Unprocessable Entity. The exact message is implementation‑specific, but the pattern—string-format rejection before any model loading occurs—is consistent across OCI‑based pipelines.
Environment‑variable shadowing If MODEL_VERSION is defined both in the pod spec and in the container’s entrypoint script, the container’s override often takes precedence, regardless of the pod‑level value. This can cause a mismatch between what the operator expects and what the process actually loads. Documenting which configuration source wins (pod spec vs. entrypoint) prevents confusion during incident triage.
Git tag drift after force‑push or rebase git tag v1.3.2 creates a pointer to the commit hash present at tag‑creation time. If the branch is subsequently rebased or force‑pushed, the tag may reference a different commit than the one used to build the associated Docker image. Always verify git rev-parse v1.3.2 against the commit that produced the image, especially in teams that share a central repository with multiple merge workflows.
Digest‑vs‑tag confusion after tag re‑pointing docker pull my-llm:v1.3.2 resolves the tag to whatever digest it currently maps to. If a teammate re‑tags v1.3.2 to a new image (e.g., docker tag my-llm:v1.3.2 my-llm:new-sha), the next docker pull my-llm:v1.3.2 will fetch the new image, potentially diverging from the version that was promoted through the CI pipeline. Preferring @sha256:… references in deployment specs eliminates this class of drift.
CI pipeline ordering bugs A common pattern is git tag → docker build → docker push. If the tagging step runs before the build completes, the tag may point to a commit that has not yet been built into an image. Subsequent kubectl set image calls will then pull a tag that resolves to an image manifest missing the intended model artifacts. A safer ordering is docker build → docker push → git tag, or to include a validation step that checks the tag’s referenced digest against the just‑pushed image before proceeding.
This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy