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

Improve parallelism of ir_dist #473

Merged
merged 9 commits into from
Jan 19, 2024
Merged

Improve parallelism of ir_dist #473

merged 9 commits into from
Jan 19, 2024

Conversation

grst
Copy link
Collaborator

@grst grst commented Jan 8, 2024

Closes #468

  • CHANGELOG.md updated
  • Tests added (For bug fixes or new features)
  • Tutorial updated (if necessary)
  • test and compare performance with old implementation and full wu2020 dataset.

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (bd168a9) 80.52% compared to head (5255317) 80.50%.

Files Patch % Lines
src/scirpy/util/__init__.py 62.50% 3 Missing ⚠️
src/scirpy/ir_dist/metrics.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #473      +/-   ##
==========================================
- Coverage   80.52%   80.50%   -0.02%     
==========================================
  Files          49       49              
  Lines        3994     4012      +18     
==========================================
+ Hits         3216     3230      +14     
- Misses        778      782       +4     

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

 * move block_size param to `calc_dist_mat` function
 * dynamically select block size based on problem size
 * Use tqdm + joblib.Parallel + joblib.delayed
@grst grst marked this pull request as ready for review January 9, 2024 17:32
@grst
Copy link
Collaborator Author

grst commented Jan 11, 2024

In general this works well (also out-of-machine computing with dask), but:

  • the tqdm progressbar is not compatible with the dask backend, or in fact pretty much any backend except for loky
    • instead, one can set the verbosity to ~5 to get some updates printed to the console. To make this nicer, maybe I can check if the backend is supported.
  • for some reason it takes ~15 seconds to spawn the loky worker threads. When rerunning the function, this is instant. Not sure what the threads are doing initially.

@grst grst mentioned this pull request Jan 11, 2024
@grst
Copy link
Collaborator Author

grst commented Jan 11, 2024

for some reason it takes ~15 seconds to spawn the loky worker threads. When rerunning the function, this is instant. Not sure what the threads are doing initially.

the reason was that the worker threads all import scirpy from scratch. It turned out to be quite slow because of import airr. I now deferred importing the airr package until it's needed (only in some IO functions) and this brought down the import time to ~1s which is acceptable and mostly due to scanpy.

@grst
Copy link
Collaborator Author

grst commented Jan 11, 2024

@felixpetschko fyi

In this PR I change how the ParallelDistanceCalculator handles parallel processing. It now uses joblib.Parallel that (amongst others) allows to use dask as a backend for multi-machine computing.

But I think your reimplementation of the hamming distance calculator anyway doesn't need this.

@grst grst mentioned this pull request Jan 11, 2024
@grst grst merged commit f253111 into main Jan 19, 2024
10 of 11 checks passed
@grst grst deleted the ir-dist-parallelism branch January 19, 2024 07:26
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.

ir_dist alignment stuck
1 participant