Manuscript Offprint
arXiv:2611.06977BlockLock: Reproducible LLM Inference with Fixed Batch Geometry
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 1. Batch-induced nondeterminism. Processing the exact same target prompt x (blue) alongside different companion requests ( , vs. ) 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 University of Electronic Science and Technology of China, Chengdu, Sichuan, China 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 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 , 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 prefill and decodes all requests simultaneously without padding decode to a worst-case server-wide concurrency envelope. Both modes still reserve prefill positions.
This paper makes the following contributions:
-
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 .
-
BlockLock fixes the target's execution geometry instead of the batch. BlockLock-Rows cuts the prompts into blocks of size 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.
-
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.
-
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.
2.1 Prefill, Decode, and Cross-Phase KV Reuse
Autoregressive inference has two distinct phases. Prefill processes prompt tokens in parallel and constructs a KV cache. Decode appends a generated token at each step and reuses that cache instead of recomputing the full history. Dynamic batching and efficient cache management improve utilization (Yu et al., 2022; Kwon et al., 2023); chunked prefill additionally partitions a prompt across model invocations (Agrawal et al., 2024).
However, in standard dynamic batching, sharing a prefill invocation ties each request's tensor padding and reduction tree to the lengths of co-scheduled requests. The central systems challenge addressed by BlockLock is to preserve efficient inference while keeping the protected request's execution geometry invariant to changes in companion requests.
2.2 Repeat Variation and Configuration Variation
Repeat variation occurs when equal logical inputs and execution geometry yield unequal numerical outputs in repeated executions. Execution-configuration variation occurs when changing , padding, physical offsets, or a distributed configuration changes the arithmetic path, even if each individual configuration is repeat-stable. In Floating-point addition it can occur that because intermediate rounding depends on the reduction order. Shape-dependent kernel dispatch and tile decomposition can therefore change logits (He & Lab, 2025; Fu et al., 2026). Batch invariance preserves request numerics across varying shapes. Canonical reproducibility assigns a target a repeatable plan within one deployment. Our backend comparisons characterize numerical behavior under controlled policies; identifying an internal mechanism such as atomic accumulation or split reduction requires kernel-level evidence.
2.3 Backend Diagnosis and Autoregressive Amplification
The problem is not only the batch: the backend itself can change the result. In a baseline single-request audit at (Appendix C), the default backend dispatch produced multiple divergent sequences for the identical prompt, whereas enforcing our restricted backend policy yielded 100% bitwise raw-logit agreement. Consequently, backend eligibility
forms a foundational requirement of our reproducibility conditions (Section 3.4)
The same effect appears under batching: across the all configurations, Padded batching reaches only 52.59% pair-weighted generated-sequence agreement, while CoRun and both BlockLock schemes reach 100% (Section 4 and Appendix B). Deterministic control is therefore needed already at , and batching makes the variation larger.
On NVIDIA H100, we observed that the default cuDNN attention backend introduces numerical variations at , ultimately causing differences in output logits and generated token sequences. We evaluated Qwen3-8B using an identical MMLU prompt, a fixed batch size of , and 320 decoding steps with greedy decoding. With cuDNN enabled, CoRun produced two distinct token sequences across four repeated runs produced three and two distinct sequences. After disabling cuDNN attention, all three schemes achieved bitwise-identical logits and token sequences across repeated executions. Further analysis revealed that small numerical perturbations could change greedy token selection: at decoding step 280, a logit value changed from 24.625 to 24.5, reversing the ranking of two competing tokens and causing subsequent output divergence.
2.4 Related Work
Deterministic kernels. Batch-invariant kernels constrain the reduction order of all the operators so the result does not depend on the batch shape (He & Lab, 2025). This requires specialized kernel implementations for each operator and each hardware. BlockLock instead pins only the geometry of the protected request and works with stock kernels. The two approaches answer different questions. Batch-invariant kernels preserve request numerics across varying batch shapes. BlockLock permits companion contents and lengths to change within a fixed canonical plan, but does not guarantee equality across different batch sizes. BlockLock fixes the batch size and the geometry of the compared runs, so it does not constrain any operator and uses the stock kernels of the framework.
Retry on difference. LLM-42 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). BlockLock does not need verification or rollback because the protected request follows the canonical path. Vosti specifies, implements, and verifies deterministic inference in a formal way (Qin et al., 2026); this is complementary to BlockLock, and the BlockLock contract could be a target for this kind of verification.
Isolated scheduling. CoRun isolates the prefill of each request and uses fixed-shape batched decode (Zhao et al.,

①Prefill: one prompt at a time
②Decode: always 256 slots and disable Split-KV

The 253 padding slots are still computed
Figure 2. Limitations of the CoRun-style baseline. (1) Prefill executes sequentially () to avoid cross-request interference, forfeiting batching efficiency. (2) Decode enforces a fixed 256-slot batch shape, wasting compute on masked padding slots when concurrency is low. The 256-slot envelope depicts CoRun's evaluated configuration.
2026), as Figure 2 illustrates. CoRun also covers seeded sampling with request-bound random-number state, and its decode path uses captured CUDA graphs. BlockLock keeps the companions in the same prefill invocation, pins only the target, and runs on a stock framework without CUDA graphs; the request-bound sampling technique of CoRun applies to BlockLock as well.
CoRun's graph capacity is configurable: 256 matches its evaluated maximum concurrency (Zhao et al., 2026). High occupancy amortizes padding; low occupancy wastes slots. Isolated prefill adds waiting behind earlier prompts. Our fixed-group timings do not measure queueing or tail latency.
Padded and prepacked batching. Prepacking packs prompts of different lengths into one batch to reduce padding and improve throughput (Zhao et al., 2025); the packing of BlockLock instead anchors the protected request so that its geometry does not change. Fu et al. measure nondeterminism through token probabilities and relate it to the execution configuration (Fu et al., 2026); BlockLock acts on the cause, the shape that the kernels see, instead of measuring the effect.
Serving systems. Serving systems improve efficiency with batching, cache management, chunked prefill, and prefill-decode disaggregation (Yu et al., 2022; Kwon et al., 2023; Agrawal et al., 2024; Zhong et al., 2024), and optimized attention kernels reduce the cost of each invocation (Dao et al., 2022). Length-based bucketing is already used in LLM serving systems to reduce padding overhead and improve resource utilization, as demonstrated by Bucket-
Serve(Zheng et al., 2025). These works do not consider reproducibility. In the measured setting, BlockLock keeps the shared batched prefill for the companions while it makes the protected request reproducible; Section 4 quantifies the cost of this protection.
3 DESIGN
BlockLock coordinates the execution geometry, the token layout, the backend eligibility, and the distributed execution so that the numerical path of a protected request is preserved through prefill and decode. This section gives the main ideas. Figure 3 shows the two schemes on one example. The batch size and the geometry are fixed only for the runs that are compared; each deployment chooses them freely for its hardware and its workload.
3.1 Setup: one protected request and many companions
The workload has one protected target request , whose output must be reproducible, and ordinary companion requests that share the GPU work. BlockLock's scheduler assigns tokenized lengths to fixed classes using an alignment granularity (set to tokens in our standard evaluation) and merges adjacent buckets when needed. Then prompts are cut into blocks of size , and a prompt of arbitrary length occupies the blocks it needs, so the width of its class is a multiple of . The class mapping is frozen for the executions that are compared. A group of requests of one class reserves prompt positions. The group contains the target and companions, and a seeded schedule changes the contents and the lengths of the companions between repetitions while the target, , and stay fixed.
We compare against two baselines: Padded batching, the normal serving behavior without any reproducibility control; CoRun, which isolates the prefill of each request and uses fixed-shape batched decode (Zhao et al., 2026).
3.2 BlockLock-Rows: fixed-width rows
BlockLock-Rows processes each group as a single tensor of shape . To keep serving efficiency and reduce padding overhead, it first groups incoming prompts into length-based buckets. Within each bucket, each request occupies a fixed-width row, with left padding aligning token sequences to the bucket width and an attention mask distinguishing real tokens from padding. The target keeps the same row and the same logical positions when the companions change, so the kernels always see the same shape for the target. One prefill invocation processes all the rows, and the decode continues with the normal batched KV cache of the requests. Because each row in the tensor occu-

BlockLock freezes x's execution geometry - the companions no longer matter.
Figure 3. Execution geometry comparison. (a) Padded batching pads all rows to the longest request in the batch, causing x's padding offset to shift with its companions. (b) BlockLock-Rows executes a single [B, W] prefill where every row is aligned to a fixed class width W (a multiple of block size L), preserving x's exact geometry and batched decode across all B requests. (c) BlockLock-Pack concatenates requests into a [1, BW] block with x anchored at the terminal interval [P - L_x, P) and an isolated dummy segment absorbing length variations, followed by target-only KV extraction and decode.
pies a fixed width W and undergoes independent row-wise reductions, the reproducibility contract (Section 3.4) holds symmetrically for any batch slot assigned a canonical plan. In our evaluation protocol (Section 4), we isolate one slot as the fixed target x while intentionally varying the contents and lengths of the other B - 1 companion rows across repetitions to rigorously stress-test cross-request invariance. For dense full attention, the score computation takes work. BlockLock-Rows does not need an explicit mask between segments, which is its main cost advantage over BlockLock-Pack.
3.3 BlockLock-Pack: terminal-anchored packing
BlockLock-Pack concatenates the companions, an optional dummy segment, and the target along the sequence dimension into one block of shape [1, P]. The capacity that is not used by real tokens is filled by an isolated dummy segment, which absorbs the changes in the companion lengths. The target is always placed last, so its physical interval is and both endpoints stay fixed when the companions change. For example, with and , the block reserves 384 positions, and companion and target lengths of 180 and 192 leave 12 dummy positions without moving the target.
Each segment uses local positions , and a segment-causal mask allows attention only inside the same segment. One forward call processes the whole packed block and produces the packed KV cache and the logits of the last position of the target. After the prefill, BlockLock-
Pack extracts the KV state of the target layer by layer: full-attention layers keep the last key and value entries, and sliding-attention layers keep the visible target suffix and restore its logical cumulative length. The decode then continues from this target-local cache, one token per step, so the target attends only to its own state. In native PyTorch, the packed path uses a dense segment mask with storage and score work; the vLLM integration uses paged-attention metadata instead (Appendix A.2); in exchange, the target decodes alone and does not pay for a batch it does not need.
BlockLock-Pack protects the prompt anchored at the end of the block, and it is the option for low-concurrency serving: protecting several prompts needs one pack per protected prompt, which costs extra prefill. By design, BlockLock-Pack targets low-concurrency or single-audit scenarios where only the terminal request x requires decoding. Attempting to batch-decode the companions alongside x after unpadded KV extraction would expose the decode attention kernel to the companions' varying sequence lengths , violating canonical geometry during decode (Whereas padding all KV caches back to W simply reduces to BlockLock-Rows). Isolating x's KV state for single-request decoding guarantees that both prefill and decode geometries remain strictly invariant to companion lengths.
3.4 What makes the output reproducible
The two schemes give the same contract. For a fixed deployment (hardware, software versions, precision, backend eligibility, length-class mapping, B, and the chosen scheme), the raw logits of the target are bitwise identical at every prediction index, for any companions. Three conditions are sufficient:
C1. Canonical geometry: the geometry and the logical isolation of the target are preserved.
C2. Repeat-stable arithmetic: the operators and the distributed collectives are repeat-stable.
C3. Faithful handoff: the cache handoff is faithful.
The backend policy excludes the components that are not repeat-stable (in our experiments, cuDNN SDPA and TF32), and each deployment is validated before the comparison. The contract is stated for greedy decoding; seeded sampling fits the same design with request-local random-number state, the technique that CoRun uses for its request-bound sampling (Zhao et al., 2026). The formal statement, the sufficient conditions, and the proof are in Appendix A.
The same logical plan runs on one GPU or on one model tensor-parallelized across two A6000 GPUs. In the two-GPU case, one rank constructs and broadcasts the plan, the ranks check that their input plans agree before inference, and the collectives must also be repeat-stable.
3.5 Overhead and scaling
The overhead of the two schemes comes from three sources. The first is the reserved space: both schemes reserve positions, so BlockLock-Rows pads each row to the class width , and BlockLock-Pack fills the unused capacity with the dummy segment, which is wasted work that grows when the companions are shorter than the reserved space. The second is the batch size: the packed mask costs storage and score work, so it grows quadratically with , while the rows keep attention work, linear in . The third is the prompt length: longer prompts move to a wider class, which increases the reserved width and the padding of the whole class. Across the eight-dataset equal-delivered-work benchmark at and 64 output tokens per request, the geometric-mean latency overhead of Torch Rows over Torch Padded is 0.5–0.8%. For distributed execution (), our evaluation focuses on verifying numerical invariance across multi-GPU collective communications, confirming 100% bitwise agreement.
4 EXPERIMENTAL RESULTS
This section presents the evaluation results in terms of determinism and performance. The exact model names, links, software versions, and the full protocol are in Appendix B.
4.1 Experimental setup
The evaluation covers three GPU platforms on two architectures: A6000 and A100 (Ampere) and H100 (Hopper). The A6000 configurations include single-GPU experiments and a separate experiment that partitions one model across two A6000 GPUs with tensor parallelism (). The main models are Qwen3-8B and Qwen3-14B, Llama3.1-8B-Instruct, Gemma3-4B and Gemma3-12B-it. The inputs are seven tinyBenchmarks (Maia Polo et al., 2024) and BFCL multiple-function queries (Patil et al., 2025). All runs use BF16 precision and greedy decoding across batch sizes . Each target and batch configuration is evaluated across 10 independent repetitions with distinct, randomly sampled companion combinations, yielding pairwise cross-companion comparisons per condition (60,120 pairwise comparisons across all 1,336 evaluated conditions). Exact model weights, repository links, and software versions are listed in Appendix B.
4.2 Checking determinism
The first check is the backend itself. We first verify at on each hardware that all tested runs reach 100% agreement on both Top-20 logits and output tokens. For each target, we repeat the same request with different companions and compare the outputs at both the logit and output-token levels. Figure 4(a,b) summarizes generated-token and Top-20 logit-trace agreement across three hardware platforms, five models, and batch sizes . Agreement is the fraction of identical run pairs within each target–configuration condition: repetitions provide pairs, including 45 pairs for ten repetitions. Token agreement compares the actual generated token-ID sequences; Top-20 agreement requires identical candidate token IDs and raw-logit values at every generation step. Figure 4(a,b) pool pairs within each dataset and then average dataset-level agreement equally. Figure 4(c) exposes variation across individual targets on A6000/Qwen3-14B at , showing q1-q4 separately for each dataset and policy. Figure 4(d-f) report agreement by dataset at for A100/Qwen3-8B, H100/Qwen3-14B, and A6000/Qwen3-14B, respectively. Each dataset contributes four targets with ten repetitions each, yielding 180 comparison pairs per policy.
The main result is that both schemes reproduce the target exactly. Both BlockLock-Rows and BlockLock-Pack reach 100% target-sequence and Top20 agreement across single-GPU conditions and TP conditions. Appendix B.6 reports 52.59% sequence and 35.93% Top20 agreement for the single-GPU subset; the TP conditions are reported separately. The vLLM BI and all four BlockLock implementations reach full agreement in every one of their 80 conditions. Standard batching has dataset-dependent variation; some conditions also agree fully. These comparisons hold and the deployment fixed.
The two-GPU experiment shows the same behavior. With one Gemma3-4B model partitioned across two A6000 GPUs (TP=2), both schemes reach 100% agreement in their 20 tested conditions each, while Padded batching degrades from 100% at to 72.4%, 43.6%, and 21.8% at .
4.3 Performance: latency and throughput
Phase Cost Characterization. We instrument prefill and decode intervals to evaluate the efficiency of both BlockLock primitives across PyTorch and vLLM engines. Because BlockLock-Rows preserves the standard batched KV cache to decode all requests simultaneously, whereas BlockLock-Pack extracts only the terminal target's KV state to decode a single request after a shared prefill, we explicitly distinguish between equal-delivered-work comparisons ( requests decoded) and single-target audit workloads.
Comparison Against Sequential Isolation (CoRun-style). Figure 4(d–f) and Table 1 compare BlockLock against standard padded batching (STD) and sequential request isolation (CoRun). As shown in Table 1, the measured CoRun-style baseline takes 4305.75 ms on Qwen3-8B and 5983.14 ms on Qwen3-14B (). In contrast, BlockLock-Rows completes in 1312.71 ms and 1913.56 ms, achieving a and end-to-end speedup (and 195.02 vs. 59.46 tokens/s on Qwen3-8B) with 2.5%–2.7% higher total latency than Padded batching in these two rows of Table 1. Across all seven tinyBenchmarks on A6000, A100, and H100 (Figure 4(f)), BlockLock-Rows sustains nearly 100% of standard useful-input prefill throughput up to .
Decoupling the phases in Table 1 clarifies two distinct sources of efficiency gain: during prefill, sharing the invocation avoids serialization; during decode, scoping the canonical batch geometry to the active cohort avoids computing across CoRun's fixed slot server-wide decode envelope.
Comparison Against Batch-Invariant Kernels (vLLM BI). Figure 5 and Table 2 evaluate seven implementations across eight datasets in two workload scopes (): STD, BI, Padded, and Rows deliver 256 output tokens per group, while Pack delivers only the protected target's 64 output tokens. Equal-delivered-work speedups compare Rows with full-batch baselines; Pack timings describe a different, target-only workload. Because batch-invariant kernels (vLLM BI) constrain reduction orders across all operators, they incur more than a latency penalty over standard vLLM (vLLM STD). By pinning the execution geometry rather than constraining kernel arithmetic, vLLM Rows incurs only a 5.4%–6.9% geometric-mean latency
overhead over vLLM STD across the eight datasets, reducing total execution time by 55.0% (Qwen3-8B) and 53.5% (Qwen3-14B) and boosting output throughput by 122.2% and 115.2% relative to vLLM BI. In native PyTorch, Torch Rows adds merely 0.5%–0.8% overhead over Torch Padded. Meanwhile, when only the audited target's output is needed, Pack further reduces total wall-clock time by avoiding companion decode overhead (0.89 s vs. 0.91 s in vLLM; 1.11 s vs. 1.23 s in PyTorch on Qwen3-8B).
Longer capacities and representative workloads. Table 3 extends our controlled target-audit protocol to long-context capacities and extended generation lengths in the native PyTorch backend with full-logit verification. We report the mean of three interleaved CUDA timing trials per method and condition at . Four synthetic stress-test conditions evaluate class widths and output lengths under the same companion-perturbation protocol. Blazedit and BurstGPT each contribute one four-request representative group with 64 generated tokens per decoded request. Rows is faster than CoRun in four of the six groups. At , Rows takes 9.176/141.141 s for 128/2048 output tokens, versus CoRun's 9.016/135.103 s; the phase breakdown reports this cost directly.
5 DISCUSSION AND FUTURE WORK
Operating Regimes: Rows vs. Pack. The choice between the two BlockLock primitives depends on the serving workload. BlockLock-Rows retains full -request batched decoding and avoids inter-segment masking overhead ( attention cost), making it ideal for throughput-oriented evaluation and RL rollout generation where all requests in a batch are decoded. Conversely, BlockLock-Pack is tailored for mixed-criticality auditing or canary verification where companion requests only require prefill processing (e.g., log-likelihood scoring, guardrail classification, or disaggregated KV pre-warming) while a single protected target requires full autoregressive decoding after sharing the prefill. While the native PyTorch implementation of Pack materializes a dense segment mask, our vLLM integration replaces this dense mask with PagedAttention metadata, substantially reducing prefill overhead (Figure 5).
Complementarity with Batch-Invariant Kernels. Table 4 summarizes the trade-offs across determinism mechanisms. Batch-invariant kernels enforce invariance across dynamically changing batch sizes at the cost of custom per-hardware implementations and a latency penalty across all requests. BlockLock instead enforces determinism within an eligible fixed deployment using stock framework kernels. Its measured overhead depends on the length class, workload, and backend; deployment validation is required on each hardware-model configuration.







