Versioning Models, Data, Prompts, and Evals

Consider a hypothetical team whose sentiment classifier starts misjudging reviews after a release. The on-call engineer does the sensible thing and rolls back: the registry alias moves from version 9 to version 8. The errors continue. Version 8 was trained with a vocabulary that has since been regenerated, so its input features no longer line up with the tokenizer the service now loads. The rollback restored the weights and nothing else. The registry listed two model versions, but the thing that had actually been working was a combination of weights, vocabulary, prompt template, runtime library, and the data and configuration behind the weights, and only one of those parts was versioned.

Versioning that whole combination is the subject here. The starting point is the platform contract in Designing a Shared AI Platform and Its Service Boundaries, which required artifacts to be pinned by digest, a rollback target to exist, and an evaluation record to exist before promotion. Here we look at how those identifiers are produced and linked. The reader is assumed to know what a hash function is, what an immutable value is, and roughly what training and evaluating a model mean; no particular framework is needed. The goals are to be able to: say what makes an artifact identifiable; build a lineage in which a change to one input invalidates exactly the artifacts that depend on it; state what must be held fixed for a training run to be reproduced and what reproducibility can and cannot promise; describe what a model registry stores and what it cannot guarantee; and design promotion and rollback so that they restore a working combination instead of a single file.

Everything in the experiments is a small local program: Python 3.12.14 and NumPy 2.2.3 on macOS 26.7.1, with a bag-of-words logistic-regression classifier standing in for a model. It is small on purpose. The questions here concern identity and dependency, and they behave the same way for a classifier with a few dozen weights as for a network with billions.

What counts as an artifact

An artifact is any stored output of a step that a later step or a running service depends on. In an AI platform that is a longer list than the model file. The model artifact entry makes the first point: the weights are not always the whole model, because a usable release also needs compatible preprocessing, configuration, and runtime dependencies, and omitting a tokenizer vocabulary can silently give wrong answers even when tensor shapes match. The list below is the working set for this article.

ArtifactWhat it isWhat it depends on
DatasetRows or files used for training, or for evaluationSource data, filters, snapshot time
Tokenizer or feature definitionThe mapping from raw input to the numbers the model seesA vocabulary or schema
Training configurationHyperparameters, seed, data order policyNone (a leaf)
Training environmentLibrary and driver versions, hardware classNone (a leaf)
Model weightsThe learned parametersDataset, tokenizer, configuration, environment
Prompt templateInstructions or formatting wrapped around inputs at serving timeNone (a leaf), but coupled to the model’s behavior
Evaluation setHeld-out cases with expected outcomes or grading rulesIts own source and curation
Evaluation resultMetric values for one model on one evaluation set under one promptModel, evaluation set, prompt, tokenizer
ReleaseThe combination that serves trafficModel, tokenizer, prompt, evaluation result, serving environment

Two kinds of dependency are mixed in this table, and separating them clarifies everything that follows. A model is built from its dataset, tokenizer, configuration, and environment, so a change to any of those can change the model’s bytes. An evaluation result is about a model, an evaluation set, and a prompt, so a change to any of those makes the old result describe a different situation. Both are dependencies, but the first is a production relationship and the second is an evidence relationship. A lineage that tracks both can answer the questions an operator actually asks: what was this made from, and what claims about it are still valid.

Names versus content identity

A name is a pointer that somebody can move. A tag such as latest, a registry alias such as champion, a file path that gets overwritten: each answers “which one do you mean” at the time of lookup and gives a different answer later. Names are convenient and they are the right way for humans and deployment tooling to refer to what is current. They are the wrong foundation for a record of what happened, because a record that says “evaluated model champion” does not say which model that was.

A content digest is the opposite. It is the output of a cryptographic hash such as SHA-256 over the artifact’s bytes, so it identifies exactly those bytes, anyone can recompute it, and a change to a single byte produces an unrelated digest. Naming data by the hash of its content in this way is called content addressing, and the name is a content-addressed identifier. A system that refers to artifacts by digest cannot silently serve something different from what was evaluated. Platform contracts therefore demand a digest wherever an exact reference is needed, and allow a name only where a moving pointer is the intended behavior.

