Manuscript Offprint

arXiv:2610.09111

Same Text, Different Prediction: Serving-Context Nondeterminism in Text Classifiers

Santhosh Kumar Kasa, Siva Rajesh Kasa, Sumit Negi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Deterministic inference is essential for reliable and trustworthy machine learning. Prior studies of text generation have shown that changing factors such as batch size, batch composition, hardware, or inference engine can alter the generated text, even when the prompt, model parameters, and sampling randomness are fixed. These differences have been attributed in part to floating-point non-associativity, shape-dependent kernel selection, and other implementation-level differences in numerical execution. However, it remains unclear whether, when, and to what extent the same factors affect text classification. We present a systematic study of serving-context non-invariance in text classifiers, which prior work has measured only through generated text. We train 180 models spanning discriminative, pseudogenerative, and fully generative classifier formulations and evaluate each across four categories of serving contexts, holding the checkpoint and the text fixed. Label stability does not imply score stability. Changing only the batch shape changes no labels across fp32 comparisons, yet under bf16 it moves up to 56.7 percentage points of predicted probability mass, with label changes concentrated at small margins. Fully generative classifiers change more labels than their discriminative counterparts under the same serving changes. We derive sufficient conditions for label stability under each serving change and give a separate mitigation for each mechanism. Our results identify and quantify the serving conditions that must be fixed for reproducible text classification.

1 INTRODUCTION

A large language model given the same prompt, the same parameters, and the same sampling seed is widely expected to produce the same output, yet in practice it often does not. With every user-visible input fixed, the generated text can still change when the batch size or batch composition changes, when numerical precision changes, when the hardware changes, or when one inference engine is exchanged for another (Pape et al., 2026; Yuan et al., 2025). This phenomenon has been termed nondeterminism. One documented cause of nondeterminism is numerical. Floating-point addition is not associative (Goldberg, 1991), and serving systems select kernels and reduction orders as a function of batch shape and load, so the same logical computation is executed as a different sequence of rounded operations (He, 2025; Yuan et al., 2025; Zhao et al., 2026). A second cause is the inference backend itself. Implementation choices such as paged attention, custom CUDA kernels, and optimized memory management introduce divergence large enough that switching backends alone, with model weights, prompts, decoding parameters, and hardware held constant, shifts benchmark scores by several percentage points, and by up to 16.6 in the extreme case (Pape et al., 2026). In autoregressive generation these perturbations compound, because a single altered token early in the sequence conditions every token that follows. Nearly all of this evidence, however, concerns text generation. Whether the same serving-context changes affect the single forward pass of a text classifier has received almost no direct attention or measurement.

Text classification is among the most widely deployed applications of neural language models, spanning sentiment analysis (Maas et al., 2011; Socher et al., 2013), topic classification (Zhang et al., 2015), emotion detection (Saravia et al., 2018), etc. Classifiers operate in both online real-time and offline batched settings, embedded in production pipelines for relevance estimation and

∗^{*}Accepted at the LIGHT, ODI, and TAE workshops at NeurIPS 2026.

ranking (Nogueira & Cho, 2019), filtering (Sahami et al., 1998), and content moderation (Lees et al., 2022; Wulczyn et al., 2017), where they form part of larger machine learning systems whose behavior must be maintained over time (Sculley et al., 2015). Transformer-era classifiers also come in distinct paradigms. Following the terminology of Kasa et al. (2025), discriminative classifiers attach a dedicated classification head to a pretrained encoder (Devlin et al., 2019); pseudo-generative classifiers are trained with a language-model objective and predict a class token in a single forward pass; and fully generative classifiers compare the likelihood of the input under each candidate class, a distinction with a long history from classical statistics to neural models (Efron, 1975; Ng & Jordan, 2001; Yogatama et al., 2017; Zheng et al., 2023). These formulations differ measurably in propensity to shortcut learning (Kasa et al., 2026; Li et al., 2025), sample efficiency (Ng & Jordan, 2001; Zheng et al., 2023), calibration (Guo et al., 2017), and privacy risk (Makroo et al., 2026), so a serving-time perturbation need not affect them equally.

In every one of these deployments, serving-context nondeterminism can change the final probabilities without any visible change to the model or the text, with direct consequences such as a reclassified review, a rerouted document, or a filtered message. Yet deployed classifiers are commonly monitored through aggregate metrics such as accuracy or F1, which are invariant to which examples flip. This motivates our present study. We ask whether the serving-context effects documented for generation transfer to classification, and whether the apparent invariance of classification reflects stability or only the absence of measurement. We present a systematic study of serving-context sensitivity in neural text classifiers, conducted through large-scale controlled experimentation. The contributions of this work are as follows:

  1. First systematic empirical study. We organize serving-context factors into a taxonomy and measure their effects. We train 180 text classifiers from scratch (four transformer classification formulations, three sizes, five datasets, three seeds) and evaluate each across 3,960 serving contexts (padded length, batch size, batch composition, precision, quantization, device, backend), holding the checkpoint and text fixed so any change is attributable to the setting rather than run-to-run randomness. Two findings follow. Changing the padded length alone changes about 10% of predicted labels, more than any other factor, and settings that change almost no labels still shift class probabilities by tens of points, so label accuracy does not reveal the instability.

  2. Mitigations. We show that each mechanism has a targeted fix and measure its invariance-cost trade-off.

  3. Theory. We formalize the conditions under which logit and probability drift can lead to label flipping. We also give sufficiency conditions to rule out padding-based non-determinism. Based on the empirical results, we formalize the three-way tension among inference speed, task accuracy, and serving-context invariance into an impossibility condition: the optimizations that make serving fast, including dynamic batching, reduced precision, quantization, and shape-dependent kernel selection, are the mechanisms that threaten invariance, while remedies that restore invariance can cost speed or accuracy.

References (53)