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

refactor: Move MLAmbiguitySolver to Core #3272

Merged
merged 63 commits into from
Dec 6, 2024

Conversation

Corentin-Allaire
Copy link
Contributor

@Corentin-Allaire Corentin-Allaire commented Jun 11, 2024

This PR moves the MLAmbiguitySolver to Core, this will allow us to test it more easily with ATLAS in the future. It also removes the DBScan version of this algorithm as it was shown to be way less effective.

Summary by CodeRabbit

  • New Features

    • Enhanced performance monitoring capabilities with the addition of machine learning-based metrics.
    • Integrated a new machine learning function for ambiguity resolution in track finding workflows.
    • Introduced a new TrackTruthMatcher algorithm to improve track validation.
  • Bug Fixes

    • Corrected naming conventions for the CsvSpacePointWriter class and its methods.
  • Chores

    • Removed deprecated configurations and algorithms to streamline the codebase.
    • Updated header inclusions to reflect new naming conventions and class structures.

@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins Track Finding Ambiguity Resolution labels Jun 11, 2024
Copy link

github-actions bot commented Jun 11, 2024

📊: Physics performance monitoring for a3555d0

Full contents

physmon summary

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.46%. Comparing base (6b2e205) to head (da5a458).
Report is 179 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3272   +/-   ##
=======================================
  Coverage   47.46%   47.46%           
=======================================
  Files         510      510           
  Lines       30198    30198           
  Branches    14639    14639           
=======================================
  Hits        14332    14332           
  Misses       5335     5335           
  Partials    10531    10531           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added Stale and removed Stale labels Jul 11, 2024
@github-actions github-actions bot added the Stale label Aug 10, 2024
@github-actions github-actions bot added Infrastructure Changes to build tools, continous integration, ... and removed Stale labels Aug 28, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
Core/src/TrackFinding/AmbiguityTrackClustering.cpp (1)

Line range hint 26-46: Sound, the clustering logic remains. Approve this change, I do.

Elegant, the two-map approach is:

  • One map for cluster membership tracks
  • Another map for hit-to-cluster mapping maintains

But remember you must: As scale grows larger, memory consumption increases with hit count it does. Consider cleanup of hitToTrack map after clustering, you should.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ea981bb and d3c9e60.

📒 Files selected for processing (3)
  • Core/include/Acts/AmbiguityResolution/AmbiguityNetworkConcept.hpp (1 hunks)
  • Core/src/TrackFinding/AmbiguityTrackClustering.cpp (1 hunks)
  • Examples/Python/python/acts/examples/reconstruction.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Core/include/Acts/AmbiguityResolution/AmbiguityNetworkConcept.hpp
🔇 Additional comments (6)
Core/src/TrackFinding/AmbiguityTrackClustering.cpp (1)

24-25: Hmmmm, reversed the iteration order is. Verify the implications we must.

Changed from forward to reverse iteration, the processing order has. Affect cluster assignments this might, as precedence to higher-numbered tracks now given is.

Run this script to understand the impact, we shall:

✅ Verification successful

The documentation reveals that keys in trackMap represent measurement counts, hmmmm. But understand the clustering behavior better, we must. Search for tests and implementation details, we shall.


Safe this change is, the Force tells me

From the documentation revealed, understand we do that trackMap's keys represent measurement counts, ordered they are. Reverse iteration means tracks with more measurements processed first they will be, which logical it is - as tracks with more measurements typically more reliable they are.

The change aligns with the Force, for:

  • Documentation states keys are "just there to facilitate the ordering"
  • Higher keys mean more measurements, more trustworthy tracks they represent
  • Processing higher-quality tracks first, better cluster seeds they make

No disturbance in the Force I sense, as the clustering logic itself unchanged remains. Only the processing order differs, prioritizing tracks with more measurements, wisdom in this approach there is.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for tests and usages of clusterDuplicateTracks
rg -A 5 "clusterDuplicateTracks.*\(" 

# Look for documentation or comments explaining track ordering
rg -A 5 "trackMap.*order" 

Length of output: 2875


Script:

#!/bin/bash
# Search for tests that verify clustering behavior
rg -A 10 "TEST.*cluster.*track" Tests/

# Look for the implementation details of how tracks are processed
ast-grep --pattern 'for (auto track = trackMap.$_(); track != trackMap.$_(); $_track) {
  $$$
}'

Length of output: 139

Examples/Python/python/acts/examples/reconstruction.py (5)

1950-1965: Hmmmm, good this configuration looks!

Properly configured, the TrackTruthMatcher is. Follow the established patterns, it does. Clear and consistent, the naming conventions are.


1973-1974: Simple yet effective, these configuration flags are!

Wisely chosen, the boolean flags are. Control the output behavior, they do.


2028-2044: Well balanced, this truth matching configuration is!

Mirror the patterns of its score-based sibling, it does. Properly set, all parameters are.


2049-2054: Clear path for output, this configuration shows!

Follow the established ways of track writing, it does. Wise choice of names, made it has.


Line range hint 1990-2006: Strong with the Force, this ML configuration is!

Properly structured, the configuration is. But verify the integration with Core module, we must.

✅ Verification successful

Strong in the Force, this integration is!

Verified the implementation has been, hmm. The path of the ML Ambiguity Resolution, clear it now is:

  • Properly integrated with Core through Acts::AmbiguityResolutionML, it is
  • ONNX model handling, well-implemented it appears
  • Configuration structure, matches the header definition it does
  • Used in multiple chain configurations, proving its readiness it is

In the repository, evidence of proper usage found we have:

  • Training scripts for the model, present they are
  • Integration tests in full chain scripts, exist they do
  • Clear separation between ML and traditional approaches, maintained it is
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the ML ambiguity resolver integration with Core

# Check for Core integration
ast-grep --pattern 'class AmbiguityResolutionML {
  $$$
}'

# Check for ONNX model handling
rg -l "\.onnx" --type python

Length of output: 122


Script:

#!/bin/bash
# Search for AmbiguityResolutionMLAlgorithm class definition
ast-grep --pattern 'class AmbiguityResolutionMLAlgorithm'

# Search for ONNX model usage in Python files
rg -t py "\.onnx"

# Check imports and usage of AmbiguityResolutionMLAlgorithm
rg -t py "AmbiguityResolutionMLAlgorithm"

# Look for Core integration patterns
rg -t py "from acts.core.*ambiguity" -A 2

Length of output: 8515

@Corentin-Allaire
Copy link
Contributor Author

@paulgessinger @CarloVarni It seem the issue with the CI bridge is gone ? Could someone reapprove ?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
Examples/Python/python/acts/examples/reconstruction.py (1)

Line range hint 2009-2079: Hmm, wise implementation this is, but documentation improve we must!

Two-stage approach, clever it is - ML-based followed by greedy resolution. But document the reasoning behind this combination, we should. Help future padawans understand the ways of the Force, it will.

Add docstring explaining:

def addAmbiguityResolutionML(...):
    """Performs two-stage ambiguity resolution:
    1. ML-based initial disambiguation
    2. Greedy cleanup for remaining ambiguities
    
    This combination leverages ML predictions while ensuring 
    final track collection meets maximum shared hits criteria.
    """
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d3c9e60 and 4b27aac.

📒 Files selected for processing (1)
  • Examples/Python/python/acts/examples/reconstruction.py (4 hunks)
🔇 Additional comments (2)
Examples/Python/python/acts/examples/reconstruction.py (2)

1969-1984: Hmmmm, good this implementation looks!

Properly configured the TrackTruthMatcher is, with double matching enabled and appropriate naming conventions followed. A well-structured addition to the score-based ambiguity resolution algorithm this is.


Line range hint 1-2084: Verify the complete removal of DBScan implementation, we must!

Mentioned in PR objectives, removal of DBScan version is. Confirm no lingering references remain, we should.

✅ Verification successful

Lingering DBScan references in the codebase, I sense

In the reconstruction.py file, DBScan configuration still exists:

  • SeedFilterMLDBScanConfig namedtuple remains defined
  • DBScan parameters like epsilonDBScan and minPointsDBScan are still present

However, this relates to seed filtering functionality, not the ambiguity resolution that PR aims to remove. The DBScan version of MLAmbiguitySolver has been successfully removed, as no traces of AmbiguityResolutionMLDBScanConfig in the ambiguity resolution code remain.

Proceed with the changes, we should. Clean is the implementation, mmm.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining DBScan references in the codebase
echo "Searching for DBScan references..."
rg -i "dbscan" 

# Specifically check for the old config
echo "Checking for old DBScan configuration..."
ast-grep --pattern 'AmbiguityResolutionMLDBScanConfig'

Length of output: 9599

Copy link
Contributor

@AJPfleger AJPfleger left a comment

Choose a reason for hiding this comment

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

re-approving. the additional changes seem fine :)

Copy link

sonarqubecloud bot commented Dec 6, 2024

@kodiakhq kodiakhq bot merged commit f57e260 into acts-project:main Dec 6, 2024
49 checks passed
@github-actions github-actions bot removed the automerge label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ambiguity Resolution Changes Performance Component - Core Affects the Core module Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins Infrastructure Changes to build tools, continous integration, ... Track Finding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants