Dynamic Stability of LLM-Generated Code
Not on the map. Why?
Abstract (arXiv)
Current evaluations of LLMs for code generation emphasize functional correctness, overlooking the fact that functionally correct solutions can differ significantly in algorithmic complexity. For instance, an (O(n2)) versus (O(n log n)) sorting algorithm may yield similar output but incur vastly different performance costs in production. This discrepancy reveals a critical limitation in current evaluation methods: they fail to capture the behavioral and performance diversity among correct solutions. To address this, we introduce a principled framework for evaluating the dynamic stability of generated code. We propose two metrics derived from opcode distributions: Static Canonical Trace Divergence (SCTD), which captures algorithmic structure diversity across generated solutions, and Dynamic Canonical Trace Divergence (DCTD), which quantifies runtime behavioral variance. Their ratio, the Behavioral Expression Factor (BEF), serves as a diagnostic signal: it indicates critical runtime instability when BEF ll 1 and functional redundancy when BEF gg 1. Empirical results on BigOBench and CodeContests show that state-of-the-art LLMs exhibit significant algorithmic variance even among functionally correct outputs. Notably, increasing sampling temperature improves pass@1 rates but degrades stability, revealing an unrecognized trade-off: searching for correct solutions in diverse output spaces introduces a "penalty of instability" between correctness and behavioral consistency. Our findings call for stability-aware objectives in code generation and new benchmarks with asymptotic test cases for robust, real-world LLM evaluation.
Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Builds on 13 of its 34 references that are in the map. First posted on arXiv 7 Nov 2025.
Builds on
13 of 34 references.
References · 13
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 11,979
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2020Sharpness-Aware Minimization for Efficiently Improving Generalizationcited by 1,404
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2020Neurosymbolic AI: The 3rd Wavecited by 253
- 2020The Next Decade in AI: Four Steps Towards Robust Artificial Intelligencecited by 194
- 2023Is ChatGPT the Ultimate Programming Assistant -- How far is it?cited by 72
- 2023A Survey on Large Language Models for Software Engineeringcited by 58
- 2024Revisiting Code Similarity Evaluation with Abstract Syntax Tree Edit Distancecited by 26
- 2025GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generationcited by 3
Built on by
Citing papers per year: 2026: 4.
4 papers.
- 2026Can Large Language Models Implement Agent-Based Models? An ODD-based Replication Studycited by 1
- 2026SQLStructEval: Structural Evaluation of LLM Text-to-SQL Generationcited by 1
- 2026Algorithmic algorithm development with LLMs: A Case Study on LLM-Usage for Contraction Order Optimization in Tensor Networkscited by 0
- 2026LLM Post-Training as Brownfield Maintenance: An Industrial Perspective on Dataware Engineeringcited by 0
- 2026LLM Post-Training as Brownfield Maintenance: An Industrial Perspective on Dataware Engineering31 Aug 2026
- 2026Algorithmic algorithm development with LLMs: A Case Study on LLM-Usage for Contraction Order Optimization in Tensor Networks1 Jun 2026
- 2026SQLStructEval: Structural Evaluation of LLM Text-to-SQL Generation8 Apr 2026
- 2026Can Large Language Models Implement Agent-Based Models? An ODD-based Replication Study8 Feb 2026