Figure 4. Reproducibility and phase efficiency across GPUs and models. (a,b) Generated-token and Top-20 logit-trace agreement within each fixed batch size. (c) Per-target token agreement. (d-f) Token agreement by dataset. (g) Prefill and decode time normalized to STD. (h) Per-dataset decode latency (evaluated at 500 output tokens per request). (i) Useful-input prefill throughput relative to STD.
Table 1. Phase latency and throughput comparison across eight datasets on NVIDIA A6000. At , all schemes decode four requests.
| Model | Method | Prefill (ms) | Decode (ms) | Total (ms) | Speedup | Output tokens | Tokens/s |
|---|---|---|---|---|---|---|---|
| Qwen3-8B | Padded batching | 66.99 | 1213.59 | 256 | 199.91 | ||
| CoRun | 91.55 | 4214.20 | 256 | 59.46 | |||
| BlockLock-Rows | 76.58 | 1236.13 | 256 | 195.02 | |||
| BlockLock-Pack | 83.86 | 1110.04 | 64 | 53.61 | |||
| Qwen3-14B | Padded batching | 106.16 | 1756.99 | 256 | 137.40 | ||
| CoRun | 137.02 | 5846.13 | 256 | 42.79 | |||
| BlockLock-Rows | 123.53 | 1790.02 | 256 | 133.78 | |||
| BlockLock-Pack | 133.94 | 1517.66 | 64 | 38.75 |
Table 2. Means of Prefill+decode time (ms). ; full-batch methods generate 256 output tokens per group. Relative latency changes below the times use vLLM STD or Torch Padded as the within-engine baseline. Positive values mean higher latency: . N/A denotes a decrease.
| Dataset | vLLM | Torch | |||||
|---|---|---|---|---|---|---|---|
| STD | BI | Rows | Pack | Padded | Rows | Pack | |
| Qwen3-8B | |||||||
| MMLU | 871.32(+133.3%) | 2032.84(+3.6%) | 902.68(N/A) | 874.84(N/A) | 1194.34(+0.6%) | 1201.19(N/A) | 1101.97(N/A) |
| AI2 ARC | 820.51(+144.5%) | 2006.00(+7.8%) | 884.39(N/A) | 857.39(N/A) | 1134.29(-0.1%) | 1133.47(N/A) | 1068.36(N/A) |
| HellaSwag | 901.02(+127.5%) | 2049.74(+5.8%) | 952.99(N/A) | 925.91(N/A) | 1342.03(+0.8%) | 1353.24(N/A) | 1158.08(N/A) |
| GSM8K | 845.56(+136.6%) | 2000.99(+6.6%) | 901.43(N/A) | 872.76(N/A) | 1179.14(+1.3%) | 1194.50(N/A) | 1084.28(N/A) |
| TruthfulQA | 835.93(+141.2%) | 2015.86(+5.7%) | 883.42(N/A) | 856.38(N/A) | 1134.94(-0.2%) | 1133.10(N/A) | 1066.34(N/A) |
| WinoGrande | 822.79(+142.9%) | 1998.76(+7.4%) | 883.49(N/A) | 856.27(N/A) | 1134.20(-0.1%) | 1133.58(N/A) | 1069.19(N/A) |
| AlpacaEval | 803.92(+149.5%) | 2005.83(+9.9%) | 883.77(N/A) | 856.41(N/A) | 1132.41(+0.4%) | 1136.67(N/A) | 1063.79(N/A) |
| BFCL v3 | 933.56(+125.9%) | 2108.74(+8.4%) | 1012.31(N/A) | 985.65(N/A) | 1530.01(+0.8%) | 1542.91(N/A) | 1233.03(N/A) |
| Qwen3-14B | |||||||
| MMLU | 1350.33(+129.1%) | 3093.99(+5.2%) | 1420.40(N/A) | 1384.39(N/A) | 1743.51(+0.9%) | 1759.06(N/A) | 1582.32(N/A) |
| AI2 ARC | 1337.29(+128.6%) | 3056.86(+4.0%) | 1391.29(N/A) | 1354.72(N/A) | 1655.48(+0.8%) | 1668.12(N/A) | 1544.64(N/A) |
| HellaSwag | 1426.65(+120.1%) | 3140.35(+5.7%) | 1508.24(N/A) | 1471.27(N/A) | 1968.27(+1.0%) | 1988.79(N/A) | 1690.10(N/A) |
| GSM8K | 1344.17(+126.8%) | 3048.39(+5.7%) | 1420.78(N/A) | 1383.55(N/A) | 1736.45(+1.5%) | 1762.16(N/A) | 1578.48(N/A) |
| TruthfulQA | 1328.39(+130.2%) | 3058.07(+4.7%) | 1391.19(N/A) | 1354.85(N/A) | 1660.74(+0.4%) | 1667.44(N/A) | 1541.07(N/A) |
| WinoGrande | 1322.82(+131.1%) | 3056.79(+5.2%) | 1391.29(N/A) | 1354.75(N/A) | 1660.18(+0.4%) | 1667.43(N/A) | 1543.16(N/A) |
| AlpacaEval | 1322.88(+131.0%) | 3056.16(+5.2%) | 1391.22(N/A) | 1354.69(N/A) | 1660.29(+0.4%) | 1667.11(N/A) | 1542.75(N/A) |
| BFCL v3 | 1497.90(+117.5%) | 3258.17(+7.2%) | 1605.74(N/A) | 1568.30(N/A) | 2222.03(+0.9%) | 2242.34(N/A) | 1818.02(N/A) |

