Research Question: Can a Graph Neural Network predict circuit power better than traditional ML because circuits are naturally graphs?
A clean, student-level benchmark that demonstrates the advantage of GraphSAGE over a Random Forest baseline on a synthetic gate-level power prediction task, using a controlled Isomer Pair dataset.
| Model | MAE | RMSE | R² Score |
|---|---|---|---|
| Random Forest | 36.64 | 41.41 | 0.1205 |
| GraphSAGE (GNN) | 9.88 | 14.19 | 0.8966 |
GraphSAGE achieves 3.7× lower MAE and an R² of 0.897 vs the Random Forest's 0.12 on the Isomer Pair benchmark — demonstrating that graph structure is critical for accurate power prediction when topology drives the power behaviour.
A digital circuit is naturally a Directed Acyclic Graph (DAG):
- Nodes = logic gates (AND, OR, NOT, NAND, NOR, XOR)
- Edges = signal wires (directed: driver gate → receiver gate)
Traditional ML models like Random Forest cannot process graphs. They flatten the circuit into aggregate statistics (e.g. average gate count, average capacitance), irreversibly losing the structural information about which gates are connected to which.
GraphSAGE learns directly from the graph by passing messages along the wires — each gate aggregates information from its direct neighbours, giving the model a structural awareness that tabular models fundamentally cannot have.
To rigorously prove the GNN's structural advantage, we use an Isomer Pair benchmark.
Each pair consists of two circuits (A and B) with identical aggregate statistics:
| Feature | Circuit A | Circuit B |
|---|---|---|
| Gate count | ✓ Same | ✓ Same |
| Wire count | ✓ Same | ✓ Same |
| Avg capacitance | ✓ Same | ✓ Same |
| Avg fan-in | ✓ Same | ✓ Same |
| Avg fan-out | ✓ Same | ✓ Same |
The only difference is the wiring of three specific gates:
- Circuit A (Hotspot): A high-capacitance gate drives another high-capacitance gate → 2× power spike
- Circuit B (Safe): The high-capacitance gate is routed safely to a low-capacitance gate → normal power
Because the Random Forest receives identical inputs for both circuits, it is provably unable to distinguish them and must predict the same power for both. The GraphSAGE model sees the actual edge connections and correctly identifies the hotspot.
gate-level-power-gnn/
│
├── data/ # Generated dataset (created at runtime)
│
├── models/
│ ├── graphsage.py # GraphSAGE power predictor (3-layer SAGEConv)
│ └── random_forest.py # Random Forest tabular baseline
│
├── scripts/
│ ├── generate_dataset.py # Isomer Pair DAG generator
│ └── train_model.py # Training + evaluation pipeline
│
├── utils/
│ ├── preprocessing.py # Z-score normalisation + train/val/test split
│ └── metrics.py # MAE, RMSE, R² computation
│
├── requirements.txt
└── README.md
Input (10 node features)
→ Linear(192) → ReLU [input projection]
→ SAGEConv(192→192) → BN → ReLU [message passing layer 1]
→ SAGEConv(192→192) → BN → ReLU [message passing layer 2]
→ SAGEConv(192→192) → BN → ReLU [message passing layer 3]
→ Global Mean Pool [aggregate nodes → graph vector]
→ Linear(192→96) → ReLU → Dropout
→ Linear(96→1) [power prediction]
Trained on 5 tabular features extracted from each graph:
- Number of gates
- Number of wires
- Average fan-in
- Average fan-out
- Average capacitance
# Clone the repository
git clone https://github.com/ansh07verma/gate-level-power-gnn.git
cd gate-level-power-gnn
# Install dependencies
pip install -r requirements.txtGPU Note: Training defaults to CPU. To enable GPU, set
FORCE_CPU = Falseinscripts/train_model.py.
python scripts/generate_dataset.pyGenerates 2,500 isomer pairs (5,000 total circuits) and saves them to data/circuit_power_dataset.pt.
python scripts/train_model.pyTrains both the GraphSAGE model and the Random Forest baseline, then prints a side-by-side comparison table of MAE, RMSE, and R² on the held-out test set.
| Hyperparameter | Value |
|---|---|
| Optimiser | Adam |
| Learning rate | 0.001 |
| Batch size | 32 |
| Max epochs | 200 |
| Early stopping patience | 25 |
| GNN hidden dim | 192 |
| GNN layers | 3 |
| Dropout | 0.1 |
| Loss function | MSELoss |
| Random seed | 42 |
The dataset is a controlled synthetic benchmark, not a real EDA dataset. The power formula was designed so that the answer depends on specific edge-level topology, while the tabular features are equalised to be identical for both isomers. This isolates the contribution of graph structure to the prediction task.
This is standard practice in GNN research (see: "How Powerful Are Graph Neural Networks?", Xu et al. 2019) and is presented transparently here.
torch>=2.0.0
torch_geometric>=2.3.0
numpy>=1.24.0
scikit-learn>=1.2.0
networkx>=3.0.0
tqdm>=4.65.0
MIT License — feel free to use and adapt for your own coursework or research.