Skip to content

Conversation

@avinash2692
Copy link
Contributor

Summary

Initial startup time for an import statement was taking too long for a fresh install as shown in #43 and also here:

Screenshot 2025-08-12 at 1 30 39 PM

After the refactor, we have a faster startup time:

Screenshot 2025-08-13 at 11 49 59 AM

Related Issue

Changes

  • Refactors imports to not load libraries that take a lot of time during a fresh install
  • Moving type hinting to use TYPE_CHECK to avoid importing torch at startup.

* Also moving type hinting to use `TYPE_CHECK` to avoid importing torch at startup.
Copy link
Contributor

@jakelorocco jakelorocco left a comment

Choose a reason for hiding this comment

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

lgtm; that's a really good improvement! do we also want to fix our pyproject packages as a part of this? ie should we thin out the packages that we download now depending on the user request? Maybe by default we install ollama and openai, but force users to specify huggingface?

@avinash2692
Copy link
Contributor Author

lgtm; that's a really good improvement! do we also want to fix our pyproject packages as a part of this? ie should we thin out the packages that we download now depending on the user request? Maybe by default we install ollama and openai, but force users to specify huggingface?

I could move them to optional dependencies, so the user would have to do something like

uv pip install "mellea[hf]" 

@nrfulton
Copy link
Contributor

nrfulton commented Aug 14, 2025

lgtm; that's a really good improvement! do we also want to fix our pyproject packages as a part of this? ie should we thin out the packages that we download now depending on the user request? Maybe by default we install ollama and openai, but force users to specify huggingface?

Maybe. The 2s "first run" startup time is acceptable; faster for subsequent runs would be nice but isn't the biggest priority in our lives rn.

I think the more important reason for dependency groups is the numpy / transformers / etc. versioning woes we're always risking by virtue of having so many "low-level" libraries imported.

I suggest we go ahead with this merge because it's a massive QoL improvement, and open an issue for dependency group stuff.

We should also let the alora and watsonx sdk folks know that they should slim up their imports. I think part of @avinash2692 's RCA was an observation that a lot of the stuff they're importing isn't necessary.

Copy link
Contributor

@nrfulton nrfulton left a comment

Choose a reason for hiding this comment

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

🚀 46s -> 2s 🚀

Thanks for the thorough RCA on this.

@avinash2692 please feel free to open 2 new issues for the stuff above and then squash-merge this.

@nrfulton nrfulton merged commit dc77222 into main Aug 14, 2025
@nrfulton nrfulton deleted the avi/fix-43-startup-time-refactor branch August 14, 2025 23:37
@avinash2692
Copy link
Contributor Author

Thanks for merging @nrfulton. A part of this is already being addressed in #64 which moves things into optional dependencies.

jakelorocco pushed a commit that referenced this pull request Aug 19, 2025
* Moves watsonx imports into a conditional
* moves transformers imports into a conditional
* moves alora stuff into a condition
* Also moving type hinting to use `TYPE_CHECK` to avoid importing torch at startup.
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.

4 participants