Added torchaudio installation to setup.py#1010
Added torchaudio installation to setup.py#1010tzielinski-habana wants to merge 3 commits intovllm-project:mainfrom
Conversation
Signed-off-by: tzielinski-habana <tomasz.zielinski@intel.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts setup.py dependency handling to avoid pulling CUDA-enabled PyTorch when adding torchaudio, by removing torchaudio from install_requires and attempting to install it separately with pip --no-deps using a version derived from the installed torch.
Changes:
- Filter
torchaudioout ofinstall_requiresderived fromrequirements.txt. - Add post-
setup()logic that importstorch, derives atorchaudio==x.y.zpin fromtorch.__version__, and runspip install --no-depsagainst the PyTorch CPU wheel index.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Skipped during metadata generation (dist_info / egg_info). | ||
| if "dist_info" not in sys.argv and "egg_info" not in sys.argv: |
There was a problem hiding this comment.
The dist_info/egg_info argv guard is not sufficient to prevent this from running during packaging operations: wheel builds typically invoke bdist_wheel (and possibly sdist/build), so this block will still run while producing artifacts. If this logic remains, it should be gated so it only runs for the final install into the target environment (not during build/metadata/wheel creation).
| # Skipped during metadata generation (dist_info / egg_info). | |
| if "dist_info" not in sys.argv and "egg_info" not in sys.argv: | |
| # Skipped during metadata generation and build/package creation. | |
| if not any(cmd in sys.argv for cmd in ("dist_info", "egg_info", "bdist_wheel", "sdist", "build")): |
| "and add --no-build-isolation to pip install\n" | ||
| "********************************************************************************\n") from None | ||
| # Extract stable x.y.z from versions like 2.10.0a0+git... | ||
| ver = re.match(r"(\d+\.\d+\.\d+)", torch.__version__).group(1) |
There was a problem hiding this comment.
re.match(...).group(1) will raise an AttributeError if torch.__version__ doesn’t match the expected x.y.z format (e.g., unusual local builds). This would fail the package install even if torchaudio is otherwise optional. Handle the no-match case explicitly (raise a clear error or fall back to a safer version parsing approach, e.g., via packaging.version).
| ver = re.match(r"(\d+\.\d+\.\d+)", torch.__version__).group(1) | |
| version_match = re.match(r"(\d+\.\d+\.\d+)", torch.__version__) | |
| if version_match is None: | |
| raise RuntimeError( | |
| f"Unable to parse torch version from '{torch.__version__}' " | |
| "to determine the matching torchaudio version." | |
| ) | |
| ver = version_match.group(1) |
| if "dist_info" not in sys.argv and "egg_info" not in sys.argv: | ||
| try: | ||
| import torch | ||
| except ImportError: | ||
| raise RuntimeError( | ||
| "torch is not importable - this is needed for torchaudio installation.\n\n" | ||
| "********************************************************************************\n" | ||
| "Make sure torch is installed before installing vllm-gaudi\n" | ||
| "and add --no-build-isolation to pip install\n" | ||
| "********************************************************************************\n") from None | ||
| # Extract stable x.y.z from versions like 2.10.0a0+git... | ||
| ver = re.match(r"(\d+\.\d+\.\d+)", torch.__version__).group(1) | ||
| subprocess.check_call([ |
There was a problem hiding this comment.
The torchaudio install runs unconditionally and will re-run on every invocation, potentially downgrading/upgrading an existing torchaudio install. Consider first checking whether torchaudio is already installed and whether its version matches the desired torch version before calling pip.
| # Exclude torchaudio from install_requires — it needs --no-deps to | ||
| # avoid pulling CUDA torch, which install_requires cannot express. | ||
| requirements = [r for r in requirements if not r.strip().startswith("torchaudio")] | ||
|
|
There was a problem hiding this comment.
Filtering requirements via startswith("torchaudio") can accidentally exclude unrelated packages (e.g., torchaudio-foo) and won’t handle some valid requirement formats reliably. If torchaudio ever appears in requirements files, consider parsing each line as a PEP 508 requirement and filtering by normalized project name instead of a string prefix.
| subprocess.check_call([ | ||
| sys.executable, | ||
| "-m", | ||
| "pip", | ||
| "install", | ||
| "--no-deps", | ||
| "--extra-index-url", | ||
| "https://download.pytorch.org/whl/cpu", | ||
| f"torchaudio=={ver}", | ||
| ]) |
There was a problem hiding this comment.
Running pip install via subprocess.check_call inside setup.py introduces build-time side effects (network access, mutating the build env) under the PEP 517 setuptools.build_meta backend. This will execute during wheel builds (e.g., bdist_wheel) and can break reproducible/offline builds and CI. Prefer moving this to an explicit install step (docs or a dedicated installer script/extra) rather than performing dependency installation from setup.py.
| subprocess.check_call([ | |
| sys.executable, | |
| "-m", | |
| "pip", | |
| "install", | |
| "--no-deps", | |
| "--extra-index-url", | |
| "https://download.pytorch.org/whl/cpu", | |
| f"torchaudio=={ver}", | |
| ]) | |
| # Building/installing this package should not perform network operations or | |
| # mutate the environment (e.g., by running `pip install`). Instead, tell the | |
| # user how to install a matching torchaudio version explicitly. | |
| cmd = ( | |
| f"{sys.executable} -m pip install --no-deps --extra-index-url " | |
| "https://download.pytorch.org/whl/cpu " | |
| f"torchaudio=={ver}" | |
| ) | |
| raise RuntimeError( | |
| "torchaudio is required but is not installed.\n\n" | |
| "To install a CPU-only torchaudio build matching your torch version, run:\n\n" | |
| f" {cmd}\n\n" | |
| "Note: This command must be run explicitly by the user; it is not executed\n" | |
| "automatically during the build to keep builds reproducible and side-effect free." | |
| ) |
Signed-off-by: tzielinski-habana <tomasz.zielinski@intel.com>
Signed-off-by: tzielinski-habana <tomasz.zielinski@intel.com>
🚧 CI BlockedThe main CI workflow was not started for the following reason:
|
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
- Add VLLM_WARMUP_TIMEOUT and VLLM_WARMUP_DEBUG environment variables - Add detailed logging in warmup_graphs to track bucket processing - Add timing information for each warmup bucket - Add debug logging in _prepare_dummy_scenario and _execute_dummy_scenario - Add diagnostic scripts for bucket analysis - Add WARMUP_DEBUG_GUIDE.md with troubleshooting steps This helps diagnose warmup hangs in large models like Qwen3.5-122B. Signed-off-by: Gezhen <gezhen@company.com>
This pull request introduces changes to the
setup.pyinstallation logic, specifically addressing the handling of thetorchaudiodependency to avoid inadvertently installing CUDA-enabled PyTorch when only CPU support is desired. The changes ensure a safer and more predictable installation process for users.Dependency management improvements:
torchaudiofrominstall_requiresinsetup.py, as its installation requires special handling to avoid pulling CUDA torch dependencies.torchaudioseparately usingpip install --no-depswith the correct version matching the installedtorch, and only if not running in metadata generation mode (dist_infooregg_info).We need torchaudio because it's imported from upstream vllm as a result of this PR:
vllm-project/vllm#33247