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

Autodiff is broken for opengl and vulkan #8524

Open
bmanga opened this issue Apr 26, 2024 · 0 comments
Open

Autodiff is broken for opengl and vulkan #8524

bmanga opened this issue Apr 26, 2024 · 0 comments

Comments

@bmanga
Copy link

bmanga commented Apr 26, 2024

Describe the bug
Using the opengl or vulkan backends result in nonsensical values even in the most basic examples. CPU and cuda work fine.

To Reproduce

import taichi as ti

ti.init(arch=ti.vulkan)

x = ti.ndarray(ti.float32, shape=(), needs_grad=True)
y = ti.ndarray(ti.float32, shape=(), needs_grad=True)
x[None] = 2.0

@ti.kernel
def forward(x: ti.types.ndarray(ti.float32, 0, needs_grad=True),
            y: ti.types.ndarray(ti.float32, 0, needs_grad=True)):
    y[None] = x[None]

with ti.ad.Tape(loss=y):
    forward(x, y)

print(x.to_numpy())       # expect 2
print(y.to_numpy())       # expect 2
print(x.grad.to_numpy())  # expect 1

Log/Screenshots

$ python my_sample_code.py
[Taichi] version 1.8.0, llvm 15.0.4, commit 52b24f3e, linux, python 3.8.8
[Taichi] Starting on arch=vulkan
4.0
0.0
0.0

Additional comments
I'm not sure if this is a known limitation, but if it is, it would be helpful if it was mentioned somewhere in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant