Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MappingEvolve (LODCE)

LLM-Driven Technology Mapping Algorithm Kernel Evolution Framework

Let LLMs evolve C++ technology mapping kernels β€” not generate scripts, but directly rewrite the compare_map logic inside production-grade EDA algorithms.

License C++17 Python


πŸ“– Overview

MappingEvolve is a hierarchical LLM-driven framework that automatically evolves the core algorithm kernels of technology mapping in logic synthesis. Instead of using LLMs as script generators, it lets them directly modify C++ source code within designated EVOLVE-BLOCK regions, then validates each modification through a three-stage pipeline: Compilation β†’ Equivalence Checking β†’ QoR Evaluation.

Metric Improvement
vs. OpenEvolve (direct evolution) 11.5Γ— higher reward
vs. ABC (area) 10.04% area reduction
Equivalence failures 0% (vs. 9% for OpenEvolve)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Planner LLM  │────▢│  Evolver LLM  │────▢│  Evaluator       β”‚
β”‚  (Scheduler)  β”‚     β”‚  (Code Writer)β”‚     β”‚  Build + CEC +   β”‚
β”‚               │◀────│               │◀────│  QoR Scoring     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β–²                                            β”‚
      └──────────── Reward Feedback β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The framework modifies three algorithmic operators within EVOLVE-BLOCK regions:

Operator File Role
Match Phase match_phase.cpp Delay/area-flow optimization with dual-mode compare
Exact Match match_phase_exact.cpp ELA-based exact area with switch-activity awareness
Drop Phase match_drop_phase.cpp Phase unification across complemented outputs

πŸ“ Project Structure

MappingEvolve/
β”‚
β”œβ”€β”€ evolve_single/             # Single-point sequential evolution (main framework)
β”‚   β”œβ”€β”€ proactive_single_point_evolve.py  # Entry: Planner β†’ Evolver iterative loop
β”‚   β”œβ”€β”€ prompts_optimized.py   # Optimized prompts with trend/stagnation/diversity signals
β”‚   β”œβ”€β”€ query_llm.py           # LLM API client
β”‚   └── openevolve_config.yaml # OpenEvolve configuration
β”‚
β”œβ”€β”€ mapping/                   # C++ Technology Mapper + Python Evaluator
β”‚   β”œβ”€β”€ mapping.hpp            # Core mapper (based on mockturtle)
β”‚   β”œβ”€β”€ main.cpp               # CLI + ISCAS85/EPFL benchmark harness
β”‚   β”œβ”€β”€ match_phase.cpp        # Operator 1: delay/area-flow optimization
β”‚   β”œβ”€β”€ match_phase_exact.cpp  # Operator 2: exact area optimization
β”‚   β”œβ”€β”€ match_drop_phase.cpp   # Operator 3: phase unification
β”‚   β”œβ”€β”€ evaluator.py           # Build β†’ Run β†’ Score evaluation pipeline
β”‚   └── CMakeLists.txt
β”‚
β”œβ”€β”€ openevolve/                # OpenEvolve integration
β”‚   β”œβ”€β”€ ccode/                 # C++ template code & assembly utilities
β”‚   β”œβ”€β”€ configs/               # Evolution configurations
β”‚   └── examples/              # OpenEvolve usage examples
β”‚
β”œβ”€β”€ output/                    # Evolution run outputs (proactive_evolve_*/)
β”œβ”€β”€ scripts/                   # Analysis utilities (aggregation, plotting)
β”œβ”€β”€ third-party/mockturtle/    # mockturtle logic synthesis library (submodule)
β”œβ”€β”€ build.sh                   # Build script
β”œβ”€β”€ CMakeLists.txt             # Top-level CMake
└── requirements.txt           # Python dependencies

πŸ”§ Prerequisites

System

  • Linux (Ubuntu 20.04+ recommended)
  • GCC 9+ or Clang 10+ with C++17 support
  • CMake 3.16+
  • CUDA 11.8 / 12.1 (for PyTorch, optional for evolution)

Python

# CUDA 12.1
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121
pip install -f https://data.pyg.org/whl/torch-2.4.0+cu121.html torch_scatter==2.1.2

# CUDA 11.8
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu118
pip install -f https://data.pyg.org/whl/torch-2.4.0+cu118.html torch_scatter==2.1.2

Install remaining dependencies:

pip install -r requirements.txt

C++ Libraries

The mockturtle submodule is included β€” no separate installation needed:

git submodule update --init --recursive

OpenEvolve (Evolver Component)

MappingEvolve uses OpenEvolve as its code evolution engine:

pip install openevolve==0.2.18

πŸš€ Quick Start

1. Build the Mapper

./build.sh
# Or manually:
# mkdir build && cd build && cmake .. && make -j$(nproc)

2. Run Technology Mapping

./build/mapping/mapping \
    third-party/mockturtle/experiments/cell_libraries/asap7.genlib \
    third-party/mockturtle/experiments/benchmarks/adder.aig \
    adder.v

Output:

[i] WARNING: 11 gates IGNORED (e.g., OA333x2_ASAP7_75t_R), too many inputs for the library settings
{"area": 92.420000, "gates": 890.000000, "delay": 2574.359997, "depth": 128.000000, "runtime": 0.055223, "nec": 0.000000}

3. Run MappingEvolve (Planner + OpenEvolve Evolver)

# Configure LLM credentials in evolve_single/openevolve_config.yaml first
python3 evolve_single/proactive_single_point_evolve.py --openevolve

