Model Serving

Model serving turns inference into an interface that users, workflows, or other systems can call reliably. Serving concerns include request batching, model loading, resource isolation, timeouts, monitoring, versioning, and rollout policy.

The serving path is usually:

Serving Contract

Serving should expose a stable contract, not just a model checkpoint.

Contract fieldQuestion
input schemawhat is accepted and rejected?
preprocessingwhich transforms and versions run before inference?
model versionwhich weights/config/tokenizer or featurizer are active?
postprocessingthresholds, calibration, formatting, validation
SLOlatency, throughput, availability, timeout, error budget
loggingwhat is recorded, redacted, or never stored?

The model version and preprocessing version must move together. A serving bug can come from a schema or preprocessing mismatch even if weights are unchanged.

Serving Modes

ModeUse whenMain risk
synchronous APIuser waits for responsetail latency and timeout
async jobrequest can complete laterstatus tracking and retries
streamingpartial output usefulcancellation and partial validity
batch endpointmany examples scored togetheroutput versioning and retry shards
agent toolLLM calls service as actionside effects and contract validation

Observability

Serving metrics should separate model behavior from system behavior.

SignalTells you
request count and error rateinterface health
p50/p95/p99 latencytail behavior
queue lengthcapacity pressure
batch size distributionbatching effectiveness
input rejection rateschema or client mismatch
model confidence/calibration driftprediction distribution change
resource utilizationCPU/GPU/memory bottleneck

Key Decisions

  • Single model or multiple model versions.
  • Synchronous, asynchronous, batch, or streaming interface.
  • Static batching, dynamic batching, or continuous batching.
  • CPU preprocessing and GPU inference boundary.
  • Canary, shadow, blue-green, or batch rollout strategy.
  • Timeout, retry, and fallback policy.
  • Logging policy that avoids private data capture.

Checks

  • What is the public contract of the endpoint or workflow?
  • Does the endpoint follow a documented inference contract?
  • Are model version and preprocessing version tied together?
  • Is the deployment strategy explicit and reversible?
  • Are tail latency and error rate measured?
  • Can the service reject unsupported inputs clearly?
  • Does logging exclude secrets, private inputs, and unpublished data?
  • Are preprocessing, model, and postprocessing versions deployed atomically?
  • Are model-quality metrics separated from system-health metrics?