LOAD-BEARINGfree
High-level designTier 11 · unit 4 of 5 · 13 min read

Training and serving skew

A model scores well in evaluation and performs badly in production. The team retrains, re-evaluates, redeploys — and it happens again. Nothing is wrong with the model. The features it sees when serving are not the features it was trained on, and that gap has a name and three quite different causes.

Cause one: two implementations of one definition

Training features come from a batch job over the warehouse — SQL or a dataframe pipeline, written by whoever built the training set. Serving features are computed in application code on the request path, written by whoever built the endpoint. Both compute "average order value over the last 30 days".

They will not agree. They will differ on whether the window is 30 days or 30 calendar days, on which timezone the boundary uses, on whether refunds subtract, on how a null is treated. Each difference is small and defensible; together they mean the model is scoring inputs it never saw during training.

This is Lesson 7.05's problem exactly — one definition, implemented twice, diverging quietly — with a nastier symptom. A diverging dashboard shows a number people can argue about. A diverging feature degrades a model with no error anywhere.

Cause two: the model learned from the future

The subtler one, and the one that produces suspiciously excellent offline results. The training set was assembled with a join that pulled in information recorded after the moment being predicted — a customer's final lifetime value in a churn feature, a status field that only gets set once the outcome is known, a slowly-changing attribute read at its current value rather than its value at the time.

The model learns from it, offline metrics look wonderful, and at serving time that information does not exist yet. The discipline that prevents it is point-in-time correctness: every feature value in a training row must be what it was at the instant of the event, not what it is now.

Which is Lesson 3.07 arriving with consequences. Getting this right requires the temporal modelling that lesson described — valid time distinct from transaction time, Type 2 dimensions that preserve what an attribute was when the order was placed. A system that only stores current state cannot build a correct training set at all, and that limitation is invisible until someone asks why the model underperforms its evaluation by twenty points.

Cause three: the world moved

No bug, no divergence — the input distribution simply changed. New products, a pricing change, a marketing campaign that brought in a different kind of user, a competitor's outage. The model is now trained on a world it no longer serves.

This one is not fixed once. It is a permanent monitoring obligation, and it is the reason the next section looks nothing like Tier 9.

The feature store, and when a library is enough

The structural answer to cause one is to compute each feature once, from a single definition, and serve it to both paths:

  • An offline store — columnar, historical, point-in-time queryable — from which training sets are built. Tier 7's warehouse, with a temporal requirement.
  • An online store — low-latency key-value, holding current values only — read on the request path. Tier 3 and Tier 4's territory, at single-digit-millisecond deadlines.
  • One definition populating both, so the two paths cannot drift apart.

Be honest about the cost: a feature store is real infrastructure with real operations, and adopting one because the architecture diagram looked incomplete is how teams acquire a system nobody owns. The property you need is a single definition, not a particular product. Below a certain size, a shared library both paths import — plus a test asserting the two produce identical values on identical input — buys most of the benefit for a fraction of the operational surface. That test is the load-bearing part either way.

The latency deadline shapes the rest: features must arrive in milliseconds, so anything requiring a join or an aggregation at request time is already too slow. Features are precomputed and materialised, which is 4.06's compute-at-write-time with a hard constraint attached — and it means every feature carries a freshness question.

Monitoring without errors

Tier 9 assumed failure was observable: a status code, a stack trace, an SLO breach. Here the model returns a confident, well-formed, wrong answer, and every dashboard stays green. Lesson 7.05 warned that data breaks silently; this is that property applied to a decision rather than a number.

So the signals are different in kind:

  • Input distributions — compare live feature values against the training distribution. Drift here is the earliest available warning and often the only one.
  • Output distribution — the shape of predictions over time. A model that suddenly approves twice as many applications has told you something even before you know whether it was right.
  • Delayed labels — actual outcomes arrive days or weeks later, so real accuracy is a lagging metric with a pipeline of its own. Build that pipeline early; retrofitting it means you cannot answer "when did this start" for the period you most care about.
The trap

Responding to skew by retraining. It works — the model is refit to whatever the serving path actually produces, the metric recovers, everyone moves on. And the two code paths are still different, so it comes back, and each retrain buries the cause a little deeper under a layer of accommodation. Retraining is the correct response to genuine drift and the wrong response to a definition mismatch, and the two are indistinguishable from the metric alone. Diff the two implementations on the same input before you touch the training pipeline.