AgRefactor: A New Frontier in Hardware Acceleration
Researchers from Carnegie Mellon University and the University of California, Los Angeles (UCLA) have introduced AgRefactor, a novel system that leverages Large Language Model (LLM) agents to refactor software code for High-Level Synthesis (HLS). This breakthrough promises to accelerate the development of hardware accelerators by automatically transforming general-purpose C/C++ code into HLS-compatible programs, achieving substantial performance improvements over existing methods.
High-Level Synthesis is a critical process in modern chip design. It allows developers to describe hardware functionality using high-level programming languages like C/C++, which are then automatically translated into hardware description languages (HDLs) such as Verilog or VHDL. This abstraction significantly speeds up the design cycle compared to traditional RTL (Register-Transfer Level) design. However, writing HLS-compatible code and optimizing it for performance often requires deep expertise and extensive manual effort. Code that performs well on a CPU might not translate efficiently to hardware without significant modifications.
AgRefactor tackles this challenge head-on by employing a multi-agent LLM workflow. Instead of a single, monolithic LLM attempting the complex task, AgRefactor orchestrates a team of specialized agents. Each agent is designed to perform specific sub-tasks within the refactoring process, mimicking a human expert team. This division of labor allows for a more systematic and effective transformation of the code.

The AgRefactor Workflow Explained
The core of AgRefactor lies in its self-evolving agentic workflow. The system doesn't just apply a fixed set of rules; it iteratively refines the code based on feedback and performance metrics. The process typically involves several key stages:
- Code Analysis: The initial step involves the LLM agents analyzing the input C/C++ code to understand its structure, identify computationally intensive kernels, and pinpoint areas suitable for hardware acceleration.
- HLS Compatibility Refactoring: Agents work to modify the code to adhere to HLS constraints. This can include removing unsupported language constructs, restructuring loops for parallelism, and introducing appropriate data types.
- Pragma Tuning: A crucial part of HLS optimization involves inserting pragmas – compiler directives that guide the synthesis tool. AgRefactor agents intelligently identify where and how to insert pragmas like
PIPELINE,UNROLL, andARRAY_PARTITIONto maximize parallelism and minimize latency. - Performance Evaluation: After refactoring and pragma insertion, the code is synthesized into hardware, and its performance is evaluated. This evaluation can involve metrics like latency, throughput, and resource utilization.
- Iterative Refinement: Based on the performance evaluation, the agents identify shortcomings and iteratively refine the code and pragma strategies. This feedback loop allows AgRefactor to continuously improve the generated HLS code.
The researchers' technical paper, titled “AgRefactor: Self-Evolving Agentic Workflow for HLS Compatibility and Performance,” details how this multi-agent approach can systematically navigate the complexities of HLS optimization. Unlike traditional tools that might rely on predefined heuristics or brute-force search, AgRefactor's agentic nature allows it to learn and adapt, potentially discovering more effective optimization strategies.
Performance Gains and Future Implications
The results presented by the Carnegie Mellon and UCLA teams are compelling. AgRefactor demonstrated a significant speedup compared to a state-of-the-art pragma tuning tool. The geometric mean speedup achieved was an impressive 6.51×. This substantial improvement indicates that LLM-based agentic workflows can outperform even sophisticated, specialized tools in the domain of HLS optimization.
This advancement has far-reaching implications for the semiconductor industry and beyond. For chip designers, AgRefactor offers a pathway to drastically reduce the time and effort required to develop high-performance hardware accelerators. By automating the complex refactoring and optimization process, it democratizes hardware acceleration, making it accessible to a wider range of developers who may not be hardware design experts.
The success of AgRefactor also highlights the growing potential of LLM agents in complex software engineering tasks. Beyond HLS, similar agentic frameworks could be applied to areas like code modernization, automated debugging, performance optimization for general software, and even the generation of new algorithms. The ability of these agents to collaborate, reason, and iterate suggests a future where AI plays an increasingly integral role in the software development lifecycle.
The research, published in June 2026, marks a significant step forward. It moves beyond using LLMs as simple code generators or assistants to employing them as autonomous, collaborative agents capable of undertaking complex engineering challenges. The iterative, self-evolving nature of AgRefactor is particularly noteworthy, suggesting that AI systems can not only perform tasks but also learn and improve their performance over time, much like human experts.
