arXiv(opens in a new tab)cs.OSAug 2026Cited by 4 papers on PaperVantage

Manuscript Offprint

arXiv:2608.14376

CoRun: Padding is Simple and Efficient for Deterministic LLM Inference

Shiju Zhao, Jiacheng Yang, Qihang Chen, Junhao Hu, Jiaqi Zheng, Guihai Chen, Xusheng Chen

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

Abstract

Despite fixed sampling parameters and random seeds, Large Language Model (LLM) inference exhibits output inconsistency, which undermines downstream tasks such as model evaluation and reinforcement learning. A major source of this nondeterminism is batch-dependent GPU execution: dynamic input shapes change kernel tiling and floating-point reduction orders. Existing systems address this problem with batch-invariant kernels, but these kernels restrict optimized tiling and split reductions, increasing more than 2×\times latency and reducing serving throughput by up to 74%. This paper observes that although most kernels are not batch-invariant, they are position-invariant. Leveraging this property, we present CoRun, a scheduling-based system that achieves deterministic inference without requiring batch invariance. CoRun employs isolated prefill and fixed-shape batched decode to handle the two stages of LLM inference, respectively, leveraging CUDA graphs for efficient execution and simplified implementation. Experiments on LLMs with diverse architectures, including Qwen and DeepSeek, show that CoRun ensures determinism while improving throughput by 15–324% over batch-invariant approaches, reducing time-to-first-token by 51.8% and time-per-output-token by 48.6% on average.

I Introduction

Large language model (LLM) inference can produce different token sequences for the same prompt even when users fix the sampling parameters and random seed [3, 4, 5, 30]. The discrepancy is easy to overlook because it often begins as a small numerical perturbation, but autoregressive generation can amplify it into a different answer. In hosted models, repeated nominally deterministic runs have produced task-score gaps of up to 70% between the best and worst observed outcomes [4]. Such variation makes model comparisons sensitive to incidental serving conditions. It also complicates debugging and reproducibility, and can create rollout mismatches that harm Reinforcement Learning (RL) training [28, 15, 33]. Deterministic execution is consequently becoming an explicit requirement in model evaluation, debugging, stability analysis, and consistent post-training [12, 15].

A major source of this nondeterminism is dynamic GPU batching. Modern LLM servers admit and retire requests between model iterations to increase utilization [29, 16]. The resulting batch shape depends on request arrival times, prompt lengths, and generation progress. GPU libraries use these dimensions to choose tiling and parallel reduction strategies. Changing the shape can change the order of floating-point operations in Mean, RMSNorm, Softmax, matrix multiplication (MatMul), and attention [13, 9, 8]. Since floating-point addition is not associative, the same token can receive different low-order bits when it runs with different co-runners. Section III explains this mechanism in detail using an illustrative reduction kernel.

Existing deterministic inference stacks address this problem with batch-invariant kernels [12, 15, 21, 23]. A batch-invariant kernel returns the same result for a token regardless of both the batch size and the token’s position. It achieves this property by retaining a fixed tiling and reduction order across supported shapes. The restriction prevents the kernel from selecting the most efficient decomposition for each input and can disable optimizations such as Split-K and Split-KV.

((a)) Design space

((b)) Latency breakdown

Fig. 1: CoRun’s design objective and the latency opportunity. (a) Positioning in the determinism-throughput design space. (b) Decode-step latency breakdown for a batch of 32 requests with variable context lengths.

Fig. 1(a) summarizes the resulting design space. Standard vLLM and SGLang provide high throughput but can produce batch-dependent outputs, while batch-invariant execution restores determinism at lower throughput. This work targets the upper-right region by retaining fast standard kernels and controlling the shapes on which they execute. Fig. 1(b) illustrates the opportunity with the latency breakdown of one variable-length decode step. Batch-invariant execution increases end-to-end latency from 19.4 ms to 88.4 ms, with MatMul accounting for most of the increase. CoRun reduces the latency to 32.6 ms by avoiding batch-invariant implementations for most operators, including MatMul and RMSNorm.

The operator-level cost is also substantial. Fig. 2 compares standard (STD) and batch-invariant (BI) implementations of four common operators. Each point is the mean of 100 executions. Across batch sizes, BI increases the latency of Mean, RMSNorm, and Softmax by 2.12–5.61×\times (Fig. 2(a)). For matrix multiplication, the overhead grows with the reduction dimension and reaches 36.2×\times (Fig. 2(b)). A larger output dimension exposes more independent work and narrows the gap, but does not remove it. End to end, these slower operators reduce serving throughput by up to 74% (Section V-C).

((a)) Mean, RMSNorm, SoftMax

Figure

((b)) MatMul

Fig. 2: Performance comparison between standard (STD) non-deterministic kernels and batch-invariant (BI) kernels.

This paper observes that full batch invariance is stronger than necessary. Although the optimized kernels in our model stack are generally not batch-invariant, most are position-invariant: a token retains the same result when it moves within a batch of the same shape. This weaker property suggests a different route to determinism: control the execution shape seen by each request, then retain the faster position-invariant kernels. We formalize the distinction and characterize the relevant kernels in Section III.

Applying this idea to existing LLM serving systems is challenging because prefill and decode have different shape distributions. Prefill processes a variable-length prompt, so padding every request to one global shape would waste substantial computation. Batching several prompts, however, makes the shape of each prefill depend on its co-runners. Decode contributes one query token per active request, but the active set changes whenever a request arrives or completes. Sampling creates a final complication: a request must consume the same random number after it moves to another batch slot.

We present CoRun, a scheduling-based system for deterministic, high-throughput LLM inference. CoRun isolates each request during prefill, preserving its natural prompt shape while removing co-runner dependence. During decode, it pads the active batch to the maximum concurrency and replays one fixed-size CUDA Graph. CoRun disables attention Split-KV for decode and uses deterministic collectives for the small set of operators that are not position-invariant. The sampler binds Random Number Generator (RNG) state to requests rather than batch slots and pads its input to the same fixed shape. Together, these mechanisms make the output independent of co-running requests, batch position, and arrival order without requiring every operator kernel to be batch-invariant. We formalize this guarantee as an end-to-end determinism contract and prove it by induction over autoregressive generation. Isolated prefill establishes an identical initial request state; fixed-shape decode and position-invariant kernels preserve that state across batch compositions and positions; request-bound RNG state then ensures that identical logits produce identical sampled tokens.

We make the following contributions:

  • We distinguish batch invariance from position invariance, characterize the invariance properties and costs of common LLM kernels, and identify execution-shape control as an alternative to making the full kernel stack batch-invariant.
  • We design CoRun, which combines isolated prefill, fixed-shape CUDA-Graph decode, selective kernel constraints, and request-bound sampling state in an existing continuous-batching engine. We state its determinism contract and prove that these mechanisms produce the same token sequence across co-running requests, batch positions, and arrival orders.
  • We evaluate CoRun on Qwen3-235B-A22B, DeepSeek-V3, and Hy3 using production, code-editing, and synthetic workloads. CoRun produces identical outputs in our determinism suite and improves throughput by 15–324% over batch-invariant inference, more than doubling aggregate throughput for every evaluated model.

References (30)