Content digests have two limits that matter for ML artifacts. First, a digest identifies bytes, not meaning. Saving the same weights again with a different timestamp in the metadata, or in a different file ordering, gives a different digest for a model that behaves identically. Anything hashed must therefore be serialized canonically, with a fixed key order, fixed float format, and no embedded clock; the code below sorts JSON keys and uses a fixed binary float layout for the weights. Second, a digest of one file says nothing about the files it was built from. A model’s digest does not tell you which dataset produced it. That is the job of lineage.

Lineage as identity that includes inputs

Provenance is the record of how an artifact was produced: which inputs, which code, which environment. A simple way to make that record tamper-evident and automatically consistent is to fold the inputs into the identity. Each artifact’s identity is a hash over its own content digest and the identities of all its inputs. Because the inputs’ identities in turn include theirs, a change anywhere upstream changes every identity downstream, much as a change in a commit changes the hash of every later commit in a Git history.

The class below implements it. It is excerpted from the program used in this article.

import hashlib, json, sys, platform
import numpy as np

def sha(b): return hashlib.sha256(b).hexdigest()
def canon(o): return json.dumps(o, sort_keys=True, separators=(",", ":")).encode()

class Artifact:
    """Identity = hash of (kind, content digest, identities of every input)."""
    def __init__(self, kind, content, inputs=None, meta=None):
        self.kind, self.inputs, self.meta = kind, dict(inputs or {}), meta or {}
        self.content = content                       # bytes
        self.content_digest = sha(content)
        self.id = sha(canon({"kind": kind, "content": self.content_digest,
                             "inputs": {k: v.id for k, v in sorted(self.inputs.items())}}))

The id is a hash of a canonical JSON object holding the kind, the content digest, and the sorted input identities. The content_digest is kept separately because the two answer different questions: the content digest says whether the bytes are the same, and the lineage id says whether the bytes and everything they were made from are the same.

The pipeline builds the artifacts in the table above and wires the inputs as the table shows.

def build(inp):
    """inp: dict of raw inputs -> dict of artifacts."""
    D = Artifact("dataset", canon(inp["rows"]))
    K = Artifact("tokenizer", canon(inp["vocab"]))
    C = Artifact("train_config", canon(inp["cfg"]))
    TE = Artifact("train_env", canon(inp["train_env"]))
    E = Artifact("eval_set", canon(inp["eval_rows"]))
    P = Artifact("prompt", inp["serve_prompt"].encode())
    SE = Artifact("serve_env", canon(inp["serve_env"]))
    w = train(inp["rows"], inp["vocab"], inp["cfg"], inp["train_prompt"])
    M = Artifact("model", w.astype("<f8").tobytes(), {"data": D, "tok": K, "cfg": C, "env": TE})
    acc = evaluate(w, inp["eval_rows"], inp["vocab"], inp["serve_prompt"])
    V = Artifact("eval_result", canon({"accuracy": round(acc, 4)}), {"model": M, "eval": E, "prompt": P, "tok": K})
    L = Artifact("release", b"release-manifest", {"model": M, "tok": K, "prompt": P, "eval": V, "env": SE})
    return dict(D=D, K=K, C=C, TE=TE, E=E, P=P, SE=SE, M=M, V=V, L=L), acc

train fits the logistic regression with mini-batch gradient descent, drawing batches in an order fixed by the configuration’s seed. evaluate returns accuracy on the evaluation set. Note the wiring of the last two artifacts. The evaluation result takes the model, the evaluation set, the prompt, and the tokenizer as inputs, which is the evidence relationship. The release takes the model, tokenizer, prompt, evaluation result, and serving environment, so a release identity captures the whole combination that serves traffic.

Data versioning follows the same rule one level down: the data versioning entry describes immutable snapshots, manifests, object versions, and table history as ways to make a dataset addressable, and the point it makes carries over: whichever mechanism is used, the identifier must be recorded with the run that used it so that a model version leads to its data version without anyone having to remember. In this article’s program the dataset’s identity is the hash of its canonical rows, which is the simplest possible form of a snapshot.

Which artifacts does one change invalidate?

The first experiment changes exactly one input at a time, rebuilds everything, and reports which identities changed. It also reports whether the model’s bytes changed and the accuracy on the evaluation set. The base inputs are 400 generated training rows and 200 generated evaluation rows with 10 percent label noise, so accuracy lands near 0.9 rather than at 1.0. Here is the output.

