mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.09k stars 246 forks source link

[Bug] Latest mitsuba3 failed for prbvolpath #1334

Closed andyyankai closed 2 days ago

andyyankai commented 1 month ago

The latest version of Mitsuba3 using the new version of DrJit failed when using prbvolpathfor backward/forward mode on heterogeneous volumes with NEE.

It seems the issue is caused by performing backward/forward operations in a loop nested within another loop during tracing, which might be related to the latest version of DrJit. Here is the error message:

Traceback (most recent call last): File "C:\xxx\mitsuba\python\ad\integrators\prbvolpath.py", line 271, in _loop_body dr.backward(δL * contrib) RuntimeError: CustomOp::backward(): the reverse-mode derivative of a complex loop (with max_iterations != -1) is not yet implemented! To reproduce the issue, you can run the code using python validation_heter.py. I have attached a file to help with this: validation_heter.zip.

The issue can be triggered by backpropagating a loss for sigma_t for any heterogeneous volume when using prbvolpath. I have also included a prbvolpath_m1 that supports forward_mode AD in the zip.

Thank you!

njroussel commented 3 weeks ago

Hi @andyyankai

We have a (temporary) fix for this in this commit which is part of #1287.

It's still unclear to me why it was necessary and so I'll be looking into that. In the meantime, you can use that patch - we've confirmed that it produces the correct result in reverse-mode AD:

andyyankai commented 3 weeks ago

Thanks, I will take a look on this.

andyyankai commented 3 weeks ago

My forward-mode AD also works after the fix, thanks! I will leave this issue open for a while in case there are some other problems.

njroussel commented 2 days ago

Closing for now. Of course, we can re-open this if you discover any discrepancies.