acceptodds
Under review as a conference paper at ICLR 2027

COPS: First-Principles Long-Context Code Compression via Constructing Context Optimal Preservation Sets

Abstract

Code large language models incur substantial computational costs and suffer from interference caused by irrelevant context during long-context reasoning. Existing code compression methods typically reduce the problem to a static ranking task based on a single context–query relevance criterion, rather than deriving the compression objective from first principles as a dynamic subset-selection problem. Consequently, they suffer from severe performance degradation when the token budget is aggressively reduced, while still retaining considerable information redundancy that interferes with downstream tasks. In this paper, we revisit long-context code compression from an information-theoretic perspective and formulate it as constructing Context Optimal Preservation Sets. Through a top-down decomposition of the mutual-information objective, we identify three fundamental principles that govern effective context selection: task relevance, dependency coverage, and information gain. Based on these principles, we propose COPS, a training-free, plug-and-play framework that instantiates all criteria with Approximated Mutual Information (AMI) and constructs preservation sets through a principled coarse-to-fine pipeline: (i) AMI-based recall followed by greedy preservation-set construction over candidate contexts; (ii) an information-saturation trigger that dynamically terminates context expansion via a one-sided concentration bound; and (iii) perplexity-anchored semantic block partitioning with positive-advantage iterative pruning for intra-function refinement. Extensive experiments on long-context benchmarks for code completion, summarization, and question answering demonstrate that COPS consistently establishes a superior Pareto frontier between compression ratio and downstream performance, achieving up to compression with negligible degradation while significantly reducing inference latency and memory consumption.

open until 14 Dec 2026

est. 32% chance this paper gets accepted at ICLR 2027.

Reject 68%Accept 32%

What do you think this paper will get?

All positions stay anonymous.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.