AgRefactor: Self-Evolving Agentic Workflow for HLS Compatibility and Performance

Yang Zou 1,* , Zijian Ding 2,* , Yizhou Sun 2 , Jason Cong 2 · 2026

Read AgRefactor: Self-Evolving Agentic Workflow for HLS Compatibility and Performance by Yang Zou 1,* , Zijian Ding 2,* , Yizhou Sun 2 , Jason Cong 2 (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2606-30949.txt.

Introduction

Yang Zou, Zijian Ding, Yizhou Sun and Jason Cong automate the tedious rewrite that turns ordinary software into code a chip-design tool can synthesise. High-Level Synthesis builds hardware from C-like code, but real-world programs use constructs the tools reject, and fixing them by hand can take experts days. AgRefactor is a multi-agent workflow in which language-model agents perform the refactoring. A self-evolving memory stores factual and strategic lessons from earlier tasks and retrieves them for new ones. Automated refactoring tools are mixed in, so cheap mechanical edits do not burn model calls.

On 9 of 11 challenging real-world benchmarks, each 5 to 10 times longer than prior work's hardest cases, AgRefactor matched or beat both the best automated tool and a strong model-based baseline. Further agent-driven optimisation gave a 6.51 times geometric-mean speedup over the leading pragma tuning tool.

Catalog record

CREATORYang Zou 1,* , Zijian Ding 2,* , Yizhou Sun 2 , Jason Cong 2
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE38 KB
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2606.30949

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

AgRefactor: Self-Evolving Agentic Workflow for HLS Compatibility and Performance Yang Zou 1,* , Zijian Ding 2,* , Yizhou Sun 2 , Jason Cong 2 Abstract High-Level Synthesis (HLS) provides a fast path from concepts to silicon, but converting real-world software into synthesizable HLS code remains challenging due to restrictive language support and the gap between software and hardware programming practices. Existing automated and LLM-based refactoring approaches partially address this problem, yet they often lack flexibility, struggle to scale, and incur high computational costs. We introduce AgRefactor , an LLM-based multi-agent workflow for refactoring software into HLS-compatible programs. AgRefactor incorporates a self-evolving memory system that accumulates and retrieves factual and strategic knowledge across tasks, improving robustness and efficiency on unseen programs. To reduce cost and enhance scalability, it integrates automated refactoring tools, enabling agents to balance LLM-driven rewrites with efficient tool-based transformations. On 9 out of 11 challenging real-world benchmarks, which are 5 − 10 × 5-10\times longer than the most complex cases studied in prior work, AgRefactor outperforms or matches the state-of-the-art automated refactoring tool and a strong LLM-based baseline built on the same framework backbone. Further agentic performance optimization yields a 6.51 × \times geometric mean speedup over the SoTA pragma tuning tool and a 1.20 × \times speedup over optimized open-source designs with less than 20% extra resources. AgRefactor is fully-automated and open-sourced. I Introduction High-Level Synthesis (HLS) [ 9 , 8 , 31 , 4 , 32 , 20 , 5 ] was introduced to streamline the process of turning design concepts into silicon implementations, by raising the abstraction level from register-transfer level (RTL) design to C/C++-based HLS designs. Practical HLS design flows begin with a tedious step: refactoring the software repository into an HLS-compatible program [ 12 , 33 , 7 ] . As reported in a real-world acceleration project of high energy physics [ 28 ] , this preparatory refactoring phase can take domain experts days to produce an initial HLS-compatible program for further optimization. This highlights the need for more automation to reduce this labor-intensive task. To address these difficulties, automated refactoring methodologies [ 12 , 33 ] have shown promise in converting software programs into HLS-synthesizable code. These approaches typically combine software engineering techniques such as dynamic invariant analysis and rely on fixed templates to rewrite non-synthesizable constructs. The increasing capabilities of large language models (LLMs) in software engineering motivate recent studies on using LLMs for HLS refactoring [ 29 , 7 ] . These methods typically feature an agentic workflow that identifies non-synthesizable constructs and applies iterative refactoring based on compiler feedback. HLSRewriter [ 29 ] introduces retrieval-augmented generation (RAG) to store factual knowledge and rewrite templates, while C2HLSC [ 7 ] first extracts each function and performs kernel-level rewriting with automatic testbench generation. TABLE I: AgRefactor achieves better refactoring performance while reducing cost compared with current state-of-the-arts. Method Generalizability Scalability Cost Rule-based [ 12 ] ✗ Poor ✓ Good ✓ Good LLM-based [ 29 ] ◐ Medium ◐ Medium ✗ Poor AgRefactor ✓ Good ✓ Good ◐ Medium Existing methods face three key challenges in HLS refactoring: generalizability, scalability, and cost. To mitigate these challenges, we propose AgRefactor , an LLM-based multi-agent workflow capable of refactoring real-world software programs into HLS-compatible programs. To address the issue of generalizability, we develop a self-envolving workflow with a specialized agentic memory system. Factual and strategic knowledge is automatically extracted and retrieved as the agents interact with diverse tasks (programs) and HLS tools. As the system accumulates knowledge from past experience, AgRefactor demonstrates higher efficiency and robustness when applied to unseen software programs. Unlike manually crafted RAG approaches, our memory system adapts to the model’s specific failure and success modes, providing targeted knowledge retrieval that improves refactoring accuracy and efficiency. Relative to general agentic memory systems [ 14 , 18 , 11 , 27 , 26 , 30 ] , we create a specialized knowledge format, dedicated interaction patterns, and a novel distance metric, all designed to achieve superior performance on this task. To alleviate the challenges of scalability and cost, we leverage the tool-calling capability of LLM agents. Specifically, we equip AgRefactor with HeteroRefactor [ 12 ] (abbreviated as HeteroRF in figures and tables), the state-of-the-art (SoTA) automated open-source refactoring tool for HLS. Naturally, for programs that can be fully handled by tools, we avoid the computational overhead of invoking LLMs. Furthermore, our framework allows LLM agents to balance between code generation and tool calls: they focus on removing or rewriting software constructs unsupported by HeteroRefactor, while delegating the remaining work to the tool. As a result, our tool-enhanced agentic workflow combines the flexibility of LLM-based code rewriting with the scalability and low cost of automated refactoring. While recent search-based approaches like AlphaEvolve [ 16 ] utilize scalar feedback (e.g., latency) to drive code mutations, AgRefactor provides the agent with richer information from raw EDA logs and scheduling reports. This capability allows the agent to pinpoint specific critical-path bottlenecks. Furthermore, we integrate a multi-tool environment that enables the agent to bootstrap from established human knowledge rather than performing blind mutations. Our contributions are summarized as follows: 1. We design and implement AgRefactor , an agentic workflow capable of refactoring real-world software into synthesizable, high-performance HLS code. Unlike existing approaches that focus solely on correctness and pragma insertion, we distinctly address structural refactoring, which most significantly impacts hardware performance. 2. We propose a self-evolving agent memory system specialized for this task. By continuously accumulating and retrieving both factual and strategic knowledge across varying tasks, our workflow enhances the base LLM’s robustness in HLS refactoring while requiring minimal human intervention. 3. We integrate automated refactoring tools into our agentic framework, creating a hybrid pipeline powered by both LLM agents and an algorithmic backend. This integration significantly reduces computational costs and improves the scalability of LLM-driven HLS refactoring. Evaluation on diverse real-world cases shows AgRefactor outperforms or matches both the state-of-the-art automated refactoring tool and a strong LLM-based baseline on 9 out of 11 benchmarks. Our optimization agent achieves a 6.51 \times geometric mean speedup over SoTA pragma tuning tools AutoDSE [ 22 ] and a 1.2 \times speedup over highly optimized open-source HLS designs with less than 20\% extra resource. II Motivation Fig. 1: Limitations of existing methods motivate our workflow design. (1) Automated refactoring suffer from poor generalizability. State-of-the-art automated refactoring cannot handle external libraries and complex struct data types. (2) LLM-based workflows require manual effort to build a RAG system and are subject to the intrinsic randomness of LLMs, leading to high variance in outputs. Moreover, pure LLM-based refactoring incurs significant cost. In contrast, AgRefactor addresses these challenges through a tool-enhanced, self-evolving workflow, enabled by an agentic memory system (Sec. III-A ). TABLE II: A comprehensive benchmark suite with complex real-world examples. Our benchmarks cover real-world programs from image/video codecs, cryptography, and computational genomics. Category Name Lines of code leetcode [ 13 ] maxSlidingWindow, delNodes, wordBreak, getSkyline, canDistribute criticalConnections, smallestRange, solveSudoku, removeInvalidParentheses, swimInWater 21-67 HLSRewriter [ 29 ] regUpdate, reverseKGroup, trap, FibSubseq, knn, rotateGrid, maxPoints, long, qrd_compute, forward, dfs, aes_encrypt 10-115 C2HLSC [ 7 ] Frequency, CumulativeSums, Overlapping, quicksort, present80_encryptBlock, sha256_update, des_crypt 11-221 HeteroRF [ 12 ] dfs, mergesort, linkedlist, ahocorasick, strassen 65-304 libsodium

Read the complete text