REVIEW 2 major objections 5 minor 21 references
LLM Program Optimization via Retrieval Augmented Search
T0 review · 2 major / 5 minor · reviewed 2026-08-09 · deepseek-v4-flash
Pith's one-line read This paper claims that a retrieval-augmented beam search, using natural-language descriptions of programs rather than source code for retrieval, nearly doubles the best blackbox LLM program optimization speedup, reaching 8.01x on the C++…
desk verdict Promising method, but the headline speedups are selected and measured on the same five test cases, making the 8.01x vs 4.42x claim an in-sample artifact until a holdout evaluation is done. read the letter →
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
The reading
What carries the argument
The load-bearing mechanism is the retrieve-optimize-evaluate loop. At each step, RAS embeds the current program by first asking an LLM to describe its algorithm, retrieves the k closest slow programs from the training set, samples candidate rewrites from an LLM prompted with each retrieved slow-fast pair, scores each candidate on test cases, and advances the beam to the fastest correct program. AEGIS changes the training set rather than the loop: it decomposes each slow-fast pair into a sequence of natural-language edits, applies them to produce intermediate programs, generalizes each edit into an 'atomic edit', and then retrieves atomic edits instead of whole pairs. The natural-language description step is what distinguishes contextual retrieval from code retrieval.
What would settle it
Use a disjoint holdout protocol: split each problem's test cases into a selection set and an evaluation set, run RAS with selection on the first set only, and report average best speedup on the second. If the held-out speedup no longer beats the dynamic retrieval baseline, the central claim fails.
Extended reading notes
Core claim
The central claim, stated on the paper's own terms, is that blackbox LLM program optimization is best done as a multi-step search rather than an end-to-end rewrite. RAS repeatedly retrieves the top-k slow-fast program pairs closest to the current program, uses an LLM to generate k candidate rewritten programs from those examples, evaluates them on test cases, and keeps the fastest correct candidate. The retrieval distance is computed not on source code but on LLM-generated natural language descriptions of each program's algorithms and data structures. This contextual retrieval plus beam search yields an average best speedup of 8.01x on the C++ test programs, versus 4.42x for dynamic code retrieval and 2.30x for instruction-only prompting. A second method, AEGIS, decomposes training pairs into generalizable atomic edits and runs the same search over those edits, achieving 6.08x while making smaller, more interpretable changes.
Load-bearing premise
The evaluation assumes that speedups measured on the same five fixed test cases used to pick the fastest program are a faithful proxy for speedups on the full test suite, even though the selection process can overfit to those five inputs.
Editorial extensions
If this is right
- RAS nearly doubles the average best speedup of the previous best blackbox adaptation strategy on the C++ test programs: 8.01x versus 4.42x for dynamic retrieval.
- Both search and contextual retrieval contribute to the gain; removing contextual retrieval about halves the improvement over dynamic retrieval.
- AEGIS keeps most of RAS's speedup (6.08x) while reducing average edit distance by 17% overall and by 30% on the first edit, supporting its interpretability claim.
- Speedups continue to grow across beam search steps, especially for AEGIS, so more iterations may further close the gap between AEGIS and RAS.
- Instruct-only prompting without retrieval or search is much weaker (2.30x), confirming that adaptation to the training distribution is the source of the gains.
Reading between the lines
- Editorial inference: because the same five test cases are used both to select the best candidate and to report its speedup, the absolute speedups are likely optimistic; a disjoint selection/evaluation split would probably shrink them, though the relative ordering over methods could survive.
- Editorial inference: RAS should transfer to non-C++ targets such as Python, SQL, or build configurations, since the loop only needs slow-fast pairs, an embedding function, and an evaluator.
- Editorial inference: AEGIS's atomic-edit database is a one-time asset; once built from the training pairs, it can be reused across many test programs, which would amortize the preprocessing cost that the paper lists as a limitation.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper proposes Retrieval Augmented Search (RAS), a blackbox LLM adaptation method for program optimization that combines contextual retrieval (embedding an LLM-generated natural-language description of the program) with iterative beam search. It also introduces AEGIS, which decomposes training slow-fast pairs into 'atomic edits' and searches over these edits. Experiments on the PIE C++ benchmark report that RAS achieves an 8.01x mean best speedup versus 4.42x for dynamic retrieval, and that AEGIS reaches 6.08x with smaller average edit distances.
Significance. If the reported results were robust, RAS would be a substantial advance: it nearly doubles the prior state-of-the-art blackbox optimization speedup on PIE. The paper includes a clear algorithmic description (Algorithm 1), a deterministic gem5-based measurement setup, and a large held-out test set (973 programs). The idea of contextual retrieval for code is well motivated, and the AEGIS decomposition is a creative step toward interpretability. However, as detailed below, the central empirical claim currently rests on an evaluation protocol that selects and evaluates on the same test-case subset, which makes the headline speedup an in-sample statistic.
major comments (2)
- [Section 5.1, Algorithm 1] The selection step in Algorithm 1 (pi = arg max_j R(p^j_i)) uses the running time R measured on a fixed subset of 5 test cases, and the reported 'mean best speedup' in Table 1 is computed on the same 5 test cases. This makes the headline speedup an in-sample selection statistic rather than an out-of-sample prediction. The validation in Section 5.1 (Pearson r = 0.89 between full-suite and 5-case running times across programs) does not address the quantity actually used in the algorithm: with k = 8 candidates per step and m = 4 steps, selection is based on order statistics (maxima) of the 5-case estimate, which are far more sensitive to test-case-specific noise than the marginal correlation suggests. To support the claimed speedups, the authors should re-evaluate the final selected programs on the full test suite (or on a separate held-out subset of test cases not used for selection) and report those numbers for RAS and for all baselines.
- [Section 5.1, Table 1] The comparison between RAS and dynamic retrieval is confounded by the number of selection rounds on the evaluation subset. Dynamic retrieval selects the best of h = 32 independent samples once, while RAS performs m = 4 rounds of arg-max over k = 8 candidates, each round using the same 5 test cases. Even if the per-sample evaluation were an unbiased estimate of full-suite speedup, the repeated selection makes RAS more prone to accumulating 5-case-specific lucky improvements across rounds, whereas dynamic retrieval is selected only once. The reported relative improvement of 1.81x therefore may be partly an artifact of this selection-protocol mismatch rather than the proposed retrieval/search innovations. The authors should either compare against a baseline that performs an equivalent number of selection rounds on the same test cases, or report a held-out evaluation after the final selection.
minor comments (5)
- [Section 5.1, hyperparameters paragraph] The sentence 'For our instruct only ablation, we retrieve k = 32 examples and use m = 1 iterations' is contradictory, since the instruct-only setting does not use retrieval; the parameter should be h = 32 samples, not k retrievals.
- [Algorithm 2] The loop 'for i in [1, ..., n]' uses an undefined n; it should iterate over the r natural-language edits produced by Fdecomp in the preceding step.
- [Section 3.2] The definition of a 'new pair' (a retrieved example not used to sample an earlier best-performing program) is given but never used in the algorithm or the experiments; either remove it or clarify its role in the method.
- [Table 3] The edit-distance metric is described as 'averaged across all pairs of programs', but it is not stated whether the pairs are consecutive programs in the beam search trajectory or all programs across the test set; this should be clarified to make the interpretability claim reproducible.
- [Tables 1 and 2] No variance or significance tests are reported for the speedup numbers; given the high variance typical of LLM optimization experiments, adding standard errors or confidence intervals across runs or across test programs would help assess the stability of the reported improvements.
Circularity Check
Headline speedup is measured on the same 5 test cases used by Algorithm 1 to select the optimized program, so the reported 8.01x is the optimized objective rather than a holdout estimate.
-
fitted input called prediction
[Section 3.2 (Algorithm 1) and Section 5.1 (Metrics)]
"Algorithm 1: pi ← arg maxj∈[k] R(pj i). Section 5.1: 'we measure running time averaged across a subset of 5 randomly selected test cases; these 5 test cases are fixed ahead-of-time.' 'Our main metric is “mean best speedup”, which is the speedup ... of the final program p′ compared to the original program p, averaged across all test programs p ∈ Πtest.'"
The final program p′ used in the headline result is chosen by Algorithm 1 as the arg max of R on exactly the same fixed 5 test cases on which Section 5.1 computes the reported mean best speedup. Thus the reported 8.01× speedup is the value of the selection objective after m rounds of maximizing it, not an independent measurement. The held-out status of Πtest refers to training problems, not to the test cases used for selection. The paper's r=0.89 validation compares full-suite vs 5-case running times across programs, but it does not validate repeated arg-max selection over k=8 candidates for m=4 rounds, which can amplify 5-case-specific noise.
full rationale
RAS is an empirical method rather than a mathematical derivation, and most of its components are independently implemented: the PIE benchmark rests on external CodeNet submissions and deterministic gem5 measurements, and the dynamic retrieval baseline is re-run rather than taken on faith from the prior PIE paper. The one load-bearing circularity is the identity between the selection objective and the reported metric: Algorithm 1 sets pi = arg max R over candidates using R measured on 5 fixed test cases, and Table 1's mean best speedup is computed from R on those same 5 test cases. This makes the headline 8.01x an in-sample optimized objective, not a holdout estimate; the r=0.89 aggregate correlation does not control for the order statistics of repeated argmax selection. The self-citations to PIE and dynamic retrieval are not circular by themselves because the benchmark and baseline are reproducible external artifacts; however, the paper's Limitations section acknowledges only compute cost, not this selection-evaluation overlap. Score reflects the partial circularity in the central quantitative claim.
Assumptions & free parameters
free parameters (4)
- k (number of retrieved examples per beam step) =
8
- m (number of beam search iterations) =
4
- n_test_cases =
5
- h (baseline sample count) =
32
assumptions (4)
- domain assumption Test cases are a sufficient proxy for semantic equivalence
- domain assumption Running time on 5 random test cases approximates full-suite running time
- domain assumption The PIE train/test split by competitive programming problem ensures semantic difference
- domain assumption LLM-generated natural language descriptions are stable and useful for retrieval
invented entities (1)
-
Atomic edits
Cite this review
Pith. "Pith review of LLM Program Optimization via Retrieval Augmented Search." pith.science (2026). https://pith.science/paper/MYKVBL4Q
@misc{pith2026250118916,
author = {Pith},
title = {Pith review of: LLM Program Optimization via Retrieval Augmented Search},
year = {2026},
howpublished = {\url{https://pith.science/paper/MYKVBL4Q}},
note = {Machine review of arXiv:2501.18916}
}
abstract
Recent work has demonstrated the potential of large language models (LLMs) for program optimization, a key challenge in programming languages. We propose a blackbox adaptation method called Retrieval Augmented Search (RAS) that performs beam search over candidate optimizations; at each step, it retrieves in-context examples from a given training dataset of slow-fast program pairs to guide the LLM. Critically, we find that performing contextual retrieval based on an LLM-generated natural language description significantly outperforms retrieval based on the source code. We also propose AEGIS, a method for improving interpretability by decomposing training examples into ''atomic edits'' that are significantly more incremental in nature. We show that RAS performs up to 2.06$\times$ better than prior state-of-the-art blackbox adaptation strategies on optimizing C++ programs, and that AEGIS performs up to 1.37$\times$ better while making significantly smaller edits. We also show that using RAS improves the mean runtime percentile of Python programs by 10.27 compared to baselines.
Figures
Reference graph
Works this paper leans on
-
[1]
Anthropic. Contextual retrieval. https://web.archive.org/web/20250121234912/https://www.anthropic.com/news/contextual-retrieval, 2024. Accessed: 2025-01-23
arXiv 2024
-
[2]
K., Saidi, A., Basu, A., Hestness, J., Hower, D
Binkert, N., Beckmann, B., Black, G., Reinhardt, S. K., Saidi, A., Basu, A., Hestness, J., Hower, D. R., Krishna, T., Sardashti, S., et al. The gem5 simulator. ACM SIGARCH computer architecture news, 39 0 (2): 0 1--7, 2011
work page 2011
-
[3]
D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al
Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. Language models are few-shot learners. Advances in Neural Information Processing Systems, 33: 0 1877--1901, 2020
1901
-
[4]
Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. D. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021
arXiv 2021
-
[5]
Douze, M., Guzhva, A., Deng, C., Johnson, J., Szilvasy, G., Mazar \'e , P.-E., Lomeli, M., Hosseini, L., and J \'e gou, H. The faiss library. arXiv preprint arXiv:2401.08281, 2024
arXiv 2024
-
[6]
Search-based llms for code optimization
Gao, S., Gao, C., Gu, W., and Lyu, M. Search-based llms for code optimization. In 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE), pp.\ 254--266. IEEE Computer Society, 2024
work page 2025
-
[7]
Gu, X., Zhang, H., and Kim, S. Deep code search. In Proceedings of the 40th International Conference on Software Engineering, pp.\ 933--944, 2018
work page 2018
-
[8]
Islam, M. A., Ali, M. E., and Parvez, M. R. M ap C oder: Multi-agent code generation for competitive problem solving. In Ku, L.-W., Martins, A., and Srikumar, V. (eds.), Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp.\ 4912--4944, Bangkok, Thailand, August 2024. Association for Computati...
Show all 21 references
-
[9]
and Cummins, C
Italiano, D. and Cummins, C. Finding missed code size optimizations in compilers using llms. arXiv preprint arXiv:2501.00655, 2024
2024 arXiv
-
[10]
u ttler, H., Lewis, M., Yih, W.-t., Rockt \
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., K \"u ttler, H., Lewis, M., Yih, W.-t., Rockt \"a schel, T., et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in Neural Information Processing Systems, 33: 0 9459--9474, 2020
2020
-
[11]
Competition-level code generation with alphacode
Li, Y., Choi, D., Chung, J., Kushman, N., Schrittwieser, J., Leblond, R., Eccles, T., Keeling, J., Gimeno, F., Dal Lago, A., et al. Competition-level code generation with alphacode. Science, 378 0 (6624): 0 1092--1097, 2022
2022
-
[12]
Portfolio: finding relevant functions and their usage
McMillan, C., Grechanik, M., Poshyvanyk, D., Xie, Q., and Fu, C. Portfolio: finding relevant functions and their usage. In Proceedings of the 33rd International Conference on Software Engineering, pp.\ 111--120, 2011
2011
-
[13]
Reframing instructional prompts to gptk’s language
Mishra, S., Khashabi, D., Baral, C., Choi, Y., and Hajishirzi, H. Reframing instructional prompts to gptk’s language. In Findings of the Association for Computational Linguistics: ACL 2022, pp.\ 589--612, 2022
2022
-
[14]
Synchromesh: Reliable code generation from pre-trained language models
Poesia, G., Polozov, A., Le, V., Tiwari, A., Soares, G., Meek, C., and Gulwani, S. Synchromesh: Reliable code generation from pre-trained language models. In The Tenth International Conference on Learning Representations, 2022
2022
-
[15]
Codenet: A large-scale ai for code dataset for learning a diversity of coding tasks, 2021
Puri, R., Kung, D., Janssen, G., Zhang, W., Domeniconi, G., Zolotov, V., Dolby, J., Chen, J., Choudhury, M., Decker, L., Thost, V., Buratti, L., Pujar, S., Ramji, S., Finkler, U., Malaika, S., and Reiss, F. Codenet: A large-scale ai for code dataset for learning a diversity of...
2021
-
[16]
W., Tong, H., Ezick, J., and Lott, C
Qiu, R., Zeng, W. W., Tong, H., Ezick, J., and Lott, C. How efficient is llm-generated code? a rigorous & high-standard benchmark. The Thirteenth International Conference on Learning Representations, 2025
2025
-
[17]
R., Yang, Y., Hashemi, M., Neubig, G., Ranganathan, P., Bastani, O., and Yazdanbakhsh, A
Shypula, A., Madaan, A., Zeng, Y., Alon, U., Gardner, J. R., Yang, Y., Hashemi, M., Neubig, G., Ranganathan, P., Bastani, O., and Yazdanbakhsh, A. Learning performance-improving code edits. In The Twelfth International Conference on Learning Representations, 2024. URL https://...
2024
-
[18]
Z., Asai, A., Yu, X
Wang, Z. Z., Asai, A., Yu, X. V., Xu, F. F., Xie, Y., Neubig, G., and Fried, D. Coderag-bench: Can retrieval augment code generation? arXiv preprint arXiv:2406.14497, 2024
2024 arXiv
-
[19]
V., Zhou, D., et al
Wei, J., Wang, X., Schuurmans, D., Bosma, M., Xia, F., Chi, E., Le, Q. V., Zhou, D., et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35: 0 24824--24837, 2022
2022
-
[20]
R., and Sun, H
Yao, Z., Peddamail, J. R., and Sun, H. Coacor: Code annotation for code retrieval with reinforcement learning. In The world wide web conference, pp.\ 2203--2214, 2019
2019
-
[21]
write newline
" write newline "" before.all 'output.state := FUNCTION n.dashify 't := "" t empty not t #1 #1 substring "-" = t #1 #2 substring "--" = not "--" * t #2 global.max substring 't := t #1 #1 substring "-" = "-" * t #2 global.max substring 't := while if t #1 #1 substring * t #2 gl...
Reviewed August 9, 2026 · model on record in the stance chip above.
Discussion (0). Continue with ORCID to comment.