TECHNOLOGY

MLServer REST null values: NaN decoding depends on datatype and codec

In this article
THE QUICK TAKE

MLServer documents null-to-NaN handling for specific REST floating-point codec paths; do not generalize it to every transport, datatype or model.

A missing feature arrives through JSON

A model supports a missing numeric feature represented internally as NaN. Its caller sends null in JSON, assuming this is universally equivalent. The result depends on the serving decoder: JSON syntax by itself does not decide which numerical object the model receives.

Separate the transport representation from the missing-value semantics learned by the model. Even a correctly decoded NaN is useful only if preprocessing and inference support that interpretation for the affected feature.

The documented conversion has explicit conditions

The content-type guide documents null-to-NaN conversion for REST, floating tensor datatypes FP16, FP32 or FP64, and the NumPy or Pandas codec. Those conditions describe a particular decoding path, not a general rule for every request field.

Do not infer the same behavior for an integer tensor, an arbitrary custom codec or another transport. Unsupported representations should have a deliberate application policy rather than silently inheriting assumptions from a different endpoint implementation.

Numeric reconstruction is a codec responsibility

The NumPy codec implementation provides primary implementation context for converting protocol tensor data into arrays. Check the runtime version used in deployment when investigating behavior beyond the documented contract.

Nullable feature contracts explain why missingness is more than a physical placeholder. A model may distinguish an absent field from a present value that represents missing data; the serving interface must define that distinction explicitly.

The runtime must consume the intended value

The custom-runtime guide describes how a runtime handles decoded requests. Inspect the value entering preprocessing rather than deciding success from an accepted HTTP request or a syntactically valid inference response.

Schema and population drift adds useful context: a deployment can preserve its schema while the frequency of missing features changes substantially. Correct decoding does not establish unchanged model behavior under that new input population.

Test missingness end to end

Construct a controlled request with a known missing numeric feature and compare the decoded value and prediction with an isolated model reference. Use FP16, FP32 or FP64 only where the chosen model contract actually expects those representations.

Also test the intended rejection or handling of unsupported combinations. The release evidence should explain both how null reaches the model and what the model means by it, without treating a transport conversion as a complete missing-data policy.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles