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

[QUESTION] How to use Autodifferentiation for soft-body parameters #346

Open
rrzhang139 opened this issue Nov 6, 2024 · 2 comments
Open
Assignees
Labels
question The issue author requires information

Comments

@rrzhang139
Copy link

Hello, thank you for building this first of all.

I have a question about differentiating the parameters in Warp. If I wanted to differentiate soft body parameters like k_mu or k_lambda in soft_grid, how would that generally work? Would I initialize some tensors and pass them into kernels to get that working? Do you have any code samples that does this for soft body simulation? Thanks!

@rrzhang139 rrzhang139 added the question The issue author requires information label Nov 6, 2024
@amabilee
Copy link

amabilee commented Nov 6, 2024

Hey there !

To differentiate soft body parameters like k_mu or k_lambda in Warp, you indeed need to initialize tensors and pass them into kernels. Warp supports automatic differentiation, which allows you to compute gradients of these parameters.

Here is the doc about it:
https://nvidia.github.io/warp/modules/differentiability.html

@shi-eric shi-eric changed the title [QUESTION] How to use Autodifferentiation [QUESTION] How to use Autodifferentiation for soft-body parameters Nov 7, 2024
@shi-eric
Copy link
Contributor

shi-eric commented Nov 7, 2024

I'm not an expert on the warp.sim things, but I'll attempt an answer. You would generally need to do two things:

  • When calling the finalize() method of the ModelBuilder class, you need to use requires_grad=True to ensure that gradients are calculated for the Model object arrays.
  • After recording the forward pass onto a wp.Tape() and calling the backward() method with the appropriate loss input, you would then get the gradients of the Model.tet_materials array. The details of this array are here: https://nvidia.github.io/warp/modules/sim.html#warp.sim.Model.tet_materials

@shi-eric shi-eric self-assigned this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue author requires information
Projects
None yet
Development

No branches or pull requests

3 participants