Skip to main content

Module partition

Module partition 

Source
Expand description

Kernighan-Lin local refinement for the chiplet hierarchical partitioner. Mirrors HierarchicalPartitioner._refine step-for-step so the Rust output is bit-identical to the Python reference (the algorithm is fully deterministic given a CSR adjacency, a list of per-edge |scc| weights, vertex weights, an initial part_map and (kl_iterations, correlation_penalty, n_parts)).

Inputs (CSR-style flat arrays):

  • adj_offsets: [V+1] — row pointers; row i covers adj_neighbours[adj_offsets[i] .. adj_offsets[i+1]]
  • adj_neighbours: [E_total] — neighbour vertex ids
  • adj_scc_abs: [E_total] — |edge_scc(v, n)| for each adjacency entry (already-pre-computed so the kernel does NO graph lookup)
  • vertex_weights: [V] — vw per Python graph.vertex_weights.get(v, 1.0)
  • part_map: [V] (mut) — initial partition id per vertex; the kernel writes the refined assignment back into the same slot

Behaviour: same as _refine — for each KL iteration, walk every vertex of every partition, compute its full per-partition cost vector in ONE neighbour scan, and move the vertex to the best-gain target if the gain is strictly positive AND the source partition has more than one vertex remaining. Stop early if no moves happened in an iteration. Returns total moves performed.

Functions§

kl_refine