Versioning Models, Prompts, Data, and Tools › Release: turning a manifest into a deployment

Michael BrenndoerferDecember 2, 20264 min read
Language AI HandbookAll chapters
Part 64 of 67Compound AI System Design
Chapter 489Versioning Models, Prompts, Data, and Tools › Release: turning a manifest into a deployment
Reading section 6 of 14 · Release: turning a manifest into a deployment · 4 minSection 6 of 14 · 4 min

Section 6 of 14 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

A canary is a partial, time-limited deployment whose results inform rollout. The stable service acts as the control. The traffic policy here uses positive weights that sum to one. Order changes which seeded draws route to an arm while preserving that arm's probability. Canarying Releases

PythonIn [14]
CollapseExpand
import math
import random


@dataclass(frozen=True)
class DeploymentRecord:
    name: str
    allocations: tuple[tuple[float, str], ...]

    def __post_init__(self):
        weights = [weight for weight, _ in self.allocations]
        identities = [mid for _, mid in self.allocations]
        if (
            any(not math.isfinite(w) or w <= 0 for w in weights)
            or not math.isclose(sum(weights), 1.0)
            or len(set(identities)) != len(identities)
        ):
            raise ValueError(
                "Use positive weights summing to one and unique ids."
            )


def activate(
    name: str, allocations, store: dict[str, bytes]
) -> DeploymentRecord:
    if any(mid not in store for _, mid in allocations):
        raise ValueError("A deployment may select only registered manifests.")
    return DeploymentRecord(name, allocations)


def route(rng: random.Random, dep: DeploymentRecord) -> str:
    draw = rng.random()
    cutoff = 0.0
    for weight, mid in dep.allocations:
        cutoff += weight
        if draw < cutoff:
            return mid
    return dep.allocations[-1][1]  # Final arm absorbs rounding at the boundary.

Create a candidate with the same retrieval components and a new prompt. The new manifest also records the parent and revision. The activation function checks that both identities are registered before constructing the deployment.

PythonIn [15]
CollapseExpand
PROMPT_V4 = (
    "You are a support agent. Put the source id after each policy claim.\n"
)
candidate = replace(
    base_manifest,
    revision=2,
    parent=stable_id,
    components={
        **base_manifest.components,
        "prompt.main": ComponentRef(
            key="prompt.main",
            version="v4",
            identity=content_identity(PROMPT_V4),
            source="content-hash",
        ),
    },
)
canary_id = register(registry, candidate)
canary = activate(
    "support-agent", ((0.9, stable_id), (0.1, canary_id)), registry
)

rng = random.Random(0)
counts = {stable_id: 0, canary_id: 0}
for _ in range(10_000):
    counts[route(rng, canary)] += 1
ConsoleOut [16]
CollapseExpand
stable 0.904
canary 0.096

The allocation is a probability for each request in this simulation. The realized fraction over a finite stream varies with the seed. Reusing the seed, allocation, and draw order reproduces the simulated counts.

The two seeded curves show how observed request share approaches the 10% target in these simulated runs. The horizontal axis uses a logarithmic scale so the early variation remains visible.

PythonIn [17]
CollapseExpand
import numpy as np


# Replay the same seeded routing stream and record the running canary fraction.
def canary_running_fraction(seed, n_total):
    r = random.Random(seed)
    dep = canary
    hits = 0
    fracs = []
    for i in range(1, n_total + 1):
        if route(r, dep) == canary_id:
            hits += 1
        fracs.append(hits / i)
    return np.arange(1, n_total + 1), np.array(fracs)


xs, frac_seed0 = canary_running_fraction(0, 10_000)
_, frac_seed1 = canary_running_fraction(1, 10_000)
target_share = 0.10
VisualizationOut [18]
CollapseExpand
Two seeded running shares fluctuate early and approach the dashed 10 percent target. Request count uses a logarithmic axis.
The running canary share from two simulated streams approaches the 10 percent target. The early draws produce more visible variation.

The unit of assignment matters when several requests belong to one session. If the desired unit is a session, assign the session once and reuse its arm. A seed based on a different identifier for every request does not keep the session on one arm. Record the assigned manifest on each request so a later traffic change cannot replace the historical record.

Use the deployment record as a separate configuration object. Replacing this record does not store or rewrite manifest bytes. Newly assigned requests use the new record once it propagates to routing processes. Existing sessions can be allowed to finish on their earlier version, reassigned, or drained, depending on their state. Keep the version assigned to each request even if a higher-level session retains its arm.

An example assistant that does several calls per request should resolve the manifest at the start and retain that binding while processing the request. If an operator changes a live alias between retrieval and generation, resolving it again could pair a new prompt with the previous retrieval configuration. The resulting request would be hard to explain from one recorded version. Latching the initial manifest separates release decisions from the work it already admitted.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy