ORFS-Agent is an LLM-based iterative optimization agent for automating parameter tuning in open-source hardware design flows. This implementation integrates with OpenROAD-flow-scripts (ORFS) to optimize chip design parameters using large language models that adaptively explore and refine parameter configurations.
The agent demonstrates improvements in wirelength and effective clock period by over 13% while using 40% fewer optimization iterations compared to baseline Bayesian optimization approaches. The framework is modular and model-agnostic, working with different LLMs without requiring fine-tuning.
The ORFS-Agent consists of several key components:
optimize.py
: Main optimization script that processes OpenROAD log files and coordinates the optimization workflowinspectfuncs.py
: Data analysis and inspection tools for understanding parameter space and design metricsmodelfuncs.py
: Machine learning utilities including Gaussian Process modeling, kernel selection, and preprocessingagglomfuncs.py
: Data aggregation and synthesis functions for combining results across multiple runsconstraint_optimizer.py
: Constraint handling and parameter space definitionprompts.py
: LLM prompt templates and interaction management
maindriver.sh
: Primary execution script that orchestrates the entire optimization workflowrun_sequential.sh
: Handles sequential optimization phases and parameter generationrun_parallel.sh
: Manages parallel execution of multiple design runsMakefile
: Modified OpenROAD Makefile supporting parallel runs with INT_PARAM configuration
opt_config.json
: Parameter constraints, ranges, and optimization settings for different design-PDK combinationsINSTRUCTIONS.md
: Setup and execution instructions
helperfuncs/csvmaker.py
: CSV data generation and formatting utilitieshelperfuncs/examine.py
: Data examination and validation toolshelperfuncs/fixall.sh
: Batch processing and cleanup utilities
- Multi-objective Optimization: Supports optimization of Effective Clock Period (ECP), wirelength (WL), or weighted combinations
- Parallel Execution: Efficient parallel processing of multiple design configurations
- Adaptive Parameter Exploration: LLM-guided parameter space exploration with constraint handling
- Multiple PDK Support: Supports ASAP7 and Sky130HD process design kits
- Circuit Flexibility: Works with various circuits including AES, IBEX, and JPEG
- OpenROAD-flow-scripts: Install and configure OpenROAD-flow-scripts from the specific commit (ce8d36a) referenced in the paper.
- Operating System: Ubuntu/Debian-based system (required)
- Hardware Resources:
- Minimum 8 vCPUs per parallel run
- 8+ GB RAM per parallel run (20-25GB for larger circuits like JPEG)
- For default configuration: 110 vCPUs and 220GB RAM total
# Create virtual environment
python3 -m venv .venv_orfs_agent
source .venv_orfs_agent/bin/activate
# Install required packages
pip install numpy pandas scikit-learn scipy anthropic python-dotenv scikit-optimize
The system requires the following Python packages:
numpy
- Numerical computingpandas
- Data manipulation and analysisscikit-learn
- Machine learning utilitiesscipy
- Scientific computinganthropic
- LLM API integration (if using Anthropic models)python-dotenv
- Environment variable managementscikit-optimize
- Bayesian optimization
# Install required system tools
sudo apt-get update
sudo apt-get install jq bc timeout
First, modify your OpenROAD Makefile to support parallel runs:
- Replace single
DESIGN_CONFIG
with multiple parametrized configurations. Instead of a singleconfig.mk
, the flow usesconfig_{INT_PARAM}.mk
to enable parallel runs. - Add
INT_PARAM
support for parallel execution. - Use the provided Makefile as a reference for required changes.
Edit opt_config.json
to define:
- Parameter Constraints: Valid ranges for each tunable parameter
- Optimization Weights: Relative importance of different metrics
- PDK-specific Settings: Process-dependent parameter bounds
Example configuration structure:
{
"parameter_constraints": {
"CORE_UTIL": {"type": "int", "range": [20, 99]},
"PIN_LAYER_ADJUST": {"type": "float", "range": [0.2, 0.7]}
},
"configurations": [
{
"platform": "asap7",
"design": "aes",
"goal": "COMBO",
"weights": {"ecp": 0.5, "dwl": 0.5}
}
]
}
Before running an optimization, you may need to adjust the config.mk
file for your chosen design, as the default files may not define all tunable parameters.
-
Placement Density: The
PLACE_DENSITY
variable in someconfig.mk
files must be replaced withLB_ADDON_PLACE_DENSITY
. Use the following values:- (aes, asap7): 0.3913
- (aes, sky130hd): 0.4936
- (ibex, sky130hd): 0.2
- (ibex, asap7): 0.2
- (jpeg, sky130hd): 0.15
- (jpeg, asap7): 0.4127
-
TCL Scripts: Ensure you are using the provided custom TCL scripts (
fastasap.tcl
,fastsky.tcl
). You must link these in theconfig.mk
file for your design. Refer to the example configuration changes inexampleaes/configchanges.mk
for guidance.
Configure resource allocation in maindriver.sh
:
TOTAL_ITERS=6 # Number of serial optimization iterations
PARALLEL_RUNS=50 # Parallel runs per iteration
TIMEOUT="45m" # Timeout per run
TOTAL_CPUS=110 # Total available vCPUs
TOTAL_RAM=220 # Total available RAM (GB)
ECP_WEIGHT=0.5 # Weight for ECP in the final objective
WL_WEIGHT=0.5 # Weight for Wirelength in the final objective
ECP_WEIGHT_SURROGATE=0.5 # Weight for post-CTS ECP in the surrogate model
WL_WEIGHT_SURROGATE=0.5 # Weight for post-CTS WL in the surrogate model
The agent requires API keys for LLM providers. You will need to add them directly into the source code:
- Anthropic API Key: In
optimize.py
, find the placeholder for the Anthropic API key and insert your key. - OpenAI API Key: In
prompts.py
, find the placeholder for the OpenAI API key and insert your key. This is required for prompt generation functionalities.
Note: For improved security, consider modifying the scripts to load keys from environment variables using the python-dotenv
package.
# Make scripts executable
chmod +x maindriver.sh run_parallel.sh run_sequential.sh
# Run optimization
./maindriver.sh -p <platform> -d <design> [options]
-p, --platform
: Target PDK (asap7
orsky130hd
)-d, --design
: Circuit design (aes
,ibex
, orjpeg
)-i, --iterations
: Number of optimization iterations (default: 6)-r, --parallel-runs
: Parallel runs per iteration (default: 50)-t, --timeout
: Timeout per run (default: 45m)-o, --objective
: Optimization goal (ECP
,DWL
, orCOMBO
)
# Optimize AES circuit on ASAP7 for ECP
./maindriver.sh -p asap7 -d aes -o ECP
# Optimize IBEX on Sky130HD with custom settings
./maindriver.sh -p sky130hd -d ibex -o COMBO -i 8 -r 30 -t 60m
# Large circuit optimization (JPEG)
./maindriver.sh -p asap7 -d jpeg -o DWL -r 20 -t 90m
Each optimization run generates:
-
../result_dump_<iteration>/
: Archived results for each iterationconfig_*.mk
: Generated configuration filesconstraint_*.sdc
: Timing constraint fileslogs_dump/
: OpenROAD execution logsresults_dump/
: Synthesis and P&R results
-
logs/
: Real-time execution logs organized by platform/design -
CSV files: Parameter configurations and results tracking
This project is licensed under the BSD 3-Clause License. See the LICENSE
file for details.
This work is based on the research paper:
ORFS-agent: Tool-Using Agents for Chip Design Optimization
Amur Ghose, Andrew B. Kahng, Sayak Kundu, and Zhiang Wang
University of California San Diego
arXiv:2506.08332v1 [cs.AI] 12 Jun 2025 | MLCAD 2025
Available at: https://arxiv.org/pdf/2506.08332
For the purposes of replication or usage, you may be interested in using this as a flow within OR-AutoTuner, OpenROAD's official BO tool.
Look within the AutoTuner-integration folder for an example of this. Within the ORFS-with-AutoTuner subdirectory, a more streamlined version of ORFS-agent appears in orfs_agent.py, which can be useful if you wish to run your experiments with a restrictive time and/or token budget.
Note that the results of the original paper were obtained with Claude-3.5 Sonnet and you must ensure that your key for replication and/or running of the tool can support frequent tool calls to the model.