Skip to content

build(python): replace pymetis with kahip for cross-platform graph partitioning#295

Merged
weinbe58 merged 5 commits intomainfrom
jason/293-build-pymetis-fails-to-compile-on-windows-find-cross-platform-alternative
Mar 23, 2026
Merged

build(python): replace pymetis with kahip for cross-platform graph partitioning#295
weinbe58 merged 5 commits intomainfrom
jason/293-build-pymetis-fails-to-compile-on-windows-find-cross-platform-alternative

Conversation

@Jason-Ludmir
Copy link
Contributor

@Jason-Ludmir Jason-Ludmir commented Mar 20, 2026

Summary

  • Replaces pymetis with kahip>=3.25 as the graph partitioning backend in physical_layout.py, fixing Windows CI compilation failures caused by METIS's dependency on the Unix-only sys/resource.h header (build: pymetis fails to compile on Windows — find cross-platform alternative #293).
  • Adapts the partitioning call from pymetis.part_graph to kahip.kaffpa, mapping the existing u_factor to KaHIP's imbalance parameter and preserving the post-partition capacity enforcement that guarantees strict word-size adherence.
  • Renames metis_seed to partitioner_seed for backend-neutral naming.
  • Adds a focused unit test (test_physical_layout_backend_adapter.py) that validates the KaHIP adapter via monkeypatching.

Changes

File Change
pyproject.toml pymetis>=2025.2.1kahip>=3.25
python/bloqade/lanes/heuristics/physical_layout.py Swap import + call to kahip.kaffpa; rename metis_seedpartitioner_seed; graceful import with try/except
python/tests/heuristics/test_physical_layout_backend_adapter.py New – backend adapter test with monkeypatched kaffpa
uv.lock Regenerated (removes pymetis entries, adds kahip wheels incl. Windows)

Motivation

pymetis wraps METIS, which relies on sys/resource.h — a POSIX header unavailable on Windows. This blocks the cross-platform CI pipeline. KaHIP provides equivalent k-way graph partitioning with prebuilt Windows wheels on PyPI, eliminating the native-compilation dependency.

Closes #293

Made with Cursor

…rtitioning

pymetis depends on METIS which includes sys/resource.h, a Unix-only
header that prevents compilation on Windows CI. KaHIP provides
equivalent multi-way graph partitioning with native Windows support
via prebuilt wheels on PyPI.

- Replace pymetis with kahip>=3.25 in pyproject.toml
- Swap partition backend in physical_layout.py to use kahip.kaffpa()
- Rename metis_seed field to partitioner_seed for backend neutrality
- Retain existing post-partition capacity enforcement for strict
  word-size adherence
- Add backend adapter unit test with monkeypatched KaHIP calls
- Regenerate uv.lock

Closes #293

Made-with: Cursor
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
5434 4577 84% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
python/bloqade/lanes/heuristics/physical_layout.py 38% 🟢
TOTAL 38% 🟢

updated for commit: da6d346 by action🐍

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the exception catching in terms of the import? its a part of the required dependency so it shuold always be installed.

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weinbe58 weinbe58 enabled auto-merge (squash) March 23, 2026 17:18
@weinbe58 weinbe58 merged commit d1b02e8 into main Mar 23, 2026
20 checks passed
@weinbe58 weinbe58 deleted the jason/293-build-pymetis-fails-to-compile-on-windows-find-cross-platform-alternative branch March 23, 2026 17:25
github-actions bot pushed a commit that referenced this pull request Mar 23, 2026
…rtitioning (#295)

* build(python): replace pymetis with kahip for cross-platform graph partitioning

pymetis depends on METIS which includes sys/resource.h, a Unix-only
header that prevents compilation on Windows CI. KaHIP provides
equivalent multi-way graph partitioning with native Windows support
via prebuilt wheels on PyPI.

- Replace pymetis with kahip>=3.25 in pyproject.toml
- Swap partition backend in physical_layout.py to use kahip.kaffpa()
- Rename metis_seed field to partitioner_seed for backend neutrality
- Retain existing post-partition capacity enforcement for strict
  word-size adherence
- Add backend adapter unit test with monkeypatched KaHIP calls
- Regenerate uv.lock

Closes #293

Made-with: Cursor

* changed bloqade lanes version

* removed asserting kahip imports

* Fixed test import

---------

Co-authored-by: Jason Ludmir <jasonludmir@JLudmir-Mac-QDNH.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: pymetis fails to compile on Windows — find cross-platform alternative

2 participants