From 0b47281f5158e992dd74ca391b814fa6a7c63093 Mon Sep 17 00:00:00 2001 From: salman Date: Tue, 7 Jan 2025 13:42:01 +0000 Subject: [PATCH] Fixing OSX installation (#2231) * bumping version, removing non-osx compatible deps * updating pylintrc * fixing linters * reverting changes --- .pre-commit-config.yaml | 2 +- .pylintrc | 3 ++- setup.py | 23 +++++++++++++++++++---- src/axolotl/utils/callbacks/lisa.py | 2 +- src/axolotl/utils/model_shard_quant.py | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f2ceac56..9409b1ef1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/PyCQA/pylint - rev: v2.17.4 + rev: v3.3.0 hooks: - id: pylint - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/.pylintrc b/.pylintrc index ed973d285..208dd32b6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,5 +1,5 @@ [MASTER] -init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))" +init-hook="from pylint.config import find_default_config_files; import sys; sys.path.append(next(find_default_config_files()).parent.as_posix())" [TYPECHECK] @@ -12,3 +12,4 @@ generated-members=numpy.*, torch.* disable=missing-function-docstring, line-too-long, import-error, too-many-arguments, too-many-locals, too-many-statements, too-many-branches, too-few-public-methods, too-many-instance-attributes, fixme, import-outside-toplevel, logging-fstring-interpolation, + too-many-positional-arguments, possibly-used-before-assignment diff --git a/setup.py b/setup.py index 4424d430a..218d85cf7 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """setup.py for axolotl""" + import ast import os import platform @@ -29,15 +30,29 @@ def parse_requirements(): elif not is_extras and line and line[0] != "#": # Handle standard packages _install_requires.append(line) - try: xformers_version = [req for req in _install_requires if "xformers" in req][0] torchao_version = [req for req in _install_requires if "torchao" in req][0] autoawq_version = [req for req in _install_requires if "autoawq" in req][0] - if "Darwin" in platform.system(): - # don't install xformers on MacOS - _install_requires.pop(_install_requires.index(xformers_version)) + # skip packages not compatible with OSX + skip_packages = [ + "bitsandbytes", + "triton", + "mamba-ssm", + "flash-attn", + "xformers", + "autoawq", + "liger-kernel", + ] + _install_requires = [ + req + for req in _install_requires + if re.split(r"[>=<]", req)[0].strip() not in skip_packages + ] + print( + _install_requires, [req in skip_packages for req in _install_requires] + ) else: # detect the version of torch already installed # and set it so dependencies don't clobber the torch version diff --git a/src/axolotl/utils/callbacks/lisa.py b/src/axolotl/utils/callbacks/lisa.py index ff20959a5..e226471b1 100644 --- a/src/axolotl/utils/callbacks/lisa.py +++ b/src/axolotl/utils/callbacks/lisa.py @@ -43,7 +43,7 @@ def lisa_callback_factory(trainer: "AxolotlTrainer"): getattr, self.layers_attribute.split("."), self.trainer.model ) LOG.info( - f"LISA will activate {self.n_layers}/{len(layers)} layers ({self.n_layers*100/len(layers)}%) every {self.step_interval} steps" + f"LISA will activate {self.n_layers}/{len(layers)} layers ({self.n_layers * 100 / len(layers)}%) every {self.step_interval} steps" ) def freeze_all_layers(self): diff --git a/src/axolotl/utils/model_shard_quant.py b/src/axolotl/utils/model_shard_quant.py index 9ed7ae471..ecbe86613 100644 --- a/src/axolotl/utils/model_shard_quant.py +++ b/src/axolotl/utils/model_shard_quant.py @@ -270,7 +270,7 @@ def load_sharded_model_quant( model.hf_quantizer = AutoHfQuantizer.from_config(quantization_config) if cfg.local_rank == 0 and verbose: - print(f"Loaded model weights in {time.time()-start:.3f} seconds") + print(f"Loaded model weights in {time.time() - start:.3f} seconds") # cleanup any extra memory usage from parallel loading torch.cuda.empty_cache()