HGNN-Part is a deep learning framework for hypergraph partitioning that leverages Variational Graph Autoencoders (VGAE) with hypergraph convolutions. This project provides an end-to-end solution for partitioning large-scale hypergraphs, commonly used in VLSI circuit design, using graph neural networks to learn optimal partition assignments while minimizing cut size and maintaining balance constraints.
- Deep Learning-Based Partitioning: Uses Variational Graph Autoencoders (VGAE) with specialized hypergraph convolutions
- Multi-Objective Optimization: Simultaneously optimizes for minimum cut, partition balance, and reconstruction quality
- Scalable Architecture: Handles large-scale hypergraphs with thousands of nodes and hyperedges
- Flexible Framework: Supports both graph and hypergraph inputs with configurable model architectures
- Integration with Traditional Methods: Can be combined with traditional partitioners (KaHyPar, hMETIS) for refinement
- Installation
- Quick Start
- Dataset Format
- Model Architecture
- Training
- Evaluation
- Project Structure
- Configuration
git clone https://github.com/THU-numbda/HGNN-Part.git
cd HGNN-Partpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtPlace your hypergraph files (.hgr format) in the data/ directory. The project includes ISPD benchmark circuits (ibm01-ibm18) for testing.
python train.py --lr 5e-4 --epochs 50 --latent_dim 64 --hidden_dim 256python test.py --filename ibm02.hgr --modelname model.pt --use_sketchbash script.sh # Tests on all IBM98 benchmark circuitsThe project uses the standard hypergraph format:
<num_hyperedges> <num_nodes>
<node_1_of_edge_1> <node_2_of_edge_1> ...
<node_1_of_edge_2> <node_2_of_edge_2> ...
...
Example:
3 4
1 2 3
2 4
1 3 4
This represents a hypergraph with 4 nodes and 3 hyperedges.
For training, hypergraphs are converted to PyTorch Geometric HyperData objects with:
x: Node features (7-dimensional by default)hyperedge_index: Sparse representation of hyperedge connections
-
VariationalEncoder:
- Multi-layer hypergraph convolutions
- Masked node feature learning (20% masking during training)
- Outputs mean (μ) and standard deviation (σ) for latent distribution
-
PartitionDecoder:
- MLP-based decoder
- Maps latent representations to partition assignments
- Softmax output for probabilistic partition assignment
-
Loss Functions:
- KL Divergence Loss: Regularizes the latent space
- Normalized Cut Loss: Minimizes hyperedge cuts
- Balance Loss: Ensures balanced partition sizes
- Combined loss:
α * KL + β * NCut + γ * Balance
- GraphPartitionModel: Standard VGAE with configurable depth
- NewVariationalEncoder: Enhanced version with LayerNorm and residual connections
python train.py \
--lr 5e-4 \
--alpha 5e-4 \ # KL loss weight
--beta 0.5 \ # Normalized cut loss weight
--gamma 100 \ # Balance loss weight
--epochs 50 \
--latent_dim 64 \
--hidden_dim 256 \
--cuda 0| Parameter | Default | Description |
|---|---|---|
--lr |
5e-4 | Learning rate |
--alpha |
5e-4 | KL divergence loss weight |
--beta |
0.5 | Normalized cut loss weight |
--gamma |
100 | Balance loss weight |
--epochs |
50 | Number of training epochs |
--latent_dim |
64 | Latent space dimensionality |
--hidden_dim |
256 | Hidden layer dimensionality |
--cuda |
0 | GPU device ID |
- Early Stopping: Automatically stops when validation loss plateaus
- Best Model Saving: Saves the model with minimum normalized cut loss
- Memory Monitoring: Tracks peak GPU memory usage
- Loss Tracking: Monitors individual loss components
python test.py \
--filename ibm02.hgr \
--modelname model.pt \
--num_partitions 2 \
--latent_dim 64 \
--hidden_dim 256 \
--use_sketch \ # Enable sketch-based preprocessing
--cuda 0- Cutsize: Number of hyperedges cut by the partition
- Imbalance: Deviation from perfectly balanced partitions
- Runtime: Preprocessing, inference, and refinement times
The test script performs:
- Initial partitioning with spectral methods
- Multiple samples from the learned model (default: 12 samples per iteration)
- V-Cycle refinement using traditional partitioners
- Iterative improvement over multiple rounds (default: 11 iterations)
HGNN-Part/
├── config.py # Path configuration and management
├── models.py # Neural network architectures
├── train.py # Training script
├── test.py # Evaluation script
├── utils.py # Utility functions (preprocessing, evaluation)
├── script.sh # Batch testing script
├── requirements.txt # Python dependencies
├── data/ # Hypergraph datasets (.hgr files)
│ ├── ibm01.hgr
│ ├── ibm02.hgr
│ └── ...
├── exec/ # External partitioning tools
│ ├── KaHyPar
│ ├── hmetis
│ └── ...
└── models/ # Saved model checkpoints
The project uses a centralized path configuration system:
from config import paths
# Access data files
data_file = paths.get_data_path("ibm01.hgr")
# Access model files
model_file = paths.get_model_path("model.pt")
# Access partition files
partition_file = paths.get_partition_file_path("ibm01", suffix="part.2")Models are saved with configuration in filename:
model.<lr>.<alpha>.<beta>.<gamma>.<latent_dim>.<hidden_dim>.pt
Example: model.5e-04.5e-04.5e-01.1e+02.64.256.pt
[1] Shengbo Tong, Rufan Zhou, Chunyan Pei, and Wenjian Yu, "HGNN-Part: A high-quality hypergraph partitioner based on hypergraph generative model," in Proc. Design, Automation & Test in Europe Conference (DATE), Verona, Italy, Apr. 2026.