baseline accuracy 0.9000
model content digest 3b14e69b378e | model id 363e49099f1e | release id c873a9291f77 

single change                     data     tok     cfg    tenv    eval  prompt    senv   model  result release   acc    model bytes
one training row label         CHANGED       .       .       .       .       .       . CHANGED CHANGED CHANGED  0.8800  differ
tokenizer vocab (+1 entry)           . CHANGED       .       .       .       .       . CHANGED CHANGED CHANGED  0.9000  differ
training seed                        .       . CHANGED       .       .       .       . CHANGED CHANGED CHANGED  0.8950  differ
one eval-set label                   .       .       .       . CHANGED       .       .       . CHANGED CHANGED  0.9050  same
serving prompt template              .       .       .       .       . CHANGED       .       . CHANGED CHANGED  0.9000  same
training library version             .       .       . CHANGED       .       .       . CHANGED CHANGED CHANGED  0.9000  same
serving runtime version              .       .       .       .       .       . CHANGED       .       . CHANGED  0.9000  same

Read the table by rows. The first three rows change something the model is trained from: one flipped training label, one extra vocabulary entry, a different seed. The model, the evaluation result, and the release all change identity, and the model’s bytes differ. This is the case everyone expects.

The fourth row flips one label in the evaluation set. The model’s identity and bytes are untouched, which is correct, since the evaluation set is not an input to training. The evaluation result and the release change identity, since the earlier measurement described a different test. Accuracy moved from 0.9000 to 0.9050: one example out of 200 is 0.005. In a system that tracks only model versions, this edit would change a reported metric with no version to explain it.

The fifth row changes only the serving prompt template. The model is unchanged, but the evidence is invalid until it is re-run, and the release is a different combination. Accuracy did not move here, because the words added by the new template are not informative to this toy model, so the example also shows why the identity must change even when the metric does not: identity says that the old evidence no longer applies, and re-running the evaluation is what discovers whether the result changed. For a large language model, where the same sentence can steer behavior substantially, a prompt edit can matter far more than any weight change.

The sixth row is the most subtle. It records a different training-library version without changing any computation: the model’s bytes are identical, yet its lineage id changes, and so do the evaluation result and release. This is the conservative direction of lineage. The system cannot know that a library upgrade left the numerical results alone, so it treats the model as different and requires either a re-evaluation or an explicit statement of equivalence from a person who has checked it. A content-digest comparison is what supports that statement: if a retrained model has the same bytes, equivalence is established; if it does not, the lineage is the starting point for investigating why. The seventh row changes only the serving runtime version, which affects the release but neither the model nor its evaluation result. That reflects a policy choice, and another platform could treat a runtime upgrade as invalidating evidence too. The section on promotion below returns to that choice.

ChangeInvalidates the modelInvalidates evaluation evidenceTypical response
Training data, tokenizer, configurationYesYesRetrain, re-evaluate, new version
Evaluation setNoYesRe-run evaluation; compare with the old set separately
Serving prompt templateNoYesRe-run evaluation; new release
Training library or hardwarePossibly (bytes can match)Yes, by defaultCompare digests; re-evaluate or attest equivalence
Serving runtimeNoPolicy-dependentSmoke test; re-evaluate if the runtime can change numerical results

What reproducibility requires

Reproducibility means that running the same procedure again yields the same result. For model training that sentence hides three levels of “same”: bit-identical weights, equivalent metrics within noise, and a similar overall behavior. Which level a platform promises determines what it must record.

The second experiment tests the first level. It runs the same inputs in three separate processes, then changes one input at a time, then repeats the training with 12 seeds, and finally adds the same 100,000 single-precision numbers in two orders.

A. same inputs, three separate processes
   3b14e69b378e 0.9000
   3b14e69b378e 0.9000
   3b14e69b378e 0.9000
B. one input changed at a time (model digest, accuracy)
   baseline                     3b14e69b378e 0.9000
   seed 7 -> 8                  35269ee829a2 0.8950
   same rows, reversed order    7a85d3a25c8b 0.8800
   epochs 20 -> 21              ed137f4cb178 0.9000
C. 12 seeds, identical data and config
   accuracies: 0.895 0.885 0.885 0.900 0.900 0.885 0.890 0.900 0.895 0.895 0.895 0.890
   min 0.885  max 0.900  distinct model digests: 12 of 12
