arXiv:2611.06977cs.AINov 2026

Manuscript Offprint

arXiv:2611.06977

BlockLock: Reproducible LLM Inference with Fixed Batch Geometry

Xiuyuan Qi, Pedro Reviriego, Javier Conde, Shanshan Liu

ABSTRACT

Reproducible LLM inference requires that a request produces the same output regardless of the other requests in the batch. Existing solutions pay for this in different ways: batch-invariant kernels constrain every operator, and isolating prefill with fixed-shape decode (our CoRun-style baseline) gives up shared prefill compute and pads decode. We present BlockLock, which keeps shared batched prefill and pins only the numerical path of the protected request: it fixes the geometry that the request sees, with two modes: BlockLock-Rows uses fixed-width rows and retains batched decode of all requests; BlockLock-Pack uses terminal-anchored packing with an isolated dummy segment, then extracts the protected request's KV state for target-only decode. Under a stated per-deployment contract, both modes preserve the target's output bitwise when its companions change. Across five dense models (Qwen3-8B/14B, Llama-3.1-8B-Instruct, and Gemma-3-4B/12B-IT) and three single-GPU deployments (NVIDIA A6000, A100, and H100), we evaluate our approach on both tinyBenchmarks and BFCL; we also include initial tensor-parallel experiments on two NVIDIA A6000 GPUs. Both modes preserve target sequences and Top20-logit bits in the reported tests. At equal delivered work, BlockLock-Rows reduces latency by 53.5–55.0% and improves throughput by 115.2–122.2% relative to vLLM Batch-Invariant; compared with batch-invariant kernels, it needs no custom kernel implementations and constrains only the protected requests.

1 INTRODUCTION

Large language models (LLMs) are now used in evaluation, in reinforcement learning, and in agentic workflows where the model calls external tools (Maia Polo et al., 2024; Guo et al., 2025; Patil et al., 2025). In these uses, the same request should produce the same output. If the output changes between runs, the comparison of two models can change, the data used to train a policy is not the data that the policy would generate, and an agent can take a different action. Reproducibility is therefore important to trust the results of these systems.

In practice, current serving systems do not provide reproducibility. Even with greedy decoding and fixed seeds, the output of a request can change when the other requests in the batch change (He & Lab, 2025; Fu et al., 2026). The reason is that floating point addition is not associative, so the result depends on the order of the sums. The order depends on the shape of the tensors that the kernels process, and the shape depends on the lengths of the other requests in the batch. A small change in the logits can flip a near-tie

Figure

Figure 1. Batch-induced nondeterminism. Processing the exact same target prompt x (blue) alongside different companion requests ( f1f_{1}, f2f_{2} vs. f3f_{3}) alters tensor padding and reduction orders, flipping near-tie logits to produce divergent outputs.

between two tokens, and from that point the rest of the generation is different (Fu et al., 2026). This effect appears in real workloads: in a study with 188 queries from the Berkeley Function Calling Leaderboard, two queries change the generated function call when the batch geometry changes (Section 2).

∗^{*}Equal contribution 1^{1}University of Electronic Science and Technology of China, Chengdu, Sichuan, China 2^{2}Universidad Politécnica de Madrid, Madrid, Community of Madrid, Spain. Correspondence to: Shanshan Liu ssliu@uestc.edu.cn.

At the same time, inference has to be efficient. Interactive services need low latency, and evaluation, rollout generation, and reasoning workloads need sustained throughput. Batching and scheduling are the main sources of efficiency in modern serving systems (Yu et al., 2022; Kwon et al., 2023; Agrawal et al., 2024; Zhong et al., 2024), together with optimized attention kernels (Dao et al., 2022). A solution for reproducibility that removes batching is therefore expensive.