The evolution framework follows the hierarchical Planner→Evolver→Evaluator loop:

  1. Planner (LLM): Analyzes recent performance history and adaptive signals β†’ selects operator + strategy
  2. Evolver (OpenEvolve): Receives the Planner's evolution plan β†’ population-based code evolution within EVOLVE-BLOCK regions
  3. Evaluator: Merges evolved operator with unchanged operators β†’ Build β†’ Equivalence Check (ABC cec) β†’ QoR Scoring on ISCAS85
  4. Decide: Dual-criteria acceptance policy (reward threshold + delay protection) β†’ accept or revert

4. Run OpenEvolve Baselines (Standalone)

To reproduce the paper's OpenEvolve baseline (directly evolve a single operator without Planner guidance).

Note: The local openevolve/ directory shadows the pip-installed openevolve package.
Use python3 -c "from openevolve.cli import main; main()" to invoke the CLI.

cd MappingEvolve

# Evolve MatchPhase operator for 90 iterations
nohup python3 -c "from openevolve.cli import main; main()" \
    --config evolve_single/openevolve_config.yaml \
    --output output/openevolve_match_phase \
    --iterations 90 \
    openevolve/mapping/match_phase.cpp \
    openevolve/mapping/evaluator.py \
    > openevolve.log 2>&1 &

# Evolve MatchPhaseExact operator
nohup python3 -c "from openevolve.cli import main; main()" \
    --config evolve_single/openevolve_config.yaml \
    --output output/openevolve_match_phase_exact \
    --iterations 90 \
    openevolve/mapping/match_phase_exact.cpp \
    openevolve/mapping/evaluator.py \
    > openevolve_exact.log 2>&1 &

# Evolve MatchDropPhase operator
nohup python3 -c "from openevolve.cli import main; main()" \
    --config evolve_single/openevolve_config.yaml \
    --output output/openevolve_match_drop_phase \
    --iterations 90 \
    openevolve/mapping/match_drop_phase.cpp \
    openevolve/mapping/evaluator.py \
    > openevolve_drop.log 2>&1 &

Alternatively, use --openevolve flag in MappingEvolve for Planner-guided evolution:

python3 evolve_single/proactive_single_point_evolve.py --openevolve

βš™οΈ Configuration

LLM Backend (evolve_single/query_llm.py / evolve/query_llm.py)

Configure your LLM endpoint via environment variables or directly in code:

MODEL = "deepseek-v3-241226"          # Model name
API_KEY = "your-api-key"              # API key
BASE_URL = "https://api.example.com"  # OpenAI-compatible endpoint

Evolution Parameters (evolve_single/proactive_single_point_evolve.py)

Parameter Default Description
num_iterations 30 Total evolution iterations
initial_temperature 1.0 Temperature for LLM sampling
revert_threshold -0.1 Minimum reward to accept a change
window_size 5 Sliding window for trend analysis

Mapper Parameters (mapping/mapping.hpp)

Parameter Default Description
cut_limit 49 Maximum cut size for enumeration
area_rounds 3 Number of area optimization rounds
exact_area_rounds 2 Number of exact area rounds
mapping_type AreaOnly Mapping mode (AreaOnly / DelayOnly)

πŸ“Š Output Structure

Each evolution run produces a timestamped directory:

output/proactive_evolve_llm_deepseek-v3_20251118_105209/
β”œβ”€β”€ log.txt                     # Full run log
β”œβ”€β”€ summary.json                # Best reward & iteration
β”œβ”€β”€ iter_1/
β”‚   β”œβ”€β”€ planner_input.txt       # Full context sent to Planner
β”‚   β”œβ”€β”€ planner_output.txt      # Raw Planner response
β”‚   β”œβ”€β”€ plan.json               # Parsed evolution plan
β”‚   β”œβ”€β”€ evolver_output.txt      # Raw Evolver response
β”‚   β”œβ”€β”€ evolved_*.cpp           # Evolved operator code
β”‚   β”œβ”€β”€ reward.json             # Evaluation scores
β”‚   └── evolved_mapping/        # Assembled full mapping code
β”œβ”€β”€ iter_2/ ...
└── iter_N/ ...

πŸ§ͺ Evaluation & Scoring

The evaluation pipeline runs on standard benchmarks:

Benchmark Suite Circuits
ISCAS85 c17, c432, c499, c880, c1355, c1908, c2670, c3540, c5315, c6288, c7552
EPFL adder, arbiter, bar, cavlc, ctrl, dec, div, int2float, log2, max, mem_ctrl, multiplier, priority, router, sin, sqrt, square, voting, i2c, mem_ctrl

Scoring Function: $S_{overall} = 0.5 \cdot S_{area} + 0.5 \cdot S_{delay}$

Safety Guarantees:

  • Compilation failure β†’ penalty (-0.5)
  • Equivalence check failure (ABC cec) β†’ penalty (-0.4 to -0.5)
  • Degradation below threshold β†’ rejected and reverted

πŸ“ˆ Analysis Tools

# Aggregate results across multiple runs
python scripts/aggregate_evolution_results.py

# Plot reward curves
python scripts/plot_rewards.py

πŸ™ Acknowledgments

This project builds upon:

  • mockturtle β€” C++ logic synthesis framework
  • OpenEvolve β€” Code evolution library
  • ABC β€” System for sequential synthesis and verification
  • ASAP7 standard cell library

οΏ½ Citation

If you use MappingEvolve in your research, please cite our paper:

@inproceedings{fu2026mappingevolve,
  author    = {Fu, Rongliang and Liu, Yi and Xu, Qiang and Ho, Tsung-Yi},
  booktitle = {Proceedings of the 63rd ACM/IEEE Design Automation Conference (DAC)},
  title     = {{MappingEvolve}: {LLM}-Driven Code Evolution for Technology Mapping},
  year      = {2026},
  volume    = {},
  number    = {},
  pages     = {1-7},
  doi       = {10.1145/3770743.3803988}
}

οΏ½πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages