Data is all you need: Finetuning LLMs for Chip Design via an Automated design-data augmentation framework

Kaiyan Chang, Kun Wang, Nan Yang, Ying Wang, Dantong Jin, Wenlong Zhu, Zhirong Chen, Cangyuan Li, Hao Yan, Yunhao Zhou, Zhuoliang Zhao, Yuan Cheng, Yudong Pan, Yiqi Liu, Mengdi Wang, Shengwen Liang, Yinhe Han, Huawei Li, Xiaowei Li · DOI · OpenReview

Abstract

Recent advances in large language models (LLMs) have demonstrated significant potential for automating hardware description language (HDL) generation. However, the field of chip design faces a critical "data desert," where the scarcity of high-quality Verilog and Electronic Design Automation (EDA) script data limits the performance of these models. This paper introduces an automated design-data augmentation framework designed to generate high-volume, high-quality natural language descriptions aligned with Verilog and EDA scripts. By utilizing Abstract Syntax Tree (AST) mapping for code generation, error injection for code repair, and synthetic description generation for EDA scripts, we produced a dataset of 3.6 million entries. Fine-tuning Llama-2 models (7B and 13B) on this data resulted in ChipGPT-FT, which achieves a 70.6% pass rate on Verilog generation benchmarks, surpassing both the previous state-of-the-art open-source models and GPT-3.5 in specific hardware tasks.

Introduction

While LLMs have revolutionized software engineering by leveraging billions of lines of code from repositories like GitHub, hardware design remains a challenging frontier. The primary bottleneck is the lack of aligned data—datasets that explicitly link human requirements to specific hardware logic or link tool error messages to the necessary code fixes. To address this, we propose an automated framework that bridges the semantic gap between natural language and hardware code, enabling the creation of specialized "Chip Design Agents."

The Automated Design-Data Augmentation Framework

Our framework employs three distinct strategies to generate training data for different aspects of the chip design flow:

1. Verilog Generation: AST-to-NL Mapping

To move beyond simple code completion, we developed a method to align Verilog code with structured natural language. Using ANTLR4, we parse Verilog files into an Abstract Syntax Tree (AST). We then apply predefined rules to map these syntax nodes to natural language descriptions. For example, a specific trigger block in the code is translated into a description such as: "This module has one trigger block... sensitive to the positive edge of clk." This ensures the model learns the structural logic of the hardware rather than just statistical patterns.

2. Verilog Repair: Error Injection and Tool Feedback

Hardware engineers spend a significant portion of their time debugging. To train the model in this skill, we programmatically introduce errors (e.g., syntax errors, bit-width mismatches) into functional Verilog code. These "broken" files are processed through Yosys, an open-source logic synthesizer, to collect real-world error messages. The resulting training pairs—comprising the error message, the broken code, and the corrected version—teach the model to ground its repairs in actual EDA tool feedback.

3. EDA Script Generation

For specialized tools like SiliconCompiler, we utilized GPT-3.5 to reverse-engineer natural language descriptions for existing Python-based EDA scripts. This created a high-quality synthetic dataset that allows the model to understand how to configure and run complex design flows.

Experimental Results

We fine-tuned Llama-2 (7B and 13B) using LoRA (Low-Rank Adaptation) on a dataset of 3.6 million entries. The resulting model, ChipGPT-FT, was evaluated against standard benchmarks including the Thakur et al. benchmark and RTLLM.

Verilog Generation Performance

ChipGPT-FT (13B) achieved a 70.6% pass rate on the Thakur benchmark. This represents a substantial improvement over the previous state-of-the-art open-source Verilog model, which stood at 58.8%. Notably, the "alignment stage" (AST-to-NL) was crucial; models trained with this alignment saw their pass rates jump from 25.7% to 45.7% compared to those trained on raw code alone.

Verilog Repair and EDA Scripting

The model demonstrated a 37.9% improvement in repair accuracy compared to GPT-3.5 and a 62.1% improvement over the base Llama-2 model. Furthermore, in EDA script generation, fine-tuning on just 200 high-quality samples allowed the 13B model to outperform much larger general-purpose models, highlighting the efficiency of targeted data augmentation.

Conclusion

This work demonstrates that for specialized domains like chip design, data quality and alignment are as vital as data volume. By automating the generation of high-fidelity, tool-grounded datasets, we can significantly enhance the capabilities of LLMs in hardware engineering. Future work will focus on expanding the framework to support additional HDLs like VHDL and Chisel, as well as integrating more complex stages of the EDA toolchain, such as physical design and timing analysis.

Summary updated

BibTeX
@inproceedings{chang2024data,
  author = {Kaiyan Chang and Kun Wang and Nan Yang and Ying Wang and Dantong Jin and Wenlong Zhu and Zhirong Chen and Cangyuan Li and Hao Yan and Yunhao Zhou and Zhuoliang Zhao and Yuan Cheng and Yudong Pan and Yiqi Liu and Mengdi Wang and Shengwen Liang and Yinhe Han and Huawei Li and Xiaowei Li},
  title = {{Data is all you need: Finetuning LLMs for Chip Design via an Automated design-data augmentation framework}},
  booktitle = {DAC},
  year = {2024},
  doi = {10.1145/3649329.3657356},
}
Figure