Skip to content

Commit

Permalink
make style
Browse files Browse the repository at this point in the history
  • Loading branch information
jimypbr committed Jul 24, 2023
1 parent 117a13f commit 6c08776
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
17 changes: 6 additions & 11 deletions optimum/graphcore/custom_ops/sdk_version_hash/sdk_version_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import cppimport.import_hook
import warnings
import logging

import cppimport.import_hook # noqa: F401


__all__ = ["sdk_version_hash"]


def sdk_version_hash() -> str:
"""Graphcore SDK version hash (sanitised output from C++ function `poplar::packageHash`)"""
try:
from . import sdk_version_hash_lib
return sdk_version_hash_lib.sdk_version_hash()
except SystemExit as error:
warn_str = f"Failed to collect Poplar SDK package hash. Failed with error: {error}"
logging.warning(warn_str)
warnings.warn(warn_str)
return "unknown"
from . import sdk_version_hash_lib

return sdk_version_hash_lib.sdk_version_hash()
1 change: 1 addition & 0 deletions optimum/graphcore/models/whisper/modeling_whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ def change_lm_head(self, restore: bool, use_cache: bool = None):
def quantize_linear_layers(self, restore: bool, num_groups: int = 16):
if not restore:
from ...quantization.group_quantize import GroupQuantLinear

logger.info("Group quantizing linear layers")
for module in self.model.encoder.layers:
module.self_attn.q_proj = GroupQuantLinear.from_model(module.self_attn.q_proj, num_groups)
Expand Down
4 changes: 3 additions & 1 deletion optimum/graphcore/quantization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pathlib import Path

from ..custom_ops.utils import load_lib


load_lib(Path(__file__).parent.parent / "custom_ops/group_quantize_decompress/group_quantize_decompress.cpp")

from .group_quantize import group_quantize_compress, group_quantize_decompress, GroupQuantLinear
from .group_quantize import GroupQuantLinear, group_quantize_compress, group_quantize_decompress
6 changes: 3 additions & 3 deletions tests/test_custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@


class TestCustomOps(unittest.TestCase):

def test_group_quantize_compiles(self):
# Importing quantize should compile
from optimum.graphcore.quantization import group_quantize
from optimum.graphcore.quantization import group_quantize # noqa: F401

def test_sdk_version_hash(self):
from optimum.graphcore.custom_ops.sdk_version_hash import sdk_version_hash
from optimum.graphcore.custom_ops.sdk_version_hash import sdk_version_hash

hash = sdk_version_hash()
self.assertTrue(type(hash) is str)

0 comments on commit 6c08776

Please sign in to comment.