christophercrouzet / nvidia-warp-houdini

Exposes NVIDIA's Warp framework to Houdini.
39 stars 5 forks source link

Differentiablility #2

Open jprnd opened 1 year ago

jprnd commented 1 year ago

Is there differentiability in this HDA?

christophercrouzet commented 1 year ago

Hi @jprnd, no, the node doesn't expose differentiability. But it's something that we might expose later on as a ROP node.

jprnd commented 1 year ago

I saw that Taichi has differentiability in one of their Houdini HDAs: https://github.com/taichi-dev/taichi_houdini

It reads: _"In our HToTi-MPM asset, we solve the ti.init() problem by making MPM_solver_shell objects inside the module. When Python imports this module for the 1st time, these objects are materialized and kept in cache while Houdini is running. Hence, for every frame, we only need to re-fill the particle information, saving time for compiling and allocating memory.

We also move the emitors and colliders to be 2 external assets and connect them to the inputs of the solver SOP. Every frame, the solver SOP will read the updated emitors and colliders and refresh the corresponding settings. This procedure decouples the geometry editing and the solver's advancing and utilizes Houdini's flexibility."_

Is there a way to do something like they did in SOPs?

christophercrouzet commented 1 year ago

From what I'm gathering in your previous comment, and from what they answered to you here, this doesn't look like differentiability to me?

To be honest, I'm not sure how this would work robustly in SOP since it's a context that allows us to go back and forth in time by scrubbing the timeline, with no definite start/end frames, whereas differentiability requires to play a simulation over a fixed frame range before being able to play it backwards, which is something that would be best done in ROP.

Would there be an issue with using a ROP node for that scenario?

jprnd commented 1 year ago

No issue. I am a grad student just learning Houdini and haven't gotten to ROPs. I think that LOPs also looks to be USD specific and has rendering, etc. I am interested in setting this up and figuring stuff out. What are your thoughts on the LOPs with Warp for differentiability?

https://www.sidefx.com/docs/houdini/nodes/lop/pythonscript.html https://www.sidefx.com/docs/houdini/nodes/lop/renderproduct.html https://www.sidefx.com/docs/houdini/nodes/lop/rendersettings.html

christophercrouzet commented 1 year ago

LOP was created to author/compose USD scenes, which is irrelevant to Warp. Whereas ROP is specifically designed to run processes over a given frame range and eventually write the result onto disk. If we really wanted to, we could create a SOP node that takes a frame start/end and requests users to click a “run” button but that feels really “ROP-esque”.

Anyways it's all up in the air so we'll see when we'll get to it! :smile:

jprnd commented 1 year ago

a SOP node that takes a frame start/end and requests users to click a “run” button

Would a Retime SOP meet these requirements?

https://www.sidefx.com/docs/houdini/nodes/sop/retime.html "The Retime SOP provides a friendly interface for retiming its input geometry according to the given playback speed or time function. For requested times that correspond to non-integer frames of the input geometry, this operator can perform the necessary interpolation to approximate intermediate results."

Or the Time Shift SOP?

https://www.sidefx.com/docs/houdini/nodes/sop/timeshift.html "The Time Shift SOP will cook its input at a different time than it itself is cooking on. This allows one to gain access to earlier or later frames, or to retrieve data always at a specific absolute frame."

There is also the Cache If SOP...

https://www.sidefx.com/docs/houdini/nodes/sop/cacheif.html "The Cache If node is very useful when it’s possible to automatically tell when the cache is invalid and should be regenerated, based on testing one or more conditions.

This node lets you test different [types of conditions]: If nodes are added, removed, or edited in the upstream network. If the geometry from a node elsewhere in the network has changed. If a parameter, or any parameters, on an upstream node have changed.

If an arbitrary expression returns True, or if the result of an expression changes. This can be a simple HScript expression or a Python expression with full scripting power. For example, you could write a Python expression that queries the Web API of your asset management system to check if an asset’s version number has changed. "

christophercrouzet commented 1 year ago

Thanks @jprnd , I'm well versed in Houdini and am aware of what all the nodes that you mentioned do, so you do not have to worry about the implementation details unless you would like to give a go at implementing something along these lines for yourself since I'm not sure when I'll have a chance to get to it.

jprnd commented 1 year ago

@christophercrouzet ok cool. Yes, I would like to give a go at implementing something like this! I am limited in my skills in Houdini but as a Design R&D grad student at the Ohio State University, I am now fulltime working on Houdini stuff since I started using it in a Procedural Animation course. If you could give me guidance, I would have time to implement it.

I also wanted to get your opinion on the dFlex library (https://github.com/NVlabs/DiffRL/tree/main/dflex) that was released with the DiffRL (https://github.com/NVlabs/DiffRL) project from NVIDIA. I think I saw a video where this was floated as an alternative to Warp.

christophercrouzet commented 1 year ago

Sounds good!

Please note that this repository is not officially part of NVIDIA but in the case it will change one day, I will likely not merge any MR here, just to keep things simple as I'm not sure what the policies are when it comes to external contributors. On the bright side it means that you can go wild and implement this however you deem it fit for your needs! 😄

As for the guidance, if you really want to go the SOP route, I'd recommend you to look into:

But what I do know though is that I'd definitely start by looking into implementing another node in ROP instead. That's precisely what it's made for.

As for your questions related to dFlex and DiffRL, I'm not familiar with these systems but, at a first glance, I'd say that Warp's strong point is that it's not limited to a given scope. Instead it's a bit like VEX for CUDA—an accessible entry point to writing fast code that run on GPUs. You'll have more chances to get a better answer by asking on the official NVIDIA's Omniverse Discord server here: https://discord.com/invite/XWQNJDNuaC 😅