When the input is 1 and the other is 0, the correct gradient values are 1 and 0.6931, respectively.
However, the TT ldexp_bw returns 0.69141 and 0.47656 as the gradient values.
Furthermore, upon examining the implementation of ldexp_bw, it can be observed that it does not utilize the grad.
Moreover, I have created a pytest that can reproduce this case, and it also passes the compare_result check. This suggests that there may be an issue with the compare_result function as well.
To Reproduce
Steps to reproduce the behavior:
Check out branch
Run 'pytest ./tests/tt_eager/python_api_testing/unit_testing/backward_ops/test_backward_ldexp.py'
Describe the bug A clear and concise description of what the bug is.
The
ldexp_bw
function returns an invalid gradient value.When the input is 1 and the other is 0, the correct gradient values are 1 and 0.6931, respectively. However, the TT ldexp_bw returns 0.69141 and 0.47656 as the gradient values.
Furthermore, upon examining the implementation of ldexp_bw, it can be observed that it does not utilize the
grad
.Moreover, I have created a pytest that can reproduce this case, and it also passes the compare_result check. This suggests that there may be an issue with the
compare_result
function as well.To Reproduce Steps to reproduce the behavior:
SPDX-License-Identifier: Apache-2.0
import torch import pytest import tt_lib from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_pt_tt, compare_results
def data_gen_pt_tt(input_shapes, device, required_grad=False, val=1): pt_tensor = (torch.ones(input_shapes, requires_grad=required_grad) * val).bfloat16() tt_tensor = ( tt_lib.tensor.Tensor(pt_tensor, tt_lib.tensor.DataType.BFLOAT16).to(tt_lib.tensor.Layout.TILE).to(device) ) return pt_tensor, tt_tensor
@pytest.mark.parametrize( "input_shapes", ( (torch.Size([1, 1, 32, 32])), ), ) def test_bw_ldexp(input_shapes, device): in_data, input_tensor = data_gen_pt_tt(input_shapes, device, True, val=1) other_data, other_tensor = data_gen_pt_tt(input_shapes, device, True, val=0)
Expected behavior A clear and concise description of what you expected to happen.
I want
ldexp_bw
to return the correct gradientScreenshots If applicable, add screenshots to help explain your problem.
Please complete the following environment information:
Additional context Add any other context about the problem here.