CodeComp: 用于代理编程的结构化KV缓存压缩
CodeComp: Structural KV Cache Compression for Agentic Coding
AI总结:
CodeComp通过引入静态程序分析,在LLM推理中整合代码属性图先验,有效压缩KV缓存,提升代码定位和生成任务的准确性与效率。
摘要:
代理代码任务如故障定位和补丁生成需要在内存受限条件下处理大型代码库,其中键值(KV)缓存成为主要推理瓶颈。现有压缩方法仅依赖注意力信号估计token重要性,系统性地丢弃结构关键token如调用站点、分支条件和赋值,这些对代码理解至关重要。我们提出CodeComp,一种无需训练的KV缓存压缩框架,通过Joern提取的代码属性图先验将静态程序分析整合到LLM推理中。在bug定位和代码生成基准测试中,CodeComp在同等内存预算下优于仅依赖注意力的压缩基线,恢复了大部分完整上下文准确性,同时在补丁生成质量上与未压缩的完整上下文推理相当,并无缝集成到基于SGLang的代理编程流水线中,无需修改模型。
英文摘要:
Agentic code tasks such as fault localization and patch generation require processing long codebases under tight memory constraints, where the Key-Value (KV) cache becomes the primary inference bottleneck. Existing compression methods rely exclusively on attention signals to estimate token importance, systematically discarding structurally critical tokens such as call sites, branch conditions, and assignments that are essential for code understanding. We present CodeComp, a training-free KV cache compression framework that incorporates static program analysis into LLM inference via Code Property Graph priors extracted by Joern. Across bug localization and code generation benchmarks, CodeComp consistently outperforms attention-only compression baselines under equal memory budgets, recovering the majority of full-context accuracy under aggressive KV cache compression, while matching the patch generation quality of uncompressed full-context inference and integrating seamlessly into SGLang-based agentic coding pipelines without model modification.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。