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

[test] Test test_ad_basic.py failed on MacOS Mojave #1679

Closed
Rullec opened this issue Aug 10, 2020 · 3 comments · Fixed by #1779
Closed

[test] Test test_ad_basic.py failed on MacOS Mojave #1679

Rullec opened this issue Aug 10, 2020 · 3 comments · Fixed by #1779
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@Rullec
Copy link
Contributor

Rullec commented Aug 10, 2020

Describe the bug
I have a developement build on my MacOS, and didn't manage to pass the test of test_ad_basic.py.

Logs shown as below:

To Reproduce
pytest test_ad_basic.py

Logs

========================= FAILURES ==========================
____________________ test_trigonometric _____________________

args = (), kwargs = {}

    def wrapper(*args, **kwargs):
        if has_autograd:
>           func(*args, **kwargs)

test_ad_basics.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_ad_basics.py:80: in test_trigonometric
    grad_test(lambda x: ti.sin(x), lambda x: np.sin(x))
test_ad_basics.py:50: in grad_test
    impl()
../../python/taichi/lang/__init__.py:449: in wrapped
    test(*test_args, **test_kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @ti.all_archs_with(default_fp=default_fp)
    def impl():
        print(f'arch={ti.cfg.arch} default_fp={ti.cfg.default_fp}')
        x = ti.var(default_fp)
        y = ti.var(default_fp)
    
        ti.root.dense(ti.i, 1).place(x, x.grad, y, y.grad)
    
        @ti.kernel
        def func():
            for i in x:
                y[i] = tifunc(x[i])
    
        v = 0.234
    
        y.grad[0] = 1
        x[0] = v
        func()
        func.grad()
    
>       assert y[0] == approx(npfunc(v))
E       assert 0.23188334703445435 == 0.2318703549116868 ± 2.3e-07
E        +  where 0.2318703549116868 ± 2.3e-07 = approx(0.2318703549116868)
E        +    where 0.2318703549116868 = <function test_trigonometric.<locals>.<lambda> at 0x123d80378>(0.234)

test_ad_basics.py:47: AssertionError
------------------- Captured stdout call --------------------
Running test on arch=Arch.x64
[Taichi] Starting on arch=x64
arch=Arch.x64 default_fp=DataType.float32
[Taichi] materializing...
Running test on arch=Arch.metal
[Taichi] Starting on arch=metal
arch=Arch.metal default_fp=DataType.float32
[Taichi] materializing...
Running test on arch=Arch.x64
[Taichi] Starting on arch=x64
arch=Arch.x64 default_fp=DataType.float32
[Taichi] materializing...
Running test on arch=Arch.metal
[Taichi] Starting on arch=metal
arch=Arch.metal default_fp=DataType.float32
[Taichi] materializing...
@Rullec Rullec added the potential bug Something that looks like a bug but not yet confirmed label Aug 10, 2020
@archibate
Copy link
Collaborator

assert 0.23188334703445435 == 0.2318703549116868 ± 2.3e-07

As you can see the error here is really small, that it should not fail at all.

I think we can do a mock in ti.approx to increase the rel tolerance a little bit like OpenGL does:

if ti.cfg.arch == ti.opengl:
kwargs['rel'] = max(kwargs.get('rel', 1e-6), 1e-3)

@Rullec would you do the same thing to metal? A good issue for you :)

@Rullec
Copy link
Contributor Author

Rullec commented Aug 10, 2020

``

As you can see the error here is really small, that it should not fail at all.

Yes! It's the same as I guess. It's always hard to find a nice "epsilon".

@Rullec would you do the same thing to metal? A good issue for you :)

Thanks! I will try to handle it under all of your guidence.

@Rullec
Copy link
Contributor Author

Rullec commented Aug 10, 2020

Btw, The other 3 tests failed on my mac as well:

[error] error when testing test_bitmasked.py, return 256
[error] error when testing test_global_store_grad.py, return 1280
[error] error when testing test_ad_basics.py, return 256
[error] error when testing test_element_wise.py, return 256

I will double check them later, and if they are not my wrong, would it be proper to report them as well in this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants