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 module import time #137

Open
rpadmanabhan opened this issue Mar 29, 2024 · 1 comment
Open

Improve module import time #137

rpadmanabhan opened this issue Mar 29, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@rpadmanabhan
Copy link

rpadmanabhan commented Mar 29, 2024

Is your feature request related to a problem? Please describe.
It takes almost 4 seconds for muon to import, it would be nice if we could import muon < 1s like scanpy

Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> import_time = timeit.timeit("import muon", number=1)
>>> print("Time taken to import muon:", import_time, "seconds")
Time taken to import muon: 4.092318220064044 seconds

Describe the solution you'd like
I have not dug into the code too much, maybe delaying any costly setups/internal imports to later when needed so most users can avoid the initial delay.

Describe alternatives you've considered
N/A

Additional context
N/A

@rpadmanabhan rpadmanabhan added the enhancement New feature or request label Mar 29, 2024
@gtca gtca added this to the v0.1.7 milestone Apr 9, 2024
@rpadmanabhan
Copy link
Author

rpadmanabhan commented Aug 20, 2024

I tried to see if I could fix this. I initially thought the top level jit compiles in preproc.py were the culprit but even after delaying them, import was still slow. It turns out the issue is related to specifying type hints, numba will always eagerly compile code in this case. The umap module apparently also does this so even if the type hints in preproc.py were removed it would still be slow to import umap and hence muon. Looks like no solution exists to force eagerness on numba's part yet, so not sure this can be resolved for now.
Relevant issue on numba : numba/numba#4956

@gtca gtca removed this from the v0.1.7 milestone Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants