Organizations: The Hong Kong University of Science and Technology, Hong Kong, Hong Kong · The Hong Kong University of Science and Technology (Guangzhou), Guangzhou, China · Dept of Electronic & Computer Engineering, The Hong Kong University of Science and Technology, Hong Kong, Hong Kong
LLM agents are rapidly shifting software development toward intent-driven vibe coding, yet their effectiveness drops sharply in high-level synthesis (HLS), where code optimization must jointly consider design structure, directive search, and downstream hardware constraints. Existing HLS optimization approaches, including both heuristic-based methods and recent LLM-assisted pipelines, typically operate at fixed abstraction levels or in weakly coupled stages, limiting their ability to leverage the strong interplay between source code restructuring and directive search outcomes. Our key insight is that HLS optimization can be reframed from a fixed, hardwired transformation pipeline into a skill-based agentic control problem: an LLM agent equipped with modular, executable optimization skills and a feedback-driven orchestrator can autonomously navigate the coupled space of code restructuring and directive search. This motivates the design of HLSClaw, the first HLS-specific, skill-based agentic harness for holistic HLS optimization. On real-world HLS benchmarks, HLSClaw achieves a 39.12x geometric-mean latency speedup, outperforming the compiler baseline ScaleHLS by 1.98x, and surpassing the commercial coding agents Claude Code and Codex by 1.86x and 1.70x, respectively, while maintaining strong timing robustness.
Figures & tables
Figure 1. Overview of HLSClaw : an LLM agent coordinates optimization skills in a feedback-driven workflow. An HLS design and a user goal enter a workflow of analysis and planning, code restructuring, differential C simulation, and directive search. A feedback arrow returns from directive search to code restructuring. An LLM agent orchestrates five underlying skills: Profiling, Rewrite, KG-RAG, Fuzzing, and the DSE Engine.
Figure 2. Motivation examples demonstrating the limitations of existing HLS compilers and the opportunity for LLMs. The green arrows show execution time reductions. Circle and pentagon markers highlight the bottlenecks and modified regions. Two rows compare original code, HLSClaw rewrites, and the corresponding hardware structures. For CRS, a loop-carried floating-point accumulation dependency is replaced by four partial sums and a tree reduction. Latency increases from 1,990 to 3,506 cycles, while the clock period decreases from 9.35 to 3.19 nanoseconds, reducing execution time by 40.0 percent. For Conv2D, repeated loading of overlapping windows through a FIFO is replaced by a line buffer and sliding-window registers. At a 5-nanosecond clock period, latency decreases from 4,502 to 1,147 cycles, reducing execution time by 74.5 percent. Numbered circle and pentagon markers connect the bottlenecks with the rewritten code and structures.
Figure 3. Overview of HLSClaw with five optimization skills, a feedback-driven workflow, and context engineering. The architecture combines a context-management layer, a feedback-driven optimization workflow, and five executable skills. An input HLS design and user goal guide analysis and planning, which sends an optimization plan and bottleneck diagnosis to code restructuring. Differential C simulation compares the original design and rewritten candidate; failures return to restructuring, while passing candidates proceed to directive search. Search reports return to analysis, and the best candidate feeds subsequent restructuring. Top States, Artifacts, ScratchPad, and Memory support the workflow, with Profiling, Rewrite, KG-RAG, Fuzzing, and DSE Engine skills below.
Figure 4. Offline construction of the KG-RAG library from multimodal documents for HLS knowledge retrieval. A left-to-right pipeline constructs a retrieval library from PDF files, web pages, and other documents. MinerU parses each document into text, images, tables, and equations. Multimodal embedding encodes the extracted content. The resulting knowledge graph links multimodal content and text representations for retrieval-augmented generation.
Figure 5. Context engineering with Top States, ScratchPad, and Artifacts for orchestration, memory, and outputs. Three connected context layers organize an agent run. Top States holds the system prompt, available-skill information, compact interaction history, and user specifications such as the latency objective, U250 board, and 200-megahertz target. ScratchPad holds the current analysis, commands, and artifact paths and exchanges information with Top States. Artifacts stores reference documents, synthesis reports, original and optimized designs, and scripts, and exchanges information with ScratchPad.
Figure 6. Performance and resource comparison across 12 HLS benchmarks. Top: normalized latency speedup, where higher is better. Bottom: normalized resource score relative to the original design, where lower is better. Two grouped bar charts compare HLSPilot, ScaleHLS, HLSRewriter, Codex, Claude Code, and HLSClaw on Atax, BNN, CNN, CRS, GEMM, GeTanh, GramSchmidt, Matrixmult, Stencil, Substring, VecNormTrans, and Viterbi, followed by geometric means. Both vertical axes are logarithmic. The upper chart shows normalized latency speedup, where higher is better; geometric means in method order are 17.3, 19.7, 14.1, 23.0, 21.0, and 39.1 times. The lower chart shows normalized resource score, where lower is better; geometric means are 14.5, 13.4, 11.3, 21.3, 12.5, and 15.2 times. HLSClaw has the highest geometric-mean speedup, with resource use varying across kernels.
Metric
HLSPilot
ScaleHLS
HLS Rewriter
Codex
Claude Code
HLSClaw
GM
11.89
18.29
14.16
13.34
14.68
30.59
ETS
3.44
6.35
5.35
4.13
5.26
7.48
EWS
4.41
4.46
4.99
4.42
4.68
5.70
Perf/HW Gain
0.82
1.36
1.25
1.18
1.17
2.01
Table 1. Execution time = latency × achieved clock period; For all four metrics, higher is better.
Figure 7. KG-RAG ablation on four kernels: (top) normalized latency speedup; (bottom) normalized resource score. Two grouped bar charts compare No-RAG, Flat-RAG, and KG-RAG on Atax, BNN, CNN, and Substring, followed by geometric means. The logarithmic axes show latency speedup above and normalized resource score below, with the original design marked at one times. Geometric-mean speedups are 3.8, 10.4, and 21.5 times, respectively; corresponding resource scores are 5.71, 14.0, and 15.4 times. KG-RAG provides the highest geometric-mean speedup and speedup per resource score, while resource use varies by kernel.
Configuration
C-sim time (s)
HLS evals
Invalid evals executed
HLS wall time (s)
Total wall time (s)
Without C-sim gate
0
80
15
966.50
966.50
With differential C-sim
94.10
65
0
295.71
389.81
Change
+94.10
−15
−15
−670.79
−576.69
Relative saving
–
18.8%
100%
69.40%
59.70%
Table 2. Impact of differential C simulation on validation and optimization wall-clock time.
Benchmark
eval-1 cycles
eval-1 gain
eval-2 cycles
eval-2 gain
eval-3 cycles
eval-3 gain
eval-4 cycles
eval-4 gain
Substring
24,607
10.65 ×
42,762
6.13 ×
4,122 †
63.59 ׆
4,121
63.61 ×
VecNormTrans
30,729
1.46 ×
6,199
7.26 ×
4,814
9.35 ×
3,127
14.39 ×
CNN
8,115
4.61 ×
14,278
2.62 ×
8,115
4.61 ×
4,105
9.11 ×
Atax
1,259
26.62 ×
977
34.30 ×
1,072 †
31.26 ׆
532
63.00 ×
Table 3. Contribution of eval-1, eval-2, eval-3, and eval-4.
Figure 8. Latency–resource trade-off on CNN. The red curve shows the Pareto frontier obtained by sweeping λ . A scatter plot shows the CNN trade-off between resource score on the horizontal axis and normalized latency on the vertical axis. Gray circles represent explored candidates, and a descending red curve connects the HLSClaw Pareto frontier. A star marks the resource-constrained endpoint at resource score 0.67 and normalized latency 1.00; another star marks a low-latency HLSClaw solution near resource score 11. A magnified inset compares this low-latency region with cross-shaped markers for HLSRewriter, HLSPilot, and ScaleHLS. Moving along the frontier reduces latency at the cost of greater resource use.
Model
NPUs
Tokens
Time (s)
Tokens/s
Qwen2.5-0.5B
1
93
4.57
20.35
openPangu-7B
1
92
7.18
12.81
Qwen2.5-32B
4
128
32.22
3.97
Table 4. Inference results of open-source LLMs on Huawei Ascend 910B1 NPUs.
Figure 9. Cycle-based latency speedup of HLSClaw using openPangu-7B and Qwen2.5-7B-Instruct on five benchmarks.
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-10x 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.51x geometric mean speedup over the SoTA pragma tuning tool and a 1.20x speedup over optimized open-source designs with less than 20% extra resources. AgRefactor is fully-automated and open-sourced.
Yang Zou, Zijian Ding, Yizhou Sun +1
1Carnegie Mellon University · University of California, Los Angeles
We present an empirical study of how far general-purpose coding agents -- without hardware-specific training -- can optimize hardware designs from high-level algorithmic specifications. We introduce an agent factory, a two-stage pipeline that constructs and coordinates multiple autonomous optimization agents. In Stage1, the pipeline decomposes a design into sub-kernels, independently optimizes each using pragma and code-level transformations, and formulates an Integer Linear Program (ILP) to assemble globally promising configurations under an area constraint. In Stage2, it launches N expert agents over the top ILP solutions, each exploring cross-function optimizations such as pragma recombination, loop fusion, and memory restructuring that are not captured by sub-kernel decomposition. We evaluate the approach on 12 kernels from HLS-Eval and Rodinia-HLS using Claude Code (Opus~4.5/4.6) with AMD Vitis HLS. Scaling from 1 to 10 agents yields a mean 8.27× speedup over baseline, with larger gains on harder benchmarks: streamcluster exceeds 20× and kmeans reaches approximately 10×. Across benchmarks, agents consistently rediscover known hardware optimization patterns without domain-specific training, and the best designs often do not originate from top-ranked ILP candidates, indicating that global optimization exposes improvements missed by sub-kernel search. These results establish agent scaling as a practical and effective axis for HLS optimization.
Application-specific FPGA accelerators offer substantial performance and energy-efficiency gains across many application domains, but developing them is costly, often requiring months of specialized effort. Even with high-level synthesis (HLS), designers still need extensive hardware expertise to build high-performance accelerators. Although large language models (LLMs) have demonstrated strong software-generation capabilities, even frontier models lack the hardware intuition and procedural knowledge needed to reliably translate baseline C/C++ programs into high-performance HLS designs: they struggle to identify effective architectures, follow the optimization processes used by HLS experts, and apply hardware transformations consistently across diverse kernels. We present HLSmith, an expert-guided framework for translating C/C++ programs into optimized HLS accelerators. HLSmith combines three components: an HLS optimization expertise library that encodes guarded transformation recipes, their applicability and prerequisite conditions, and unsafe cases to avoid; a staged, feedback-driven orchestration flow modeled on expert HLS development practice that guides agents through synthesis, bottleneck analysis, and optimization; and a tool-grounded model-adaptation pipeline that converts optimization trajectories from commercial frontier models into training data for fine-tuning open-weight LLMs. We evaluate HLSmith on PolyBench against ChatHLS, a leading prior agent-orchestration framework for HLS accelerator development. HLSmith achieves a geometric mean speedup of 4.24x over ChatHLS while producing functionally correct designs, in both software and RTL simulation, for every benchmark, compared with ChatHLS's 57% valid-design rate. It further reaches speedups of up to 252x and 138x with commercial frontier models and open-weight models, respectively.
Yuebo Luo, Ahmad Sedigh Baroughi, Philip Stachura +4
University of Minnesota Twin Cities · Simon Fraser University · Argonne National Laboratory