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

TL;DR

This paper introduces an automated framework to solve the massive data scarcity problem in AI-driven chip design. By using program analysis to align Verilog code with natural language and incorporating real-world EDA tool feedback, the authors fine-tuned Llama-2 models that outperform GPT-3.5 in hardware description language (HDL) generation and repair tasks.

What Problem Does This Paper Address?

While Large Language Models (LLMs) have revolutionized software engineering, they struggle with hardware design. The core issue is a "data desert": while there are billions of lines of Python or Java available for training, high-quality, open-source Verilog code is scarce.

Furthermore, a true "Chip Design Agent" needs to do more than just autocomplete code; it must understand natural language requirements, fix bugs based on compiler errors, and write scripts for Electronic Design Automation (EDA) tools. Existing models often fail because they lack "aligned" data—datasets that explicitly link a human's description to the specific logic of a Verilog module or a tool's error message to the necessary fix.

Methods

The authors propose a multi-stage automated design-data augmentation framework to bridge the gap between natural language and hardware code:

  1. Verilog Generation (AST-to-NL): Instead of relying on human-written comments, the framework uses ANTLR4 to parse Verilog into an Abstract Syntax Tree (AST). It then uses predefined rules to map these syntax nodes back into structured natural language descriptions (e.g., "This module has one trigger block... sensitive to the positive edge of clk").
  2. Verilog Repair (Error Injection): To teach the model how to debug, the framework programmatically introduces errors into healthy Verilog code (e.g., removing semicolons, changing bit-widths). It then runs these "broken" files through Yosys (an open-source logic synthesizer) to collect real error messages. The final training pair consists of: [Error Message + Broken Code] $\rightarrow$ [Correct Code].
  3. EDA Script Generation: For specialized tools like SiliconCompiler, the authors used GPT-3.5 to "reverse-engineer" natural language descriptions for existing Python-based EDA scripts, creating a high-quality synthetic dataset for fine-tuning.
  4. Fine-tuning: The researchers used LoRA (Low-Rank Adaptation) to fine-tune Llama-2 (7B and 13B versions) on the resulting massive synthetic dataset.

Datasets

The framework generated a staggering 3,671k (3.6 million) data entries.

  • Training Data: Sourced from GitHub and HuggingFace, then augmented via the methods above.
  • Evaluation Benchmarks: The models were tested against the Thakur et al. benchmark and RTLLM, which are standard sets for Verilog generation and repair.

Key Insights and Ideas

  • Structure over Randomness: The most significant "aha" moment is that program analysis (AST mapping) is far superior to naive code completion. By forcing the model to learn the relationship between specific syntax structures and their natural language definitions, the "semantic gap" is narrowed.
  • Feedback Loops Matter: Teaching a model to fix code using actual EDA tool feedback (like Yosys error logs) makes the model "grounded" in reality. It learns to act like a human engineer who iterates based on compiler output.
  • Small Data, Big Impact for Scripts: Interestingly, for EDA script generation, the authors found that fine-tuning on just 200 high-quality samples allowed their 13B model to outperform much larger general-purpose models.

Key Results

The fine-tuned model, dubbed ChipGPT-FT, showed impressive gains:

  • Verilog Generation: On the Thakur benchmark, the 13B model achieved a 70.6% pass rate, a significant jump from the previous state-of-the-art open-source model (58.8%) and even surpassing GPT-3.5 in specific hardware tasks.
  • Verilog Repair: The model improved repair accuracy by 37.9% compared to GPT-3.5 and 62.1% compared to the base Llama-2 model.
  • Alignment Benefit: Adding the "alignment stage" (AST-to-NL) increased the pass rate from 25.7% to 45.7% compared to simple code-completion training, proving that "data quality and alignment" are just as important as "data volume."

Limitations and Future Work

  • Rule-Based Constraints: The current AST-to-NL mapping relies on predefined rules that do not yet capture the full, complex syntax of all Verilog standards.
  • Computational Cost: While the augmentation is automated, generating millions of entries and running them through logic synthesizers like Yosys requires significant compute time.
  • Future Directions: The authors suggest expanding the framework to support more HDLs (like VHDL or Chisel) and integrating more complex EDA tool chains (like physical design and timing analysis) into the feedback loop.

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},
}

Loading related content...

Figure