Figure 5. Mean instrumented prefill and decode latency across the seven evaluated methods, averaged over eight datasets ( output tokens per decoded request). Dark and light bars show prefill and decode. Asterisks mark target-only Pack (one output request); other methods decode four.
Table 3. Fixed-target workload time (s). . Padded, CoRun, and Rows decode all four requests; Pack decodes the protected target only. Each trace workload is one representative four-request group. Relative latency changes below the times use Padded as the baseline. Positive values mean higher latency: . N/A denotes a decrease.
| Width / output | Padded | CoRun | Rows | Pack |
|---|---|---|---|---|
| 1024 / 128 | 3.542 | 8.472(+139.2%) | 3.761(+6.2%) | 2.654(N/A) |
| 1024 / 2048 | 72.988 | 134.345(+84.1%) | 75.812(+3.9%) | 36.678(N/A) |
| 4096 / 128 | 8.187 | 9.016(+10.1%) | 9.176(+12.1%) | 6.132(N/A) |
| 4096 / 2048 | 129.529 | 135.103(+4.3%) | 141.141(+9.0%) | 39.669(N/A) |
| Blazedit / 64 | 2.133 | 4.421(+107.3%) | 3.061(+43.5%) | 2.339(N/A) |
| BurstGPT / 64 | 1.173 | 4.175(+255.9%) | 1.198(+2.1%) | 1.134(N/A) |
Table 4. Qualitative comparison of reproducible LLM inference approaches. BlockLock guarantees bitwise-identical outputs per deployment with repeat-stable kernels without requiring custom operator implementations.
| Approach | Bitwise-reproducible across companions | Needs custom kernels | Batched prefill efficiency | Decode efficiency | Scope / limits |
|---|---|---|---|---|---|
| Padded batching | No (52.59% overall) | No | Yes (pads to longest) | Shared batched | No determinism guarantee |
| Batch-invariant kernels | Yes (across batch shapes) | Yes (per op/GPU) | Shared, constrained | Shared, constrained | Constrains all requests |
| LLM-42 | Yes (via verification) | No | Fast path + verify | Rollback on mismatch | Verification/rollback cost |
| CoRun | Yes (never mixed) | No | No ( prefill) | Fixed-shape padded slots | Underutilizes prefill |
| BlockLock-Rows | Yes (per deployment) | No | Shared [] | Batched ( requests) | Per deployment |
| BlockLock-Pack | Yes (per deployment) | No | Shared [] | Target only (1 request) | Per deployment |
Limitations and Future Work. Our evaluation covers dense models only; evaluating BlockLock on mixture-of-experts (MoE) models is left to future work. First, BlockLock’s determinism contract holds per deployment configuration ; changing GPU architectures (e.g., Ampere to Hopper) or tensor-parallel degrees alters underlying kernel reduction trees and remains outside our scope. Second, when companion lengths exhibit extreme variance within a coarse length class , padding waste increases (as observed at in Table 3). Future work includes integrating canonical geometry locking with chunked prefill and prefix caching, as well as extending deterministic execution plans to Mixture-of-Experts (MoE) token routing where capacity-factor dropping can induce cross-request interference.
6 CONCLUSIONS
Current LLM serving does not give reproducible outputs, because the batch changes the order of the floating point sums. Existing fixes pay for reproducibility with custom kernels, verification work, or by giving up shared prefill. BlockLock instead pins the geometry that the protected request sees and keeps shared batched prefill, with two schemes: BlockLock-Rows uses fixed-width rows and BlockLock-Pack uses terminal-anchored packing with an isolated dummy segment. Under a stated per-deployment contract, the output of the protected request is bitwise identical for any companions. Across the eight-dataset benchmark, at and 64 output tokens per request, BlockLock-Rows adds only 0.5–0.8% latency overhead over standard PyTorch padded batching while reducing vLLM Batch-Invariant (BI) execution time by 53.5–55.0%. Extended capacity sweeps up to and further confirm that BlockLock-Rows outperforms sequential isolation across moderate context lengths, while BlockLock-Pack offers a low-latency alternative for single-target auditing when class padding is extreme. These results support canonical scheduling as an efficient way to protect a target while retaining batched prefill.
REFERENCES
Agrawal, A., Kedia, N., Panwar, A., Mohan, J., Kwatra, N., Gulavani, B., Tumanov, A., and Ramjee, R. Taming {Throughput-Latency} tradeoff in {LLM} inference with {Sarathi-Serve}. In 18th USENIX symposium on operating systems design and implementation (OSDI 24), pp. 117–134, 2024.
Dao, T., Fu, D., Ermon, S., Rudra, A., and Ré, C. Flashattention: Fast and memory-efficient exact attention with io-awareness. Advances in neural information processing systems, 35:16344–16359, 2022.
Fu, T., Martínez, G., Conde, J., Arriaga, C., Qi, X., Liu, S., and Reviriego, P. Beyond reproducibility: Token probabilities expose large language model nondeterminism. IEEE Transactions on Computers, 2026.
Gond, R., Kamath, A. K., Ramjee, R., and Panwar, A. Llm-42: Enabling determinism in llm inference with verified speculation. In Proceedings of the ACM SIGOPS 32nd Symposium on Operating Systems Principles, pp. 916–931, 2026.
Guo, D., Yang, D., Zhang, H., Song, J., Wang, P., Zhu, Q., Xu, R., Zhang, R., Ma, S., Bi, X., et al. Deepseek-r1 incentivizes reasoning in llms through reinforcement learning. Nature, 645(8081):633–638, 2025.
He, H. and Lab, T. M. Defeating nondeterminism in llm inference. Thinking Machines Lab: Connectionism, 2025. doi: 10.64434/tml.20250910. https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/.
Kwon, W., Li, Z., Zhuang, S., Sheng, Y., Zheng, L., Yu, C. H., Gonzalez, J., Zhang, H., and Stoica, I. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th symposium on operating systems principles, pp. 611–626, 2023.
Maia Polo, F., Weber, L., Choshen, L., Sun, Y., Xu, G., and Yurochkin, M. tinyBenchmarks: evaluating LLMs with fewer examples. In Salakhutdinov, R., Kolter, Z., Heller, K., Weller, A., Oliver, N., Scarlett, J., and Berkenkamp, F. (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 34303–34326. PMLR, 21–27 Jul 2024.
Patil, S. G., Mao, H., Yan, F., Ji, C. C.-J., Suresh, V., Stoica, I., and Gonzalez, J. E. The berkeley function calling leaderboard (bfcl): from tool use to agentic evaluation of large language models. In Proceedings of the 42nd International Conference on Machine Learning, ICML'25, 2025.
Qin, J., Du, A., Zhang, D., Lentz, M., and Zhuo, D. Vosti: Specifying, implementing, and verifying deterministic llm inference. arXiv preprint arXiv:2609.38981, 2026.
Yu, G.-I., Jeong, J. S., Kim, G.-W., Kim, S., and Chun, B.-G. Orca: A distributed serving system for {Transformer-Based} generative models. In 16th USENIX symposium on operating systems design and implementation (OSDI 22), pp. 521–538, 2022.
Zhao, S., Israel, D. M., den Broeck, G. V., and Grover, A. Prepacking: A simple method for fast prefilling and increased throughput in large language models. In Li, Y., Mandt, S., Agrawal, S., and Khan, E. (eds.), Proceedings of The 28th International Conference on Artificial Intelligence and Statistics, volume 258 of Proceedings of Machine Learning Research, pp. 4393–4401. PMLR, 03–05 May 2025.
Zhao, S., Yang, J., Chen, Q., Hu, J., Zheng, J., Chen, G., and Chen, X. Corun: Padding is simple and efficient for deterministic llm inference. arXiv preprint arXiv:2608.14376, 2026.
Zheng, W., Xu, M., Song, S., and Ye, K. Bucketserve: Bucket-based dynamic batching for smart and efficient llm inference serving. In 2025 IEEE International Conferences on Internet of Things (iThings) IEEE Green Computing & Communications (GreenCom) IEEE Cyber, Physical & Social Computing (CPSCom) and IEEE Smart Data (SmartData) and IEEE Congress on Cybermatics (Cybermatics), pp. 103–111. IEEE, 2025.
Zhong, Y., Liu, S., Chen, J., Hu, J., Zhu, Y., Liu, X., Jin, X., and Zhang, H. {DistServe}: Disaggregating prefill and decoding for goodput-optimized large language model serving. In 18th USENIX symposium on operating systems design and implementation (OSDI 24), pp. 193–210, 2024.
AI USAGE DISCLOSURE
Following the MLSys policy, we disclose the use of AI tools in the preparation of this paper, by category:
-
Ideation and experiment design: a general-purpose LLM assistant was used to discuss design alternatives and evaluation plans; the authors made all the decisions.
-
Literature search and reference checking: a general-purpose LLM assistant was used to find and verify the cited references.
-
Code and experiments: a general-purpose LLM assistant was used for code review and for help with the experimental infrastructure; the authors verified the results.
-
Figures and writing: generative AI tools were used to produce the schematic figures and for writing and editing support; the authors revised the final text and figures.
Large language models are also the object of study of this paper: they are the models evaluated in the experiments. The authors designed the work, verified the results, and take full responsibility for the content of this paper.
BLOCKLOCK: REPRODUCIBLE LLM INFERENCE WITH FIXED BATCH GEOMETRY
Xiuyuan Qi Pedro Reviriego Javier Conde Shanshan Liu
A FORMAL DESIGN AND DETERMINISM CONTRACT
BlockLock coordinates execution geometry, token layout, backend eligibility, and distributed collective execution to preserve a protected target request's numerical path through prefill and decode. This appendix formalizes the canonical execution groups, the two prefill primitives (BlockLock-Rows and BlockLock-Pack), the request-local KV cache extraction for the packed path, and the deployment-level determinism contract along with its proof.
A.1 Canonical Execution Groups and Mixed-Criticality Co-Batching
The serving workload comprises a protected target request x requiring bitwise reproducibility and a set of ordinary companion requests F that share accelerator compute. Our controlled companion-perturbation protocol varies the companion set F around a fixed target x, realizing mixed-criticality co-batching at the execution-group level.
Let denote the tokenized prompt length of request , and let denote the capacity-alignment block granularity (e.g., or 128 tokens, matching Section 3.1 of the main text). Initial length buckets are indexed by . Adjacent buckets may be merged into deterministic length classes with a fixed class width (). The length-class mapping is frozen across all compared executions within a deployment. For a logical batch of co-scheduled requests belonging to a class of width , BlockLock reserves a total capacity of
prompt token positions. Each group contains the protected target and eligible companions . Across repetitions, a seeded schedule perturbs both the token contents and exact lengths of the companions while holding the target , batch size , class width , and canonical layout strictly fixed.
Distributed execution plan (TP = 2). The same logical plan governs both single-GPU execution and multi-GPU tensor parallelism (TP = 2) across two NVIDIA A6000 GPUs. The distributed runner initializes a torch.distributed NCCL process group with one rank per GPU and shards the model via the native Transformers tensor-parallel interface (tp_plan="auto" with tp_size=2). Rank 0 constructs and broadcasts the canonical batch plan (token IDs, padding/segment masks, and position IDs) to all ranks. Before executing the forward pass, all ranks verify via hash checks that their received input plans and model sharding topologies match identically. Consequently, all column- and row-parallel linear layers execute an identical sequence of collective communications across both prefill and decode phases.
Rank assignment, tensor-sharding boundaries, software versions, and NCCL collective configurations jointly define the distributed deployment environment (PyTorch Contributors, n.d.a; NVIDIA, n.d.). Because NCCL dynamically selects communication rings/trees and protocols based on tensor shapes and topology, our contract requires that the chosen collective algorithms be repeat-stable under fixed tensor shapes (Condition C2).
A.2 Two Canonical Prefill Primitives: Row Locking and Packed Locking
Both BlockLock primitives reserve prompt positions and enforce the same backend eligibility policy, but expose distinct attention-masking and decode-state trade-offs tailored to different serving regimes.
Primitive 1: Fixed-width rows (BlockLock-Rows). The batch is structured as a 2D tensor of shape . Each request occupies a dedicated row of fixed width , where left-padding aligns real tokens to the right boundary of the row and a 2D padding mask isolates valid tokens from padding. Because the target request occupies a fixed row index with invariant logical positions and row width , row-wise operators and attention reductions observe the exact same tensor geometry regardless of how companion lengths vary in other rows. A single batched prefill invocation processes all rows simultaneously, and decoding proceeds via standard -request batched KV caching.
For dense full attention (omitting head and hidden-dimension factors), attention score computation requires work. Crucially, because requests are separated along the batch dimension, BlockLock-Rows requires no dense 2D inter-segment causal mask, giving it a significant complexity advantage over BlockLock-Pack as scales. Moreover, because every row in has fixed width , any row whose request is held fixed enjoys the same geometric invariance as the audited target row.
Primitive 2: Terminal-anchored capacity packing (BlockLock-Pack). In BlockLock-Pack, the companions, an isolated dummy filler segment, and the protected target are concatenated along the sequence dimension into a single packed block of shape . Let denote the total number of real prompt tokens in the group. The remaining unused capacity is absorbed by a dummy segment of length
By placing the companions first, the -token dummy segment second, and the protected target strictly last, is anchored at the fixed terminal physical interval
Consequently, both the start offset and end offset of the target remain completely invariant to fluctuations in companion lengths . For instance, with and (), a companion of length 180 and a target of length 192 induce a -token dummy segment, leaving unchanged.
Within the packed sequence, each real segment is assigned reset local position IDs (for RoPE embeddings). Let denote the segment index of physical token position , where the dummy segment is assigned its own isolated segment identity. In the native PyTorch implementation, logical isolation is enforced via an additive segment-causal attention mask :
where . This mask guarantees strictly segment-local causal visibility. A single forward pass over computes the packed KV cache and yields the target's initial next-token logits at position . In native PyTorch, materializing requires memory and attention score work; in our vLLM integration, segment isolation is instead handled via PagedAttention block tables and segment metadata without materializing a dense matrix.
Algorithm 1 BlockLock-Pack: Terminal-Anchored Packed Prefill and Target-Local Decode
Require: Target prompt (length ), companions , class width , batch size , decode horizon
1: ; (require )
2: Pack sequence of shape by concatenating , an isolated -token dummy segment (if ), and at interval
3: Construct segment-reset local position IDs and segment-causal mask
4:
5:
6: for to do
7: ; record token and raw logits
8: if then
9:
10: end if
11: end for
12: return Target token sequence , raw-logit trace, and CUDA phase timings
A.3 Request-Local KV Extraction and Decode Handoff
Following the shared prefill in BlockLock-Pack (Algorithm 1), BlockLock constructs a standalone target-local KV cache (DynamicCache in Transformers or target block table in vLLM) by extracting only 's state layer by layer:
-
Full-attention layers: The extractor slices and retains the terminal key and value states corresponding to .
-
Sliding-window attention layers: For models employing hybrid full/sliding-window attention (such as Gemma-3-4B/12B-IT), the extractor retains the visible target suffix within the sliding window and restores the cache's logical cumulative sequence length metadata ('_seen_tokens') to .
This handoff guarantees that every KV entry visible to 's attention window is preserved bit-for-bit without value conversion. Subsequent decode steps execute with input shape , target-local position IDs , and the isolated cache . By decoding in isolation rather than batch-decoding companions with varying unpadded lengths , BlockLock-Pack ensures that the decode phase also strictly satisfies canonical geometry (Condition C1).
A.4 Configuration-Level Determinism Contract and Proof
Let denote the protected target prompt, the frozen model weights, and the deployment configuration tuple:
Each distinct GPU architecture (A6000 Ampere, A100 Ampere, H100 Hopper, or 2×A6000 TP = 2) constitutes a distinct deployment . Let denote the companion composition and scheduling instance, the canonical execution plan assigned to , and the raw full-vocabulary logit vector produced for target at generation step prior to argmax selection.
Definition 1 (Per-Deployment Bitwise Reproducibility Contract). For any two companion schedules and compatible with the canonical plan under a fixed deployment , the raw logit vectors of target are bitwise identical at every generation step :
The contract relies on three sufficient conditions (stated in Section 3.4 of the main text):
C1. Canonical Geometry and Logical Isolation: The target's tensor dimensions, row/terminal physical offsets, local position IDs, and causal attention masks remain invariant across and , preventing companion tokens from contributing to target attention values. In , shard boundaries and collective call sequences are likewise invariant.
C2. Repeat-Stable Operator and Collective Arithmetic: Under a fixed tensor shape and alignment, all enabled kernel dispatches and distributed NCCL collectives are deterministic across repeated invocations, and companion values in masked/other-row positions do not alter the floating-point reduction tree of the target's positions.
C3. Faithful Cache-State Handoff: The transition from prefill to decode preserves the exact bitwise KV tensors, sliding-window suffixes, and position metadata of the target without numerical cast or truncation of visible states.
Proposition 1 (Conditional Deterministic State Preservation). Under a fixed deployment and canonical plan satisfying Conditions C1–C3, deterministic greedy decoding produces bitwise-identical raw logits , identical
generated token IDs , and identical target KV states across all compatible companion schedules .
Proof. We proceed by induction on the generation step . Base case (, Prefill): By Condition C1, target occupies the exact same row in (Rows) or terminal interval in (Pack) with identical local positions and causal masking under both and . By Condition C2, every linear projection, normalization, attention kernel, and TP collective executes the exact same reduction tree over 's isolated representation. Thus, the prefill step produces bitwise-identical initial target logits and identical visible target KV entries. By Condition C3, the decode handoff yields bitwise-identical target KV caches .
Inductive step (, Decode): Suppose that at step , both executions share bitwise-identical token histories , raw logits , and target KV states . Deterministic greedy selection (argmax with fixed tie-breaking) selects the exact same token . At step , the decode invocation receives identical input token , position ID , cache state , and step geometry with row-independent reductions in Rows, or in Pack). By Conditions C1 and C2, the resulting updated KV cache and next-step raw logits are bitwise identical: . By induction, the claim holds for all .
B EXPERIMENTAL DETAILS AND PROTOCOL
This section provides the details on the experimental setup. The code and results are available at the following repository: Omitted for double-blind review.
B.1 Hardware Platforms and Software Stack
Our evaluation spans three NVIDIA GPU platforms across two architectures:
- NVIDIA RTX A6000 (48 GB, Ampere): Single-GPU evaluation and dual-GPU tensor-parallel () evaluation via NVLink/PCIe with NCCL.
- NVIDIA A100 (80 GB, Ampere): Single-GPU evaluation.
- NVIDIA H100 NVL (Hopper): Single-GPU evaluation (including MIG 3g, 47gb slices in backend audits and full-device runs).
The software stack uses Python 3.11, PyTorch 2.11.0+cu128, HuggingFace Transformers 5.13.0, vLLM (with native
Batch-Invariant kernel support enabled for vLLM BI), CUDA 12.8, and cuDNN 9.19. To satisfy Condition C2, our restricted backend policy sets torch.backends.cuda.matmul.allow_tf32 = False, torch.backends.cudnn.allow_tf32 = False, and disables cuDNN SDPA (enable_cudnn.sdp (False)), while retaining FlashAttention-2, Memory-Efficient SDPA, and Math SDPA according to hardware/dtype eligibility (PyTorch Contributors, n.d.c;n). All models run in eval() mode with bfloat16 (BF16) weights and activations and a fixed seed of 0.
B.2 Evaluated Models
We evaluate five open-weight dense instruction-tuned and base models spanning three model families (including dense standard attention, Grouped-Query Attention, and Gemma-3's interleaved local sliding-window / global full attention):
-
Qwen3-8B: https://huggingface.co/Qwen/Qwen3-8B
-
Qwen3-14B: https://huggingface.co/Qwen/Qwen3-14B
-
Llama-3.1-8B-Instruct: https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct
-
Gemma-3-4B-IT: https://huggingface.co/google/gemma-3-4b-it
-
Gemma-3-12B-IT: https://huggingface.co/google/gemma-3-12b-it
B.3 Datasets and Workloads
-
Eight-Dataset Core Benchmark: Comprises seven suites from tinyBenchmarks (https://huggingface.co/tinyBenchmarks) (Maia Polo et al., 2024)—MMLU, AI2 ARC, HellaSwag, GSM8K, TruthfulQA, WinoGrande, and AlpacaEval—plus multi-function tool-use queries from the Berkeley Function Calling Leaderboard (BFCL v3) (https://gorilla.cs.berkeley.edu/) (Patil et al., 2025). BFCL queries are evaluated in both standard prompt-rendering mode and native tool-calling chat-template mode where supported by the tokenizer. (The 188-query BFCL study cited in Section 1 is an independent motivational audit.)
-
Long-Context and Real-World Trace Workloads (Table 3 of main text): Evaluates synthetic stress tests with class widths and output lengths alongside real-world
variable-length prompt traces sampled from Blazedit and BurstGPT ( generated tokens per decoded request, ). Blazedit and BurstGPT each supply one representative four-request group; these are controlled tests, not full arrival-trace replays.
- Implementation of vLLM Rows: In our vLLM adapter, BlockLock-Rows explicitly enforces canonical prefill geometry by constructing a flattened input tensor of exactly tokens, prepending left-padding tokens before request such that:
Inserting physical query padding tokens is necessary because merely shifting sequence offsets in a ragged tensor would still expose the projection, normalization, and FFN layers to companion-dependent total token counts . Our vLLM integration decouples prefill query padding from decode KV storage. Zero KV Cache Pollution (): All padding positions are assigned , preventing them from allocating or writing to PagedAttention KV blocks. Exact Causal Alignment: Each request retains its true context length and local RoPE positions , while FlashAttention's bottom-right causal alignment isolates leading padding queries from the valid prefix. The adapter also pins attention bounds, enforces a single attention split (disabling nondeterministic Split-KV), and replays captured CUDA graphs.
B.4 Companion-Perturbation Protocol and Agreement Metrics
Across batch sizes , each target question in a dataset is evaluated over independent repetitions. In repetition , the target prompt is co-scheduled with a distinct, randomly sampled tuple of companion prompts drawn from the same length class. This yields pairwise cross-companion comparisons per (platform, model, dataset, target, ) condition, totaling 1,316 single-GPU conditions and 20 conditions (60,120 pairwise comparisons per scheme).
Generated-Sequence Agreement (). Suppose repetitions of a fixed target partition into distinct generated token-ID sequences with multiplicities (). The within-condition pairwise sequence agreement is
if and only if all companion-perturbed runs produce the exact same token sequence ().
Top-20 Logit-Trace Agreement () and Full-Vocabulary Hash Audit. Even when greedy argmax tokens agree, subtle floating-point drift can alter underlying logits. At every generation step , we record the top-20 candidate token IDs and their exact 16-bit BF16 raw logit bit patterns. Two runs agree in Top-20 trace if and only if both the ordered top-20 candidate IDs and their raw logit bits match identically at every step . In our vLLM and PyTorch 8-dataset benchmarks (80 conditions per method), we additionally compute SHA-256 hashes over the full-vocabulary raw logit tensor at every step to verify strict bitwise identity across the entire vocabulary.
B.5 Phase Timing Instrumentation and Dual-Engine Scope
Prefill and decode latencies are bracketed using hardware torch.cuda.Event (enable_timing=True) markers synchronized around the respective model forward calls. Because our experiments evaluate deterministic batch execution mechanics rather than network queuing, we report exact prefill and decode phase durations rather than arrival-queue TTFT or TPOT.
- Equal-Delivered-Work Benchmarks (STD, vLLM BI, Padded, CoRun-style, BlockLock-Rows):
All requests in the batch are prefilled and decoded for tokens. The standard agreement and timing suite, including all panels in Section E, uses ; the small-scale dual-engine (vLLM vs. PyTorch) benchmark uses its separately specified decode horizon.
- Single-Target Audit Benchmarks (BlockLock-Pack*): All requests share the [1, BW] prefill, after which only the protected target is decoded. The results in Section E use target tokens; the small-scale dual-engine audit uses .
For the small-scale dual-engine benchmark with and , actual output throughput (tokens/s) is computed as , where is the number of generated tokens (256 for full-batch methods; 64 for Pack*) and is the stacked prefill-plus-decode duration in milliseconds. Memory comparisons enforce identical logit-capture modes across methods to prevent diagnostic trace buffers from skewing peak GPU allocation measurements.
B.6 Condition Breakdown and Backend Eligibility Filtering
Table 1 details the per-configuration breakdown of the 1,316 single-GPU conditions and 20 dual-GPU () conditions summarized in Section 4.2 of the main text. Across all 1,316 single-GPU conditions, standard padded batching (STD) achieves only 52.59% pair-weighted generated-sequence agreement and 35.93% Top-20 raw-logit agreement, whereas CoRun, BlockLock-Rows, and BlockLock-Pack achieve 100.0% on both metrics.
C SINGLE-REQUEST () BACKEND AUDIT AND KERNEL INTERVENTION
A critical finding of our study (Section 2.3) is that LLM inference can fail to be reproducible even at batch size with fixed seeds and greedy decoding if the underlying kernel dispatch violates repeat stability (Condition C2).
To isolate backend-induced nondeterminism from batch-composition effects, we conducted a controlled audit on an NVIDIA H100 NVL GPU (MIG 3g. 47gb instance) running Qwen3-8B in BF16 on a fixed 117-token tinyMMLU prompt over 320 greedy decoding steps. Even though the logical input and tensor geometry were held completely static across repetitions, PyTorch's default SDPA backend dispatcher selected cuDNN's fused attention kernel, on the divergent execution path. This identifies the dispatched backend, but does not establish which internal reduction or workspace operation caused the variation.
As shown in Table 2, under the default backend policy, repeating the exact same execution yielded 2 unique sequences out of 4 runs for CoRun, 3 out of 3 distinct sequences for Padded, and 2 out of 3 for BlockLock-Rows. Kernel-level profiling via NVIDIA Nsight Systems confirmed that cuDNN SDPA was invoked on the divergent path. When our restricted backend policy disables cuDNN SDPA and TF32 (restricting the eligible attention backend set), all repeated runs collapsed to a single unique sequence () with 100% bitwise raw-logit identity across all 320 steps. This empirical evidence motivates Condition C2 of our contract: canonical geometry (Condition C1) must be paired with a verified repeat-stable backend policy.
D DEPLOYMENT VALIDATION AND REPRODUCIBILITY CHECKLIST
To validate the conditions required for end-to-end bitwise reproducibility in production or evaluation pipelines, each
Table 1. Pair-weighted generated-sequence agreement (%) and Top-20 raw-logit agreement (%) across the evaluated single-GPU and TP = 2 configurations with T = 500 generated output tokens per request (, 10 repetitions per condition). The single-GPU subtotal and the combined total are distinct populations. CoRun, BlockLock-Rows, and BlockLock-Pack achieve 100.0% across all 1,336 conditions.
| Platform | Model | Padded Seq. Agree. (%) | BlockLock Agree. (%) | Evaluated Conditions |
|---|---|---|---|---|
| A100 | Qwen3-14B | 57.4 | 100.0 | 135 |
| A100 | Qwen3-8B | 56.6 | 100.0 | 159 |
| A6000 | Qwen3-14B | 55.8 | 100.0 | 105 |
| A6000 | Qwen3-8B | 62.9 | 100.0 | 160 |
| A6000 | Gemma-3-4B-IT | 40.4 | 100.0 | 130 |
| A6000 | Llama-3.1-8B | 44.9 | 100.0 | 160 |
| H100 | Qwen3-14B | 55.8 | 100.0 | 160 |
| H100 | Qwen3-8B | 57.5 | 100.0 | 160 |
| H100 | Llama-3.1-8B | 51.1 | 100.0 | 147 |
| Single-GPU Subtotal / Mean (Top-20 Logit Agreement) | 52.59 (35.93) | 100.0 (100.0) | 1,316 1,316 | |
| () Gemma-3-4B-IT | 59.4 | 100.0 | 20 | |
| Total Evaluated Conditions | 52.69 | 100.0 | 1,336 | |
Table 2. Single-request () repeat-stability audit on NVIDIA H100 (Qwen3-8B, BF16, 117-token prompt, 320 greedy steps). Counts indicate unique generated sequences / total repeated runs.
| Execution Path | Default Backend (cuDNN SDPA + TF32) | Restricted Policy (No cuDNN SDPA / TF32) | Raw-Logit Bit Match |
|---|---|---|---|
| CoRun() | 2 / 4 unique (Divergent) | 1 / 4 unique (Identical) | 100% |
| Padded () | 3 / 3 unique (Divergent) | 1 / 3 unique (Identical) | 100% |
| BlockLock-Rows () | 2 / 3 unique (Divergent) | 1 / 3 unique (Identical) | 100% |
BlockLock deployment enforces the following automated validation checklist prior to serving:
-
Decoding and Seed Lock: Enforce deterministic greedy selection (or request-bound RNG state for sampling) with fixed tie-breaking and stopping criteria.
-
Backend Eligibility Gate (Condition C2): Disable non-deterministic kernel dispatches (cudnn_sdp = False, allow_tf32 = False) and use a repeat check as an initial canary. Validation must also cover the deployed model, precision, prefill/decode shapes, length classes, and TP configuration; passing the canary alone does not establish Condition C2 for other dispatches.
-
Environment Pinning: Record exact hardware SKU, driver/CUDA/cuDNN versions, and framework releases (PyTorch, Transformers, vLLM).
-
Canonical Geometry Lock (Condition C1): Freeze the alignment granularity , length-class width mapping , batch size , and primitive layout (Rows or Pack with terminal interval ).
-
Multi-GPU Collective Verification (): Verify via pre-inference rank broadcasts and post-inference SHA-256 logit-hash comparisons that all tensor-parallel ranks execute identical plans and repeatable NCCL reductions.
-
Audit Logging: Optionally persist generated token IDs, Top-20 raw-logit traces (or full-vocabulary SHA-256 hashes), and CUDA-event phase intervals for post-hoc verification.
Any modification to hardware topology, driver/library versions, or batch-class geometry constitutes a new deployment and triggers re-validation of the checklist.
E DETAILED EXPERIMENTAL RESULTS
This section presents generated-sequence agreement, Top-20 raw-logit agreement where available, and prefill/decode timings for individual model–GPU configurations across the eight datasets. All experiments shown in this section use BF16, batch sizes , ten companion-perturbed repetitions per condition, and a decode horizon of tokens per decoded request. Agreement metrics follow Section B. The target-question identifier and input mode are retained in each panel's original title where provided.
Method-name correspondence. The original plot labels Normal, CoRun, Scheme 1, and Scheme 2 correspond to STD, CoRun, BlockLock-Rows, and BlockLock-Pack, respectively, in the text. In particular, Normal denotes standard padded batching, Scheme 1 denotes fixed-width row locking, and Scheme 2 denotes terminal-anchored capacity packing with target-local decode. We use the manuscript names below and retain the original labels inside the plots.
Reading the panels. Colors indicate batch size. Generated-sequence and Top-20 agreement are pairwise percentages across repeated runs. Timing bars stack the median prefill and median decode CUDA durations, with solid and pale fills identifying the two phases. Blank cells indicate unavailable or incomplete measurements. Under BlockLock-Pack, shared prefill is followed by decoding the protected target; the other methods decode all requests in the batch. All decoded requests in these panels use the same 500-token horizon. Top-20 panels are included for configurations with an available export.
E.1 NVIDIA RTX A6000
Qwen--Qwen3-8B · BF16 · prompt · Deterministic Token number

(a) Generated-sequence agreement.
Qwen--Qwen3-8B · BF16 · prompt · Stacked cost

(b) Prefill and decode CUDA time.
Figure 1. Qwen3-8B on NVIDIA RTX A6000 (BF16, prompt, ): (a) generated-sequence agreement; (b) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Top-20 raw-logit agreement.

(c) Prefill and decode CUDA time.
Figure 2. Qwen3-14B on NVIDIA RTX A6000 (BF16, prompt, target question Q1, T = 500): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.
meta-llama--Llama-3.1-8B-Instruct · BF16 · prompt · Stacked cost

(b) Prefill and decode CUDA time.
Figure 3. Llama-3.1-8B-Instruct on NVIDIA RTX A6000 (BF16, prompt, ): (a) generated-sequence agreement; (b) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Top-20 raw-logit agreement.

(c) Prefill and decode CUDA time.
Figure 4. Gemma-3-4B-IT on NVIDIA RTX A6000 (BF16, prompt, target question Q1, T = 500): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode CUDA time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Top-20 raw-logit agreement.

(c) Prefill and decode CUDA time.
Figure 5. Gemma-3-12B-IT on NVIDIA RTX A6000 (BF16, prompt, target question Q0, T = 500): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.
E.2 NVIDIA A100
Qwen-Qwen3-8B · BF16 · prompt · Target Q2 · Deterministic Token Agreement

(a) Generated-sequence agreement.
Qwen-Qwen3-8B · BF16 · prompt · Target Q2 · Top-20 Logit Agreement

(b) Top-20 raw-logit agreement.
Qwen-Qwen3-8B · BF16 · prompt · Target Q2 · Stacked Time cost

(c) Prefill and decode CUDA time.
Figure 6. Qwen3-8B on NVIDIA A100 (BF16, prompt, target question Q2, ): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Top-20 raw-logit agreement.

(c) Prefill and decode CUDA time.
Figure 7. Llama-3.1-8B-Instruct on NVIDIA A100 (BF16, prompt, target question Q0, T = 500): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode CUDA time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Top-20 raw-logit agreement.

(c) Prefill and decode CUDA time.
Figure 8. Gemma-3-4B-IT on NVIDIA A100 (BF16, prompt, target question Q0, T = 500): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Top-20 raw-logit agreement.

(c) Prefill and decode CUDA time.
Figure 9. Gemma-3-12B-IT on NVIDIA A100 (BF16, prompt, target question Q0, T = 500): (a) generated-sequence agreement; (b) top-20 raw-logit agreement; (c) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.
E.3 NVIDIA H100
Qwen-Qwen3-8B · BF16 · native · Target Q1 · Deterministic Token Agreement 10 repeats per cell · Target question 1

(a) Generated-sequence agreement.
Qwen-Qwen3-8B · BF16 · native · Target Q1 · Stacked Time cost 10 repeats per cell · Target question 1

(b) Prefill and decode CUDA time.
Figure 10. Qwen3-8B on NVIDIA H100 (BF16, native, target question Q1, ): (a) generated-sequence agreement; (b) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.

(b) Prefill and decode CUDA time.
Figure 11. Qwen3-14B on NVIDIA H100 (BF16, prompt, target question Q1, ): (a) generated-sequence agreement; (b) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.
meta-llama--Llama-3.1-8B-Instruct · BF16 · prompt · Stacked cost

(b) Prefill and decode CUDA time.
Figure 12. Llama-3.1-8B-Instruct on NVIDIA H100 (BF16, prompt, T = 500): (a) generated-sequence agreement; (b) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.

(a) Generated-sequence agreement.
google-gemma-3-4b-it · BF16 · prompt · Stacked cost

(b) Prefill and decode CUDA time.
Figure 13. Gemma-3-4B-IT on NVIDIA H100 (BF16, prompt, ): (a) generated-sequence agreement; (b) prefill and decode cuda time. Method labels follow the correspondence defined at the start of Section E.
REFERENCES
Maia Polo, F., Weber, L., Choshen, L., Sun, Y., Xu, G., and Yurochkin, M. tinyBenchmarks: evaluating LLMs with fewer examples. In Salakhutdinov, R., Kolter, Z., Heller, K., Weller, A., Oliver, N., Scarlett, J., and Berkenkamp, F. (eds.), Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 34303–34326. PMLR, 21–27 Jul 2024.
NVIDIA. NCCL user guide: Environment variables. https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/env.html, n.d. Accessed October 18, 2026.
Patil, S. G., Mao, H., Yan, F., Ji, C. C.-J., Suresh, V., Stoica, I., and Gonzalez, J. E. The berkeley function calling leaderboard (bfc): from tool use to agentic evaluation of large language models. In Proceedings of the 42nd International Conference on Machine Learning, ICML'25, 2025.
PyTorch Contributors. Distributed communication package: torch.distributed. PyTorch 2.11 documentation, https://docs.pytorch.org/docs/2.11/distributed.html, n.d.a. Accessed October 18, 2026.
PyTorch Contributors. Reproducibility. PyTorch 2.11 documentation, https://docs.pytorch.org/docs/2.11/notes/randomness.html, n.d.b. Accessed October 13, 2026.
PyTorch Contributors. Scaled dot-product attention (SDPA). PyTorch 2.11 documentation, https://docs.pytorch.org/docs/2.11/generated/torch.nn.functional.scaled_dot_product_attention.html, n.d.c. Accessed October 18, 2026.