Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unconstrained Refinement #160

Merged
merged 152 commits into from
Sep 19, 2023
Merged

Unconstrained Refinement #160

merged 152 commits into from
Sep 19, 2023

Conversation

N-Maas
Copy link
Collaborator

@N-Maas N-Maas commented Sep 13, 2023

This PR adds the new unconstrained refinement algorithms from our most recent paper (Parallel Unconstrained Local Search for Partitioning Irregular Graphs). Details can be found there.

Summary:

  • Unconstrained LP: Performs moves without considering the balance constraint and rebalances after each round.
  • Unconstrained FM: Computes an approximate penalty for unconstrained moves, rebalancing happens after the localized search. The rebalancing moves are then interleaved with the FM moves to create a global move sequence where balance is immediately restored after each move, thereby maximizing the number of valid prefixes for the global rollback.
  • High-Quality Rebalancer: Based on a central concurrent priority queue where the priority is computed as the (negative) gain of a move divided by the node weight.

With regards to the code architecture, the new algorithms require the introduction of a new rebalancer interface as well as an interface for the FM strategy. Furthermore, the data for computing approximate penalties is added to the shared FM data.

Results on the medium hypergraph set (k <= 32):
quality running_time

Note that the quality improvement is much more significant on highly irregular graphs (see paper). Specifically, unconstrained has much better quality there than n-level while being almost as fast as the current default configuration. I plan to investigate the results on hypergraphs in more detail within the next week, but I think it makes sense to already open the PR.

Unconstrained has only minimal running time overhead in the multilevel configuration. Consequently, I've added it to the default and quality configurations.

In the n-level setting, the overhead is much more significant. This is because unconstrained refinement has some operations (initialization of penalty estimation and rebalancing) which require scanning the whole graph. The consequence is potentially quadratic total work since this can happen for every batch uncontraction. Therefore, the PR does not change the highest_quality config. A possible solution is to use unconstrained refinement only for the global refinement rounds. This would probably need some significant changes to the n-level code.

Additional notes:

  • We haven't tested unconstrained refinement during initial partitioning yet
  • The PR adds tools for converting hmetis/mtx to metis format
  • The PR removes the old rebalancer. There seems little point in keeping it, since the new rebalancer outpeforms it
  • The diff size is somewhat blown up because the PR includes a typo fix (SyncronizedEdgeUpdate -> SynchronizedEdgeUpdate). We could also merge this separately if it simplifies review

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #160 (e0a5aed) into master (858c9f0) will increase coverage by 0.72%.
The diff coverage is 91.28%.

❗ Current head e0a5aed differs from pull request most recent head 41003aa. Consider uploading reports for the commit 41003aa to get more accurate results

@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
+ Coverage   77.94%   78.66%   +0.72%     
==========================================
  Files         192      202      +10     
  Lines       18699    19626     +927     
  Branches     7589     8015     +426     
==========================================
+ Hits        14575    15439     +864     
- Misses       4124     4187      +63     
Files Changed Coverage Δ
...ar/partition/coarsening/multilevel_uncoarsener.cpp 61.53% <ø> (ø)
...ahypar/partition/coarsening/nlevel_uncoarsener.cpp 78.00% <ø> (ø)
...-kahypar/partition/coarsening/nlevel_uncoarsener.h 100.00% <ø> (ø)
.../initial_partitioning/greedy_initial_partitioner.h 100.00% <ø> (ø)
...rtitioning/label_propagation_initial_partitioner.h 100.00% <ø> (ø)
...ar/partition/refinement/gains/cut/cut_gain_cache.h 78.09% <0.00%> (-1.52%) ⬇️
...gains/cut_for_graphs/cut_gain_cache_for_graphs.cpp 93.93% <0.00%> (ø)
...t/gains/cut_for_graphs/cut_gain_cache_for_graphs.h 71.62% <0.00%> (+1.75%) ⬆️
...artition/refinement/gains/soed/soed_gain_cache.cpp 75.28% <0.00%> (ø)
.../partition/refinement/gains/soed/soed_gain_cache.h 77.04% <0.00%> (-1.29%) ⬇️
... and 49 more

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@kittobi1992 kittobi1992 left a comment

Choose a reason for hiding this comment

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

Lgtm. Only some minor changes. If these issues are addressed, feel free to merge (after fixing the windows build) ;-)

# main -> refinement -> fm
r-fm-type=kway_fm
r-fm-type=unconstrained
Copy link
Member

Choose a reason for hiding this comment

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

I would rename this to "unconstrained_fm"

@@ -57,7 +57,7 @@ i-r-fm-iter-moves-on-recalc=true
# main -> initial_partitioning -> refinement -> flows
i-r-flow-algo=do_nothing
# main -> refinement
r-rebalancer-type=simple_rebalancer
r-rebalancer-type=rebalancer
Copy link
Member

Choose a reason for hiding this comment

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

did we remove the "simple_rebalancer"? These configs should be not modified as they refer to the state in our dissertations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the PR so that it doesn't remove the simple rebalancer anymore

@@ -1,123 +0,0 @@
/*******************************************************************************
* MIT License
Copy link
Member

Choose a reason for hiding this comment

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

Is there another test for the rebalancer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added one

@@ -119,6 +119,14 @@ class SparseMapBase {
return _dense[index].value;
}

Value operator[] (const Key key) const {
Copy link
Member

Choose a reason for hiding this comment

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

This is a confusing semantic of the []-operator. Can we use at(key) function instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using getOrDefault(key) now

// Contains data required for unconstrained FM: We group non-border nodes in buckets based on their
// incident weight to node weight ratio. This allows to give a (pessimistic) estimate of the effective
// gain for moves that violate the balance constraint
struct UnconstrainedFMData {
Copy link
Member

Choose a reason for hiding this comment

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

this looks to me more like a class rather than a struct.

const std::vector<HypernodeWeight>& max_part_weights,
vec<vec<Move>>& rebalancing_moves_by_part);

void insertMovesToBalancePart(const PartitionedHypergraph& phg,
Copy link
Member

Choose a reason for hiding this comment

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

I prefer the term "block" over "part"

*
*/

class GainCacheStrategy {
class LocalGainCacheStrategy {
Copy link
Member

Choose a reason for hiding this comment

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

move this in a separate file

@@ -72,4 +72,42 @@ class IRefiner {
const double time_limit) = 0;
};

class IRebalancer: public IRefiner {
Copy link
Member

Choose a reason for hiding this comment

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

move this into "i_rebalancer.h"



template <typename TypeTraits, typename GainTypes>
class RebalancerV2 final : public IRebalancer {
Copy link
Member

@kittobi1992 kittobi1992 Sep 18, 2023

Choose a reason for hiding this comment

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

I do not like the naming. Suggestion: "AdvancedRebalancer". Also I would still keep the old rebalancer for our old configurations.



template<typename TypeTraits, typename GainTypes>
class UnconstrainedStrategy: public IFMStrategy {
Copy link
Member

Choose a reason for hiding this comment

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

would split this into two separate files "unconstrained_fm_strategy.h" and "local_unconstrained_fm_strategy.h"

@N-Maas N-Maas merged commit 9bbc98b into master Sep 19, 2023
15 checks passed
@N-Maas N-Maas deleted the ufm-cleanup branch November 30, 2023 12:33
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.

3 participants