Skip to content

Commit

Permalink
Fix tests failing with Synapse 1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitgola005 committed Oct 29, 2024
1 parent b25cbaa commit 162c371
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .azure/hpu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ jobs:
-k test_autocast_operators_override --runxfail \
-W ignore::FutureWarning --junitxml=hpu_precision_test_override-results.xml
env:
LOWER_LIST: tests/test_pytorch/ops_fp32.txt
FP32_LIST: tests/test_pytorch/ops_bf16.txt
PT_HPU_AUTOCAST_LOWER_PRECISION_OPS_LIST : tests/test_pytorch/ops_fp32.txt
PT_HPU_AUTOCAST_FP32_OPS_LIST : tests/test_pytorch/ops_bf16.txt
displayName: 'HPU precision test'
- bash: |
Expand Down
36 changes: 36 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# 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.
import os
import shutil
from pathlib import Path

import pytest
Expand Down Expand Up @@ -41,3 +43,37 @@ def device_count(pytestconfig):
return 1
assert arg_hpus <= HPUAccelerator.auto_device_count(), "More hpu devices asked than present"
return arg_hpus


@pytest.fixture()
def _check_distributed(device_count):
if device_count <= 1:
pytest.skip("Distributed test does not run on single HPU")


@pytest.fixture()
def clean_folder(request):
"""A pytest fixture that checks if a folder exists and removes it if it does.
Usage:
@pytest.mark.parametrize('folder_path', ['my_test_folder'])
def test_something(clean_folder):
# The folder will be clean before the test
# and removed after the test
pass
"""
folder_path = request.param if hasattr(request, "param") else ""

# Clean up any existing folder
if os.path.exists(folder_path):
shutil.rmtree(folder_path)

# Create a fresh folder
os.makedirs(folder_path)

yield folder_path

# Clean up after the test
if os.path.exists(folder_path):
shutil.rmtree(folder_path)
3 changes: 2 additions & 1 deletion tests/test_pytorch/test_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def test_hpu_precision_convert_modules_precision_not_fp8():


@pytest.mark.skipif(get_device_name_from_hlsmi() == "GAUDI", reason="fp8 supported on Gaudi2 and above.")
@pytest.mark.parametrize("clean_folder", [os.path.join(os.environ["HABANA_LOGS"], "inc_output")], indirect=True)
@pytest.mark.parametrize("patch_path", ["tmpdir", None])
@pytest.mark.parametrize(
"fp8_config",
Expand All @@ -270,7 +271,7 @@ def test_hpu_precision_convert_modules_precision_not_fp8():
),
],
)
def test_hpu_precision_fp8_patch(patch_path, tmpdir, fp8_config):
def test_hpu_precision_fp8_patch(patch_path, tmpdir, fp8_config, clean_folder):
"""Tests fp8 jsons are patched correctly."""
model = BaseBM()
plugin = HPUPrecisionPlugin(precision="fp8")
Expand Down

0 comments on commit 162c371

Please sign in to comment.