beanmachine icon indicating copy to clipboard operation
beanmachine copied to clipboard

Fix error message when an unsupported non-torch distribution is used

Open ericlippert opened this issue 1 year ago • 2 comments

Summary: All functions -- including type constructors -- in the torch modules are treated as "special" by the compiler. For special functions we have a "can have stochastic arguments" allow list; if your function call has stochastic arguments and is a special function, but not on the allowed list, then you get an error message saying that the function is not supported by BMG.

The idea here is that user-supplied functions we will attempt to rewrite, and models which have calls to third party libraries we will just pass the graph node and hope for the best, but torch functions that we do not support we strongly believe will not work, and so we should stop compilation and let the user know.

The case I missed here was: constructors for distributions that inherit from torch.Distribution but are not declared in torch.distributions. Such as our Unit distribution.

We now treat any constructor of a distribution as a special function and give an appropriate error message if an attempt is made to call an unsupported one with stochastic arguments.

As noted in the code, we do not yet treat instance methods of such distributions as special. We should. That will be in a later diff.

Reviewed By: ToddSmall

Differential Revision: D38224341

ericlippert avatar Jul 27 '22 23:07 ericlippert

This pull request was exported from Phabricator. Differential Revision: D38224341

facebook-github-bot avatar Jul 27 '22 23:07 facebook-github-bot

Hi @ericlippert!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

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 [email protected]. Thanks!

facebook-github-bot avatar Dec 01 '22 08:12 facebook-github-bot