Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] invalid erfc result #6737

Closed
Tracked by #6445
hschoi4448 opened this issue Mar 25, 2024 · 4 comments
Closed
Tracked by #6445

[Bug Report] invalid erfc result #6737

hschoi4448 opened this issue Mar 25, 2024 · 4 comments
Assignees
Labels
bug Something isn't working forward moreh moreh contribution op_cat: eltwise P1

Comments

@hschoi4448
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
1.Copy and past below code

# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.

# 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

import ttnn
from tests.tt_eager.python_api_testing.sweep_tests import (
    pytorch_ops,
    tt_lib_ops
)
from tests.ttnn.python_api_testing.sweep_tests import ttnn_ops

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 test1(input_shapes, device):
    val = float('-1')
    in_data, input_tensor = data_gen_pt_tt(input_shapes, device, True, val=val)
    
    print("input_tensor", input_tensor)
    
    golden_tensor = pytorch_ops.erfc(in_data)
    tt_output_tensor_on_device = tt_lib.tensor.erfc(input_tensor)
    
    print("tt_output_tensor_on_device", tt_output_tensor_on_device)
    print("golden_tensor", golden_tensor)
    
  1. Run with pytest
input_tensor ttnn.Tensor([[[[-1.00000, -1.00000,  ..., -1.00000, -1.00000],
               [-1.00000, -1.00000,  ..., -1.00000, -1.00000],
               ...,
               [-1.00000, -1.00000,  ..., -1.00000, -1.00000],
               [-1.00000, -1.00000,  ..., -1.00000, -1.00000]]]], shape=Shape([1, 1, 32, 32]), dtype=DataType::BFLOAT16, layout=Layout::TILE)
tt_output_tensor_on_device ttnn.Tensor([[[[ 1.00000,  1.00000,  ...,  1.00000,  1.00000],
               [ 1.00000,  1.00000,  ...,  1.00000,  1.00000],
               ...,
               [ 1.00000,  1.00000,  ...,  1.00000,  1.00000],
               [ 1.00000,  1.00000,  ...,  1.00000,  1.00000]]]], shape=Shape([1, 1, 32, 32]), dtype=DataType::BFLOAT16, layout=Layout::TILE)
golden_tensor tensor([[[[1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          ...,
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438]]]],
       dtype=torch.bfloat16, grad_fn=<ErfcBackward0>)

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Please complete the following environment information:

  • OS: [e.g. Ubuntu 20.04]
  • Version of software (eg. commit 729e6c6)
  • Device: wormhole_b0

Additional context
Add any other context about the problem here.

@VirdhatchaniKN
Copy link
Contributor

VirdhatchaniKN commented Apr 4, 2024

Hi @hschoi4448 , @eyonland , @jliangTT , @tt-aho , @rtawfik01
Fix provided for forward erfc op - PR Link
All post-commit tests - Link - PASSED

VirdhatchaniKN added a commit that referenced this issue Apr 12, 2024
VirdhatchaniKN added a commit that referenced this issue Apr 15, 2024
@hschoi4448
Copy link
Contributor Author

hschoi4448 commented Apr 16, 2024

input_tensor ttnn.Tensor([[[[-1.00000, -1.00000,  ..., -1.00000, -1.00000],
               [-1.00000, -1.00000,  ..., -1.00000, -1.00000],
               ...,
               [-1.00000, -1.00000,  ..., -1.00000, -1.00000],
               [-1.00000, -1.00000,  ..., -1.00000, -1.00000]]]], shape=Shape([1, 1, 32, 32]), dtype=DataType::BFLOAT16, layout=Layout::TILE)
tt_output_tensor_on_device ttnn.Tensor([[[[ 1.00000,  1.00000,  ...,  1.00000,  1.00000],
               [ 1.00000,  1.00000,  ...,  1.00000,  1.00000],
               ...,
               [ 1.00000,  1.00000,  ...,  1.00000,  1.00000],
               [ 1.00000,  1.00000,  ...,  1.00000,  1.00000]]]], shape=Shape([1, 1, 32, 32]), dtype=DataType::BFLOAT16, layout=Layout::TILE)
golden_tensor tensor([[[[1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          ...,
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438],
          [1.8438, 1.8438, 1.8438,  ..., 1.8438, 1.8438, 1.8438]]]],
       dtype=torch.bfloat16, grad_fn=<ErfcBackward0>)

Still has a problem. Please check again.

hash: a059360
arc: wormhole_b0

@umadevimcw
Copy link
Contributor

@hschoi4448 PR is not yet merged

VirdhatchaniKN added a commit that referenced this issue Apr 16, 2024
VirdhatchaniKN added a commit that referenced this issue Apr 16, 2024
@VirdhatchaniKN
Copy link
Contributor

Hi @hschoi4448 , @jliangTT
Fix merged : Link
Screenshot 2024-04-16 at 1 03 33 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forward moreh moreh contribution op_cat: eltwise P1
Projects
None yet
Development

No branches or pull requests

3 participants