Source-linked AI summary

Accelerating Cross-Model LLM Inference via Attention Map Reuse

Zhan Jin, Yuze Luo, Bin Cui, Xupeng Miao

arXiv:2610.14688v1cs.LG

TL;DR

Prefix-heavy LLM data workflows repeatedly process shared context across heterogeneous models, while conventional prefix caching is largely limited to identical models. MapFlow reuses attention maps with translation, partial recomputation, sparse compression, and fused retrieval. It reduces TTFT and improves throughput while maintaining generation quality in the evaluated heterogeneous and multi-turn workloads.

  • Problem

    Prefix-heavy data workflows repeatedly process shared context across heterogeneous models, while existing prefix caching is largely restricted to identical models.

    Source: §1 · p. 2
  • Method

    MapFlow transfers attention maps across models, using lightweight linear translation, partial recomputation, block-level sparse compression, and fused retrieval.

    Source: §1 · p. 2
  • Results

    MapFlow reduces TTFT by 15%–20% and increases end-to-end throughput by up to 25% while maintaining generation quality across heterogeneous model pairs and multi-turn workloads.

    Source: §10 · p. 23
  • Takeaways & Limitations

    Attention maps are a promising reusable state for heterogeneous prefix reuse in LLM-augmented data workflows.

    Source: §9 · p. 23

    MapFlow is currently most effective when sender and receiver share a tokenizer and process the same canonicalized context; mismatched tokenizers, canonicalization, or more divergent architectures remain challenges.

    Source: §9 · p. 22

Abstract

from arXiv · show

LLM-augmented data workflows often involve multiple heterogeneous models operating over substantial shared context, such as schemas, tool specifications, interaction history, and intermediate results. Although prefix caching can reduce prefilling overhead, existing approaches are largely limited to reuse within the same model because KV states are tightly coupled to model-specific architectures. We present MapFlow, a system for efficient heterogeneous LLM serving via cross-model attention map reuse. Instead of reusing KV states, MapFlow reuses attention maps, which capture token dependency patterns and are more transferable across models. To enable efficient and accurate reuse, we combine partial recomputation with lightweight linear translation across layers and heads. To make attention reuse practical for long contexts, we further introduce block-level sparse compression and a fused retrieval kernel. Experiments show that MapFlow reduces prefilling latency and improves end-to-end serving efficiency while preserving generation quality across heterogeneous model pairs and multi-turn routing workloads. These results suggest that attention maps provide an effective reusable state for heterogeneous LLM serving, especially in prefix-heavy data workflows. Our code is available: https://github.com/PKU-DAIR/MapFlow.

1 Introduction

Prefix-heavy data workflows repeatedly process shared context across heterogeneous models, where existing KV caching is largely restricted to identical models. MapFlow reuses attention maps across models and combines translation, partial recomputation, and sparse retrieval to reduce serving latency.

1 Introduction

  • Shared structured contexts recur across turns and operators, making redundant prefix processing a major bottleneck for interactive latency and throughput.Examples include schemas, system constraints, tool specifications, interaction history, and intermediate results.Source: §1 · p. 2
  • Existing prefix caching is largely limited to identical models because KV tensors are coupled to model-specific representations, dimensions, structures, and parameters.Translating KV states across heterogeneous architectures risks accuracy loss or adaptation overhead.Source: §1 · p. 2
  • MapFlow reuses attention maps because token-dependency patterns can be more structurally similar across models than KV tensors, then applies lightweight linear translation and partial recomputation.The stated setting assumes models share a tokenizer and process the same context.Source: §1 · p. 2
  • Block-level top-p compression and a fused retrieval kernel address attention maps’ quadratic size and avoid materializing dense receiver-side intermediates.Prefix-hash indexing and overlapping retrieval with partial recomputation support online reuse.Source: §1 · pp. 2–3
  • MapFlow reduces TTFT by 15%–20% and improves end-to-end throughput by up to 25% while maintaining generation quality across heterogeneous models and multi-turn workloads.Benefits are especially pronounced in long-context, multi-turn settings.Source: §1 · p. 3

2 Background

This section introduces Transformer attention and inference phases, then reviews prefix caching, multi-LLM routing, sparse attention, and cross-model communication. Together, these topics frame the challenge of reusing shared context across heterogeneous models.

2 Background

  • Decoder-only Transformer models provide the architectural context for attention-based LLM inference [63].A standard block has multi-head attention and a feed-forward network.Source: §2.1 · p. 3

2.1 Transformer and Multi-Head Attention

  • Each attention head projects embeddings into queries, keys, and values; scaled dot-product attention weights values before head outputs are concatenated and projected.The attention map encodes token-to-token weights.Source: §2.1 · pp. 3–4

