8000 Flow refinement: report no change when no flow problem can be built by schulzchristian · Pull Request #175 · KaHIP/KaHIP · GitHub
[go: up one dir, main page]

Skip to content

Flow refinement: report no change when no flow problem can be built - #175

Merged
schulzchristian merged 1 commit into
masterfrom
fix-flow-nochange
Nov 17, 2026
Merged

schulzchristian merged 1 commit into
masterfrom
fix-flow-nochange

Conversation

@schulzchristian
Copy link
Copy Markdown
Member

Summary

A one-place fix in the pairwise flow refinement (cut_flow_problem_solver::get_min_flow_max_cut, 7 lines). When no flow network can be built for a block pair, the solver now reports "no change" instead of a result that moves the whole rhs stripe to lhs while the stored cut of the pair stays the old value.

Output changes only where most balanced minimum cuts are on (strong, strongsocial, or --most_balanced_flows), and there only rarely: 15 of 858 strong / strongsocial jobs on our identity set, with no change of the cut in geometric mean. Every other preconfiguration gives bit-identical partitions.

The bug

For a pair of adjacent blocks (lhs, rhs), two_way_flow_refinement grows a region (two stripes) around the boundary and calls get_min_flow_max_cut. convert_ds builds the flow network and returns false if one of the stripes has no outer boundary, i.e. the region covers a whole block, which happens for small blocks (large k, small graphs, a large flow region factor). In that case the solver returned initial_cut and left new_rhs_nodes empty.

The caller reads new_rhs_nodes as the set of stripe nodes that end up in rhs. An empty list therefore means "every stripe node goes to lhs", with the cut value reported as unchanged. Then:

  • without most balanced minimum cuts (eco, fastsocial, ecosocial, the separator variants), the result is accepted only if its cut is smaller than the current one, which initial_cut never is, so it is always undone and nothing changes;
  • with most balanced minimum cuts (strong, strongsocial), the result is also accepted when it improves the balance of the pair and stays under the bound. Then the whole rhs stripe moves to lhs, and boundary.setEdgeCut stores the old cut for the pair, although the real cut changed.

The fix

If convert_ds builds no network, the solver returns every rhs stripe node in new_rhs_nodes, i.e. the unchanged partition, together with initial_cut. The caller then sees "no change", keeps the partition, and its bookkeeping stays correct. fast never reaches the flow code (it uses FM refinement only).

ParHIP has its own copy of the library (parallel/modified_kahip). Its edge_cut_flow_solver::get_min_flow_max_cut has the same early return (if(!do_something) return initial_cut;) and is not changed here.

How often it fires, and what changes

Small set: 6 graphs (4elt, fe_body, luxembourg, PGPgiantcompo, email-EuAll, rgg_n_2_18) x k = 2, 8, 16, 64, 256 x seeds 1, 2, imbalance 3%, with a build that logs every case without a flow network:

preconfiguration runs where the case occurs cases runs with changed output
strong 41 / 60 10426 3 / 60
strongsocial 37 / 60 7712 2 / 60
eco 27 / 60 1860 0 / 60
fastsocial 22 / 60 158 0 / 60
ecosocial 25 / 60 440 0 / 60

So the case is common (mostly at k = 64 and 256), but only with most balanced minimum cuts does the broken result get accepted.

Identity set: the 537 benchmark jobs of #171 x seeds 1 to 3 at imbalance 3%, plus a crosscheck grid (the 6 graphs above x all six preconfigurations x k = 2, 8, 64, 256 x seeds 1 to 3 x imbalance 1, 3, 5%), 2907 runs, compared by sha256 of the partition file against v3.26 (master since then only has the link fix of 3.27):

8000
preconfiguration runs bit identical
fast 516 516
eco 507 507
fastsocial 516 516
ecosocial 510 510
strong435 425
strongsocial 423 414

The 19 differing runs (15 distinct jobs; a few jobs are both in the benchmark and in the grid) are on PGPgiantcompo, email-EuAll and fe_body at k = 32 to 256. Cut of the fix vs master on them: 11 smaller, 8 larger, geometric mean ratio 0.9991; over all strong runs 0.99994, over all strongsocial runs 1.00002. Every partition was checked by an independent checker (cut and block weights recomputed from the graph). Balance: strong unchanged; strongsocial loses one balanced run (fe_body k = 256, seed 1, imbalance 3%: cut 13371 over the bound instead of 13305 within it), and the other three differing strongsocial runs at k = 256 are over the bound in master and with the fix alike.

Node separators (node_separator, all six preconfigurations on 4elt and PGPgiantcompo): bit identical to v3.26. kaffpaE uses the same kaffpa code in its operators, so it changes exactly where kaffpa does.

Tests

  • builds without MPI (-DNOMPI=ON) and with MPI (kaffpaE);
  • interface_test runs;
  • the Python test of the CI (callkahipfrompython.py) was not run locally (no pybind11 on the test machine).

When the region around a block pair covers a whole block, convert_ds builds no flow network and
get_min_flow_max_cut returned the old cut with an empty list of rhs nodes. The caller read that as
"every stripe node goes to lhs". With most balanced minimum cuts (strong, strongsocial,
--most_balanced_flows), such a result was accepted whenever it improved the balance, so the whole rhs
stripe moved to lhs while the stored cut of the pair stayed the old value. Now the solver returns all
rhs stripe nodes, i.e. the unchanged partition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0