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

Leaf Subsampler Speedup #228

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Leaf Subsampler Speedup #228

merged 1 commit into from
Oct 19, 2023

Conversation

colganwi
Copy link
Collaborator

@colganwi colganwi commented Oct 18, 2023

This PR makes the UniformLeafSubsampler ~50X faster for large trees by improving remove_leaves_and_prune_lineages. Specifically, instead of checking internal nodes many times, we are now using a heap to check internal nodes in order from the bottom of the tree to the top. Additionally, the __network now is modified directly which avoids repeated calls to __check_network_initialized().

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (d53e6d9) 79.49% compared to head (cf2cbc2) 79.53%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #228      +/-   ##
==========================================
+ Coverage   79.49%   79.53%   +0.04%     
==========================================
  Files          89       89              
  Lines        8050     8064      +14     
==========================================
+ Hits         6399     6414      +15     
+ Misses       1651     1650       -1     
Files Coverage Δ
cassiopeia/data/CassiopeiaTree.py 92.09% <100.00%> (+0.30%) ⬆️

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

@colganwi
Copy link
Collaborator Author

Also, speeds up the BirthDeathFitnessSimulator since a large proportion of this simulations time is spent cleaning up dead lineages.

@mattjones315 mattjones315 self-requested a review October 19, 2023 20:50
Copy link
Collaborator

@mattjones315 mattjones315 left a comment

Choose a reason for hiding this comment

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

Looks great! Fantastic improvement in runtime and scaling up a lot of our simulation engines.

@mattjones315 mattjones315 merged commit 2ca07df into master Oct 19, 2023
3 checks passed
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