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

Dynamic model class loading #101

Merged
merged 2 commits into from
Jan 25, 2024
Merged

Dynamic model class loading #101

merged 2 commits into from
Jan 25, 2024

Conversation

comaniac
Copy link
Collaborator

This PR attempts to make the model loading process more systematic and self-contained. Currently when addinga new model, we have to explicitly import the model entry class in model_runnter.load_model function. This introduces two drawbacks:

  1. model_runner.py cannot focus on the changes of "model runner".
  2. Developers have to change 2 files when adding a new model. The change inmodel_runner.py is easy to be missed and may result in conflicts.

sglang.srt does not follow the standard Python package structure (i.e., leveraging __init__.py to construct module hierarchy), so it's not straightforward to use a model registry with decorator. In this PR, I tried to dynamically scan all model files under models, and load their entry classes. The major drawback of this approach is that every model file has to have EntryClass alias to be scanned. IMHO it should be relatively easy for developers to follow.

Please share your thoughts.

@merrymercy merrymercy merged commit 3a581e9 into main Jan 25, 2024
@merrymercy merrymercy deleted the cody/model branch January 25, 2024 23:29
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.

None yet

2 participants