边生成边执行:在LLM代码解释器中隐藏执行延迟
Executing as You Generate: Hiding Execution Latency in LLM Code Interpreters
AI总结:
提出并行执行范式,通过将生成、检测和执行三阶段流水线化,在代码生成过程中提前执行,显著降低端到端延迟。
摘要:
当前的LLM系统越来越多地配备代码解释器,用于执行生成的代码以获得结果。这是串行工作的:模型首先生成完整的代码,然后解释器执行它。这种顺序工作流在执行器生成期间空闲,在生成器执行期间空闲,导致不必要的端到端延迟。我们的关键观察是,LLM与人类开发者不同,它从左到右发出代码令牌,并且不会回溯已经写好的内容。这使得在后续令牌仍在生成时开始执行一段代码成为可能。我们形式化了这种并行执行范式,将其建模为生成、检测和执行的三阶段流水线,并推导出闭式延迟界限,表征其加速潜力和操作机制。然后,我们提出了EAGER,一个具体实现,包括基于AST的分块、带门控执行的动态批处理和早期错误中断。我们在四个基准、七个LLM和三个执行环境中评估了EAGER。重叠机制几乎将所有执行隐藏在生成之后,将执行的非重叠部分减少高达99.8%,并在无错误运行中将端到端延迟降低高达37.3%。
英文摘要:
Current LLM systems are increasingly equipped with a code interpreter that executes generated code to obtain results. This works serially: the model first generates the complete code, then an interpreter executes it. This sequential workflow leaves the executor idle during generation and the generator idle during execution, resulting in unnecessary end-to-end latency. Our key observation is that an LLM, unlike a human developer, emits code tokens left to right and does not backtrack over what it has already written. This makes it possible to start executing a piece of code while later tokens are still being generated. We formalize this parallel execution paradigm, modeling it as a three-stage pipeline of generation, detection, and execution, and derive closed-form latency bounds that characterize its speedup potential and operating regimes. We then present EAGER, a concrete implementation featuring AST-based chunking, dynamic batching with gated execution, and early error interruption. We evaluate EAGER across four benchmarks, seven LLMs, and three execution environments. The overlap mechanism hides almost all execution behind generation, reducing the non-overlapped portion of execution time by up to 99.8% and cutting end-to-end latency by up to 37.3% on error-free runs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。