You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It may be desirable in some cases (e.g. #882) to have one consistent backend for all cases, which would enable the propagation of gradients throughout pyhf model construction, for instance. Backends will hit a wall when trying to take the gradient with respect to something that involves pure numpy.
An example implementation of this could be as simple as adding the argument set_default=False to set_backend, followed by something like
def set_backend(..., set_default=False):
...
backend = tensorlib
if set_default:
global default_backend
default_backend = tensorlib
...
tensorlib._setup()
if set_default:
default_backend._setup()
It seems like this would be fine at first glance, since the backend checks are done in the lines before this. I managed to get the logpdf of hepdata_like with no issues, but I was unsure what would be a more robust test for changing the default backend. Ideally, one would want to run the whole test suite I guess, to make sure this doesn't secretly change some functionality.
Hope this is useful!
The text was updated successfully, but these errors were encountered:
The default backend can be set w/o changing the rest of the code. It'll help with the diff'able case for sure. My first guess is you should be able to do
It may be desirable in some cases (e.g. #882) to have one consistent backend for all cases, which would enable the propagation of gradients throughout pyhf model construction, for instance. Backends will hit a wall when trying to take the gradient with respect to something that involves pure numpy.
An example implementation of this could be as simple as adding the argument
set_default=False
toset_backend
, followed by something likeIt seems like this would be fine at first glance, since the backend checks are done in the lines before this. I managed to get the
logpdf
ofhepdata_like
with no issues, but I was unsure what would be a more robust test for changing the default backend. Ideally, one would want to run the whole test suite I guess, to make sure this doesn't secretly change some functionality.Hope this is useful!
The text was updated successfully, but these errors were encountered: