Skip to content

Commit 7bf9521

Browse files
committed
[SW-193263] Switch HQT unit tests to run on INC
Modify test to point to the correct package in INC instead of HQT. Add __init__.py file to include needed content for test_layers' tests. Change-Id: If47acdfc9f7521a54a7f350a444711a7c2b3e5b2
1 parent a5b6ef8 commit 7bf9521

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

test/3x/torch/algorithms/fp8_quant/fp8_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import habana_frameworks.torch.core as htcore
2-
import habana_quantization_toolkit
31
import torch
2+
import habana_frameworks.torch.core as htcore
3+
import neural_compressor.torch.algorithms.fp8_quant
44

55
# This file is for small tests run for debug flow and accuracy. (Not for CI)
66

@@ -73,7 +73,7 @@ def forward(self, x, b):
7373
model.eval()
7474
model = model.to("hpu").to(torch.bfloat16)
7575
htcore.hpu_initialize()
76-
habana_quantization_toolkit.prep_model(model) # fp8 additions
76+
neural_compressor.torch.algorithms.fp8_quant.prep_model(model) # fp8 additions
7777

7878

7979
with torch.no_grad():
@@ -170,4 +170,4 @@ def forward(self, x, b):
170170
# 5) tensor([[232.]], device='hpu:0', dtype=torch.bfloat16)
171171

172172
# fp8 additions
173-
habana_quantization_toolkit.finish_measurements(model)
173+
neural_compressor.torch.algorithms.fp8_quant.finish_measurements(model)

test/3x/torch/algorithms/fp8_quant/unit_tests/test_deepspeed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import pytest
44
import torch
5-
from habana_quantization_toolkit._quant_common.quant_config import ScaleMethod
6-
from habana_quantization_toolkit.tests import TestVector, run_accuracy_test
5+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.quant_config import ScaleMethod
6+
from ..tester import run_accuracy_test, TestVector
77

88

99
class LinearBlock(torch.nn.Module):

test/3x/torch/algorithms/fp8_quant/unit_tests/test_functions/test_config_json.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Use this module as an example of how to write new unit tests for layers."""
2-
3-
import habana_quantization_toolkit as hqt
2+
import os
43
import torch
5-
from habana_quantization_toolkit._quant_common.helper_modules import Matmul
6-
from habana_quantization_toolkit._quant_common.quant_config import QuantMode
4+
import neural_compressor.torch.algorithms.fp8_quant as fp8_quant
5+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.quant_config import QuantMode
6+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.helper_modules import Matmul
77

88

99
class Model(torch.nn.Module):
@@ -20,6 +20,7 @@ def test_config_json():
2020
QuantMode.MEASURE: "measure",
2121
QuantMode.QUANTIZE: "quant",
2222
}[mode]
23-
config_path = f"llama_{name}"
24-
hqt.prep_model(model, config_path=config_path)
25-
hqt.finish_measurements(model)
23+
config_path = os.path.join(os.environ.get("NEURAL_COMPRESSOR_FORK_ROOT"),
24+
f"neural_compressor/torch/algorithms/fp8_quant/custom_config/llama_{name}.json")
25+
fp8_quant.prep_model(model, config_path=config_path)
26+
fp8_quant.finish_measurements(model)

test/3x/torch/algorithms/fp8_quant/unit_tests/test_functions/test_matmul_fp8.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import itertools
22
from typing import Iterable, Tuple
3-
4-
import habana_frameworks.torch.utils.experimental as htexp
53
import pytest
64
import torch
7-
from habana_quantization_toolkit._core.fp_utils import FP8_143_SCALES
8-
from habana_quantization_toolkit._quant_common.helper_modules import matmul_fp8
5+
from neural_compressor.torch.algorithms.fp8_quant._core.fp_utils import FP8_143_SCALES
6+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.helper_modules import matmul_fp8
7+
import habana_frameworks.torch.utils.experimental as htexp
98

109

1110
def run_test_matmul_fp8(

test/3x/torch/algorithms/fp8_quant/unit_tests/test_layers/__init__.py

Whitespace-only changes.

test/3x/torch/algorithms/fp8_quant/unit_tests/test_layers/test_conv2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import pytest
44
import torch
5-
from habana_quantization_toolkit._quant_common.quant_config import ScaleMethod
6-
from habana_quantization_toolkit.tests import TestVector, run_accuracy_test
5+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.quant_config import ScaleMethod
6+
from ...tester import run_accuracy_test, TestVector
77

88

99
def get_test_vectors(*, dtype: torch.dtype, C_in: int, H: int, W: int) -> typing.Iterable[TestVector]:

test/3x/torch/algorithms/fp8_quant/unit_tests/test_layers/test_linear.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import pytest
44
import torch
5-
from habana_quantization_toolkit._quant_common.quant_config import ScaleMethod
6-
from habana_quantization_toolkit.tests import TestVector, run_accuracy_test
5+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.quant_config import ScaleMethod
6+
from ...tester import run_accuracy_test, TestVector
77

88

99
def get_test_vectors(*, dtype: torch.dtype, N: int, D_in: int) -> typing.Iterable[TestVector]:

test/3x/torch/algorithms/fp8_quant/unit_tests/test_layers/test_matmul.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import pytest
44
import torch
5-
from habana_quantization_toolkit._quant_common.quant_config import ScaleMethod
6-
from habana_quantization_toolkit.tests import TestVector, run_accuracy_test
5+
from neural_compressor.torch.algorithms.fp8_quant._quant_common.quant_config import ScaleMethod
6+
from ...tester import run_accuracy_test, TestVector
77

88

99
def get_test_vectors(*, dtype: torch.dtype) -> typing.Iterable[TestVector]:
@@ -31,8 +31,8 @@ def get_test_vectors(*, dtype: torch.dtype) -> typing.Iterable[TestVector]:
3131

3232

3333
class Matmul(torch.nn.Module):
34-
"""This is a mimic of other implementations of `Matmul`.
35-
34+
"""
35+
This is a mimic of other implementations of `Matmul`.
3636
It is here to not create a dependency on optimum-habana (which is logically needed).
3737
It should not be used directly in user code.
3838
"""

0 commit comments

Comments
 (0)