Skip to content

Commit

Permalink
modified unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achew010 committed Jul 16, 2024
1 parent 22fda95 commit bda159a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 3 additions & 1 deletion plugins/accelerated-peft/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ bitsandbytes
# Used to manage the thread limit in functions for converting old
# GPTQ models to new GPTQ model format that support symmetrical=False
# https://github.com/AutoGPTQ/AutoGPTQ/pull/640
threadpoolctl
threadpoolctl >= 3.5.0

datasets >= 2.20.0
22 changes: 13 additions & 9 deletions plugins/accelerated-peft/tests/test_peft_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def autogptq_unavailable(package_name: str):
) as framework:
pass

# - Test that gptqmodel is used when use_external_lib is False
from fms_acceleration_peft.gptqmodel.nn_modules.qlinear.qlinear_tritonv2 import QuantLinear # pylint: disable=import-outside-toplevel
from fms_acceleration_peft.framework_plugin_autogptq import AutoGPTQAccelerationPlugin
# - Test that plugin attribute is set when config field `use_external_lib` is False
# When plugin attribute is set correctly, it will route to correct package on model loading
with instantiate_framework(
update_configuration_contents(
read_configuration(CONFIG_PATH_AUTO_GPTQ),
Expand All @@ -128,20 +129,23 @@ def autogptq_unavailable(package_name: str):
),
require_packages_check=False,
) as framework:
model = framework.model_loader(MODEL_NAME_AUTO_GPTQ)
assert any(isinstance(mod, QuantLinear) for mod in model.modules()), \
"use_external_lib=False, but local autogptq package not used by model"
for _, plugin in framework.active_plugins:
if isinstance(plugin, AutoGPTQAccelerationPlugin):
assert plugin.use_external_lib is False, \
"Plugin attribute not correctly set from config field"

# - Test that gptqmodel is used when use_external_lib is not set in config
# - Test that plugin attribute is set when config field `use_external_lib` is None
# When plugin attribute is set correctly, it will route to correct package on model loading
default_config = read_configuration(CONFIG_PATH_AUTO_GPTQ)
default_config['peft']['quantization']['auto_gptq'].pop('use_external_lib')
with instantiate_framework(
default_config,
require_packages_check=False,
) as framework:
model = framework.model_loader(MODEL_NAME_AUTO_GPTQ)
assert any(isinstance(mod, QuantLinear) for mod in model.modules()), \
"use_external_lib=None, but local autogptq package not used by model"
for _, plugin in framework.active_plugins:
if isinstance(plugin, AutoGPTQAccelerationPlugin):
assert plugin.use_external_lib is False, \
"Plugin attribute not correctly set from config field"

# We do not enable the skip since this test does not actually require the packages
# installed
Expand Down
3 changes: 2 additions & 1 deletion plugins/accelerated-peft/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ deps =
# for the tests, we need to install the deps ourselves
# as the package will install the github version
-e {toxinidir}/../framework
-r {toxinidir}/requirements.txt
# set skip package installation as it will install package pyproject.toml before deps, will throw error when AutoGPTQ needs torch
skip_install = true
commands =
# install the current package
pip install --no-deps {toxinidir}
pip install threadpoolctl protobuf sentencepiece datasets # these packages are required for some tests
pip install protobuf sentencepiece # these packages are required for some tests
pytest {posargs:tests}

[testenv:lint]
Expand Down

0 comments on commit bda159a

Please sign in to comment.