Skip to content

Prototype pairwise seeding and optimize find-orientations#907

Draft
joelvbernier wants to merge 3 commits intomasterfrom
jbernier/find-orientations-cleanup
Draft

Prototype pairwise seeding and optimize find-orientations#907
joelvbernier wants to merge 3 commits intomasterfrom
jbernier/find-orientations-cleanup

Conversation

@joelvbernier
Copy link
Copy Markdown
Member

Summary

This PR tightens the performance and robustness of the legacy find-orientations workflow and also prototypes a new seeded indexing path based on pairwise continuous fiber intersections (work in progress).

What changed

  • added pairwise and pairwise-greedy orientation candidate generators that avoid rasterizing continuous fibers into dense point clouds before scoring
  • added Friedel-pair condensation ahead of candidate generation so duplicate eta-omega seed peaks are reduced before discrete fibers are generated
  • made Friedel condensation the default for seeded searches, while keeping it configurable
  • added exact post-hoc quaternion misorientation merging for sparse greedy candidates
  • added a synthetic eta-omega scaling benchmark harness based on simulateOmeEtaMaps()
  • refactored multiprocessing in the legacy path to use HEXRD's platform-aware multiprocessing context
  • fixed paintGrid chunk sizing for small jobs
  • added spawn-aware serial fallback for fine-grained pools on macOS/Windows, where process overhead dominated runtime
  • added a paintGrid eta/omega tolerance floor to the map bin width, with warnings when the requested tolerance is below map resolution

Why

The original seeded workflow was robust but wasteful: it rasterized many candidate orientations along each fiber, scored them all, and relied on clustering to recover the true modes afterward.

This PR moves toward a more economical seeded-forward-model approach while also improving the existing discrete-fiber path:

  • reduce redundant seeds early via Friedel pairing
  • preserve cross-platform behavior under Linux/macOS/Windows multiprocessing constraints
  • keep paintGrid and downstream scoring physically consistent with the eta-omega map resolution

Benchmark notes

On the multiruby eta-omega benchmark with the legacy discrete-fibers path:

  • 1 CPU, Friedel off: 14.314 s, 71,281 candidates, 3 grains
  • 1 CPU, Friedel on: 10.264 s, 38,520 candidates, 3 grains
  • 4 CPU, Friedel on (macOS spawn context): 10.188 s, 38,520 candidates, 3 grains

So the Friedel condensation clearly wins in the legacy path, and the spawn-aware fallback prevents multiprocessing from becoming dramatically slower on macOS.

Testing

  • python -m unittest tests.test_indexer tests.config.test_find_orientations

Follow-up

  • Profile the legacy path on a fork-based Linux environment to confirm the multiprocessing upside there
  • Continue iterating on the pairwise-greedy path now that the legacy baseline is stronger and better characterized

@joelvbernier joelvbernier self-assigned this Mar 16, 2026
@joelvbernier joelvbernier marked this pull request as draft March 16, 2026 07:25
@psavery
Copy link
Copy Markdown
Collaborator

psavery commented Mar 25, 2026

This needs to be updated to use the simpler formulas that Don determined over the past couple of weeks.

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.

2 participants