Existing solutions obtain reproducibility in different ways, and all of them have a cost. Batch-invariant kernels constrain the reduction order of every operator so that the result does not depend on the batch shape (He & Lab, 2025). This requires specialized kernel implementations for each operator and each hardware, and the constraint is applied to all the requests, also to the ones that do not need reproducibility. Verified speculation runs a fast path that can be non-reproducible and then verifies the result and rolls back when it is not the canonical one (Gond et al., 2026); the verification and the rollback add work. CoRun isolates the prefill of each request, with batch size one, uses fixed-shape batched decode, and supports seeded sampling by binding the random-number-generator state to the request instead of the batch slot (Zhao et al., 2026). The CoRun baseline is simple, but it gives up shared prefill compute, so the GPU processes one prompt at a time even when several prompts could be processed together. Our CoRun-style baseline has 3.12–3.28× the end-to-end latency of shared batched execution (Section 4); this comparison does not isolate the cost of serialized prefill.

BlockLock takes a different approach. It keeps shared batched prefill, protects only the requests that need reproducibility, and runs on a stock framework without custom kernels or captured graphs. The main idea is that the numbers of a request stay fixed if the shape that the kernels see for that request stays fixed. BlockLock therefore pins the geometry of the protected request instead of removing the batch, with two schemes that fix the geometry in different ways: BlockLock-Rows and BlockLock-Pack. Companions share the same prefill invocation, but the protected request always sees the same tensor shapes, the same positions, and the same reduction order, independently of the contents and the lengths of the companions.

This design is the opposite trade from batch-invariant kernels. Batch-invariant kernels guarantee determinism across different batch sizes, so every operator is constrained for every request. BlockLock instead fixes the batch size and the execution geometry for each deployment. When the geometry is fixed, every run executes the same kernels with the same shapes, the same positions, and the same reduction order, so the protected request produces bitwise identical outputs with the stock kernels. The batch size and the class

widths are free parameters of the deployment: they are chosen to fit the hardware and the workload, and the determinism contract holds for that fixed configuration. Fixing the geometry retains shared batched execution, subject to padding and backend costs: the protected request shares one prefill invocation with its companions, and in BlockLock-Rows all the requests decode together in the normal batched decode. The cost of the fixed geometry is the padding of the rows or the filler segment, and Section 4 quantifies this cost.

BlockLock combines deterministic length classes with two schemes. In the first scheme, BlockLock-Rows, the batch is a tensor of shape [B,W][B, W] and the protected request keeps a stable row when the companions change. In the second scheme, BlockLock-Pack, the requests are packed into one block of shape [1,BW][1, BW], the protected request is anchored at the end of the block, and an isolated dummy segment absorbs the remaining space. After the prefill, the decode continues from the request's own KV state, so the numerical path of the protected request is preserved end to end. BlockLock does not need new kernels: it works with stock frameworks and only requires that the operators are repeatable for a fixed shape, which is checked as part of a per-deployment contract (Section 3 and Appendix A).

BlockLock-Rows retains shared [B,W][B, W] prefill and decodes all BB requests simultaneously without padding decode to a worst-case server-wide concurrency envelope. Both modes still reserve BWBW prefill positions.

This paper makes the following contributions:

  1. Batch-dependent output is a geometry problem, not only a kernel problem. Padding, row width, and position change with the companions. Padded batching agrees only 52.59% across companion changes, and the default backend path can vary even at B=1B = 1.

  2. BlockLock fixes the target's execution geometry instead of the batch. BlockLock-Rows cuts the prompts into blocks of size LL in fixed-width rows. BlockLock-Pack uses one block with the target at the end and a segment-causal mask. Both keep batched prefill and need no new kernels.

  3. Determinism after prefill under three conditions (canonical geometry, repeat-stable arithmetic, faithful cache handoff) is validated with 100% agreement over ten repeats and 100% for single and double GPU implementations.

  4. Measured efficiency on Torch and vLLM. Across eight standard benchmarks, BlockLock-Rows incurs only 0.5–0.8% latency overhead over standard PyTorch batching and runs 2.15–2.22× faster than vLLM Batch-Invariant (BI) at equal delivered work.

The rest of the paper is organized as follows. Section 2 gives the background and the related work. Section 3 describes the design, Section 4 presents the experimental results, and Section 5 discusses the scope and the limitations. The formal contract and the proof are in Appendix A, and the complete experimental details are in Appendix B.