diff --git a/Makefile b/Makefile index 61a2edad..6bc83f80 100644 --- a/Makefile +++ b/Makefile @@ -109,8 +109,7 @@ install_cli_cpu_neural_compressor: install_cli_cuda_pytorch: pip install -e .[testing,timm,diffusers,peft,autoawq,auto-gptq,bitsandbytes,deepspeed] - optimum-benchmark +install_auto_awq_from_source=True - optimum-benchmark +install_auto_gptq_from_source=True + curl -s https://raw.githubusercontent.com/huggingface/optimum-benchmark/main/scripts/total_tests_runs.py | python - --install-autoawq --install-auto-gptq install_cli_rocm_pytorch: pip install -e .[testing,timm,diffusers,peft,autoawq,auto-gptq,deepspeed] diff --git a/optimum_benchmark/backends/pytorch/backend.py b/optimum_benchmark/backends/pytorch/backend.py index 1992720f..22259e09 100644 --- a/optimum_benchmark/backends/pytorch/backend.py +++ b/optimum_benchmark/backends/pytorch/backend.py @@ -293,7 +293,7 @@ def process_quantization_config(self) -> None: raise ImportError( "GPTQ quantization requires the AutoGPTQ package. " "Please install it from source at `https://github.com/AutoGPTQ/AutoGPTQ`" - "Or run optimum-benchmark +install_auto_gptq_from_source=True" + "Or `curl -s https://raw.githubusercontent.com/huggingface/optimum-benchmark/main/scripts/total_tests_runs.py | python - --install-auto-gptq`" ) self.quantization_config = GPTQConfig( @@ -308,7 +308,7 @@ def process_quantization_config(self) -> None: raise ImportError( "AWQ quantization requires the AutoAWQ package. " "Please install it from source at `https://github.com/casper-hansen/AutoAWQ`" - "Or run optimum-benchmark +install_auto_awq_from_source=True" + "Or `curl -s https://raw.githubusercontent.com/huggingface/optimum-benchmark/main/scripts/total_tests_runs.py | python - --install-autoawq`" ) self.quantization_config = AwqConfig( diff --git a/optimum_benchmark/cli.py b/optimum_benchmark/cli.py index 014698f2..57c6b054 100644 --- a/optimum_benchmark/cli.py +++ b/optimum_benchmark/cli.py @@ -6,8 +6,6 @@ from hydra.core.config_store import ConfigStore from omegaconf import DictConfig, OmegaConf -from optimum_benchmark.install_utils import InstallConfig, install_autoawq, install_autogptq - from . import ( Benchmark, BenchmarkConfig, @@ -57,20 +55,10 @@ cs.store(group="launcher", name=ProcessConfig.name, node=ProcessConfig) cs.store(group="launcher", name=TorchrunConfig.name, node=TorchrunConfig) -cs.store(name="install_config", node=InstallConfig) - # optimum-benchmark @hydra.main(version_base=None) def main(config: DictConfig) -> None: - if "install_auto_awq_from_source" in config and config.install_auto_awq_from_source: - install_autoawq() - return - - if "install_auto_gptq_from_source" in config and config.install_auto_gptq_from_source: - install_autogptq() - return - log_level = os.environ.get("LOG_LEVEL", "INFO") log_to_file = os.environ.get("LOG_TO_FILE", "1") == "1" override_benchmarks = os.environ.get("OVERRIDE_BENCHMARKS", "0") == "1" diff --git a/optimum_benchmark/install_utils.py b/optimum_benchmark/install_utils.py deleted file mode 100644 index cf004ac2..00000000 --- a/optimum_benchmark/install_utils.py +++ /dev/null @@ -1,90 +0,0 @@ -import os -import re -import subprocess -import sys -from dataclasses import dataclass - -EXTERNAL_REPOS_DIR = "external_repos" - - -@dataclass -class InstallConfig: - install_auto_awq_from_source: bool = False - install_auto_gptq_from_source: bool = False - - -def remove_torch_from_setup(setup_file_path): - """Remove any torch requirement from the setup.py file.""" - with open(setup_file_path, "r") as file: - setup_content = file.read() - - # Use a regular expression to remove any line containing "torch==" - setup_content = re.sub(r'"torch==[^\"]+",', "", setup_content) - - # Write the modified content back to setup.py - with open(setup_file_path, "w") as file: - file.write(setup_content) - - -def clone_or_pull_repo(repo_url, repo_location_path): - """Clone the repo if it doesn't exist; otherwise, pull the latest changes.""" - if os.path.exists(repo_location_path): - print(f"Directory {repo_location_path} already exists. Pulling the latest changes.") - subprocess.run(f"cd {repo_location_path} && git pull", shell=True, check=True) - else: - repo_name = repo_location_path.split("/")[-1] - print(f"Cloning {repo_name} into {repo_location_path}") - subprocess.run(f"git clone {repo_url} {repo_location_path}", shell=True, check=True) - - -def install_autogptq(): - """Install the AutoGPTQ package from GitHub.""" - - print("Installing AutoGPTQ package.") - - autogptq_repo_path = os.path.join(EXTERNAL_REPOS_DIR, "AutoGPTQ") - - clone_or_pull_repo("https://github.com/PanQiWei/AutoGPTQ.git", autogptq_repo_path) - - subprocess.run("pip install numpy gekko pandas", shell=True, check=True) - - subprocess.run( - f"cd {autogptq_repo_path} && {sys.executable} -m pip install -vvv --no-build-isolation -e .", - shell=True, - check=True, - ) - - print("AutoGPTQ package installed.") - - -def install_autoawq(): - """Install the AutoAWQ and AutoAWQ_kernels packages from GitHub.""" - - print("Installing AutoAWQ and AutoAWQ_kernels packages.") - - autoawq_kernels_repo_name = "AutoAWQ_kernels" - autoawq_repo_name = "AutoAWQ" - - kernels_repo_path = os.path.join(EXTERNAL_REPOS_DIR, autoawq_kernels_repo_name) - autoawq_repo_path = os.path.join(EXTERNAL_REPOS_DIR, autoawq_repo_name) - - clone_or_pull_repo(f"https://github.com/casper-hansen/{autoawq_kernels_repo_name}", kernels_repo_path) - - kernels_setup_file_path = os.path.join(kernels_repo_path, "setup.py") - remove_torch_from_setup(kernels_setup_file_path) - subprocess.run( - f"cd {kernels_repo_path} && {sys.executable} -m pip install --no-build-isolation -e .", - shell=True, - check=True, - env=os.environ, - ) - - clone_or_pull_repo(f"https://github.com/casper-hansen/{autoawq_repo_name}", autoawq_repo_path) - - autoawq_setup_file_path = os.path.join(autoawq_repo_path, "setup.py") - remove_torch_from_setup(autoawq_setup_file_path) - subprocess.run( - f"cd {autoawq_repo_path} && {sys.executable} -m pip install -e .", shell=True, check=True, env=os.environ - ) - - print("AutoAWQ and AutoAWQ_kernels packages installed.")