Verify a change between two running servers (staged)¶
remote_endpoint_change.v1 compares a reference and a candidate
inference server through their OpenAI-compatible completions APIs. Use it for
changes you deploy as a server: a new engine version, a different KV-cache
dtype, a quantized checkpoint, or new server flags.
Staged
Native CPU and GPU runs are retained (see Retained evidence), but the profile stays staged because server identity is claimed: Metria records what each server reports about itself and checks it stays consistent, but cannot verify which weights or binary a remote server runs.
With host evidence collectors on each serving host,
engine configuration, model file digests and GPUs become signed,
collector_observed evidence instead of server claims.
Requirements¶
- Two running servers with a flavor that returns token IDs (
vllm), reachable overhttps, orhttpon loopback. - A local copy of the tokenizer the servers use. Its files are hashed into the recipe and used to tokenize every prompt.
- A JSONL workload whose prompts declare task checks, and a policy JSON file.
The result is always
PASSorFAIL. To use real traffic, build the workload withimport-traffic.
Prepare and verify¶
metria recipe prepare-endpoint \
--model-id served-model-name \
--tokenizer /path/to/tokenizer-dir \
--workload tasks.jsonl \
--policy policy.json \
--reference-url-env METRIA_REFERENCE_URL \
--candidate-url-env METRIA_CANDIDATE_URL \
--reference-key-env METRIA_REFERENCE_KEY \
--candidate-key-env METRIA_CANDIDATE_KEY \
--reference-declared kv_cache_dtype=auto \
--candidate-declared kv_cache_dtype=fp8 \
--output endpoint-study.json
export METRIA_REFERENCE_URL=https://reference.example.internal
export METRIA_CANDIDATE_URL=https://candidate.example.internal
metria verify endpoint-study.json --output endpoint-verification
The recipe stores only environment-variable names. URLs and keys never enter the recipe, run records, reports or error messages.
Declaring the change¶
--reference-declared and --candidate-declared (repeatable KEY=VALUE)
state what each deployment is. Allowed keys: engine, engine_version,
model_root, model_revision, max_model_len, dtype, kv_cache_dtype,
tensor_parallel_size, pipeline_parallel_size, hardware.
- Keys whose values differ are the intended change. Preparation derives
comparison.varyfrom them; the verifier rejects any othervary. engine_version,max_model_lenandmodel_rootare also checked against what the server reports: a contradiction fails the run before any prompt. When one of these is the declared change, the matching server-reported identity is allowed to differ.- Any other difference the servers report, such as an engine version you
did not declare, makes the runs
NOT_COMPARABLE.
What the verifier checks¶
| Check | Outcome when it fails |
|---|---|
| Same tokenizer pins, workload, scenario (temperature 0 and a seed) and runtime settings, apart from endpoint variables and declarations | Rejected before execution |
| Server identity unchanged between launch and the last request | INSUFFICIENT_EVIDENCE |
Server /tokenize agrees with the pinned tokenizer |
INSUFFICIENT_EVIDENCE |
| Echoed prompt token IDs match the request | The run fails |
Every request returned complete token IDs (and top-20 logprobs with --staged-kld) |
The run fails |
| Task checks retained for every measured trial | INSUFFICIENT_EVIDENCE |
Trials run sequentially. Server state, including any prefix cache, is not reset between trials, and the workload evidence says so.
Sampling, stop sequences and chat templates¶
Endpoint runs accept production decode settings in addition to greedy decoding:
Option (prepare-endpoint) |
Effect |
|---|---|
--temperature T (0–2) with --seeds 1,2,3 (1–32 distinct) |
Each prompt runs once per seed with that per-request seed, so reference and candidate draw the same seeded samples. Greedy runs keep a single --seed. |
--top-p P (0–1] |
Nucleus sampling on both servers |
--stop TEXT (repeatable, up to 4) |
Stop sequences on both servers |
--chat-template |
Metria renders the chat template from the pinned tokenizer_config.json (one user turn, generation prompt added) in a sandboxed Jinja environment, tokenizes it without adding special tokens again, and sends token IDs. The server's own template is never used. Requires jinja2. |
The rendered template is the one identity component that is verified: Metria
rendered it from hashed bytes. Its SHA-256 is retained under
observed.identity.chat_template.
With sampling, exact token agreement is a strict criterion. Judge sampled changes by task pass rates with 95% confidence intervals:
| Policy target | Meaning |
|---|---|
quality.candidate_pass_rate_lower_bound |
Lower Wilson bound of the candidate pass rate |
quality.pass_rate_delta_lower_bound / quality.pass_rate_delta_upper_bound |
Newcombe hybrid score interval of candidate minus reference |
Intervals treat each check outcome as an independent trial. Checks sharing a prompt or seed are correlated, so the intervals are approximate; more prompts narrow them more honestly than more seeds. They are available in every profile with task checks, not only endpoints.
The retained native run
used temperature 0.8 with three seeds, top_p 0.95, a stop string and a
locally rendered ChatML template against two vllm serve processes: the server
tokenizer agreed with every rendered prompt, identical servers drew identical
seeded samples, and 24 of 24 checks passing gave a lower bound of 0.862.
Concurrency and batch invariance¶
Production servers batch concurrent requests, and batching can change the
numerics of a forward pass. Add --concurrency N (2–64) and optionally
--concurrency-rounds R (1–10, default 2) to prepare-endpoint. After the
sequential trials, each run sends every prompt R times with up to N
requests in flight, and compares each output with the same prompt's first
sequential output. The schedule is part of both runs' trial policy.
| Policy target | Meaning |
|---|---|
behavior.reference_batch_invariance, behavior.candidate_batch_invariance |
Fraction of concurrent requests whose token IDs equal the sequential output |
client.requests_per_second_ratio |
Candidate/reference throughput of the concurrent pass, higher is better |
client.request_latency_ratio |
Candidate/reference mean request time in the concurrent pass, lower is better |
All four use analysis metria.batch_invariance version 1. The client.*
targets are measured on the client clock and include the network and
anything else sharing the server, so use them only between deployments
measured from the same place under comparable load. A server started with a
single sequence slot (vLLM --max-num-seqs 1) queues requests instead of
batching them, which makes invariance trivially 1.
On real CPU servers with --max-num-seqs 4, the
retained run
measured batch invariance 1.0 for both deployments (12 of 12 concurrent
requests), while client throughput differed 2× between two identically
configured servers because of host contention.
Decision¶
Trajectory agreement, task-check pass rates and reference repeatability (with
two or more measured trials) feed the policy.
--staged-kld adds the staged behavior.trajectory_kld_* targets. Latency is
reported as client-side request time, including the network, load balancer
and any other traffic on the server; it is descriptive and does not feed
performance.* targets.
Retained evidence¶
artifacts/qualification/endpoint-cpu/
runs this profile against real vllm serve processes (pinned 0.30.0+cpu,
SmolLM2-135M):
- identical servers PASS with agreement 1.0 and trajectory KLD 0;
- float32 → bfloat16 PASS a declared policy with agreement 0.953 and KLD 0.0559 nats, exactly matching the in-process vLLM result;
- a declared engine version the server contradicts ends
EXECUTION_FAILED; - an undeclared
max_model_lendifference endsNOT_COMPARABLE.
Endpoint token IDs match the in-process engine for every prompt.
On GPUs, endpoint-fp8-l4
compares two vllm serve processes on separate L4s, automatic versus FP8 KV
cache, with a trajectory-KLD policy: PASS with mean KLD 0.105 nats and
agreement 48.4, the candidate's own log confirming the FP8 cache.
See the endpoint adapter for request, retry and privacy details.