LLM workloads sometimes ask many independent questions about the same long document, as in document QA, data labeling and LLM-based evaluation. Prefix caching removes the redundant prefill shared by these queries, but each decode step still reads the document's key-value (KV) cache once per question, so decoding is bound by memory bandwidth and scales with the number of questions. We present Parallel Prompting, which decodes P questions as P independent streams of a single request all at once, fixing this issue. In our method, every step reads the shared document once for all P streams, and a stream-id attention mask, evaluated inside the attention kernel, keeps each answer conditioned only on the document and its own question. We implement Parallel Prompting in SGLang by adding about 80 lines to three existing files and a small engine package; the mask needs no dense tensor, and every decode step has a fixed shape that is captured as a CUDA graph. With CodeLlama-7B, 8k-16k-token documents and 64-256 questions per document, Parallel Prompting is 3.7x faster than stock SGLang with its FlashInfer backend on an A100 and 5.9-6.0x faster on an RTX A6000, on two SGLang releases, including the most recent release. Timed on identical inputs, it is faster than stock SGLang in all 144 runs (2 GPUs x 2 releases x 6 workloads x 6 input sets). Code: https://github.com/jlab-nlp/parallel-prompting
Figures & tables
Figure 1: Three ways to answer several questions about one document, shown at one decode step (dark: the token generated in this step). A serving engine such as SGLang or vLLM runs a batch of requests , and every decode step adds one token to each request. Batched requests with prefix caching store the document’s KV once but use one request per question, so every step reads the document once per question. Batch prompting ( Cheng et al., 2023 ; Lin et al., 2024 ) puts all questions and answers in one sequence: it reads the document once, but the answers are generated one after another, and later answers attend to earlier ones. Parallel Prompting decodes the questions as streams of one request: every step adds one token per stream and reads the document once for all of them, and a stream mask ( Figure 2 ) keeps the answers independent. The batch still has room for other requests, for example for other documents ( Figure 6 ).
File
Change
Lines
extend_attention.py
stream-id mask in both kernel stages; small tile for decode steps
+50
triton_backend.py
pass q_sid , slot_sid to the kernel
+11
logits_processor.py
one logit row per stream ( logit_index )
+18
parallel_prompt/
new: layout, reference mask, engine
new
Table 1: Modifications based on SGLang v0.5.22. The three edited files gain 79 lines.
Figure 2: The in-kernel mask in one decode step: a request with a 3-token document, P=3 streams and 1-token questions, at decode step 2 ( aik is stream i ’s k -th answer token). Each KV slot carries its stream id slot_sid ( −1 for the document), and the streams share positions. The new token a12 of stream 1 attends only to the document and to stream 1’s slots. Stage 1 of the kernel reads the cached slots through kv_indices ; stage 2 reads the step’s new tokens.
Figure 3: Speedup of Parallel Prompting over stock SGLang on 8k/16k-token documents with 64–256 questions. Error bars are 95% bootstrap CIs over 36 paired runs per setting. PP wins all 144 runs.
Doc
Q
FI
Triton
PP ( P )
Speedup
8k
64
9.76
18.19
3.54 (16)
2.72 ×
8k
128
16.19
34.44
4.66 (32)
3.47 ×
8k
256
32.26
68.07
8.30 (32)
3.89 ×
16k
64
16.17
32.61
5.29 (16)
3.06 ×
16k
128
30.61
63.55
6.80 (32)
4.50 ×
16k
256
59.99
126.15
12.31 (32)
4.87 ×
Table 2: Wall time (s, mean of 6 seeds) on SGLang v0.4.2 with an A100-80GB, and PP’s speedup over the faster stock configuration. Wall time is the time to answer all Q questions about one document, which is already cached ( subsection 5.1 ). FI = FlashInfer; all configurations use CUDA graphs.
Figure 4: Left: speedup over the faster stock configuration as document length and questions per document grow (128 output tokens). Right: speedup as answers get longer (8k-token document, 128 questions).
Figure 5: Wall time versus streams per request P on the calibration seed, normalized to the best P (16k-token documents). The curve is U-shaped, with its minimum at P = 16–64 on every setting.
QuALITY
LooGLE
Config
Time
Acc
Time
Recall
Stock FlashInfer
133.2
76.13
403.6
83.41
Stock Triton
155.9
76.22
568.0
83.77
PP
73.6
75.89
508.3
83.61
Table 3: QuALITY and LooGLE on an A100-SXM4-80GB with Qwen2.5-7B-Instruct and SGLang v0.5.22, every configuration with the radix prefix cache. Time (s) is the wall time for the whole benchmark from an empty cache, including document prefill (mean of two passes, all rows on one GPU). LooGLE is scored by token recall; token F1 is 17.29, 17.41 and 17.36.
Uniform
Mixed
Config
Time
Steps
Time
Steps
PP
161.0
752
356.5
6,160
PP+CB
161.0
752
292.1
4,176
Speedup
1.00 ×
1.22 ×
Table 4: Continuous batching on QuALITY in the chat template (Qwen2.5-7B-Instruct, RTX A6000, P=4 , 512-token budget, mean of two passes). Uniform : every answer is the letter (2 tokens). Mixed : every other article asks for an explanation first (87 tokens on average, at most 169).
Model
Attn.
KV/tok
GPU
vs FI
vs Triton
Wins
Qwen2.5-1.5B
GQA
28 KB
A6000
1.28 ×
1.42 ×
12/24
Qwen2.5-7B
GQA
56 KB
A6000
1.32 ×
1.51 ×
24/24
Qwen2.5-14B
GQA
192 KB
A6000
1.87 ×
2.08 ×
24/24
Qwen2.5-32B †
GQA
256 KB
A100
1.26 ×
1.49 ×
12/12
CodeLlama-7B ‡
MHA
512 KB
A6000
5.91 ×
5.65 ×
36/36
CodeLlama-13B †
MHA
800 KB
A6000
3.54 ×
3.42 ×
12/12
Table 5: PP speedup across models on SGLang v0.5.22 (paired geometric mean over 6 seeds per workload, 128 output tokens). KV/token is the KV-cache size per token in bf16. Workloads are 8k and 16k-token documents with 64 and 256 questions, except where noted.
Method
Q/batch
Time (s)
Speedup
Mem (GiB)
F1
Standard
32(max)
1799
1.0 ×
53.6
33.99
PP
8
872
2.1 ×
16.9
33.96
PP
16
677
2.7 ×
19.8
33.98
PP
32
420
4.3 ×
24.7
34.05
PP
64
352
5.1 ×
33.1
33.87
PP
128
342
5.3 ×
54.1
33.92
Table 6: Peak GPU memory of the HuggingFace prototype on QuAC (Llama 3–8B, A100-80GB) as the maximum number of questions per batch, across documents, varies. Standard prompting asks one question per prompt, with batches as large as memory allows; its row comes from a separate run. Speedup is over standard prompting.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 6: Speedup of PP over the faster stock configuration as more documents share a batch (4k-token documents, 64 questions each, 128 output tokens). Sixteen documents do not fit in the A6000’s KV pool.
Config
EM
F1
Δ F1 [95% CI]
Time (s)
PP ( P=32 )
21.51
45.14
–
237.6
FlashInfer
21.50
45.25
−0.11 [ −.25 , .03 ]
406.5
Triton
21.55
45.18
−0.04 [ −.20 , .12 ]
409.2
Appendix
Table 7: SQuAD v1.1 dev (10,570 questions, 48 articles split into 71 chunks of at most 8k tokens) on SGLang v0.5.22 with CodeLlama-7B-Instruct on an RTX A6000. Answer time excludes document prefill for all configurations. Δ F1 is PP minus stock, with a paired bootstrap 95% CI over questions.
Questions
Method
512
1024
2048
8×128
Hydragen
2479
2161
1743
8×128
Ours
2528
1995
1355
Appendix
Table 8: Synthetic throughput (tokens/s) of the prototype and Hydragen, 8 documents, CodeLlama-7B-Instruct, A100-80GB.
Method
SQuAD
QuAC
DROP
Times(s)
Std
F1(%)
Time(s)
Std
F1(%)
Time(s)
Std
F1(%)
Standard
597
–
87.2
1937
–
34.0
647
–
58.1
SeqBatch
365
–
84.3
346 ∗
–
32.4 ∗
843
–
42.6
Hydragen
1651
20.9
87.1
1230
6.74
34.0
471
3.85
58.2
vLLM
373
0.46
87.4
897
0.57
32.8
417
0.44
58.5
Parallel
169
–
87.2
238 ∗
–
34.2 ∗
117
–
58.2
Appendix
Table 9: Comparison of generation time and performance for downstream tasks with different methods with Llama 3 8B model on A100-80G. Standard, SeqBatch and Parallel are rerun with the original scripts; Hydragen and vLLM[0.6.4] are from the original runs. subsection 5.2 compares against current SGLang. Std is the across-run standard deviation of the time where available. ∗ QuAC Parallel and SeqBatch score only the questions that fit in memory (5,951 and 2,899 of 7,354). F1 is computed as the harmonic mean of precision and recall in extractive QA.
Dataset
Method
Time(s)
Memory(GiB)
SQuAD
Standard
590
54.4
Parallel
168
47.5
QuAC
Standard
1799
53.6
Parallel
352
33.1
DROP
Standard
654
54.3
Parallel
111
36.1
Appendix
Table 10: Comparison of memory usage with different methods with Llama 3 8B model on A100-80G. These runs are a separate run set from Table 9 , so their times differ. Memory is in GiB; the SQuAD values were converted from 55,700 and 48,600 MiB.
Num_Questions
Batch Size
Throughput- 1.3B
Throughput-7B
128
1
4283
1931
2
4625
1843
4
3654
1468
8
2850
1018
256
1
5911
2115
2
6384
2250
Appendix
Table 11: Throughput (tokens/sec) under different batch sizes for parallel generation with Sheared-LLaMA-1.3B and CodeLlama-7B when doc_len=512 , q_len=12 , and ans_len=5 .
doc_len
Throughput(1.3B)(tokens/second)
Throughput(7B)(tokens/second)
256
9514
2751
512
8199
2430
1024
6592
1924
Appendix
Table 12: Comparing the throughput using parallel Batching with CodeLlama-7B and Sheared-LLaMA-1.3B with different lengths of doc length when q_len=12∥q_num=128∥ans_len=5 and the number of unique doc content equals 8. Throughput falls by about 30% for both models as the document length grows from 256 to 1024 tokens.