fix: sort space points before Acts seeding to ensure MT reproducibility - #2804
Open
wdconinc wants to merge 3 commits into
Open
fix: sort space points before Acts seeding to ensure MT reproducibility#2804wdconinc wants to merge 3 commits into
wdconinc wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves multi-thread reproducibility in the tracking seeding chain by deterministically ordering SpacePoint inputs before building the Acts space-point container and running Acts::SeedFinderOrthogonal, reducing sensitivity to input-order-dependent KDTree behavior.
Changes:
- Added a deterministic
std::stable_sortofspacePointsinTrackSeeding::processusing a lexicographic coordinate key and anObjectIDtie-breaker. - Added the necessary
<algorithm>include to support the new sort.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+104
to
+114
| std::stable_sort(spacePoints.begin(), spacePoints.end(), [](const auto* lhs, const auto* rhs) { | ||
| const auto lhsPositionKey = std::tuple{lhs->r(), lhs->phi(), lhs->z(), lhs->x(), lhs->y()}; | ||
| const auto rhsPositionKey = std::tuple{rhs->r(), rhs->phi(), rhs->z(), rhs->x(), rhs->y()}; | ||
| if (lhsPositionKey != rhsPositionKey) { | ||
| return lhsPositionKey < rhsPositionKey; | ||
| } | ||
|
|
||
| const auto lhsId = lhs->getObjectID(); | ||
| const auto rhsId = rhs->getObjectID(); | ||
| return std::tie(lhsId.collectionID, lhsId.index) < std::tie(rhsId.collectionID, rhsId.index); | ||
| }); |
SpacePoint only exposes x(), y(), z(), r(). Use (r, z, x, y) as the sort key; phi = atan2(y, x) is fully encoded by (x, y) so no sorting information is lost. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| auto [trk_seeds, trk_params] = output; | ||
|
|
||
| std::vector<const eicrecon::SpacePoint*> spacePoints = getSpacePoints(*trk_hits); | ||
| std::stable_sort(spacePoints.begin(), spacePoints.end(), [](const auto* lhs, const auto* rhs) { |
Contributor
There was a problem hiding this comment.
use a ranges version of this algorithm
Suggested change
| std::stable_sort(spacePoints.begin(), spacePoints.end(), [](const auto* lhs, const auto* rhs) { | |
| std::ranges::stable_sort(spacePoints,, [](const auto* lhs, const auto* rhs) { |
…ty (fix: iwyu) (#2812) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/30486835399. Please merge this PR into the branch `wdconinc-fix-trackseeding-sp-sort-for-mt-reproduc` to resolve failures in PR #2804. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Contributor
Capybara summary for PR 2804
Last updated 2026-07-29T20:36-04:00 227195c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Briefly, what does this PR introduce? Please link to any relevant presentations or discussions.
This introduces a deterministic pre-sort of
spacePointsinTrackSeeding::processbefore constructing the Acts space-point container and callingActs::SeedFinderOrthogonal.The sort is
std::stable_sortwith lexicographic key(r, phi, z, x, y)and a finalObjectID(collectionID, index)tie-breaker for exact coordinate ties. This canonicalizes seeding input order across runs.Motivation/background:
compare-single-multi-threadedinvestigations showed ~1 ULP ST/MT differences inCentralCKFTracksUnfiltered/CentralCKFTrackParametersUnfiltereddue to ordering sensitivity in the seed/track chain.Acts::SeedFinderOrthogonaluses KDTree internals whose split behavior (std::partition) can be input-order sensitive for near-equal coordinates.wdconinc-fix-digi-determinism, commitcc20d099e).What is the urgency of this PR?
What kind of change does this PR introduce?
Please check if any of the following apply
AI usage: assisted with implementing the deterministic stable sort, preparing commit/PR text, and running targeted local build/configuration checks.