Table of Contents
Fetching ...

Optimizing High-Level Synthesis Designs with Retrieval-Augmented Large Language Models

Haocheng Xu, Haotian Hu, Sitao Huang

TL;DR

This work proposes a novel retrieval-augmented LLM-based approach to effectively optimize high-level synthesis (HLS) programs, and proposes a unique framework, Retrieve Augmented Large Language Model Aided Design (RALAD), designed to enhance LLMs’ performance in HLS code optimization tasks.

Abstract

High-level synthesis (HLS) allows hardware designers to create hardware designs with high-level programming languages like C/C++/OpenCL, which greatly improves hardware design productivity. However, existing HLS flows require programmers' hardware design expertise and rely on programmers' manual code transformations and directive annotations to guide compiler optimizations. Optimizing HLS designs requires non-trivial HLS expertise and tedious iterative process in HLS code optimization. Automating HLS code optimizations has become a burning need. Recently, large language models (LLMs) trained on massive code and programming tasks have demonstrated remarkable proficiency in comprehending code, showing the ability to handle domain-specific programming queries directly without labor-intensive fine-tuning. In this work, we propose a novel retrieval-augmented LLM-based approach to effectively optimize high-level synthesis (HLS) programs. Our proposed method leverages few-shot learning, enabling large language models to adopt domain-specific knowledge through natural language prompts. We propose a unique framework, Retrieve Augmented Large Language Model Aided Design (RALAD), designed to enhance LLMs' performance in HLS code optimization tasks. RALAD employs advanced embedding techniques and top-\emph{k} search algorithms to dynamically source relevant knowledge from extensive databases, thereby providing contextually appropriate responses to complex programming queries. Our implementation of RALAD on two specialized domains, utilizing comparatively smaller language models, achieves an impressive 80\% success rate in compilation tasks and outperforms general LLMs by 3.7 -- 19$\times$ in latency improvement.

Optimizing High-Level Synthesis Designs with Retrieval-Augmented Large Language Models

TL;DR

This work proposes a novel retrieval-augmented LLM-based approach to effectively optimize high-level synthesis (HLS) programs, and proposes a unique framework, Retrieve Augmented Large Language Model Aided Design (RALAD), designed to enhance LLMs’ performance in HLS code optimization tasks.

Abstract

High-level synthesis (HLS) allows hardware designers to create hardware designs with high-level programming languages like C/C++/OpenCL, which greatly improves hardware design productivity. However, existing HLS flows require programmers' hardware design expertise and rely on programmers' manual code transformations and directive annotations to guide compiler optimizations. Optimizing HLS designs requires non-trivial HLS expertise and tedious iterative process in HLS code optimization. Automating HLS code optimizations has become a burning need. Recently, large language models (LLMs) trained on massive code and programming tasks have demonstrated remarkable proficiency in comprehending code, showing the ability to handle domain-specific programming queries directly without labor-intensive fine-tuning. In this work, we propose a novel retrieval-augmented LLM-based approach to effectively optimize high-level synthesis (HLS) programs. Our proposed method leverages few-shot learning, enabling large language models to adopt domain-specific knowledge through natural language prompts. We propose a unique framework, Retrieve Augmented Large Language Model Aided Design (RALAD), designed to enhance LLMs' performance in HLS code optimization tasks. RALAD employs advanced embedding techniques and top-\emph{k} search algorithms to dynamically source relevant knowledge from extensive databases, thereby providing contextually appropriate responses to complex programming queries. Our implementation of RALAD on two specialized domains, utilizing comparatively smaller language models, achieves an impressive 80\% success rate in compilation tasks and outperforms general LLMs by 3.7 -- 19 in latency improvement.

Paper Structure

This paper contains 12 sections, 5 figures, 2 tables.

Figures (5)

  • Figure 1: (left) Original HLS C code; (middle) Code-Llama-13B + RAG generated HLS C code; (right) GPT-3.5 + RAG generated HLS C code.
  • Figure 2: The Overview of Our Proposed RALAD HLS Code Optimization Framework
  • Figure 3: The Structure of Input Prompts
  • Figure 4: We ignore the initialization part of the query code, only extract the main loops as input, as shown in the yellow part of the graph
  • Figure 5: Manual Annotations: We add hints to the prompt manually by human experts to enhance the performance of the generator