-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Core] Don't do platform detection at import time #12933
[Core] Don't do platform detection at import time #12933
Conversation
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
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.
LGTM, I also want to make the import lazy, but unfortunately we have lots of from vllm.platforms import current_platform
in the top level, because people don't like the long vllm.platforms.current_platform.
usage :(
Can you fix the failure in Helm Chart CI? |
thanks for pointing it out. I'll take a look. |
Yeah ... it's not obvious that importing that way is a problem and it'll be hard to remember to look for it during code reviews. I was thinking about changing it to be a function instead of an attribute, then it could be imported this way without a problem. That was just a much bigger change and I wanted to fix this immediate impact to the CLI first. |
I think this was just a huggingface error. I'll get it to run again. |
Running just `vllm` or `vllm --version` or something similar resulted in several lines of log noise about platform detection. This is because several places were triggering this to occur at import time by doing the following: ```python from vllm.platforms import current_platform ``` Platform detection runs the first time the `current_platform` attribute is requested, which includes this import. Importing `vllm.platforms` and delaying the reference to `current_platform` until code actually needs it avoids running it in cases where it was never needed. I only changed the places that caused a problem in my environment when running `vllm`, though I'd say importing it like this at the top of a module is an anti-pattern in general. Signed-off-by: Russell Bryant <[email protected]>
cc4124d
to
a9cb538
Compare
When putting in newlines, it ends up being split across several log events. Signed-off-by: Russell Bryant <[email protected]>
Signed-off-by: Russell Bryant <[email protected]> Signed-off-by: SzymonOzog <[email protected]>
Running just
vllm
orvllm --version
or something similar resultedin several lines of log noise about platform detection. This is because
several places were triggering this to occur at import time by doing the
following:
Platform detection runs the first time the
current_platform
attribute isrequested, which includes this import. Importing
vllm.platforms
and delayingthe reference to
current_platform
until code actually needs it avoids runningit in cases where it was never needed.
I only changed the places that caused a problem in my environment when running
vllm
, though I'd say importing it like this at the top of a module is ananti-pattern in general.
Signed-off-by: Russell Bryant [email protected]