2.2 Inference Phases: Prefill and Decode

  • Prefill processes the prompt in parallel and produces the first token, whereas decode generates subsequent tokens autoregressively, one at a time.Prefill latency is TTFT; decode is typically memory-bound.Source: §2.2 · p. 4

2.3 Prefix Caching

  • Prefix caching retrieves stored KV tensors to bypass redundant computation for shared prefixes, but traditionally requires identical model architectures and weights [33] [84].Source: §2.3 · p. 4

2.4 Multi-LLM Systems

  • Multi-LLM routers assign queries to models suited to their complexity, so identical prompt prefixes may be processed by different models [7] [10].Source: §2.4 · p. 4

2.5 Sparse Attention

  • Attention is sparse in practice, with |S| ≪ k enabling near-linear storage with minimal precision loss; MapFlow targets prefill acceleration through sparse attention-map reuse [71] [78].Other methods accelerate prefill by finding sparse patterns or focus on decode after full prefill [28] [34] [42] [52].Source: §2.5 · pp. 4–5

2.6 Cross-model Communication

  • Cross-model communication approaches send raw text or reuse KV states through partial recomputation or learned adaptation [73] [16] [75] [32] [13].Raw-text transfer requires full receiver prefill; some learned approaches still require both models to compute KV caches.Source: §2.6 · pp. 5–6

3 Motivation

MapFlow addresses the difficulty of reusing model-specific KV states across heterogeneous architectures by reusing attention maps instead. Because transferability varies by layer and model pair, it combines calibrated linear mapping with partial recomputation.

3.1 Terminology

  • Table 1 collects the mathematical notation used throughout the paper.The section introduces the notation before discussing cross-model reuse.Source: §3.1 · p. 6, Table 1 · p. 6

3.2 Challenges in Cross-Model Reuse

  • Heterogeneous layer and head dimensions defeat homogeneous reuse designs, while learned KV adapters can erase latency gains and KV dependence on model weights and dimensions makes accurate translation difficult.KV distributions can differ even between models fine-tuned from the same checkpoint.Source: §3.2 · p. 6

3.3 Attention Maps as Reuse States

  • Attention maps capture token dependencies and may be more structurally similar across models sharing a tokenizer and context than model-specific KV states.The proposed reusable state is the attention map rather than KV tensors.Source: §3.3 · p. 6
  • Transferability depends on the model pair and layer mapping, so MapFlow calibrates and validates it offline rather than assuming it holds universally.An appropriate mapping can linearly approximate receiver-layer attention from corresponding sender-layer maps.Source: §3.3 · p. 7
  • Simplex-constrained weights form a nonnegative, normalized convex mixture of sender heads, enabling lightweight linear mapping that can be fused with sparse retrieval and value aggregation.Calibration fits weights on a small set to diagnose transferability and guide layer selection; deployed weights are optimized using receiver end-to-end response loss.Source: §3.3 · pp. 7–8
  • Early receiver layers fit poorly, so MapFlow recomputes them and reuses later layers; increasing recomputation from 3 to 15 raised TTFT from 0.3205s to 0.3556s without ROUGE-L improvement.The system profiles layer-wise TV distance offline to select the recomputation boundary and uses suffix alignment for layer mapping.Source: §3.3 · p. 8

4 Data Flow in MapFlow

MapFlow’s data flow combines receiver-side partial recomputation with layer and head mapping to reuse sender attention maps. Sparse compression makes the maps more practical to store and reuse for long sequences.

4 Data Flow in MapFlow

  • MapFlow accelerates prefill through attention reuse, organizing its data flow around partial recomputation, layer mapping, and head mapping.These are the system’s three core components.Source: §4 · p. 8
  • The receiver computes its first r layers normally, then skips heavy attention computation and reuses cached sender attention maps for subsequent layers.The first r layers provide accurate receiver hidden states.Source: §4 · p. 8
  • Layer mapping selects a sender layer for each reused receiver layer, while linear head mapping computes each receiver head from sender attention maps.The formal description identifies learned linear transformation weights for head mapping.Source: §4 · p. 8
  • Top-p compression stores attention maps in Block Sparse Row format to address their O(N^2) storage cost.The retained blocks reduce dependence on sequence length from quadratic to near-linear in the reuse path when the average retained positions k are much smaller than L.Source: §4 · p. 9

5 MapFlow System Design

MapFlow’s runtime addresses attention-map storage and retrieval costs through compression, cache management, and a fused retrieval kernel. It also calibrates head mappings for each sender–receiver pair while keeping the language models frozen.

5 MapFlow System Design

  • MapFlow addresses quadratic attention-map storage and costly receiver-side reconstruction through block-wise compression, prefix-hash cache management, and fused retrieval.The fused GPU kernel combines receiver attention reconstruction with value-vector multiplication without intermediate dense materialization.Source: §5 · p. 10

5.1 Offline Calibration and Training

  • For each sender–receiver pair, MapFlow trains only head-mapping weights while freezing both LLMs, optimizing them with receiver end-to-end response loss.For Ministral3-8B→Ministral3-3B on Conversation, weights account for less than 0.001% of receiver parameters and converge within two 20-hour epochs on two A800 80GB GPUs.Source: §5.1 · pp. 10–11

5.2 Attention State Compressor

  • The compressor applies block-level top-p sparsity and stores retained attention blocks in BSR format, avoiding full dense materialization and reducing memory footprint and transmission payload.Compression runs once after the sender produces the map and does not block its critical path; the compressed map can serve multiple receivers.Source: §5.2 · pp. 11–12

5.3 Block Manager

  • Because retained attention blocks have dynamic shapes across sequence positions and layers, the Block Manager uses block-wise indexing and prefix hashes to retrieve cached blocks during receiver partial recomputation.The cache server maps each prefix hash to block indices across sender layers and streams hit blocks to the receiver GPU.Source: §5.3 · p. 12

5.4 Attention Retrieval with Fused Kernel

  • A fused GPU kernel reconstructs receiver attention from sparse sender maps and mapping weights, then applies it to receiver values without materializing a dense attention matrix in global memory.Fusion keeps intermediate attention scores on-chip and eliminates the need to instantiate receiver attention in HBM.Source: §5.4 · pp. 13–14

6 Implementation

The implementation integrates MapFlow’s sender, receiver, and cache server with vLLM and uses a Triton fused retrieval kernel. It stores compressed maps in GPU memory and uses shared GPU resources for the cache server.

6 Implementation

  • The 5K-line Python server has sender, receiver, and cache-server modules; sender and receiver integrate with vLLM, and the fused retrieval kernel is written in Triton.The kernel supports PagedAttention, Chunked Prefill, and Variable Length Sequences Packing.Source: §6 · p. 14
  • A preallocated GPU buffer registered for IPC shares tensor data through negotiated offsets, amortizing handle creation and avoiding per-transfer CUDA API overhead.Modules signal tensor availability through lightweight metadata messages.Source: §6 · p. 14
  • The cache server reconstructs and compresses attention maps on the GPU once during caching, allowing multiple receiver instances to reuse them without recomputation or recompression.Source: §6 · p. 14
  • The evaluated implementation assumes co-located deployment, but the method can also transfer compressed block-sparse maps to a receiver in distributed settings for local fused retrieval.The co-location assumption is used to isolate the computational benefit of attention-map reuse.Source: §6 · pp. 14–15

7 Experiments

MapFlow improves prefill and multi-turn serving performance while preserving generation quality, with benefits across long-context and routed workloads. Its gains vary by task and model pair, and the evaluation compares it with full prefill, cross-model KV reuse, sparse prefill, and attention-map reuse baselines.

7.1 Setup

  • Evaluation uses Qwen3 and Ministral3 model pairs and compares MapFlow with full prefill, cross-model KV reuse, sparse prefill, and attention-map reuse baselines.DroidSpeak was not compared because its embedding transfers are infeasible for heterogeneous pairs with differing hidden dimensions.Source: §7.1 · p. 15

7.2 Prefill Latency–Generation Quality Trade-off

  • 15%–20% lower prefill delay than full prefill across four model pairs and three datasets, without compromising generation quality.Compared with FlexPrefill, MapFlow further reduces prefill delay by 7%–12% with better or equal generation quality; it outperforms IAM on latency and quality in most settings.Source: §7.2 · p. 15, Figure 7 · p. 16
  • Performance depends on model pair and task: Ministral3 pairs preserve quality more consistently than Qwen3 pairs, while QA is more sensitive to attention errors than conversation and summarization.The reported trends favor calibrating reuse per model pair and workload rather than enabling it universally.Source: §7.2 · p. 16

7.4 End-to-End Throughput Improvement on Multi-turn Conversation

  • Up to 25% higher throughput at the same P90 TTFT, with lower P90 TTFT across arrival rates and reduced tail latency for large-to-small routed turns.The TTFT distribution shifts left across evaluated model pairs, with the gap widening at the upper tail.Source: Figure 8 · p. 17, §7.4 · pp. 17–18

7.3 Long-Context Evaluation

  • On 20K RULER contexts, MapFlow achieves better F1 than FlexPrefill, IAM, and MInference for all four model pairs while maintaining competitive prefill latency.Latency speedups are less significant than on short datasets because the long-context setting uses larger top-p values.Source: §7.3 · pp. 16–17, Table 2 · p. 16

7.5 Sparsification Analysis

MapFlow’s block-level top-p sparsification keeps compressed-map memory stable at long context lengths, but quality loss depends on the threshold and model.

