Skip to content

Some Imports are extremely slow (~3 seconds to import) #3041

@drorIvry

Description

@drorIvry

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
A clear and concise description of what the bug is.

some imports are very slow

from google.adk.models import LLMRegistry, BaseLlm
from google.adk.models.lite_llm import LiteLlm

takes a lot of time on first import here is a screenshot from profiling it.

Image

To Reproduce
Please share a minimal code and data to reproduce your problem.
Steps to reproduce the behavior:

  1. pip install -U google-adk - I ran on google-adk==1.15.1
  2. run the following code:
import time
start_time = time.time()

from google.adk.models import LLMRegistry, BaseLlm
from google.adk.models.lite_llm import LiteLlm

end_time = time.time()
print(f"Time taken: {end_time - start_time} seconds")

WITH PROFILING

import cProfile
import pstats
from io import StringIO

pr = cProfile.Profile()
pr.enable()


import time
start_time = time.time()

from google.adk.models import LLMRegistry, BaseLlm
from google.adk.models.lite_llm import LiteLlm

end_time = time.time()
print(f"Time taken: {end_time - start_time} seconds")

pr.disable()
s = StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)

# Save the profiling stats to a file
ps.dump_stats('profile_stats.prof')
  1. this already reproduces the issue but to open the profile file I used snakeviz
snakeviz profile_stats.prof

Expected behavior
A clear and concise description of what you expected to happen.
The import shouldn't take so long

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Desktop (please complete the following information):

  • OS: macos
  • Python version(python -V): 3.11.5
  • ADK version(pip show google-adk):1.15.1

Model Information:

  • Are you using LiteLLM: Yes but this happens with other imports like LLMRegistry
  • Which model is being used - N/A

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    models[Component] Issues related to model support

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions