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

Make dense layout algorithm deterministic when run in parallel #13133

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/accelerate/src/dense_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct SubsetResult {
pub error: f64,
pub map: Vec<usize>,
pub subgraph: Vec<[usize; 2]>,
pub index: usize,
}

fn bfs_sort(adj_matrix: ArrayView2<f64>, start: usize, num_qubits: usize) -> Vec<usize> {
Expand Down Expand Up @@ -190,6 +191,7 @@ pub fn best_subset_inner(
error,
map: bfs,
subgraph,
index: k,
}
};

Expand All @@ -199,6 +201,7 @@ pub fn best_subset_inner(
map: Vec::new(),
error: f64::INFINITY,
subgraph: Vec::new(),
index: usize::MAX,
}
};

Expand All @@ -209,7 +212,7 @@ pub fn best_subset_inner(
} else {
best
}
} else if curr.count > best.count {
} else if curr.count > best.count || (curr.count == best.count && curr.index < best.index) {
curr
} else {
best
Expand Down
Loading