Let the Code LLM Edit Itself When You Edit the Code
On the map: Efficient LLM inference and serving → KV cache optimization
Abstract (arXiv)
In this work, we investigate a typical scenario in code generation where a developer edits existing code in real time and requests a code assistant, e.g., a large language model, to re-predict the next token or next line on the fly. Naively, the LLM needs to re-encode the entire KV cache to provide an accurate prediction. However, this process is computationally expensive, especially when the sequence length is long. Simply encoding the edited subsequence and integrating it to the original KV cache meets the temporal confusion problem, leading to significantly worse performance. We address this efficiency and accuracy trade-off by introducing underlinetextbfPositional Integrity Encoding (PIE). Building upon the rotary positional encoding, PIE first removes the rotary matrices in the Key cache that introduce temporal confusion and then reapplies the correct rotary matrices. This process ensures that positional relationships between tokens are correct and requires only a single round of matrix multiplication. We validate the effectiveness of PIE through extensive experiments on the RepoBench-C-8k dataset, utilizing DeepSeek-Coder models with 1.3B, 6.7B, and 33B parameters. Our evaluation includes three real-world coding tasks: code insertion, code deletion, and multi-place code editing. Results demonstrate that PIE reduces computational overhead by over 85% compared to the standard full recomputation approach across all model sizes and tasks while well approximating the model performance.
Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Placed in KV cache optimization, one of 12 directions in Efficient LLM inference and serving. Builds on 59 of its 68 references that are in the map. First posted on arXiv 3 Jul 2024.
Builds on
59 of 68 references.
Closest ancestors · 3
Same direction, newest first
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttention12 Sep
- 2023H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models24 Jun
- 2023Scissorhands: Exploiting the Persistence of Importance Hypothesis for LLM KV Cache Compression at Test Time26 May
Other references · 56
- 2017Attention Is All You Needcited by 60,361
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,139
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2019DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lightercited by 4,307
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
38 more
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,850
- 2020Reformer: The Efficient Transformercited by 1,668
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,653
- 2020Rethinking Attention with Performerscited by 1,601
- 2019Generating Long Sequences with Sparse Transformerscited by 1,546
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,474
- 2022SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Modelscited by 1,386
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2023PaLM 2 Technical Reportcited by 1,162
- 2023SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shotcited by 1,121
- 2018Self-Attention with Relative Position Representationscited by 1,120
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2023Accelerating Large Language Model Decoding with Speculative Samplingcited by 1,006
- 2022GLM-130B: An Open Bilingual Pre-trained Modelcited by 843
- 2024Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Headscited by 843
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2023LLM-Pruner: On the Structural Pruning of Large Language Modelscited by 650
- 2024EAGLE: Speculative Sampling Requires Rethinking Feature Uncertaintycited by 578
- 2023FlexGen: High-Throughput Generative Inference of Large Language Models with a Single GPUcited by 575
- 2022Efficiently Scaling Transformer Inferencecited by 539
- 2022ZeroQuant: Efficient and Affordable Post-Training Quantization for Large-Scale Transformerscited by 526
- 2024Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Servecited by 526
- 2020Efficient Content-Based Sparse Attention with Routing Transformerscited by 471
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2023LLM-QAT: Data-Free Quantization Aware Training for Large Language Modelscited by 324
- 2018Blockwise Parallel Decoding for Deep Autoregressive Modelscited by 323
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
- 2020Sparse Sinkhorn Attentioncited by 251
- 2020SpAtten: Efficient Sparse Attention Architecture with Cascade Token and Head Pruningcited by 234
- 2020IntelliCode Compose: Code Generation Using Transformercited by 227
- 2019Blockwise Self-Attention for Long Document Understandingcited by 159
- 2023Accelerating LLM Inference with Staged Speculative Decodingcited by 151
- 2023REST: Retrieval-Based Speculative Decodingcited by 150
- 2022A Length-Extrapolatable Transformercited by 127
- 2023Rethinking the Expressive Power of GNNs via Graph Biconnectivitycited by 119
- 2021Accelerated Sparse Neural Training: A Provable and Efficient Method to Find N:M Transposable Maskscited by 103
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 86
50 most cited of 56 All 56 (JSON)
Built on by
Citing papers per year: 2024: 1; 2025: 3; 2026: 6.
10 papers.
- 2024RethinkMCTS: Refining Erroneous Thoughts in Monte Carlo Tree Search for Code Generationcited by 26
- 2025LLM as Effective Streaming Processor: Bridging Streaming-Batch Mismatches with Group Position Encodingcited by 9
- 2025A3: Attention-Aware Accurate KV Cache Fusion for Fast Large Language Model Servingcited by 8
- 2025In-Place Feedback: Reliable Refinement for Multi-Turn Expert-LLM Collaborationcited by 1
- 2026Context Language Modelscited by 1
- 2026Functional Cache Grafting: Robust and Rapid Code-Policy Synthesis for Embodied Agentscited by 0
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generationcited by 0
- 2026Fine-Tuning a KV Cache Concatenation-Aware Model or Recomputing KV Caches? Why Not Both?cited by 0
- 2026Budgeted KV-Cache Repair for Evolving Contextscited by 0
- 2026Diff Diffusion: Predicting Edit Paths with Diffusion Models for Efficient Code Editingcited by 0
- 2026Diff Diffusion: Predicting Edit Paths with Diffusion Models for Efficient Code Editing13 Oct 2026
- 2026Budgeted KV-Cache Repair for Evolving Contexts12 Oct 2026
- 2026Context Language Models29 Sep 2026
- 2026Fine-Tuning a KV Cache Concatenation-Aware Model or Recomputing KV Caches? Why Not Both?9 Sep 2026
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation1 Sep 2026
- 2026Functional Cache Grafting: Robust and Rapid Code-Policy Synthesis for Embodied Agents11 Jun 2026
- 2025A3: Attention-Aware Accurate KV Cache Fusion for Fast Large Language Model Serving13 Nov 2025
- 2025In-Place Feedback: Reliable Refinement for Multi-Turn Expert-LLM Collaboration1 Oct 2025
- 2025LLM as Effective Streaming Processor: Bridging Streaming-Batch Mismatches with Group Position Encoding22 May 2025
- 2024RethinkMCTS: Refining Erroneous Thoughts in Monte Carlo Tree Search for Code Generation15 Sep 2024
Similar, not cited
Close in wording, no citation either way
- 2026Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editing
- 2024Get More with LESS: Synthesizing Recurrence with KV Cache Compression for Efficient LLM Inference
- 2026KVEraser: Learning to Steer KV Cache for Efficient Localized Context Erasing
- 2026From Brute Force to Semantic Insight: Performance-Guided Data Transformation Design with LLMs
- 2024RefreshKV: Updating Small KV Cache During Long-form Generation
- 2025KVShare: An LLM Service System with Efficient and Effective Multi-Tenant KV Cache Reuse
- 2024Don't Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs
- 2024SelfCodeAlign: Self-Alignment for Code Generation