From 26ee8eab67c106b2c44663ba91a396cecfbedd64 Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Sat, 10 Feb 2024 23:33:47 +0200 Subject: [PATCH] Update base for Update on "Extend SampleInput str representation with tensor data." As in the title. The aim of this addition is to make debugging certain CI failures (that cannot be reproduced locally) easier. For instance, currently we see messages like ``` Exception: Caused by sample input at index 0: SampleInput(input=Tensor[size=(20,), device="cuda:0", dtype=torch.float64], args=(), kwargs={}, broadcasts_input=False, name='') ``` that is not really useful (as all those sample parameters can often be detected by other means) without showing actual sample data. The sample data can then be related to the `index` part in the error messages like: ``` Mismatched elements: 2 / 20 (10.0%) Greatest absolute difference: nan at index (10,) (up to 1e-05 allowed) Greatest relative difference: nan at index (10,) (up to 1e-07 allowed) ``` As an example of usefulness of this PR, consider the following failure message: ``` inductor/test_torchinductor_opinfo.py::TestInductorOpInfoCPU::test_comprehensive_polygamma_polygamma_n_0_cpu_int32 ('RERUN', {'yellow': True}) [1.5510s] [ 70%] inductor/test_torchinductor_opinfo.py::TestInductorOpInfoCPU::test_comprehensive_polygamma_polygamma_n_0_cpu_int32 ('RERUN', {'yellow': True}) [0.0473s] [ 70%] inductor/test_torchinductor_opinfo.py::TestInductorOpInfoCPU::test_comprehensive_polygamma_polygamma_n_0_cpu_int32 FAILED [0.0493s] [ 70%] ==================================== RERUNS ==================================== __ TestInductorOpInfoCPU.test_comprehensive_polygamma_polygamma_n_0_cpu_int32 __ Traceback (most recent call last): AssertionError: Tensor-likes are not close! Mismatched elements: 9 / 25 (36.0%) Greatest absolute difference: inf at index (0, 0) (up to 1e-05 allowed), inf vs 20177651499008.0 Greatest relative difference: inf at index (0, 0) (up to 1.3e-06 allowed) The above exception was the direct cause of the following exception: Exception: Caused by sample input at index 0: SampleInput(input=Tensor[size=(5, 5), device="cpu", dtype=torch.int32, data=[-8, 6, 9, 0, 0, 5, 5, 7, 6, 5, 1, -5, 2, -1, 8, -4, 0, -6, 3, -5]], args=(1), kwargs={}, broadcasts_input=False, name='') ``` from which we learn that `torch.polygamma` result is actually correct because `polygamma(0, -8) -> inf` while the used reference value (20177651499008.0) is wrong (see https://github.com/pytorch/pytorch/issues/106692 for more details). [ghstack-poisoned] --- test/test_mps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_mps.py b/test/test_mps.py index 2b505a79cea3e..7840af5aaa95c 100644 --- a/test/test_mps.py +++ b/test/test_mps.py @@ -620,7 +620,7 @@ def mps_ops_modifier(ops): 'polygammapolygamma_n_3': [torch.float32, torch.int16, torch.int64, torch.int8], 'polygammapolygamma_n_4': [torch.float32, torch.int16, torch.int64, torch.int8], 'special.polygamma': [torch.float32, torch.int16, torch.int32, torch.int8], - 'special.polygammaspecial_polygamma_n_0': [torch.float32, torch.int16, torch.int32, torch.int64, torch.int8], + 'special.polygammaspecial_polygamma_n_0': [torch.float32, torch.int16, torch.int8], } # Those ops are not expected to work