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 transformers and quantization imports #1770

Merged
merged 12 commits into from
Oct 18, 2023
2 changes: 1 addition & 1 deletion src/sparseml/modifiers/obcq/utils/layer_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import torch.nn as nn
from torch.nn import Module

from sparseml.modifiers.obcq.utils.sparsegpt import SparseGPT
from sparseml.pytorch.utils.helpers import get_dependency_order
from sparseml.transformers.sparsification.obcq.utils.sparsegpt import SparseGPT


_LOGGER = logging.getLogger(__name__)
Expand Down
13 changes: 13 additions & 0 deletions src/sparseml/modifiers/quantization/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
8 changes: 7 additions & 1 deletion tests/sparseml/modifiers/quantization/test_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from tests.sparseml.modifiers.conf import LifecyleTestingHarness, setup_modifier_factory
from tests.sparseml.pytorch.helpers import ConvNet, LinearNet
from tests.sparseml.pytorch.sparsification.quantization.test_modifier_quantization import ( # noqa E501
_match_submodule_name_or_type,
_test_qat_wrapped_module,
_test_quantized_module,
)
Expand Down Expand Up @@ -56,7 +57,12 @@ def _test_qat_applied(modifier, model):
_test_qat_wrapped_module(model, name)
elif is_quantizable:
# check each target module is quantized
_test_quantized_module(model, modifier, module, name)
override_key = _match_submodule_name_or_type(
module,
name,
list(modifier.scheme_overrides.keys()),
)
_test_quantized_module(model, modifier, module, name, override_key)
else:
# check all non-target modules are not quantized
assert not hasattr(module, "quantization_scheme")
Expand Down
Loading