-
-
Notifications
You must be signed in to change notification settings - Fork 20.1k
[Bugfix] Enforce installed FlashInfer version to match optional requirement #24671
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,10 +15,12 @@ | |||||||||
|
|
||||||||||
| import requests | ||||||||||
| import torch | ||||||||||
| from packaging.version import parse | ||||||||||
|
|
||||||||||
| import vllm.envs as envs | ||||||||||
| from vllm.logger import init_logger | ||||||||||
| from vllm.platforms import current_platform | ||||||||||
| from vllm.version import FLASHINFER_VERSION | ||||||||||
|
|
||||||||||
| logger = init_logger(__name__) | ||||||||||
|
|
||||||||||
|
|
@@ -39,6 +41,22 @@ def has_flashinfer() -> bool: | |||||||||
| return importlib.util.find_spec("flashinfer") is not None | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def valid_flashinfer_version() -> bool: | ||||||||||
| """Check the installed FlashInfer version matches the expected.""" | ||||||||||
| if not has_flashinfer(): | ||||||||||
| return False | ||||||||||
|
|
||||||||||
| try: | ||||||||||
| import flashinfer | ||||||||||
|
|
||||||||||
| # Parse both versions to handle version comparison properly | ||||||||||
| expected = parse(FLASHINFER_VERSION) | ||||||||||
| actual = parse(flashinfer.__version__) | ||||||||||
| return actual == expected | ||||||||||
| except (ImportError, AttributeError): | ||||||||||
| return False | ||||||||||
|
Comment on lines
+56
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| def _missing(*_: Any, **__: Any) -> NoReturn: | ||||||||||
| """Placeholder for unavailable FlashInfer backend.""" | ||||||||||
| raise RuntimeError( | ||||||||||
|
|
@@ -65,6 +83,11 @@ def _lazy_import_wrapper(module_name: str, | |||||||||
| def _get_impl(): | ||||||||||
| if not has_flashinfer(): | ||||||||||
| return None | ||||||||||
| if not valid_flashinfer_version(): | ||||||||||
| raise RuntimeError( | ||||||||||
| "Installed FlashInfer version is not supported. " | ||||||||||
| f"Please install flashinfer-python=={FLASHINFER_VERSION} " | ||||||||||
| "or use the vLLM extra: pip install 'vllm[flashinfer]'") | ||||||||||
| mod = _get_submodule(module_name) | ||||||||||
| return getattr(mod, attr_name, None) if mod else None | ||||||||||
|
|
||||||||||
|
|
@@ -355,6 +378,7 @@ def flashinfer_scaled_fp8_mm( | |||||||||
|
|
||||||||||
| __all__ = [ | ||||||||||
| "has_flashinfer", | ||||||||||
| "valid_flashinfer_version", | ||||||||||
| "flashinfer_trtllm_fp8_block_scale_moe", | ||||||||||
| "flashinfer_cutlass_fused_moe", | ||||||||||
| "fp4_quantize", | ||||||||||
|
|
||||||||||
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.
Why not >=?
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.
Agree >= would work