Skip to content

Fix broken linalg unittests on ARM platform #125438

@malfet

Description

@malfet

🐛 Describe the bug

If test_linalg.py is run on Mac M1 4 tests are failing:

======================================================================
ERROR: test_vector_norm_cpu_bfloat16 (__main__.TestLinalgCPU)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 2757, in wrapper
    method(*args, **kwargs)
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 432, in instantiated_test
    raise rte
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 419, in instantiated_test
    result = test(self, **param_kwargs)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1289, in test_vector_norm
    run_test_case(
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1262, in run_test_case
    result_dtype_reference = vector_norm_reference(input, ord, dim=dim, keepdim=keepdim, dtype=norm_dtype)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1246, in vector_norm_reference
    result = torch.linalg.norm(input_maybe_flat, ord, dim=dim, keepdim=keepdim, dtype=dtype)
RuntimeError: Found dtype Float but expected BFloat16

To execute this test, run the following from the base repo dir:
     python test/test_linalg.py -k test_vector_norm_cpu_bfloat16

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

======================================================================
ERROR: test_vector_norm_cpu_float16 (__main__.TestLinalgCPU)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 2757, in wrapper
    method(*args, **kwargs)
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 432, in instantiated_test
    raise rte
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 419, in instantiated_test
    result = test(self, **param_kwargs)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1289, in test_vector_norm
    run_test_case(
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1262, in run_test_case
    result_dtype_reference = vector_norm_reference(input, ord, dim=dim, keepdim=keepdim, dtype=norm_dtype)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1246, in vector_norm_reference
    result = torch.linalg.norm(input_maybe_flat, ord, dim=dim, keepdim=keepdim, dtype=dtype)
RuntimeError: Found dtype Float but expected Half

To execute this test, run the following from the base repo dir:
     python test/test_linalg.py -k test_vector_norm_cpu_float16

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

======================================================================
ERROR: test_vector_norm_cpu_float32 (__main__.TestLinalgCPU)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 2757, in wrapper
    method(*args, **kwargs)
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 432, in instantiated_test
    raise rte
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 419, in instantiated_test
    result = test(self, **param_kwargs)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1289, in test_vector_norm
    run_test_case(
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1262, in run_test_case
    result_dtype_reference = vector_norm_reference(input, ord, dim=dim, keepdim=keepdim, dtype=norm_dtype)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 1246, in vector_norm_reference
    result = torch.linalg.norm(input_maybe_flat, ord, dim=dim, keepdim=keepdim, dtype=dtype)
RuntimeError: Found dtype Double but expected Float

To execute this test, run the following from the base repo dir:
     python test/test_linalg.py -k test_vector_norm_cpu_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

======================================================================
FAIL: test_addmv_cpu_float16 (__main__.TestLinalgCPU)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 2757, in wrapper
    method(*args, **kwargs)
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_device_type.py", line 419, in instantiated_test
    result = test(self, **param_kwargs)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 5611, in test_addmv
    self._test_addmm_addmv(torch.addmv, t, m, v)
  File "/Users/nshulga/git/pytorch/pytorch-tmp/test/test_linalg.py", line 5576, in _test_addmm_addmv
    self.assertEqual(res1, res3)
  File "/Users/nshulga/git/pytorch/pytorch/torch/testing/_internal/common_utils.py", line 3640, in assertEqual
    raise error_metas.pop()[0].to_error(
AssertionError: Tensor-likes are not close!

Mismatched elements: 50 / 50 (100.0%)
Greatest absolute difference: 0.08056640625 at index (35,) (up to 0.001 allowed)
Greatest relative difference: 0.74755859375 at index (1,) (up to 0.001 allowed)

To execute this test, run the following from the base repo dir:
     python test/test_linalg.py -k test_addmv_cpu_float16

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

----------------------------------------------------------------------
Ran 1032 tests in 44.906s

FAILED (failures=1, errors=3, skipped=83)

Versions

CI

cc @mruberry @ZainRizvi @jianyuh @nikitaved @pearu @walterddr @xwang233 @lezcano @snadampal

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: armRelated to ARM architectures builds of PyTorch. Includes Apple M1module: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmulmodule: testsIssues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy