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

Autograd warning spam [control_flow_graph.cpp:get_store_forwarding_data@341] stmt 130 loaded in stmt 131 before storing. #8454

Open
oliver-batchelor opened this issue Dec 27, 2023 · 2 comments

Comments

@oliver-batchelor
Copy link
Contributor

oliver-batchelor commented Dec 27, 2023

Code below causes warnings below, I haven't been able to workaround the problem - unsure if it actually matters.

Taichi nightly (commit f74d75d)

import taichi as ti
from taichi.math import  vec2, vec3, mat3
import torch

@ti.kernel
def project_to_image_kernel(  
  position: ti.types.ndarray(vec3, ndim=1), 
  T_image_camera: ti.types.ndarray(ndim=2),  # (3, 3)  
  points: ti.types.ndarray(vec2, ndim=1)):
  for idx in range(position.shape[0]):
      image_camera = mat3([T_image_camera[i, j] 
                            for i in ti.static(range(3)) for j in ti.static(range(3))])
      
      p = position[idx]
      uv = (image_camera @ p) / p.z
      points[idx] = uv.xy

ti.init(arch=ti.cuda, debug=True, log_level=ti.DEBUG)


position = torch.randn(100, 3).requires_grad_(True)
T_image_camera = torch.eye(3).requires_grad_(True)

point = torch.zeros(100, 2).requires_grad_(True)
project_to_image_kernel(position, T_image_camera, point)

point.grad = torch.ones_like(point)
project_to_image_kernel.grad(position,  T_image_camera, point)

Console output with logging DEBUG:

[Taichi] version 1.7.0, llvm 15.0.4, commit f74d75d9, linux, python 3.10.11
[Taichi] Starting on arch=x64
(Snip)

[D 12/27/23 21:37:27.739 178147] [kernel_compilation_manager.cpp:compile_and_cache_kernel@244] Cache kernel 'project_to_image_kernel_c76_0' (key='T06d24e7044ed87004d85c05738e85ea0c89e55c3f8a958abf810a2ae5b36276d')
[D 12/27/23 21:37:27.862 178147] [kernel_compilation_manager.cpp:compile_and_cache_kernel@244] Cache kernel 'project_to_image_kernel_c77_0_reverse_grad' (key='T61b02bfef15d20dd0ec5492f552c7b0f191bc99a18d55f71245d2bbd327aeb8b')

**[W 12/27/23 21:37:28.029 178150] [control_flow_graph.cpp:get_store_forwarding_data@341] stmt 130 loaded in stmt 131 before storing.
(10 more lines like this)**

[D 12/27/23 21:37:28.040 178150] [control_flow_graph.cpp:determine_ad_stack_size@1471] Unable to determine the necessary size for autodiff stacks [$123]. Use configured size (CompileConfig::default_ad_stack_size) 32 instead.
@github-project-automation github-project-automation bot moved this to Untriaged in Taichi Lang Dec 27, 2023
@oliver-batchelor oliver-batchelor changed the title Autograd simple projection kernel [control_flow_graph.cpp:get_store_forwarding_data@341] stmt 130 loaded in stmt 131 before storing. Autograd warning spam [control_flow_graph.cpp:get_store_forwarding_data@341] stmt 130 loaded in stmt 131 before storing. Dec 27, 2023
@oliver-batchelor
Copy link
Contributor Author

Update: despite these warnings it still seems to produce a correct gradient (though whatever I'm doing in the "larger" version makes the gradient kernel take a long time to compile!)

@lstrgar
Copy link

lstrgar commented Jul 30, 2024

Did you ever resolve what the issue was that was causing these warnings and long compile time?

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

2 participants