百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

mt-kahypar

> 数据库
开源

Mt-KaHyPar(多线程卡尔斯鲁厄超图分区器)是一个带有并行实现的共享内存多级图和超图分区器。

191 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Mt-KaHyPar(多线程卡尔斯鲁厄超图分区器)是一个带有并行实现的共享内存多级图和超图分区器。

Mt-KaHyPar - Multi-Threaded Karlsruhe Graph and Hypergraph Partitioner

License Linux, MacOS & Windows Build Code Coverage Zenodo

Table of Contents

  • About Mt-KaHyPar
  • Features
  • Installing Mt-KaHyPar
  • Building Mt-KaHyPar from Source
  • Running Mt-KaHyPar
  • The C Library
  • The Python Library
  • Supported Objective Functions
  • Improving Compile Times
  • Licensing

About Mt-KaHyPar

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.

Features

Besides its fast and high-quality partitioning algorithm, Mt-KaHyPar provides many other useful features:

  • Scalability: Mt-KaHyPar has excellent scaling behaviour (up to 25 with 64 threads), while increasing the number of threads does not adversely affect the solution quality.
  • Deterministic Partitioning: Mt-KaHyPar offers a high-quality deterministic partitioning algorithm, ensuring consistent solutions for the same input and random seed.
  • Large K Partitioning: We provide a partitioning configuration for partitioning (hyper)graphs into a large number of blocks (e.g., k > 1024).
  • Graph Partitioning: Mt-KaHyPar includes optimized data structures for graph partitioning, achieving a speedup by a factor of two for plain graphs.
  • Objective Functions: Mt-KaHyPar can optimize the cut-net, connectivity, and sum-of-external-degrees metric (for more details, see Supported Objective Functions)
  • Mapping (Hyper)Graphs Onto Graphs: In many applications (e.g., distributed computation), the partition is assigned to a communication network that can be represented as a graph. However, conventional objective functions do not consider the topology of the target graph. We therefore provide a mode that maps the nodes of a (hyper)graph onto a target graph via the Steiner tree metric.
  • Fixed Vertices: Fixed vertices are nodes that are preassigned to a particular block and are not allowed to change their block during partitioning.

Installing Mt-KaHyPar

For Linux and MacOS, the Mt-KaHyPar Python package can be installed via pip:

bash
pip install mtkahypar

We also provide Debian packages that contain the CLI application and the C library interface for the latest release.

Building Mt-KaHyPar from Source

Mt-KaHyPar requires:

  • A 64-bit Linux, MacOS, or Windows operating system.
  • A modern, C++17-ready compiler such as g++ version 7 or higher, clang version 11.0.3 or higher, or MinGW compiler on Windows.
  • The [cmake][cmake] build system (>= 3.26).
  • The [Intel Thread Building Blocks][tbb] library (TBB, minimum required version is OneTBB 2021.5.0). If you don't want to install TBB by yourself, you can add the -DKAHYPAR_DOWNLOAD_TBB=On flag to the cmake command to download oneTBB and extract the necessary dependencies automatically.
  • The [Portable Hardware Locality][hwloc] library (hwloc). This dependency is not strictly necessary, you can add the -DKAHYPAR_DISABLE_HWLOC=On flag to remove it.

Linux

The following command will install most of the required dependencies on a Ubuntu machine:

bash
sudo apt-get install libtbb-dev libhwloc-dev

MacOS

The following command will install most of the required dependencies on a MacOS machine:

bash
brew install tbb hwloc

Windows

The following instructions set up the environment used to build Mt-KaHyPar on Windows machines:

  1. Download and install [MSYS2][MSYS2] from the official website (https://www.msys2.org/).
  2. Launch the MSYS2 MinGW x64 terminal.
  3. Update the package manager database by running the following command:
pacman -Syu
  1. The following command will then install all required dependencies:
pacman -S make mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-python3 mingw-w64-x86_64-tbb

Build Commands

To build Mt-KaHyPar, use the following commands:

  1. Clone the repository including submodules:

    git clone https://github.com/kahypar/mt-kahypar.git

  2. Create a build directory: mkdir build && cd build

  3. Only on Windows machines: export CMAKE_GENERATOR="MSYS Makefiles"

  4. Run cmake: cmake .. --preset=

  5. 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.

Running Mt-KaHyPar

To partition a hypergraph with our default configuration, use the following command:

./mt-kahypar/application/MtKaHyPar -h  --preset-type=default -t  -k  -e  -o km1

Available options are described in more detail below. You can also use --help to print a summary of the most important options.

Partitioning Configurations

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 fast
  • quality: computes high-quality partitions (uses flow-based refinement)
  • highest_quality: highest-quality configuration (uses n-level coarsening and flow-based refinement)
  • deterministic: fast deterministic partitioning
  • deterministic_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.

Objective Functions

Mt-KaHyPar can optimize the cut-net, connectivity, and sum-of-external-degrees metric (see Supported Objective Functions).

-o 

Mapping (Hyper)Graphs onto Graphs

To map a (hyper)graph onto a target graph, use the following parameters:

-g  -o steiner_tree

The 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).

Graph Partitioning

To partition a graph in Metis format, use the following parameters:

-h  --file-format=metis -o cut

Mt-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

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 

Individual Target Block Weights

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_k

Note that the sum of all individual target block weights must be larger than the total weight of all nodes.

Write Partition to Output File

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.

Display Options

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 det

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++algorithm-engineeringgraph-algorithmsgraph-partitioninggraphs

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库