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

add auto check jacobian #461

Closed
wants to merge 1 commit into from
Closed

Conversation

xphsean12
Copy link

Motivation and Context

Add an example on auto-checking Jacobian by using the AutoDiffCostFunction, which requires only few changes at the original customized Cost function

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot
Copy link

Hi @xphsean12!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@mhmukadam mhmukadam added the enhancement New feature or request label Feb 9, 2023
@luisenp
Copy link
Contributor

luisenp commented Feb 9, 2023

Hi @xphsean12, thanks a lot for the contribution! It would be nice if the auto check example would use the same cost function we have been using in the notebook, to avoid introducing extra complexity beyond the goals of this tutorial.

Also, looking at the logic you are following, I think we should be able to add a generic utility function that would do the check against autograd jacobians automatically, and then we could just call this in the notebook, rather than explaining to users how to do this check manually on their own.

If this is something you'd be interested in adding, happy to let you drive it, otherwise I can take a look at it in the next few days. We can then update this PR once that part is ready. Let me know your preference.

@luisenp
Copy link
Contributor

luisenp commented Feb 13, 2023

@xphsean12 following up on the comment above. Let me know if adding the generic function for autochecking is something you are interested in doing. Thanks!

@xphsean12
Copy link
Author

Hi @xphsean12, thanks a lot for the contribution! It would be nice if the auto check example would use the same cost function we have been using in the notebook, to avoid introducing extra complexity beyond the goals of this tutorial.

Also, looking at the logic you are following, I think we should be able to add a generic utility function that would do the check against autograd jacobians automatically, and then we could just call this in the notebook, rather than explaining to users how to do this check manually on their own.

If this is something you'd be interested in adding, happy to let you drive it, otherwise I can take a look at it in the next few days. We can then update this PR once that part is ready. Let me know your preference.

Thanks for your comments and great efforts on this project. I have submitte the CLA, but I don't know how to check it. For your advices on adding a generic utility, I am confused on the implementation in several aspects:

  1. When should the auto-checking be conducted. For example, the moment when the user creates the CostFunction or Objective?
  2. How many times should the auto-checking be conducted? Because checking jacobian requires extra calculation. I suppose most of the users will only check it for the very first time when the CostFunction is created.
    Regarding the above question, I believe it would be much more proper to make it generic on your own. Since it requires adding more components into the CostFunction or Objective layer. By the way, I check it in the process of adding CostFunction into Objective, because I do not need to create any artifact data by myself. I can just use the data that define the optimization problem.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 16, 2023
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@luisenp
Copy link
Contributor

luisenp commented Feb 16, 2023

Hi @xphsean12, thanks a lot for the contribution! It would be nice if the auto check example would use the same cost function we have been using in the notebook, to avoid introducing extra complexity beyond the goals of this tutorial.
Also, looking at the logic you are following, I think we should be able to add a generic utility function that would do the check against autograd jacobians automatically, and then we could just call this in the notebook, rather than explaining to users how to do this check manually on their own.
If this is something you'd be interested in adding, happy to let you drive it, otherwise I can take a look at it in the next few days. We can then update this PR once that part is ready. Let me know your preference.

Thanks for your comments and great efforts on this project. I have submitte the CLA, but I don't know how to check it. For your advices on adding a generic utility, I am confused on the implementation in several aspects:

  1. When should the auto-checking be conducted. For example, the moment when the user creates the CostFunction or Objective?
  2. How many times should the auto-checking be conducted? Because checking jacobian requires extra calculation. I suppose most of the users will only check it for the very first time when the CostFunction is created.
    Regarding the above question, I believe it would be much more proper to make it generic on your own. Since it requires adding more components into the CostFunction or Objective layer. By the way, I check it in the process of adding CostFunction into Objective, because I do not need to create any artifact data by myself. I can just use the data that define the optimization problem.

For now I was just thinking of creating the utility that receives a CostFunction object, runs the check and returns a boolean whether the check passes or not, and if it doesn't, prints out some information about the error. For the notebook, we would just need to call this utility manually.

Following on your last comment, I'll write a draft of this on my own. Is it OK if I tag you as a reviewer in the resulting PR?

Thanks!

@xphsean12
Copy link
Author

Sure. It is my pleasure.

@mhmukadam
Copy link
Member

Let's rebase this on main after #465 is merged and use the new utility function in the notebook to merge this PR.

@mhmukadam mhmukadam closed this May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants