Adaptive Test-Time Compute Allocation for Efficient Code Generation under Hidden Inefficiency
Abstract
Large language models can produce code that passes visible tests while failing under valid worst-case inputs because runtime or memory behavior does not scale. We study this gap as a test-time compute allocation problem rather than only a repair problem. The proposed framework uses adversarial efficiency evidence to decide when an online generation run should stop, patch locally, replan, or escalate model effort. We evaluate architecture-controlled controller variants on a controlled paper-mode pilot: 100 medium-difficulty Codeforces problems, one seed, a fixed three-attempt cap, deterministic evaluation, shared per-run budget caps, and method-independent final adversarial suites. Under this shared-cap regime, the adaptive policy reaches a 44% online efficient solve rate, matching an always- escalate policy on the primary robust outcome while using substantially less budget per efficient solve (54.9k vs. 78.4k billed budget units). It also outperforms a fixed policy on online efficient solve rate (44% vs. 28%) and budget per efficient solve (54.9k vs. 102.3k). Paired problem-level analysis gives 22 adaptive-only efficient-solve wins against 6 fixed-only wins (exact McNemar p = 0.0037). The evidence supports a narrow systems claim: in this pilot setting, adversarially informed adaptive allocation improves cost-normalized robust code-generation utility compared with non-adaptive allocation.