Skip to content
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

Fix quantization tests #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions nn_pruning/modules/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
prepare_fx,
prepare_qat_fx,
)
from transformers.modeling_fx_utils import symbolic_trace

from transformers.utils.fx import symbolic_trace
from .quantization_config import create_qconfig


Expand Down Expand Up @@ -113,11 +112,10 @@ def _prepare(
else:
model.eval()

traced = symbolic_trace(
model, input_names=input_names, batch_size=batch_size, sequence_length=sequence_length, num_choices=num_choices
)
traced = symbolic_trace(model, input_names=input_names)

change_attention_mask_value(traced)
# traced=model
prepare_custom_config_dict = {"preserved_attributes": ["config", "dummy_inputs"]}
prepared_model = torch_prepare_fn(traced, qconfig_dict, prepare_custom_config_dict)

Expand Down
15 changes: 12 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ def readme():
with open("README.md") as f:
return f.read()


extras = {
"tests": ["pytest"],
"examples": ["numpy>=1.2.0", "datasets>=1.4.1", "ipywidgets>=7.6.3", "matplotlib>=3.3.4", "pandas>=1.2.3"],
"tests": ["pytest", "transformers==4.15.0", "torch==1.9"],
"examples": [
"numpy>=1.2.0",
"datasets>=1.4.1",
"ipywidgets>=7.6.3",
"matplotlib>=3.3.4",
"pandas>=1.2.3",
],
}


def combine_requirements(base_keys):
return list(set(k for v in base_keys for k in extras[v]))


extras["dev"] = combine_requirements([k for k in extras if k != "examples"])


Expand All @@ -33,7 +42,7 @@ def combine_requirements(base_keys):
author_email="",
license="MIT",
packages=["nn_pruning", "nn_pruning.modules"],
install_requires=["click", "transformers>=4.3.0", "torch>=1.6", "scikit-learn>=0.24"],
install_requires=["click", "transformers>=4.3", "torch>=1.6", "scikit-learn>=0.24"],
extras_require=extras,
test_suite="nose.collector",
tests_require=["nose", "nose-cover3"],
Expand Down