Manuscript Offprint
arXiv:2609.05707Intra-Prompt Parallel Decoding for Common-Context Question Answering
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
In common-context question answering (CCQA) tasks, multiple input questions share a common context to base their answers from. However, Large Language Models typically generate each answer using an independent prompt. While existing batching and caching techniques help improve parallelism and reduce repeated computations, the separation of questions across prompts limits the achievable speedup, as modern GPUs are underutilized due to a memory bottleneck during attention. We present Intra-Prompt Parallel Decoding (IPPD), a novel inference method that answers multiple common-context questions in parallel within a single prompt. IPPD directly addresses the bottleneck by efficiently sharing both memory and computation during the attention process, as the next token for every question is decoded in a single inference step. IPPD uses virtual position IDs and attention mask manipulation to generate the same output as standard prompting without requiring fine-tuning or any changes to the LLM architecture. Since all parallelism occurs within a prompt, IPPD is fully compatible with batched inference, even when each prompt features a different context. Our experiments show that IPPD delivers up to 7X the effective throughput as standard decoding without quality degradation, and outperforms prefix caching with PagedAttention in most settings.
1 Introduction
Text generation has emerged as a core capability of LLMs, powering downstream NLP applications such as dialogue systems (Yi et al., 2025), summarization (Zhang et al., 2026), and question answering (QA) (Yue, 2025). Within the broad landscape of text generation, contextual QA stands out as a representative benchmark task: given a document and a question, a model must not only locate relevant pieces of evidence within the context, but also integrate and reason across them to answer the question. A large subset of QA tasks referred to as reading comprehension follows this setting, where multiple questions are asked about the same passage (Lai et al., 2017; Yang et al., 2018; Rajpurkar et al., 2018; Kočiský et al., 2018). We define common-context question answering (CCQA) as the task of producing multiple outputs by answering different questions about a shared context, such as a document. This setting is common in industrial information extraction, where systems must extract numerous fields or facts from the same long, unstructured input, including financial statements, medical records, legal documents, and web pages (Mandal et al., 2025; Brinkmann et al., 2024).
Although LLMs excel at generating free-form answers for a wide range of applications, the computational cost of generative LLMs limits their adoption in large-scale real-world scenarios. This challenge is particularly critical in CCQA because, despite substantial context overlap across questions, autoregressive decoding repeatedly computes the same prompt and passage for each question, wasting GPU resources with redundant computations and amplifying inefficiencies.
Motivated by cost savings, a significant body of literature has focused on improving the efficiency of LLM inference for text generation as well as CCQA. A major performance bottleneck arises from the challenge of fully utilizing highly-parallel GPU architectures, due to the high memory requirements and sequential nature of autoregressive decoding. State-of-the-art serving platforms, such as vLLM (Kwon et al., 2023), implement a variety of advanced methods to address this. Continuous batching dynamically groups incoming requests to maximize GPU utilization, PagedAttention (Kwon et al., 2023) shares the memory-intensive key-value
This work was done as part of an internship at Amazon.
Work done while at Amazon. Currently at Apple.
(KV) cache across requests, and Cascade inference (Ye et al., 2024b; Juravsky et al., 2024) shares the compute-expensive attention score calculation of shared prefixes across requests. While these innovations have substantially accelerated inference, the computational cost of processing large, common contexts for millions of queries remains a key challenge, particularly in offline scenarios requiring high throughput, and when not all batched requests share the same context.
To address the above challenges, we introduce Intra-Prompt Parallel Decoding (IPPD),¹ a novel inference method for maximizing the batched throughput of CCQA with intra-prompt parallelism (Figure 1), where multiple questions are combined into a single prompt, and answers are decoded in parallel within it. By decoding tokens out of order and adjusting the attention mask, IPPD increases throughput while not affecting the final output. The increased efficiency of IPPD stems from dramatically reducing the number of required memory accesses during attention, which is known to be heavily memory bottlenecked (Recasens et al., 2025). Importantly, IPPD can be easily applied to existing systems without changes to the core model implementation, maintains compatibility with orthogonal inference acceleration methods, and is up to 7 times more computationally efficient than standard batched inference on realistic CCQA tasks.
Batch parallelism Another relevant research direction is accelerating LLM inference by sharing memory and computation across batched prompts. Prefix caching (Kwon et al., 2023; Ye et al., 2024a; Pan et al., 2025a) and PagedAttention (Kwon et al., 2023) are common methods that create a shared Key-Value (KV) cache to reduce memory usage and avoid recomputing KV matrices for common prefixes in batched prompts. While these techniques reduce the required floating point operations (FLOPs) during attention, they are limited by the large number of memory accesses required to independently compute attention scores for each prompt, resulting in GPU underutilization. We elaborate on this phenomenon in Section 4.3.
Tree-based decoding Recent work has demonstrated the success of using tree data structures to share memory and computation of partially overlapping queries. A KV cache tree stores shared contexts without duplication, and cross-attention is performed in chunks between the incoming queries and shared KV (Ye et al., 2024b; Juravsky et al., 2024; Yao et al., 2025; Wang et al., 2025). The final attention scores are then computed using a merge operator on the partial attention scores. Although strong performance can be obtained by designing optimized low-level attention kernels, this approach suffers from the overhead of the merge operation. Since a custom kernel and KV cache manager are required, existing methods are often limited in their batching functionality, or incompatible with newer models and inference platforms (Yao et al., 2025; Pan et al., 2025b; Ye et al., 2024b). These factors limit their applicability and longevity. Rather than breaking up the attention process into many parts, IPPD combines common-context questions into a single KV cache and attention operation without any context duplication. By supplying the model with a custom attention mask, IPPD parallelizes CCQA tasks without modifying the model implementation or breaking compatibility with orthogonal methods.
¹Code is available at https://github.com/networkslab/IPPD Corresponding author: theodore.glavas@mail.mcgill.ca

Figure 1: In QA tasks, multiple questions often reference the same context. Traditional batched inference separates each question into a separate prompt, and processes prompts independently to generate the answer. IPPD combines multiple questions and contexts within a single prompt and jointly decodes multiple answers in parallel. This eliminates repeated computations and reduces the memory bottleneck of GPUs during attention to generate the same answers in a fraction of the time.
3 Problem Formulation: CCQA
We begin by denoting the inputs to the LLM in a QA setting. All LLM inputs are comprised of the following components: a common instruction or prompt prefix , a context (for example a document or passage), and a question . Usually, these three logical parts form a triplet which, after tokenization, becomes a contiguous sequence presented to the model. In realistic workflows, we can have many such triplets, and several triplets may share the same context. To capture this, let denote contexts and for each context let denote the associated questions. The set of logical triplets is then . We assume this set to be fully available offline at inference time. We further assume that each question can be answered independently: generating may depend on , , , and its own previously generated tokens, but not on the answers to other questions.
A traditional LLM loop to process the triplets would be to issue independent prompts, each requiring a separate LLM forward pass . During autoregressive answer generation, each answer token is generated and fed back into the input sequence and passed through forward pass . As a result, the -th token of the answer is obtained using , where represents the first answer tokens generated for question index of context . At the end of the process, we obtain the answer set .
Traditional inference methods employ batch-
ing to process multiple prompts concurrently. Although parts of the computation, such as the MLP layers, can be effectively parallelized across prompts, computations in the attention layers are performed independently for each prompt. This introduces a bottleneck for batched inference, particularly when batch elements share a common context . We elaborate on this phenomenon in Section 4. To overcome this limitation, we wish to develop an inference method that can efficiently share computation in the attention layers, while maintaining batched inference compatibility and not requiring any training or fine-tuning. To achieve this, we aim to parallelize the generation of across within a prompt. It is important to note that each token within an answer will still be generated autoregressively, as we are parallelizing across the question set. The core methodological challenges are ensuring that the introduced intra-prompt parallelism is computationally efficient and does not affect the quality of the generated answers .
We evaluate candidate strategies by comparing against batched autoregressive generation along two complementary axes: throughput (efficiency) and answer quality (fidelity to the ground truth question answers). Throughput measures how many logical triplets are answered per unit time per GPU. Answer quality is measured at the task level using standard metrics (Accuracy, F1, ROUGE-L). Task-level metrics compare generated answers to ground truth answers . See Appendix B for definitions of throughput and metrics.
Standard Batched Inference
IPPD (our method)

Figure 2: The attention process between the queries (rows) and keys (columns) is depicted with green cells representing unmasked query-key pairs. In standard batched inference, the sequence contains a common instruction , shared context , question and partial answer (simplified as one or two tokens for illustrative purposes). The arrows indicate which token is generated using the output of that query row. IPPD concatenates multiple contexts and queries into a single stacked prompt. The attention mask ensures that each query can only attend to past tokens from the relevant context and question, identifiable by color and shade respectively. At inference step , IPPD generates the -th token of four answers through a single shared attention operation per layer in this example. Batched inference would require four independent attention calculations to achieve the same result.
4 Method: Intra-Prompt Parallel Decoding (IPPD)
We introduce Intra-Prompt Parallel Decoding (IPPD), a strategy that enables multiple context-question triplets to be processed in parallel within a single prompt. Section 4.1 describes how we replace the independent forward passes of the canonical autoregressive loop with a single, structured forward-pass strategy that: (i) stacks contexts and questions into one prompt, (ii) assigns hierarchical position identifiers so positional relationships do not induce cross-question leakage, (iii) builds an attention mask that enforces per-question causal inference, and (iv) decodes tokens in parallel across the question set. Figure 2 provides an illustrative example of the process: the IPPD prompt combines two contexts and with two questions each, and respectively. During the prefill stage, the attention mask prevents the questions from (a) attending to each other, and (b) attending to the non-relevant context. After a full forward pass, we can extract four answer tokens, corresponding to the first token of each question. These tokens are passed in parallel
during the decode stage with appropriate masking to maintain high parallelism throughout generation. Our goal is to ensure that each generated token's conditional distribution under this multi-query, per-step parallel scheme matches the distribution produced by independent autoregressive decoding on the corresponding triplet , which we demonstrate in Section 4.2. Section 4.3 describes the computational efficiency of IPPD, arising from increasing GPU utilization during attention.
4.1 Input pre-processing
We construct a stacked token sequence containing the global instruction , contexts, and the associated questions. We append the answers after this header. The header region of the prompt is
and the full token sequence at any point in decoding equals the header followed by the concatenation of all answer tokens produced so far. We do not reserve fixed answer slots inside the header; instead answers are accumulated at the end of the sequence as they are generated.
To track the role and origin of each token and make masking causal, we compute a small metadata tuple for each token index in : a virtual position ID , a context identifier (with indicating tokens in ), and a question identifier (with for tokens in and ).
We distinguish between a virtual position that encodes the per-triplet autoregressive ordering and the absolute position that reflects the token's index in the concatenated sequence s. The virtual position of the t-th token of the answer for question is defined as the position that token would occupy if the triplet were decoded in isolation:
where denotes the token length of a sequence. For header tokens inside p, , or , their virtual positions cover these ranges:
For answer tokens, gives the local offset inside their parent triplet. Appendix A.1 provides a derivation for the absolute position IDs.
We define the masking logical expressions to use virtual positions for the causality constraint. Let be token indices in and , be the context and question identifiers as previously defined. The elementary logical expressions become
The final mask logic is the conjunction
of the causal, context and question masks. The transformer's attention matrix mask is then set by
Negative infinity inputs result in zero activation post-softmax in the attention block.
Because answers are appended at the end of the sequence and are labeled with their originating question and context, this mask guarantees that any answer token may attend only to the global instruction (via ), to tokens in its parent context (via ), and to tokens in its own question/answer pair and previously generated answer tokens (via ). Tokens belonging to other questions or contexts fail at least one mask and are therefore blocked, preventing cross-question information leakage despite the single forward-pass execution.
4.2 Parallel Decoding
Building on the hierarchical position and masking scheme described above, we now argue that the resulting forward pass is equivalent to independent autoregressive decoding over each triplet . The key point is that the attention mechanism for any output token is restricted by construction to exactly the same set of tokens it would see in the autoregressive case: the shared instruction , the corresponding context , the question , and its own previously generated tokens . Tokens from other questions or contexts are masked and therefore have no influence.
Formally, let be the query vector for token and let be the matrix of key vectors over all tokens. Let denote the set of key indices that the autoregressive computation treats as valid, which the causal mask determines through . In the autoregressive setting, we have
The additive mask assigns to every key outside S, which removes those keys from the softmax support without any explicit restriction of the softmax. Under IPPD, the same attention score is computed over all keys but with a mask applied:
Since adding to a logit removes it from the softmax support, the resulting distribution is identical to that of the autoregressive case:
Thus, each token in the stacked prompt follows exactly the same computational path as in the independent autoregressive runs, establishing the equivalence of the two procedures.
Each forward pass at step generates the -th token of each answer, which is appended to the prompt with the correct virtual position ID for the next pass. We stop appending tokens for answers that generate the end-of-sequence token, continuing the others until all answers are complete. This process is demonstrated in Fig. 2. Standard LLM frameworks such as Hugging Face Transformers (Wolf et al., 2020) natively support the multi-token output and custom attention masks required by IPPD. Consequently, IPPD requires no modifications to the model implementation, attention kernel and KV cache structure. This ensures broad compatibility and a significantly lower barrier to adoption compared to tree-based alternatives.
4.3 Computational Efficiency
IPPD allows for more efficient computation in the attention layers. We provide a high-level explanation in this section, with a more detailed analysis and comparison to Cascade inference available in Section A.2. At each attention layer, the attention computation involves multiplying and , followed by a multiplication with post-softmax. These large multiplications incur a time cost for each byte of memory accessed to load these matrices, as well as a time cost for each floating point operation (FLOP) required for calculating the output. In autoregressive decoding, attention is almost exclusively bottlenecked by memory accesses, even for small models and large batch sizes (Recasens et al., 2025). This means that modern GPUs are underutilized because the ratio of FLOPs to bytes accessed from memory, known as arithmetic intensity, is too low. IPPD alleviates this bottleneck by increasing arithmetic intensity.
Let denote the keys and values belonging to the instruction tokens and the common context tokens respectively. These keys and values can be computed once and cached for all prompts in the batch, in a process known as prefix caching. Nevertheless, for each attention layer, batched autoregressive inference still requires each key and value to be accessed for every output token, as each prompt requires an independent attention calculation. Since IPPD combines all questions into one stacked prompt, it exposes reuse of within a shared attention operation that generates output tokens. As the instruction and context usually contain the most tokens, this reuse can substantially reduce repeated memory traffic per output token. Although IPPD processes more FLOPs per output token, this tradeoff improves decoding throughput when attention is memory-bound. Section A.2 quantifies this tradeoff and contrasts it with tree-based decoding strategies. We summarize the analysis into three key observations:
(i) For tasks requiring a single-token answer, like multiple-choice QA (RACE in Table 1), IPPD is most effective with shorter contexts due to lower arithmetic intensity.
(ii) For tasks requiring a multi-token answer (NarrativeQA in Table 1), IPPD is effective for both short and long contexts, as arithmetic intensity is low regardless of context length.
(iii) In CCQA scenarios characterized by long shared contexts and short unique suffixes, IPPD is better suited than tree-based decoding, as the overhead of combining partial attention scores in tree methods outweighs the few FLOPs IPPD consumes on masked attention entries.
4.4 Batch Inference Compatibility
IPPD is fully compatible with batched inference. We can batch stacked prompts each with contexts. This allows us to trade off having shorter stacked prompts but lower intra-prompt parallelism. When using batched inference with IPPD, special care must be taken to maintain a uniform input length across stacked prompts. During prefill, the initial prompt is left-padded, as is normally done with standard batching. During decoding, each prompt may produce a variable number of output tokens per inference step. This is because (a) the number of questions or contexts may vary across stacked prompts, and (b) some answers may complete at an earlier step than others, thus reducing the number of outputs in the next step non-uniformly. To address this, we append pad tokens at each decoding step to match the input length of the prompt with the most answers currently being generated. We assign these pad tokens a virtual position ID of infinity (implemented as the maximum integer value), so that the causal mask in Equation (6) prevents any attention. The virtual position IDs of other tokens also ignore the existence of pad tokens, so the batched output of IPPD is unchanged. We implement prefix caching within IPPD only for the dataset-wide instruction . This affects Nar-
| Dataset | Number of contexts | Avg. Parallelism | Average token length | |||
|---|---|---|---|---|---|---|
| Instruction | Context | Question | Answer | |||
| NarrativeQA (5s) | 355 | 29.73 | 2,754.00 | 737.45 | 11.97 | 5.81 |
| SQuAD 2.0 | 1,365 | 8.70 | 47.00 | 177.94 | 12.58 | 3.94 |
| RACE | 1,407 | 3.51 | 40.00 | 344.30 | 39.81 | 1.00 |
| LongHealth | 20 | 20.00 | 73.00 | 11,719.75 | 72.50 | 1.00 |
Table 1: Dataset statistics with the average token length of each prompt sub-section. (5s) means the instruction includes 5 few-shot examples. Average parallelism is the average number of questions sharing a common context, i.e., for a dataset with contexts and questions per context .
rativeQA, where contains five few-shot examples, and allows its KV cache to be reused across batched stacked prompts. IPPD also covers workloads in which only some questions share a context. Questions with distinct contexts can be stacked in the same prompt, each carrying its own context, which still lowers the number of inference steps even though the gain is smaller than for questions that share a context. Table 5 shows that stacking up to six contexts per prompt is throughput-optimal on multi-token answer tasks such as SQuAD 2.0. Because every IPPD modification acts at the level of a single prompt, the method could compose with strategies such as length-based grouping or continuous batching. Supporting these strategies in a production serving system nevertheless requires backend-specific integration work.
5 Experimental Setup
Datasets We evaluate IPPD on four CCQA datasets (Table 1). First, we evaluate on NarrativeQA (Kočiský et al., 2018), a challenging dataset where answers are not required to be spans of the input. We employ 5-shot prompting (Liang et al., 2023) to investigate performance on long prefixes. We select SQuAD 2.0 (Rajpurkar et al., 2018) as an extractive QA benchmark with shorter contexts. We also evaluate on the multiple-choice benchmarks RACE (Lai et al., 2017) and LongHealth (Adams et al., 2025) to cover a wide range of prefix and answer lengths combinations as well as domains. Although IPPD is best suited for large-scale industrial workloads, the scarcity of public datasets of such magnitude necessitates the use of these benchmarks as proxies. Table 1 provides the important dataset statistics, while Section B.2 contains additional details.
Models We evaluate open-source LLMs of varying sizes, namely, Qwen-3 (32B, 8B, 4B-Instruct-2507, 1.7B) (Yang et al., 2025) using non-thinking mode for computational efficiency. We also evaluate Phi-4 14B (Abdin et al., 2024) and OLMo-2-0325-32B-Instruct (OLMo et al., 2025). Models larger than 8B parameters are quantized to 4 bits to fit on a single GPU.
Baselines As the current version of IPPD is implemented using HuggingFace Transformers (Wolf et al., 2020), we use Transformers’ standard batched inference as our primary baseline. We also compare our method to inference using prefix caching and PagedAttention (Kwon et al., 2023) (PC+PA), using vLLM as a backend. Like IPPD, these methods prevent KV recomputation and efficiently shares KV cache memory across questions with a shared context. Since vLLM is a production-oriented backend, it provides a number of orthogonal optimizations not available with Transformers, such as advanced scheduling and custom efficient model code. As our goal is to directly compare IPPD against PC+PA specifically, we adjust the vLLM inference hyperparameters to most closely match our baseline system, with other confounding factors mitigated or removed. Section B.3 provides full experimental details, including hyperparameter selection for each method.
Profiling and controlled ablations In addition to end-to-end throughput, we profile the prefill and decode phases separately to identify where IPPD reduces inference time. We also vary the number of questions sharing each context from 1 to 32 and increase context length from to to characterize how the available shared-context parallelism and prefill cost affect speedup. These experiments use controlled variants of the real benchmark examples rather than fully synthetic inputs. Their construction and complete results are described in Sections D.1 and D.2.
| Model | NarrativeQA (5 shot) | SQuAD 2.0 | RACE | LongHealth | ||||
|---|---|---|---|---|---|---|---|---|
| ROUGE-L | EM% | F1 | EM% | Acc.% | EM% | Acc.% | EM% | |
| Qwen3-32B | 96.5 | 96.9 | 99.7 | 99.5 | ||||
| OLMo-2-32B | 97.6 | 98.1 | 99.8 | - | - | |||
| Phi4-14B | 91.3 | 95.8 | 99.9 | 99.3 | ||||
| Qwen3-8B | 97.5 | 97.5 | 99.6 | 100 | ||||
| Qwen3-4B-Instr. | 95.7 | 98.1 | 99.7 | 99.5 | ||||
| Qwen3-1.7B | 95.7 | 95.5 | 99.1 | 99.3 | ||||
Table 2: Quality metrics for standard batched inference, with the delta to IPPD outputs shown in subscript. EM (Exact Match)% measures the percentage of batched inference and IPPD answers matching each other exactly. IPPD provides the same computational path for each token but numerical instabilities result in a near 100% EM rate.


Figure 3: Throughput measured in questions answered per second. Normalized throughput is relative to the standard batched inference baseline. IPPD outperforms prefix caching + PagedAttention for both short answer QA tasks (top), and for one of the two multiple-choice tasks (bottom). Darker colored shades represent batched inference (baseline), medium shades represent prefix caching + PagedAttention, and lighter shades represent IPPD.
6 Results
Table 2 shows that IPPD maintains near-identical performance to batched inference, with task-metric differences within one percentage point across all models and benchmarks. Exact match rates range from 91.3% to 100%, with 22 of 23 model–dataset combinations exceeding 95%. Section C.1 explains the finite-precision arithmetic differences.
Figure 3 showcases the throughput of IPPD and prefix caching + PagedAttention (PC+PA) relative to standard batched inference across datasets and models. Absolute throughput numbers are available in Appendix C. For the short answer generation datasets, IPPD consistently outperforms both batched inference and PC+PA. NarrativeQA throughput increases by up to 32X with Qwen3-8B. Because IPPD prefix-caches the dataset-wide instruction p for NarrativeQA, which contains five
few-shot examples, part of this speedup is attributable to reusing that prefix. IPPD nevertheless outperforms PC+PA by 2.2X despite PC+PA's more advanced cache management through the vLLM backend. IPPD also performs strongly with SQuAD 2.0, which features a much shorter instruction and average context length than NarrativeQA. IPPD's relative throughput is consistent across models, ranging from 4.1-5.6X for all models except Phi4-14B, where we measure a 7.2X relative throughput. Although IPPD performs well across the entire model range, it is strongest on larger models, as shown by throughput on SQuAD 2.0 being slightly lower than PC+PA with Qwen3-1.7B but convincingly higher for models with 8 billion parameters or more. This trend suggests that IPPD becomes increasingly valuable as attention computations scale.
For our multiple-choice datasets, IPPD consistently outperforms standard batched inference. RACE contains the lowest average number of questions per context, which results in a 2.1-2.7X relative throughput increase for IPPD. However, PC+PA fails to provide a substantial throughput increase, likely due to the short average context length limiting the effects of KV caching and limiting arithmetic intensity. By stacking six contexts per prompt, IPPD provides a 5.8X greater increase in throughput (+171% vs. +29%) with OLMo2-32B. This result validates our theoretical analysis in Section A.2, which states that attention can still be memory bottlenecked during prefill when contexts are short. In contrast, LongHealth features extremely long contexts, which have higher arithmetic intensity during prefill. IPPD is not as effective in this setting as PC+PA, as the advantages of efficient KV cache management for long prefixes outweigh the memory access reductions of IPPD when prefill is already arithmetically intense.
The phase-level profiling in Section D.1 confirms that IPPD reduces both prefill and decode time relative to batched autoregressive inference in every supported multi-token model–dataset setting. Decode-time reductions generally track the reduction in decoding steps, consistent with decode remaining memory-bandwidth bound despite the additional FLOPs in each IPPD step.
The question-count ablation in Section D.2.1 identifies shared-context parallelism as the primary driver of IPPD's benefit: its win rate against PC+PA rises from 0% at one question per context to 73% at 16 and 32 questions, with LongHealth accounting for five of the six remaining losses. Although longer contexts reduce IPPD's relative advantage, the context-length ablation in Section D.2.2 shows that it still wins 75% of supported comparisons at 8× context length.
7 When to Use IPPD
IPPD performs best in throughput-oriented workloads where many independently answerable questions are available together. The number of questions per context is the clearest practical indicator of its benefit, as examined in Section D.2.1. For multi-token outputs, IPPD remains effective across context lengths because decoding is memory-bandwidth bound. Its advantage narrows when answers are long relative to the shared context and question-specific suffixes dominate the stacked
| Short context | Long context | |
|---|---|---|
| Single-token answer | IPPD | PC+PA |
| Multi-token answer | IPPD | IPPD |
| Long generation | Standard inf. | PC+PA |
Table 3: Recommended inference method by answer length and context length, assuming several questions share each context.
prompt, as analyzed in Sections A.2, D.1 and D.2.2. For single-token outputs, short contexts such as RACE favor IPPD, whereas long contexts have higher prefill arithmetic intensity and can favor PC+PA, as on LongHealth in Figure 3. Table 3 summarizes these regimes. With short contexts and long generations, neither method targets the dominant question-specific decoding work, so standard batched inference or a specialized method such as speculative decoding (Leviathan et al., 2023) may be preferable. A large class of practically important CCQA workloads fall into the regime preferred by IPPD, such as extracting many distinct fields from unstructured documents, product and web data, or validating documents against a set of requirements for quality assurance. IPPD can also apply inside workloads that appear sequential, since reasoning problems can often be decomposed into sub-questions answered before any cross-dependency arises.
8 Conclusion
We introduce IPPD, a novel approach that accelerates LLM inference for tasks with shared context such as CCQA. By manipulating position IDs and attention masks, IPPD can decode the next token for all questions in parallel without requiring any modifications to the LLM architecture. IPPD is fully compatible with batched inference, handling multiple prompts with different contexts simultaneously. IPPD achieves up to 7X speedup without sacrificing model performance. Experimental results demonstrate that IPPD outperforms batched autoregressive decoding on every benchmark dataset and model size we test, and outperforms prefix caching with PagedAttention in most evaluated settings. While our experiments focus on CCQA, the core concept of IPPD can extend to broader shared-context generation tasks such as recommendation systems and multi-aspect information extraction. Future work could explore combining IPPD with orthogonal efficiency techniques in systems such as vLLM to further reduce inference costs.
Limitations
Our evaluation targets offline workloads in which the full question set is available in advance, and IPPD requires that questions sharing a context be answerable independently, so tasks whose answers condition one another fall outside its scope. Section 7 discusses a way to apply IPPD inside nominally sequential tasks, which we do not evaluate. IPPD's advantage also narrows in two regimes. Very long contexts paired with single-token answers raise arithmetic intensity during pre-fill, where prefix caching with PagedAttention outperforms IPPD on LongHealth. Generations that are long relative to the shared context reduce the advantage as well, as noted in Section A.2, though we do not measure this regime.
IPPD is implemented on top of HuggingFace Transformers for ease of experimentation and low-level control during inference. Unlike vLLM, this implementation is not optimized for high-throughput serving applications. As such, the reported inference speed likely understates IPPD's attainable efficiency. We leave the integration of IPPD with vLLM as a promising opportunity for future work. Since IPPD modifies the attention mask, it is not directly compatible with FlashAttention (Dao, 2024). However, it is compatible with the new implementation of FlexAttention (Dong et al., 2025), which provides similar benefits to FlashAttention with the flexibility of custom attention masks. IPPD is implemented with both FlexAttention and standard scaled dot-product attention (SDPA), since the latter performs better in most of our experiments. This may change in the future as support for FlexAttention matures and becomes better optimized. We do not evaluate every model size on all hardware platforms, so throughput may vary for untested model-hardware combinations.
We compare against standard batched inference and prefix caching with PagedAttention. Specialized shared-prefix and tree-based systems such as Cascade inference, Hydragen, DeFT and FastTree lack implementations compatible with the model families and inference platforms used here, so we do not compare against them. We have not implemented or evaluated IPPD with production batching policies, which remains future work.
References
Marah I Abdin, Jyoti Aneja, Harkirat Behl, Sébastien Bubeck, Ronen Eldan, Suriya Gunasekar, Michael Harrison, Russell J. Hewett, Mojan Javaheripi, Piero Kauffmann, James R. Lee, Yin Tat Lee, Yuanzhi Li, Weishung Liu, Caio CT Mendes, Anh Nguyen, Eric Price, Gustavo de Rosa, Olli Saarikivi, and 8 others. 2024. Phi-4 technical report. ArXiv preprint: arXiv 2412.08905.
Lisa Adams, Felix Busch, Tianyu Han, Jean-Baptiste Excoffier, Matthieu Ortala, Alexander Löser, Hugo JWL Aerts, Jakob Nikolas Kather, Daniel Truhn, and Keno Bressem. 2025. Longhealth: A question answering benchmark with long clinical documents. Journal of Healthcare Informatics Research, 9:280–296.
Alexander Brinkmann, Roee Shraga, and Christian Bizer. 2024. Extractgpt: Exploring the potential of large language models for product attribute value extraction. In Information Integration and Web Intelligence: 26th International Conference, IiWAS 2024, Proceedings, Part I, pages 38–52. Springer-Verlag.
Tianle Cai, Yuhong Li, Zhengyang Geng, Hongwu Peng, Jason D. Lee, Deming Chen, and Tri Dao. 2024. Medusa: Simple llm inference acceleration framework with multiple decoding heads. In Proceedings of the 41st International Conference on Machine Learning, volume 235, pages 5209–5235.
Tri Dao. 2024. Flashattention-2: Faster attention with better parallelism and work partitioning. In The Twelfth International Conference on Learning Representations.
Juechu Dong, BOYUAN FENG, Driss Guessous, Yanbo Liang, and Horace He. 2025. Flexattention: A programming model for generating fused attention variants. In Proceedings of Machine Learning and Systems, volume 7.
Yichao Fu, Peter Bailis, Ion Stoica, and Hao Zhang. 2024. Break the sequential dependency of llm inference using lookahead decoding. In Proceedings of the 41st International Conference on Machine Learning, volume 235, pages 14060–14079.
Jordan Juravsky, Bradley Brown, Ryan Saul Ehrlich, Daniel Y Fu, Christopher Re, and Azalia Mirhoseini. 2024. Hydragen: High-throughput LLM inference with shared prefixes. In Workshop on Efficient Systems for Foundation Models II @ ICML.
Tomáš Kočiský, Jonathan Schwarz, Phil Blunsom, Chris Dyer, Karl Moritz Hermann, Gábor Melis, and Edward Grefenstette. 2018. The NarrativeQA reading comprehension challenge. Transactions of the Association for Computational Linguistics, 6:317–328.
Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. 2023. Efficient memory management for large language model serving with pagedattention. In Proceedings of the ACM SIGOPS 29th Symposium on Operating Systems Principles, pages 611–626.
Guokun Lai, Qizhe Xie, Hanxiao Liu, Yiming Yang, and Eduard Hovy. 2017. RACE: Large-scale ReAding comprehension dataset from examinations. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 785–794. Association for Computational Linguistics.
Yaniv Leviathan, Matan Kalman, and Yossi Matias. 2023. Fast inference from transformers via speculative decoding. In Proceedings of the 40th International Conference on Machine Learning, volume 202, pages 19274–19286.
Percy Liang, Rishi Bommasani, Tony Lee, Dimitris Tsipras, Dilara Soylu, Michihiro Yasunaga, Yian Zhang, Deepak Narayanan, Yuhuai Wu, Ananya Kumar, Benjamin Newman, Binhang Yuan, Bobby Yan, Ce Zhang, Christian Alexander Cosgrove, Christopher D Manning, Christopher Re, Diana Acosta-Navas, Drew Arad Hudson, and 31 others. 2023. Holistic evaluation of language models. Transactions on Machine Learning Research.
Mingdao Liu, Aohan Zeng, Bowen Wang, Peng Zhang, Jie Tang, and Yuxiao Dong. 2024. Apar: Llms can do auto-parallel auto-regressive decoding. ArXiv preprint: arXiv 2401.06761.
Souvik Mandal, Nayancy Gupta, Ashish Talewar, Paras Ahuja, Prathamesh Juvatkar, and Gourinath Banda. 2025. Idpleaderboard: A unified leaderboard for intelligent document processing tasks. https://idpleaderboard.org.
Xuefei Ning, Zinan Lin, Zixuan Zhou, Zifu Wang, Huazhong Yang, and Yu Wang. 2024. Skeleton-of-thought: Prompting LLMs for efficient parallel generation. In The Twelfth International Conference on Learning Representations.
Team OLMo, Pete Walsh, Luca Soldaini, Dirk Groeneveld, Kyle Lo, Shane Arora, Akshita Bhagia, Yuling Gu, Shengyi Huang, Matt Jordan, Nathan Lambert, Dustin Schwenk, Oyvind Tafjord, Taira Anderson, David Atkinson, Faeze Brahman, Christopher Clark, Pradeep Dasigi, Nouha Dziri, and 24 others. 2025. 2 olmo 2 furious. ArXiv preprint: arXiv 2501.00656.
Rui Pan, Zhuang Wang, Zhen Jia, Can Karakus, Luca Zancato, Tri Dao, Yida Wang, and Ravi Netravali. 2025a. Marconi: Prefix caching for the era of hybrid llms. In Proceedings of Machine Learning and Systems, volume 7.
Zaifeng Pan, Yitong Ding, Yue Guan, Zheng Wang, Zhongkai Yu, Xulong Tang, Yida Wang, and Yufei Ding. 2025b. Fasttree: Optimizing attention kernel and runtime for tree-structured llm inference. In Proceedings of Machine Learning and Systems, volume 7.
Pranav Rajpurkar, Robin Jia, and Percy Liang. 2018. Know what you don't know: Unanswerable questions for SQuAD. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pages 784–789. Association for Computational Linguistics.
Pol G. Recasens, Ferran Agulló, Yue Zhu, Chen Wang, Eun Kyung Lee, Olivier Tardieu, Jordi Torres, and Josep Ll. Berral. 2025. Mind the memory gap: Unveiling gpu bottlenecks in large-batch llm inference. In 2025 IEEE 18th International Conference on Cloud Computing (CLOUD), pages 277–287.
Zhibin Wang, Rui Ning, Chao Fang, Zhonghui Zhang, Xi Lin, Shaobo Ma, Mo Zhou, Xue Li, Zhongfeng Wang, Chengying Huan, Rong Gu, Kun Yang, Guihai Chen, Sheng Zhong, and Chen Tian. 2025. Flashforge: Ultra-efficient prefix-aware attention for llm decoding. ArXiv preprint: arXiv 2505.17694.
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, and 3 others. 2020. Huggingface's transformers: State-of-the-art natural language processing. ArXiv preprint: arXiv 1910.03771.
An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, Chujie Zheng, Dayiheng Liu, Fan Zhou, Fei Huang, Feng Hu, Hao Ge, Haoran Wei, Huan Lin, Jialong Tang, and 41 others. 2025. Qwen3 technical report. ArXiv preprint: arXiv 2505.09388.
Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. 2018. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 2369–2380. Association for Computational Linguistics.
Jinwei Yao, Kaiqi Chen, Kexun Zhang, Jiaxuan You, Binhang Yuan, Zeke Wang, and Tao Lin. 2025. DeFT: Decoding with flash tree-attention for efficient tree-structured LLM inference. In The Thirteenth International Conference on Learning Representations.
Lu Ye, Ze Tao, Yong Huang, and Yang Li. 2024a. ChunkAttention: Efficient self-attention with prefix-aware KV cache and two-phase partition. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 11608–11620. Association for Computational Linguistics.
Zihao Ye, Ruihang Lai, Bo-Ru Lu, Chien-Yu Lin, Size Zheng, Lequn Chen, Tianqi Chen, and Luis Ceze. 2024b. Cascade inference: Memory bandwidth efficient shared prefix batch decoding.
Zihao Yi, Jiarui Ouyang, Zhe Xu, Yuwen Liu, Tianhao Liao, Haohao Luo, and Ying Shen. 2025. A survey on recent advances in llm-based multi-turn dialogue systems. ACM Computing Surveys, 58.
Murong Yue. 2025. A survey of large language model agents for question answering. ArXiv preprint: arXiv 2503.19213.
Yang Zhang, Hanlei Jin, Dan Meng, Jun Wang, and Jinghua Tan. 2026. A comprehensive survey on process-oriented automatic text summarization with exploration of llm-based methods. Neurocomputing, 663:131928.
Appendix
A Method Details
A.1 Position IDs and Attention Mask
In the stacked sequence , each token has an absolute position determined by its literal index in the concatenated prompt. As answers are appended sequentially, absolute positions grow continuously across all contexts and questions. Formally, the absolute position of the -th token of the -th question under context is
where is the length of the instruction plus all context and question headers, is the fixed ordering of question pairs in the prompt, and is the token length of the generated answer for question . This absolute index reflects the physical layout of the stacked sequence.
In contrast, our method introduces a virtual position , which maps tokens back to positions that are local to their own instruction, context, and question triplet. For a generated token , the virtual position is
Header tokens are similarly assigned virtual positions aligned with their logical block boundaries. By mapping absolute indices into logically local virtual positions, we ensure that attention remains causal within each sequence, even if two sequences are physically distant in s. In other words, preserves the illusion that each triplet is decoded autoregressively in isolation, while still allowing parallel execution within a single stacked prompt.
A.2 Computational Efficiency
We provide a deeper analysis of the FLOP and memory access trade-off of IPPD against prefix caching and PagedAttention (PC+PA). For this section, we assume that IPPD uses one context , with questions stacked in one prompt. We calculate how FLOPs and memory accesses scale with the length of , and , which we write as . We consider only one attention head of one attention layer, as the computation pattern for each head is the same. The FLOPs and bytes of memory accessed depend on the sequence length of the input and the hidden dimension of the query, key and value associated to each token. Since the hidden dimension is static, we focus on the sequence-length dependent dimension of and , which we denote as . Table 4 contains and for both methods during different stages of inference. The memory accesses required for each attention computation are linearly proportional to the dimensions of and , so we write that the bytes of memory accessed are , ignoring scaling constants for simplicity. Similarly, the FLOPs required for multiplication during attention are . The arithmetic intensity is defined as the ratio of FLOPs to memory accesses, which scales as
Low arithmetic intensity signifies that memory accesses are causing a performance bottleneck, which Recasens et al. show is often the case with LLM inference. The following two sections compare the approximated FLOPs and memory accesses of PC+PA and IPPD for both prefill and decode. For a context and an inference step , we consider the total FLOPs and memory accesses for computing attention for one output token of every question, .
A.2.1 Prefill
The first prefill with PC+PA for the prompt answering requires , as the prefix cache has not yet been computed. In subsequent prefills, we only require since the instruction and context are in the prefix cache. The most significant FLOP cost is during the first prefill, which scales as . attention operations are required to prefill all questions, each requiring the full and . Therefore, the memory accesses scale as . For IPPD, the FLOP cost scales as , since the prompt contains all questions. Under our operation-level model, memory traffic scales as because the questions are processed through a shared attention operation. Writing , the tradeoff obtained by IPPD is a reduction in memory accesses by a factor of , in exchange for an increase in FLOPs by a factor of
There are two scenarios where this is advantageous:
-
When , and , the relative increase in FLOPs is minor compared to the reduction in memory accesses.
-
Since arithmetic intensity (FLOPs / mem. access ratio) scales as , shorter , , and result in lower arithmetic intensity. This scenario is more memory bottlenecked, so it benefits more from the reduction in memory accesses.
We observe in Table 1 that the RACE dataset matches both of these scenarios: the contexts are short, but the questions are even shorter. Figure 3 shows IPPD significantly outperforming PC+PA in this task. For the LongHealth dataset, the contexts are extremely large ( tokens on average), which increases arithmetic intensity linearly. This dataset is therefore more likely to be FLOP bottlenecked, and not benefit as much from IPPD. We observe in our results that PC+PA outperforms IPPD on this dataset. Both RACE and LongHealth require only one token per answer, so their performance characteristics are solely determined by the prefill stage.
A.2.2 Decode
During decode, PC+PA contains a single query, as tokens are generated autoregressively. However, that query must attend to all prior tokens, which requires a separate memory access to the keys and values of and , and partial output . Arithmetic intensity is very low as both the FLOPs and memory accesses scale linearly with the sequence length. With IPPD, the first decode step has queries. Writing , FLOPs per token are increased by a factor of
By exposing reuse of and within a shared attention operation that generates tokens, IPPD reduces repeated memory traffic to the shared context. In subsequent decoding steps, some of the answers may complete generation, reducing the parallelism in future steps. We write in Table 4 to denote this effect.
To conclude, the decode stage is characterized by a much lower arithmetic intensity than the pre-fill stage, resulting in a severe memory access bottleneck. Unlike prefill, the decode stage benefits from IPPD's memory access reduction even for extremely large and . We see in Figure 3 that IPPD performs better than PC+PA for both datasets involving multi-token answers, which range from very short and in SQuAD 2.0 to very large and with 5-shot NarrativeQA.
A.2.3 Comparison to Cascade Inference
Cascade inference (Ye et al., 2024b) fulfills a similar objective as IPPD: to reduce the number of memory accesses to the common contexts, thereby increasing arithmetic intensity. The way this is achieved is very different from IPPD: Cascade inference computes separate attention scores for keys that are part of the common prefix and those unique to a prompt. This allows queries from different prompts to attend to the common prefix keys in a shared operation, exposing reuse and reducing repeated memory traffic to those keys. Cascade inference also introduces more FLOPs, because a merge operator is required to combine the prefix attention scores with the unique suffixes for each prompt. For settings where the common prefix is much larger than the questions, IPPD's FLOPs increase is minimal, as shown in Section A.2.1. In settings with long questions or generations relative to the context, the segmentation of attention by Cascade inference would be preferable. The real-world CCQA datasets used in this work more closely match the composition preferred by IPPD as evidenced in Table 1, while general few-shot prompting is likely to contain longer suffixes and generations. Direct comparison with Cascade inference and other tree-based decoding methods mentioned in Section 2 is infeasible due to the lack of a general implementation compatible with the model families and inference platforms studied in this work, which are representative of real-world applications.
B Additional Experimental Details
B.1 Evaluation Metric
We evaluate candidate decoding strategies by benchmarking them against standard batched in-
| Method | Prefill | Decode | |
|---|---|---|---|
| First | Subsequent | ||
| PC+PA | Frequency | Once per | 1$+|y_{Once per |
| IPPD | Frequency | Once per | $+ \sum_{k'=1}^{M_j} ((|x_{j,k'}| + |y_{Once per set $\{y_{ |
Table 4: Summary of the matrix dimensions for queries and keys/values and for a single attention head, using prefix caching + PagedAttention (PC+PA) and IPPD with one context per prompt. denotes the dimension that varies with sequence length, ignoring the hidden dimension. Prefill denotes the first forward pass of each prompt, with the First column representing the calculation of the prefix cache. Subsequent prefills leverage this cache to avoid recomputations. The decode column represents the autoregressive decoding stage. The Frequency row indicates how often attention must be performed using these matrix dimensions. denotes the number of questions in context . The indicates that the value may decrease after multiple inference steps, as some answers complete generation before others. The table shows that IPPD's stacked prompts require larger dimensions but fewer attention calculations.
ference along two complementary dimensions: throughput (efficiency) and answer quality (fidelity to ground truth answers).
Throughput captures how many logical triplets can be processed per unit time per GPU, directly reflecting efficiency improvements. Concretely, let denote the number of answered triplets, the measured wall-clock latency to produce all answers, and the number of GPUs used. We define
Answer quality is measured at the task level using standard NLP evaluation metrics, including Accuracy, F1, and ROUGE-L. These metrics compare generated answers to ground truth answers across all triplets. We use standard definitions for these metrics from the literature.
B.2 Dataset Details
NarrativeQA (Kočiský et al., 2018) NarrativeQA is a reading comprehension benchmark containing books and movie scripts. We use the human-written summaries as document contexts. About 30 human-generated questions/answer pairs per document are provided. We report results on the test set using 5-shot prompting following the HELM benchmark (Liang et al., 2023).
SQuAD 2.0 (Rajpurkar et al., 2018) is an extractive reading comprehension task based on the
original Stanford Question Answering Dataset. It contains human generated questions about Wikipedia articles, where the answer is a span of the input text. SQuAD 2.0 adds an additional set of unanswerable questions to increase the difficulty of the task. We report results on the publicly available development set, prompting the LLM to write "null" for unanswerable questions.
RACE (Lai et al., 2017) RACE is an English reading comprehension dataset derived from Chinese middle and high school exams. Multiple-choice questions are provided for each text passage by human English instructors covering a variety of topics. We report results on the test set, prompting the LLM to respond with the answer letter.
LongHealth (Adams et al., 2025) LongHealth is a collection of detailed patient cases each containing multiple discharge notes. Although realistic in form, structure and content, the documents are entirely fictional, so the dataset contains no real patient information. It was written by experienced physicians. We report results on the entire dataset, using the Task 1 setting from Adams et al. (2025). We do not truncate documents, and modify their provided prompt to instruct the LLM to only respond with the answer letter.
B.3 Inference Details
General Details We run all primary experiments on the Amazon EC2 g6e.8xlarge server using one Nvidia L40S 48GB GPU. The profiling and controlled ablations were run on a Nvidia A100 40GB GPU, which slightly varies the exact throughput metrics but retains the same overall results. We use greedy decoding for all generations, and non-thinking mode for all hybrid models. We also set a maximum output token length for each dataset: 40 for NarrativeQA, 30 for SQuAD 2.0 and 1 for RACE and LongHealth. Phi4-14B, Qwen3-32B and OLMo-2-32B are quantized to NF4 using BitsAndBytes. Tokenization time is excluded from time measurements. The time required to calculate the attention mask for IPPD is included.
Standard batched inference We use the Hugging Face Transformers backend with the generate() method and FlashAttention. Prefix caching is not enabled as it is not supported for batched inference. We increase the batch size for each model-dataset pair until throughput saturates or VRAM limits are exceeded.
Prefix caching + PagedAttention We use the vLLM backend for optimized support of prefix caching and PagedAttention. Some vLLM features, such as the asynchronous V1 Engine, provide an inherent advantage over Transformers, irrespective of the inference acceleration methods used. To make a direct comparison between IPPD and prefix caching + PagedAttention, we adjust vLLM settings to exclude advantages that IPPD could also benefit from, were it also implemented on the same backend. We use the synchronous V0 Engine, enforcing eager mode as well as the use of the Transformers model implementation to match the one used by IPPD. We tune vLLM performance by providing access to all available VRAM, and setting the maximum model length to the longest prompt + output length for each dataset, so as to maximize the automatically managed batch size. FlashAttention is enabled.
IPPD Our method is implemented with Hugging Face Transformers and Accelerate. The model code for each LLM is unchanged, as all IPPD functionality is achieved through a custom inference loop. We implement prefix caching only for , the dataset-wide instruction. This affects NarrativeQA, where contains five few-shot examples. Prefix caching and IPPD are complementary in this setting: prefix caching avoids recomputing , while IPPD reduces repeated processing of the contexts and questions within each stacked prompt. For each model-dataset pair, we select the optimal number of shared contexts per prompt and batch size. In practice, we find that these hyperparameters are largely independent of model size. The optimal number of contexts per prompt is largely determined by the context length, number of questions, and hardware architecture. Table 5 shows the hyperparameters used for each method. We largely keep the same IPPD hyperparameters across model size as far as VRAM limits allow.
C Additional Experimental Results
C.1 Numerical Stability
IPPD follows the same idealized computational path as standard batched inference, so the remaining output variation is attributable to finite-precision arithmetic. Floating-point addition is not associative, and IPPD's stacked prompts differ in shape and size from a standard batch, which leads the GPU to select different tiling and reduction strategies when parallelizing the underlying matrix multiplications. Bitwise reproducibility is guaranteed only across runs with identically shaped inputs, a condition that batched inference and IPPD cannot satisfy simultaneously. These differences occasionally flip a greedy argmax and then propagate through the remainder of an answer, so longer generations accumulate more divergence. They introduce no systematic change in task-level quality.
C.2 Throughput Measurements
Table 6 presents absolute throughput scores, i.e., questions answered per second (QPS), for all benchmarks.
D Profiling and Controlled Ablations
D.1 Prefill and Decode Speedup
Purpose and methodology. We separately profile the prefill and decode phases to determine whether IPPD's end-to-end throughput gains arise in both phases of inference. For standard batched autoregressive inference and IPPD, we record the total number of prefill and decode steps and their cumulative wall-clock time. We exclude PC+PA from this phase-level comparison because its vLLM scheduler uses a different execution pattern, scheduling consecutive prefills and large decode batches backed by paged KV-cache entries.
| Model | NarrativeQA (5s) | SQuAD 2.0 | RACE | LongHealth | |||||
|---|---|---|---|---|---|---|---|---|---|
| B | C/P | B | C/P | B | C/P | B | C/P | ||
| Batched Inf. | Qwen3-32B | 8 | 1 | 30 | 1 | 5 | 1 | 1 | 1 |
| OLMo-2-32B | 8 | 1 | 30 | 1 | 5 | 1 | 1 | 1 | |
| Phi-4-14B | 8 | 1 | 30 | 1 | 5 | 1 | 1 | 1 | |
| Qwen3-8B | 20 | 1 | 30 | 1 | 5 | 1 | 1 | 1 | |
| Qwen3-4B-Instr. | 20 | 1 | 30 | 1 | 5 | 1 | 1 | 1 | |
| Qwen3-1.7B | 20 | 1 | 30 | 1 | 5 | 1 | 1 | 1 | |
| IPPD | Qwen3-32B | 2 | 3 | 5 | 6 | 2 | 2 | 1 | 1 |
| OLMo-2-32B | 2 | 3 | 5 | 6 | 2 | 2 | 1 | 1 | |
| Phi-4-14B | 3 | 4 | 6 | 6 | 2 | 2 | 1 | 1 | |
| Qwen3-8B | 3 | 4 | 6 | 6 | 2 | 2 | 1 | 1 | |
| Qwen3-4B-Instr. | 3 | 4 | 6 | 6 | 2 | 2 | 1 | 1 | |
| Qwen3-1.7B | 3 | 4 | 6 | 6 | 2 | 2 | 1 | 1 | |
Table 5: Hyperparameter selection for batch size B and contexts stacked per prompt C/P for IPPD and standard batched inference. Hyperparameters are mostly constant across model sizes, except when VRAM limits require a lower batch size.
| Model | NarrativeQA (5s) | LongHealth | SQuAD 2.0 | RACE | |
|---|---|---|---|---|---|
| QPS | QPS | QPS | QPS | ||
| Qwen3-32B | Batched Inference | 0.48 | 0.18 | 2.86 | 4.52 |
| PC + PA | 7.06 | 2.82 | 11.90 | 5.84 | |
| IPPD | 10.74 | 1.93 | 15.74 | 11.78 | |
| OLMo-2-32B | Batched Inference | 0.54 | - | 3.47 | 4.75 |
| PC + PA | 7.15 | - | 12.54 | 6.15 | |
| IPPD | 14.53 | - | 19.43 | 12.91 | |
| Phi4-14B | Batched Inference | 0.91 | 0.44 | 5.36 | 10.84 |
| PC + PA | 14.42 | 7.02 | 27.11 | 13.90 | |
| IPPD | 26.13 | 5.05 | 38.55 | 28.55 | |
| Qwen3-8B | Batched Inference | 1.75 | 0.71 | 14.25 | 21.18 |
| PC + PA | 26.39 | 11.43 | 50.10 | 25.17 | |
| IPPD | 57.77 | 6.95 | 62.04 | 52.12 | |
| Qwen3-4B-Instr. | Batched Inference | 1.90 | 1.02 | 18.01 | 34.72 |
| PC + PA | 37.84 | 16.00 | 79.68 | 40.11 | |
| IPPD | 54.48 | 8.92 | 82.88 | 82.98 | |
| Qwen3-1.7B | Batched Inference | 4.54 | 2.40 | 35.36 | 77.74 |
| PC + PA | 78.20 | 33.33 | 172.07 | 94.88 | |
| IPPD | 105.91 | 20.34 | 145.02 | 169.79 | |
Table 6: Throughput comparison of all models on four selected CCQA datasets. We compare batched inference, prefix caching + PagedAttention (PC + PA), and our proposed IPPD. We use queries per second (QPS) as the measurement. The highest score for each setting is in bold.
This makes their separate timings difficult to compare directly with the Transformers backend. Table 7 reports the ratio between the autoregressive and IPPD measurements, such that values above 1× indicate a reduction from IPPD. We use the original, unmodified datasets and otherwise follow the general setup in Section B.3, maximizing the batch size for each setting subject to the available VRAM.
Results. IPPD accelerates both prefill and decode relative to standard batched autoregressive inference. During prefill, IPPD reduces the number of forward passes by jointly processing questions that share a context and by stacking multiple contexts in a prompt. Although each IPPD prefill step processes a larger sequence and therefore requires more FLOPs than a corresponding batched-inference step, the reduction in step count yields a substantial reduction in total prefill time. In most settings, the time reduction is smaller than the step reduction because prefill already has relatively high arithmetic intensity, making its additional FLOPs more consequential. The decode-step reduction is smaller because the number of steps is determined by the longest active answer in each batch. Nevertheless, decode-time reductions mostly track the corresponding step reductions. Thus, the additional FLOPs per IPPD decode step do not substantially increase its latency, consistent with decode being
| Model | Dataset | Prefill steps | Prefill time | Decode steps | Decode time |
|---|---|---|---|---|---|
| Qwen3-32B | NarrativeQA (5s) | ||||
| SQuAD 2.0 | |||||
| RACE | – | – | |||
| LongHealth | – | – | |||
| OLMo-2-32B | NarrativeQA (5s) | ||||
| SQuAD 2.0 | |||||
| RACE | – | – | |||
| LongHealth | – | – | – | – | |
| Phi-4-14B | NarrativeQA (5s) | ||||
| SQuAD 2.0 | |||||
| RACE | – | – | |||
| LongHealth | – | – | |||
| Qwen3-8B | NarrativeQA (5s) | ||||
| SQuAD 2.0 | |||||
| RACE | – | – | |||
| LongHealth | – | – | |||
| Qwen3-4B-Instr. | NarrativeQA (5s) | ||||
| SQuAD 2.0 | |||||
| RACE | – | – | |||
| LongHealth | – | – | |||
| Qwen3-1.7B | NarrativeQA (5s) | ||||
| SQuAD 2.0 | |||||
| RACE | – | – | |||
| LongHealth | – | – |
Table 7: Prefill and decode step and time reductions from IPPD relative to batched autoregressive inference. Values are multiplicative speedups (higher is better). Dashes denote datasets with single-token outputs or configurations that exceed the model's maximum sequence length.
primarily memory-bandwidth bound as analyzed in Section A.2.
D.2 Controlled Ablations
Controlled-ablation design. For the following two ablations, we perturb real benchmark examples rather than construct fully synthetic prompts. In practice, throughput depends on the joint distribution of instruction, context, question, and answer lengths, which varies across examples and datasets. A synthetic sweep that varies one length while holding the others fixed would not capture these interactions and may not represent realistic workloads. Our controlled variants therefore modify one axis of the original datasets while retaining their remaining content and natural length variation.
D.2.1 Question Count Ablation
Purpose and methodology. This ablation measures how IPPD scales with the amount of parallelism available among questions that share a context. For each dataset, we construct variants containing exactly 1, 2, 4, 8, 16, or 32 questions per context. For a target count , we retain the first question–answer pairs when a context contains at least pairs. When it contains fewer than , we cycle through its existing pairs until the tar-
get count is reached, duplicating the corresponding answers and options and numbering repeated query strings so that they remain distinct inputs. The context and other prompt components remain fixed. We evaluate IPPD and PC+PA on each variant and report throughput relative to standard batched autoregressive inference in Table 8. All other settings follow Section B.3.
Results. The speedup from IPPD depends strongly on the number of questions sharing a context. With one question per context, shared-context parallelism is absent, and IPPD provides little or no benefit beyond that obtained by stacking distinct contexts in one prompt. Its speedup then grows rapidly with the question count and is generally largest at 32 questions per context. PC+PA provides a substantial initial gain at one question per context, but scales more slowly as additional questions are added. Consequently, IPPD overtakes PC+PA in an increasing number of model–dataset settings. LongHealth is the main exception. Its contexts are extremely long and its answers contain only one token, leaving no iterative decode phase. PC+PA is therefore consistently faster than IPPD by a broadly similar factor as the question count increases. We attribute much of this difference to the efficient FlashAttention kernels used by
| Model | 1 | 2 | 4 | 8 | 16 | 32 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PC+PA | IPPD | PC+PA | IPPD | PC+PA | IPPD | PC+PA | IPPD | PC+PA | IPPD | PC+PA | IPPD | |
| NarrativeQA (5s) | ||||||||||||
| Qwen3-32B | ||||||||||||
| OLMo-2-32B | - | - | - | - | - | - | - | - | - | - | - | - |
| Phi-4-14B | ||||||||||||
| Qwen3-8B | ||||||||||||
| Qwen3-4B-Instr. | ||||||||||||
| Qwen3-1.7B | ||||||||||||
| SQuAD 2.0 | ||||||||||||
| Qwen3-32B | ||||||||||||
| OLMo-2-32B | ||||||||||||
| Phi-4-14B | ||||||||||||
| Qwen3-8B | ||||||||||||
| Qwen3-4B-Instr. | ||||||||||||
| Qwen3-1.7B | ||||||||||||
| RACE | ||||||||||||
| Qwen3-32B | ||||||||||||
| OLMo-2-32B | ||||||||||||
| Phi-4-14B | ||||||||||||
| Qwen3-8B | ||||||||||||
| Qwen3-4B-Instr. | ||||||||||||
| Qwen3-1.7B | ||||||||||||
| LongHealth | ||||||||||||
| Qwen3-32B | ||||||||||||
| OLMo-2-32B | - | - | - | - | - | - | - | - | - | - | - | - |
| Phi-4-14B | ||||||||||||
| Qwen3-8B | ||||||||||||
| Qwen3-4B-Instr. | ||||||||||||
| Qwen3-1.7B | ||||||||||||
| Total wins | 22 | 0 | 17 | 5 | 16 | 6 | 11 | 11 | 6 | 16 | 6 | 16 |
Table 8: Questions-per-context ablation across datasets and models. Values are throughput speedups relative to batched autoregressive inference (higher is better). The better method for each model and column is in bold, and dashes denote configurations that exceed the model's maximum sequence length.
the PC+PA backend, whereas IPPD uses standard scaled dot-product attention (SDPA) to support its custom attention mask.
D.2.2 Context Length Ablation
Purpose and methodology. This ablation evaluates how increasing the shared-context length affects the relative throughput of IPPD and PC+PA. We exclude LongHealth due to its existing long context. For the remaining three datasets, we retain each example's questions and construct nested context variants by concatenating contexts sampled from other randomly drawn examples, producing context-length factors of , , , and on average. We rerun all three inference methods for each variant and report speedup relative to standard batched autoregressive inference in Table 9. The remaining setup follows Section B.3.
Results. Increasing context length generally reduces IPPD's speedup relative to autoregressive inference, although the trend is not monotonic for every model. As the context grows, a larger fraction of inference time is spent in the FLOP-intensive prefill phase, reducing the relative benefit of IPPD's memory-access savings. Even at context length, however, IPPD retains substantial speedups on NarrativeQA, SQuAD 2.0, and RACE. It outperforms PC+PA in 12 of the 16 supported model-dataset comparisons at this context length, demonstrating that its benefit persists well beyond the original context-length distribution.
| Model | Context length | |||||||
|---|---|---|---|---|---|---|---|---|
| 1× | 2× | 4× | 8× | |||||
| PC+PA | IPPD | PC+PA | IPPD | PC+PA | IPPD | PC+PA | IPPD | |
| NarrativeQA (5s) | ||||||||
| Qwen3-32B | ||||||||
| OLMo-2-32B | - | - | - | - | - | - | ||
| Phi-4-14B | - | - | - | - | ||||
| Qwen3-8B | ||||||||
| Qwen3-4B-Instr. | ||||||||
| Qwen3-1.7B | ||||||||
| SQuAD 2.0 | ||||||||
| Qwen3-32B | ||||||||
| OLMo-2-32B | ||||||||
| Phi-4-14B | ||||||||
| Qwen3-8B | ||||||||
| Qwen3-4B-Instr. | ||||||||
| Qwen3-1.7B | ||||||||
| RACE | ||||||||
| Qwen3-32B | ||||||||
| OLMo-2-32B | ||||||||
| Phi-4-14B | ||||||||
| Qwen3-8B | ||||||||
| Qwen3-4B-Instr. | ||||||||
| Qwen3-1.7B | ||||||||
| Total wins | 2 | 16 | 5 | 12 | 3 | 13 | 4 | 12 |
Table 9: Context-length ablation across datasets and models. Values are throughput speedups relative to batched autoregressive inference (higher is better). The better method for each model and column is in bold, and dashes denote configurations that exceed the model's maximum sequence length.