-
Notifications
You must be signed in to change notification settings - Fork 220
Minor bug fix: Make SkyRL's vllm engine compatible with higher versions of VLLM #882
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a compatibility issue with newer versions of the VLLM library by dynamically checking the signature of OpenAIServingModels before instantiation. This is a good approach to maintain compatibility across library versions. My review includes a suggestion to make this version check more robust by inspecting parameter names instead of the parameter count, and also includes some minor code cleanup.
| from inspect import signature | ||
| sig = signature(OpenAIServingModels) | ||
| base_model_paths = [BaseModelPath(name=model_name, model_path=model_path)] | ||
| models = OpenAIServingModels(engine, model_config, base_model_paths) | ||
| if len(sig.parameters) == 4: | ||
| # For OLD vllm (<0.11.2) | ||
| models = OpenAIServingModels(engine, model_config, base_model_paths) | ||
| else: | ||
| # For NEW vllm (>= 0.11.2) | ||
| models = OpenAIServingModels(engine, base_model_paths=base_model_paths)#model_config) | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good way to handle different versions of vllm. However, checking the number of parameters can be brittle if future versions add new optional parameters. A more robust approach would be to check for the existence of the model_config parameter in the signature. I've also cleaned up the commented-out code and removed the extra blank lines for better readability.
| from inspect import signature | |
| sig = signature(OpenAIServingModels) | |
| base_model_paths = [BaseModelPath(name=model_name, model_path=model_path)] | |
| models = OpenAIServingModels(engine, model_config, base_model_paths) | |
| if len(sig.parameters) == 4: | |
| # For OLD vllm (<0.11.2) | |
| models = OpenAIServingModels(engine, model_config, base_model_paths) | |
| else: | |
| # For NEW vllm (>= 0.11.2) | |
| models = OpenAIServingModels(engine, base_model_paths=base_model_paths)#model_config) | |
| from inspect import signature | |
| sig = signature(OpenAIServingModels) | |
| base_model_paths = [BaseModelPath(name=model_name, model_path=model_path)] | |
| if 'model_config' in sig.parameters: | |
| # For OLD vllm versions that have the 'model_config' parameter | |
| models = OpenAIServingModels(engine, model_config, base_model_paths) | |
| else: | |
| # For NEW vllm versions | |
| models = OpenAIServingModels(engine, base_model_paths=base_model_paths) | |
OpenAIServingModels from VLLM has different signatures depending on version