D. floating-point addition is not associative
   forward sum : -90.82496643066406
   reverse sum : -90.82673645019531
   bit-identical: False

Part A shows that bit-identical results are achievable. On one machine, with the same library versions, a fixed seed, a fixed data order, and no source of nondeterminism, three processes produce the same digest. This is the baseline reproducibility check a platform can run: train twice and compare digests.

Part B shows how little it takes to lose it. Moving the seed from 7 to 8 changes the batch order and the digest. Reversing the dataset’s row order, with the seed unchanged, changes it again, because the seeded permutation then selects different rows for each batch. Training for one extra epoch changes the weights. The lesson is that “the same data” means the same rows in the same order if the training procedure is order-sensitive, so a dataset’s identity should include its order or the pipeline should canonicalize it.

Part C separates bit-identical from equivalent. Twelve seeds on identical data and configuration give twelve different digests and accuracies between 0.885 and 0.900. With 200 evaluation examples, the sampling error of an accuracy near 0.9 is about \( \sqrt{0.9 \times 0.1 / 200} \approx 0.021 \), the standard error of a proportion, which is larger than the whole spread across seeds. A candidate model that scores 0.01 higher than the incumbent has not shown an improvement on this evidence, and the evaluation gate in the platform contract should include uncertainty, not a bare threshold. Two models with different digests are different artifacts even when they are statistically indistinguishable, and the registry should treat them as different versions.

Part D shows one low-level reason why bit-exactness is fragile. Floating-point addition is not associative, so summing the same numbers in a different order changes the result. Here the forward and reverse sums of 100,000 numbers differ by about 0.0018. Parallel hardware reorders reductions routinely, so identical code can give different bits when the number of threads, the library version, or the device changes. The PyTorch reproducibility notes say as much: completely reproducible results are not guaranteed across releases, individual commits, or platforms, nor between CPU and GPU executions even with identical seeds, and they describe settings such as seeding with torch.manual_seed(), calling torch.use_deterministic_algorithms(True) where available, disabling cuDNN benchmarking, and seeding data-loader workers, at a cost: deterministic operations are often slower.

What the platform should therefore record, and what it should promise, follows:

  • Record everything that determined the run: dataset identity (including order), tokenizer identity, configuration with the seed, code revision, library versions, and hardware class. These are the leaves of the lineage above.
  • Promise bit-identical reproduction only where the record includes the full environment and the training procedure is deterministic, and verify it by actually repeating the run.
  • Otherwise promise metric-equivalent reproduction: repeat the run, measure the spread across seeds, and state the noise floor that evaluation gates must exceed.
  • Treat resumption as part of reproducibility. A run that was stopped and restarted has to restore not just weights but optimizer state, random-number state, and data position to be equivalent to an uninterrupted run, which is the subject of the last article in this module.

What a model registry holds

A model registry is the shared catalog of model identities, versions, and metadata. The model registry entry notes that a registry can link a version to its artifact, training run, evaluation evidence, and intended use, that supported records and approval workflows vary by implementation, and that registration is not approval. MLflow is a widely used open-source example, and its documentation is a useful concrete reference for the concepts. An MLflow registered model is a named container for versions; each model version is added under that name with an automatically incremented number; tags are key-value pairs that can be placed on a model or a version, for instance a validation status; aliases are mutable references to a version, for example champion, which can be used in a URI of the form models:/<name>@<alias>; and lineage connects a registered model to the run or notebook that produced it. The documentation also states that registry stages are deprecated and that aliases, tags, and separate registered models per environment (with access controls) replace them. Concrete operations are set_registered_model_alias() to create or move an alias and set_model_version_tag() to annotate a version.

This is a product layer sitting on top of the principles above, and it helps to see how they map. A registry version number identifies a registration event. It is not a content digest, and it does not by itself bind the tokenizer, the prompt, or the evaluation set unless those are recorded as metadata and checked. An alias is a name: moving it changes what future lookups return, and the glossary entry points out that a running process that loaded version 7 is not necessarily reloaded when the alias moves to version 8, so deployment logic must apply the change and monitoring must report the version actually serving. A registry gives a place to attach the records; the platform still has to decide which records are mandatory and check them.

The program below is a minimal registry that does exactly that, and it is written to make the checks visible. Versions are immutable records holding the model’s lineage id, its content digest, a requires declaration naming the tokenizer it was built with, and a list of evidence records. Aliases are the only mutable part, and every change goes to an append-only log.

from lineage import *

class Registry:
    def __init__(self):
        self.versions = {}      # (name, n) -> record (immutable once written)
        self.aliases = {}       # (name, alias) -> n   (mutable)
        self.log = []           # append-only audit trail
    def register(self, name, art, requires):
        n = 1 + max([v for (nm, v) in self.versions if nm == name], default=0)
        self.versions[(name, n)] = {"id": art.id, "digest": art.content_digest, "requires": requires,
                                    "lineage": {k: v.id for k, v in art.inputs.items()}, "evidence": []}
        self.log.append(f"register {name} v{n} id={art.id[:8]}")
        return n
    def attach_evidence(self, name, n, result):          # written by the evaluation service
        self.versions[(name, n)]["evidence"].append({"model_id": result.inputs["model"].id,
                                                     "eval_id": result.inputs["eval"].id,
                                                     "metrics": json.loads(result.content)})
        self.log.append(f"evidence {name} v{n} {json.loads(result.content)}")
    def promote(self, name, n, alias, min_acc, serving_tok, approver, owner):
        rec = self.versions[(name, n)]
        if approver == owner: return self._deny(name, n, alias, "approver is owner")
        ok = [e for e in rec["evidence"] if e["model_id"] == rec["id"] and e["metrics"]["accuracy"] >= min_acc]
        if not ok: return self._deny(name, n, alias, "no evidence for this exact version meets the gate")
        if rec["requires"]["tokenizer_id"] != serving_tok.id:
            return self._deny(name, n, alias, "tokenizer mismatch: model trained with a different vocabulary")
        prev = self.aliases.get((name, alias))
        self.aliases[(name, alias)] = n
        self.log.append(f"promote {name} v{n} -> @{alias} (was v{prev}) by {approver}")
        return True
    def rollback(self, name, alias, to):
        cur = self.aliases[(name, alias)]; self.aliases[(name, alias)] = to
        self.log.append(f"rollback {name} @{alias}: v{cur} -> v{to}")
    def _deny(self, name, n, alias, why):
        self.log.append(f"DENIED promote {name} v{n} -> @{alias}: {why}"); return False

Promotion applies the contract’s rules from the previous article in code. It refuses an approver who owns the model. It looks for evidence that was produced for this exact version, matching on the model’s lineage id, and that meets the gate. It checks that the tokenizer the model requires is the tokenizer the serving release uses. Only then does it move the alias, and it records what the alias pointed to before.

The scenario registers three versions of the classifier. Versions 1 and 2 differ in seed. Version 3 was trained with a one-word-larger vocabulary. Evidence for version 2 is attached by mistake from version 1’s evaluation. The script then tries four promotions and one rollback.

register sentiment v1 id=363e4909
register sentiment v2 id=10b4e9ff
register sentiment v3 id=ff09f514
evidence sentiment v1 {'accuracy': 0.9}
evidence sentiment v3 {'accuracy': 0.895}
evidence sentiment v2 {'accuracy': 0.9}
promote sentiment v1 -> @champion (was vNone) by quality-team
DENIED promote sentiment v2 -> @champion: no evidence for this exact version meets the gate
DENIED promote sentiment v3 -> @champion: tokenizer mismatch: model trained with a different vocabulary
DENIED promote sentiment v1 -> @challenger: approver is owner
evidence sentiment v2 {'accuracy': 0.895}
promote sentiment v2 -> @champion (was v1) by quality-team
rollback sentiment @champion: v2 -> v1
aliases: {'sentiment@champion': 'v1'}

The first promotion succeeds: version 1 has matching evidence at 0.90 and a compatible tokenizer. The second is denied, even though version 2 has an evidence record at 0.90, because that record names version 1’s model id; a check that only looked for “some evidence above the gate” would have passed it. The third is denied for a compatibility reason: version 3 has good evidence, but it was trained with a vocabulary that differs from the one the serving release loads, which is the problem in the opening scenario caught before release. The fourth is denied because the approver is the owner. After the right evidence is attached for version 2, its promotion succeeds and the log records that the alias previously pointed to version 1. The rollback then returns the alias to version 1.

Compatibility is part of the version

Each denial above rests on a statement that two artifacts belong together. These couplings are the reason the opening rollback failed, and they are the main thing a plain version number does not capture. The common ones are:

  • **Model and tokenizer or feature schema.** The model learned weights indexed by token or feature position. A different vocabulary shifts the meaning of every input. The requires field in the registry code is the declaration of this coupling.
  • **Model and prompt template.** A model tuned or tested under one instruction format may behave differently under another, and a model that has a chat format baked in expects inputs in that format.
  • **Model and serving runtime.** Serialized formats, supported operators, numerical libraries, and hardware features limit where a model can run and how it behaves. MLflow’s model format records an environment description and a model signature alongside the weights: the MLmodel file lists flavors, a creation time, the producing run, and the schema of inputs and outputs, and accompanying files such as requirements.txt and python_env.yaml describe the dependencies.
  • **Model and training lineage.** A fine-tuned or adapted model is only valid on top of the exact base it was derived from; this is the same dependency recorded as an input in the lineage.
  • **Model and downstream consumers.** If the output schema changes, consumers can break. The platform contract’s interface rules apply to model outputs as much as to HTTP responses.

Declaring a coupling is not enough on its own, because declarations can be wrong. The checks need to run at two points: at promotion, as the registry code does, and again when the service loads the artifact, so that a service refuses to start with an incompatible combination. A signature or requires declaration says what the author intended; a representative load-and-predict test says whether it works. Both are cheap compared with an incident, and the model-artifact entry makes the same point: identity and usability are separate checks, and a digest identifies bytes without demonstrating that the model runs correctly in a new environment.

Promotion and rollback as operations on combinations

Promotion authorizes a particular combination to serve. The model promotion entry lists the checks that precede it: input checks, a comparison against the incumbent under a predefined criterion, important slices within limits, a validated decision rule, and an authority that approves the transition, with a record of the approved candidate, the prior version, evidence, and what actually received traffic. The registry code above implements the parts that are mechanical, and adds the independence rule from the platform contract. What it cannot do is decide the criterion, and that remains with the evaluation owner.

Rollback is the reverse operation, and the registry code’s rollback is deliberately naive: it moves the alias and nothing else. That is the same mistake as in the opening scenario, avoided here only because version 1’s required tokenizer still equals the serving tokenizer. A safe rollback has four requirements. The previous version’s artifact must still exist, which means retention policy must not delete it while it is the designated fallback. Its compatible tokenizer, prompt template, and runtime must also still exist and be selectable together, which is why the release, not the model, is the unit of rollback. The compatibility checks must run again against the current environment, since the environment may have moved since the fallback was last live. And the application of the change must be confirmed: deployment or reload logic has to act on the new alias value, and the serving record should show which release answered requests afterward.

Three limits remain. A rollback does not undo effects that the newer version already had, such as predictions written to a downstream store or features computed from them. A rollback to an old model that was trained on data since deleted for compliance reasons may be possible technically and prohibited by retention rules. And a rollback is only as quick as the combination is available: restoring weights from cold storage can take long enough to matter, so the recovery time objective should be set with the fallback’s storage tier in mind.

Recording what served each request

The last piece closes the loop with the platform contract, whose runtime service promised to record which artifact served which request. For this article the useful record is the release id: the lineage id of the combination, not only the model version. With the release id in each request log, an incident review can answer which model, tokenizer, prompt, evaluation evidence, and runtime were in use, and a quality change can be tied to a single changed input by comparing the lineage of two releases. If a release id appears in requests after the registry says it was rolled back, then the alias moved without a reload, which is the failure the registry entry warns about.

From versions to the machines that run them

This article treated an AI platform’s outputs as a graph of immutable, content-addressed artifacts joined by lineage: identity that includes inputs, evidence that is tied to the exact version it measured, compatibility declared and checked, and promotion and rollback performed on whole releases. The next article, Scheduling GPU Workloads and Managing Resource Isolation, turns to the resource those artifacts compete for. It explains how GPUs are described to a scheduler, how jobs are placed and queued under quotas, and how sharing a device changes what isolation can promise.

References


Discover more from Insightful Data Lab

Subscribe to get the latest posts sent to your email.

Similar Posts

Questions, corrections, or additional insights?

This site uses Akismet to reduce spam. Learn how your comment data is processed.