Research map / Large language models / Language, safety and interpretability
Let the Code LLM Edit Itself When You Edit the Code
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Proposes Positional Integrity Encoding (PIE), which removes and reapplies RoPE rotations to cached keys so that code KV caches can be updated after real-time edits without full recomputation, cutting KV-update overhead by over 85% on RepoBench-C-8k with DeepSeek-Coder models.
Problem
Real-time code edits force LLM code assistants to re-encode the entire KV cache for next-line prediction, which is expensive for long contexts; naively reusing edited KV entries causes temporal (positional) confusion and degrades accuracy.
Approach
Build on RoPE: since the rotary positional information lives in cached keys, remove the old rotation from each post-edit key and re-apply the correct rotation for its new position with a single matrix multiplication, avoiding recomputation of subsequent KV entries while keeping positional indices unique and consecutive.
Key results
- PIE matches full-recomputation EM/ES within about 0.3% (EM) on XF-F insertion/deletion/edition across DeepSeek-Coder 1.3B/6.7B/33B, while Conflict Fast Encoding drops EM to a few percent.
- Averaged KV-update overhead reduction for the edition task is 87.9%/88.2% (1.3B), 92.4%/92.8% (6.7B), and 94.8%/95.2% (33B) on Python/Java.
- On HumanEval Python, PIE achieves Pass@1 43.9 versus 49.4 for full recomputation and 11.0 for Conflict Fast Encoding.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Use PIE instead of full KV-cache recomputation after code edits | DeepSeek-Coder 6.7B · RepoBench-C-8k XF-F insertion, deletion, and edition | EM: 28.95 -> 28.83; 28.95 -> 28.86; 28.95 -> 28.07 (Python) | No clear effect |
| Use PIE instead of full KV-cache recomputation after code edits | DeepSeek-Coder 6.7B · RepoBench-C-8k XF-F insertion, deletion, and edition | time: 561ms -> 50ms; 561ms -> 43ms; 705ms -> 54ms (Python) | Helped |
| Use Conflict Fast Encoding instead of full KV-cache recomputation | DeepSeek-Coder 6.7B · RepoBench-C-8k XF-F insertion, deletion, and edition | EM: 28.95 -> 5.35; 28.95 -> 0.51; 28.95 -> 11.26 (Python) | Hurt |
| Use PIE instead of full KV-cache recomputation after code edits | DeepSeek-Coder 6.7B · HumanEval and HumanEval-X | Pass@1: 49.4 -> 43.9; 50.3 -> 49.7 | Mixed |
| Use PIE instead of Conflict Fast Encoding | DeepSeek-Coder 6.7B · HumanEval and HumanEval-X | Pass@1: 11.0 -> 43.9; 15.5 -> 49.7 | Helped |
| Use PIE instead of Conflict Fast Encoding | DeepSeek-Coder 6.7B · RepoBench-C-8k contextually related insertion, 5–15 lines | EM: 7.92 -> 27.40 (Python, 5 lines); 2.81 -> 30.04 (Java, 5 lines) | Helped |
| Reuse the pre-edit context without modifying its KV cache | DeepSeek-Coder 6.7B · HumanEval and HumanEval-X | Pass@1: 49.4 -> 17.7; 50.3 -> 29.2 | Hurt |
Surprising findings
- Naive reuse of edited KV entries (Conflict Fast Encoding) severely degrades accuracy, with EM falling to near zero in several settings, showing positional confusion matters more than semantic changes for code edits.
- The authors report that semantic impact of minor code edits on the rest of the context is relatively small compared with the structural temporal confusion.
Limitations
- Semantic impact of larger or more semantically significant edits is not fully handled; PIE's accuracy on short contexts like HumanEval drops relative to full recomputation (43.9 vs 49.4 Pass@1).
- Evaluation limited to next-line prediction with simulated random edits on code; generalization to natural language dialogue is not tested.
Experimental setup
Datasets: RepoBench-C-8k HumanEval HumanEval-X
Benchmarks: RepoBench-C-8k HumanEval HumanEval-X
Metrics: Exact Match Edit Similarity Pass@1 latency (ms) cosine similarity of KV representations KL divergence of token distributions
Baselines: Full-recomputation Conflict Fast Encoding Reuse baseline
Builds on: RoPE DeepSeek-Coder KV cache
Closest papers by meaning
- Training Language Models on Synthetic Edit Sequences Improves Code Synthesis (ICLR 2025 · similarity 0.87)
- NextCoder: Robust Adaptation of Code LMs to Diverse Code Edits (ICML 2025 · similarity 0.87)
- SelfCodeAlign: Self-Alignment for Code Generation (NeurIPS 2024 · similarity 0.87)
- How efficient is LLM-generated code? A rigorous & high-standard benchmark (ICLR 2025 · similarity 0.87)
- LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code (ICLR 2025 · similarity 0.86)
- LLM-Assisted Code Cleaning For Training Accurate Code Generators (ICLR 2024 · similarity 0.86)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
