Mt-KaHyPar (Multi-Threaded Karlsruhe Hypergraph Partitioner) is a shared-memory multilevel graph and hypergraph partitioner equipped with parallel implementatio
Mt-KaHyPar (Multi-Threaded Karlsruhe Hypergraph Partitioner) is a shared-memory multilevel graph and hypergraph partitioner equipped with parallel implementatio
Mt-KaHyPar - Multi-Threaded Karlsruhe Graph and Hypergraph Partitioner
| License | Linux, MacOS & Windows Build | Code Coverage | Zenodo |
|---|---|---|---|
Mt-KaHyPar is a shared-memory algorithm for partitioning graphs and hypergraphs. The balanced (hyper)graph partitioning problem asks for a partition of the node set of a (hyper)graph into k disjoint blocks of roughly the same size (usually a small imbalance is allowed by at most 1 + ε times the average block weight), while simultaneously minimizing an objective function defined on the (hyper)edges. Mt-KaHyPar can optimize the cut-net, connectivity, sum-of-external-degrees, and Steiner tree metric (see Supported Objective Functions).
The highest-quality configuration of Mt-KaHyPar computes partitions that are on par with those produced by the best sequential partitioning algorithms, while being almost an order of magnitude faster with only ten threads (e.g., when compared to KaFFPa or KaHyPar). Besides our high-quality configuration, we provide several other faster configurations that are already able to outperform most of the existing partitioning algorithms with regard to solution quality and running time. The figure below summarizes the time-quality trade-off of different hypergraph (left, connectivity metric) and graph partitioning algorithms (right, cut-net metric). The plot is based on an experiment with over 800 graphs and hypergraphs and relates the average solution quality and running time of each algorithm to the best achievable results. Points on the lower-left are considered better. Partially transparent markers indicate solvers producing more than 15% infeasible partitions (either imbalanced or timeout). For more details, we refer the reader to our publications.
Besides its fast and high-quality partitioning algorithm, Mt-KaHyPar provides many other useful features:
For Linux and MacOS, the Mt-KaHyPar Python package can be installed via pip:
pip install mtkahyparWe also provide Debian packages that contain the CLI application and the C library interface for the latest release.
Mt-KaHyPar requires:
g++ version 7 or higher, clang version 11.0.3 or higher, or MinGW compiler on Windows.-DKAHYPAR_DOWNLOAD_TBB=On flag
to the cmake command to download oneTBB and extract the necessary dependencies automatically.-DKAHYPAR_DISABLE_HWLOC=On flag to remove it.The following command will install most of the required dependencies on a Ubuntu machine:
sudo apt-get install libtbb-dev libhwloc-devThe following command will install most of the required dependencies on a MacOS machine:
brew install tbb hwlocThe following instructions set up the environment used to build Mt-KaHyPar on Windows machines:
MSYS2 MinGW x64 terminal.pacman -Syupacman -S make mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-python3 mingw-w64-x86_64-tbbTo build Mt-KaHyPar, use the following commands:
Clone the repository including submodules:
git clone https://github.com/kahypar/mt-kahypar.git
Create a build directory: mkdir build && cd build
Only on Windows machines: export CMAKE_GENERATOR="MSYS Makefiles"
Run cmake: cmake .. --preset=
Run make: make MtKaHyPar -j4
The build produces the executable MtKaHyPar, which can be found in build/mt-kahypar/application/.
As a user of Mt-KaHyPar, the default cmake preset is appropriate (or python for installing the Python interface).
If you work on Mt-KaHyPar or want to run benchmarks, use the dev preset.
Please note that Mt-KaHyPar was primarily tested and evaluated on Linux machines. While a Windows build has been provided and tested on MSYS2 using pacman to install the required dependencies, we cannot provide any performance guarantees or ensure that the Windows version is free of bugs. We are happy to accept contributions to improve Windows support.
To partition a hypergraph with our default configuration, use the following command:
./mt-kahypar/application/MtKaHyPar -h --preset-type=default -t -k -e -o km1Available options are described in more detail below. You can also use --help to print a summary of the most important options.
Mt-KaHyPar provides several partitioning configurations with different time-quality trade-offs. The configurations are stored in ini files located in the config folder. However, we recommend using the --preset-type parameter:
--preset-type=default: computes good partitions very fastquality: computes high-quality partitions (uses flow-based refinement)highest_quality: highest-quality configuration (uses n-level coarsening and flow-based refinement)deterministic: fast deterministic partitioningdeterministic_quality: high-quality deterministic partitioning (uses flow-based refinement)large_k: configuration for partitioning (hyper)graphs into a large number of blocks (e.g. >= 1024 blocks)The presets can be ranked from lowest quality to highest quality as follows: large_k,
default, deterministic, quality, deterministic_quality, and highest_quality (the quality of the matching deterministic and non-deterministic configurations is roughly equivalent).
We recommend using the default configuration to compute good partitions very fast and the quality configuration to compute high-quality solutions.
The highest_quality configuration computes better partitions than our quality configuration by 0.5% on average at the cost of a two times longer running time for medium-sized instances (up to 100 million pins).
When you have to partition a (hyper)graph into a large number of blocks (e.g., >= 1024 blocks), you can use our large_k configuration.
However, we only recommend using this if you experience high running times with one of our other configurations as this can significantly worsen the partitioning quality.
Mt-KaHyPar can optimize the cut-net, connectivity, and sum-of-external-degrees metric (see Supported Objective Functions).
-o To map a (hyper)graph onto a target graph, use the following parameters:
-g -o steiner_treeThe target graph is expected to be in Metis format. The nodes of the (hyper)graph are then mapped onto the nodes of the target graph, while optimizing the Steiner tree metric (see Supported Objective Functions).
To partition a graph in Metis format, use the following parameters:
-h --file-format=metis -o cutMt-KaHyPar uses optimized data structures for graph partitioning, which speeds up the partitioning time by a factor of two in comparison to hypergraphs.
For graphs in hMetis format, the optimized data structures can be enabled with --instance-type=graph.
Fixed vertices are nodes that are preassigned to particular block and are not allowed to change their block during partitioning. Mt-KaHyPar reads fixed vertices from a file in the hMetis fix file format, which can be provided via the following command line parameter:
-f Per default, Mt-KaHyPar enforces that the weight of each block must be smaller than the average block weight (weight of the hypergraph divided by the number of blocks) times (1 + ε). However, you can provide individual target block weights for each block via
--part-weights=weight_of_block_0 weight_of_block_1 ... weight_of_block_kNote that the sum of all individual target block weights must be larger than the total weight of all nodes.
To enable writing the partition to a file after partitioning, you can add the following command line parameters to the partitioning call:
--write-partition-file --partition-output-folder=The partition file name is generated automatically based on parameters such as k, imbalance, seed and the input file name and will be located in the folder specified by --partition-output-folder. If you do not provide a partition output folder, the partition file will be placed in the same folder as the input hypergraph file.
There are several useful options to control which output is shown:
-q/--quiet: Disable partitioning output-v/--verbose: Displays more detailed information on the partitioning process--show-detailed-timings: Shows detNo open issues yet, or sync has not completed.