7.5.1 Memory Footprint.

  • MapFlow’s memory footprint initially increases with sequence length, then plateaus after 12k tokens; memory usage remains stable across all top-p settings in the 12k–24k-token range.Source: §7.5.1 · p. 18

7.5.2 Quality Loss.

  • Qwen3 1.7B quality falls from 0.286 to 0.092 as top-p drops from 0.85 to 0.8, so sparsification thresholds require per-model calibration.Quality degrades gracefully at top-p=0.9 for most tested models, but drops sharply below top-p=0.85 for several models.Source: §7.5.2 · p. 19, Table 4 · p. 19

7.6 Generalizability Evaluation

MapFlow’s transfer weights generalize across the tested datasets, its speedups grow with large-to-small transitions, and its three-model workflow case study shows measurable end-to-end gains.

7.6 Generalizability Evaluation

  • Transfer weights trained on HotpotQA retain similar generation quality when evaluated zero-shot on 2WikiMultihopQA, without retraining.The experiment suggests the weights capture model-pair-level attention correspondence rather than dataset-specific behavior.Source: §7.6 · p. 19

7.7 Case Study of Different Routing Thresholds

  • MapFlow delivers speedups across transition probabilities, with the most pronounced improvements at higher probabilities of large-to-small transitions.Higher transition probability increases the large-model-inherited TTFT while small-model-inherited TTFT stays relatively constant; more frequent large-model routing also raises baseline latency while improving generation quality.Source: Figure 10 · p. 20, §7.7 · p. 20

7.8 Single-Workflow Latency for Three Models

  • 0.48–0.73 seconds saved per round, with up to 5.4% end-to-end speedup in a three-model Ministral3 workflow.The workflow routes through 14B, 8B, and 3B models; because MapFlow accelerates prefill rather than decode, its benefit is bounded when decoding dominates latency.Source: Figure 11 · p. 21, §7.8 · p. 21

8 Related Work

Related work spans LLM-augmented data systems, multi-model serving, and KV-cache management; the paper frames shared-prefix reuse across heterogeneous models as an unmet serving need.

  • LLM-driven database workflows process redundant schemas, system constraints, and multi-turn instructions, motivating cross-model state reuse to reduce prefill costs.Source: §8 · p. 21
  • Routing, prefix caching, adapter serving, and heterogeneous model multiplexing address different parts of multi-model serving, but the surveyed frameworks remain unoptimized for shared prompts.Source: §8 · p. 22
  • KV-cache paging, prefix sharing, compression, and eviction improve cache management, yet these approaches remain tied to KV tensors and are orthogonal to MapFlow’s attention-map design.Source: §8 · p. 22

9 Limitations and Future Work

MapFlow is most effective when sender and receiver share a tokenizer and canonicalized context, while long-context, high-reuse workloads can still incur nontrivial attention-cache memory. These boundaries motivate broader alignment and compression designs without changing the conclusion that attention maps are a promising abstraction for heterogeneous prefix reuse.

Applicability beyond shared tokenization

  • Shared-tokenizer, canonicalized-context deployments are MapFlow's most effective setting; mismatched tokenizers, prompt canonicalization, or more divergent architectures remain broader challenges.The paper identifies token-level correspondence recovery and intermediate semantic anchoring as possible alignment strategies.Source: §9 · p. 22

Compact representations for reusable attention state

  • Reusable attention states can still occupy nontrivial memory in long-context, high-reuse workloads despite block-level Top-p compression.Proposed directions include quantized sparse or low-rank representations and sharing one sender-layer cache across semantically aligned receiver layers.Source: §9 · pp. 22–23

Overall conclusion

  • The stated limitations leave attention maps a promising systems abstraction for heterogeneous prefix reuse.They also point to a broader design space for reusable cross-model execution states.Source: §9 · p. 23

10 Conclusion

MapFlow addresses redundant prompt processing across heterogeneous models with shared semantic attention maps and lightweight serving mechanisms. Evaluations report reduced Time-to-First-Token and increased end-to-end throughput for multi-turn routing while maintaining generation quality.

Conclusion

  • 15% to 20% reduction in Time-to-First-Token and up to a 25% increase in end-to-end throughput for multi-turn routing, while maintaining generation quality.The conclusion attributes these results to MapFlow's evaluated system.Source: §10 · p. 23
  • MapFlow shares semantic attention maps across different LLMs to reuse prefixes and address redundant prompt processing in multi-LLM systems.The system combines a lightweight linear adapter, block-level Top-p sparse compression, and a custom fused kernel.Source: §10 · p. 23
  • MapFlow is presented as a scalable, memory-efficient solution for accelerating complex multi-model workflows.The conclusion frames this as the system's practical contribution.Source: §10 · p. 23
Loading 2610.14688v1…