Repository: scikit-hep/pyhf

Issue:
PyTorch v1.8.0 breaks public API
# Description

<details>
<summary>Current Release Workflow Failure:</summary>

```pytb
============================= test session starts ==============================
platform linux -- Python 3.8.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/runner/work/pyhf/pyhf, configfile: pyproject.toml
plugins: cov-2.11.1
collected 59 items

tests/test_public_api.py ..........................................FF... [ 79%]
.......FF...                                                             [100%]

=================================== FAILURES ===================================
____________________________ test_hypotest[pytorch] ____________________________

backend = (<pyhf.tensor.pytorch_backend.pytorch_backend object at 0x7fd40661f500>, None)
model_setup = (<pyhf.pdf.Model object at 0x7fd359ff8af0>, [55, 50, 53, 53, 57, 59, ...], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, ...])

    def test_hypotest(backend, model_setup):
        model, data, init_pars = model_setup
        mu = 1.0
>       pyhf.infer.hypotest(
            mu,
            data,
            model,
            init_pars,
            model.config.suggested_bounds(),
            return_expected_set=True,
        )

tests/test_public_api.py:165:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/__init__.py:141: in hypotest
    teststat = calc.teststatistic(poi_test)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/calculators.py:331: in teststatistic
    qmuA_v = teststat_func(
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/test_statistics.py:177: in qmu_tilde
    return _qmu_like(mu, data, pdf, init_pars, par_bounds, fixed_params)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/test_statistics.py:19: in _qmu_like
    tmu_like_stat, (_, muhatbhat) = _tmu_like(
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/test_statistics.py:38: in _tmu_like
    mubhathat, fixed_poi_fit_lhood_val = fixed_poi_fit(
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/mle.py:190: in fixed_poi_fit
    return fit(data, pdf, init_pars, par_bounds, fixed_params, **kwargs)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/mle.py:122: in fit
    return opt.minimize(
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/optimize/mixins.py:157: in minimize
    result = self._internal_minimize(**minimizer_kwargs, options=kwargs)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/optimize/mixins.py:38: in _internal_minimize
    result = self._minimize(
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/optimize/opt_scipy.py:74: in _minimize
    return minimizer(
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/_minimize.py:627: in minimize
    return _minimize_slsqp(fun, x0, args, jac, bounds,
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/slsqp.py:375: in _minimize_slsqp
    sf = _prepare_scalar_function(func, x, jac=jac, args=args, epsilon=eps,
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/optimize.py:261: in _prepare_scalar_function
    sf = ScalarFunction(fun, x0, args, grad, hess,
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py:136: in __init__
    self._update_fun()
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py:226: in _update_fun
    self._update_fun_impl()
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py:133: in update_fun
    self.f = fun_wrapped(self.x)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py:130: in fun_wrapped
    return fun(x, *args)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/optimize.py:74: in __call__
    self._compute_if_needed(x, *args)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/scipy/optimize/optimize.py:68: in _compute_if_needed
    fg = self.fun(x, *args)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/optimize/opt_pytorch.py:30: in func
    constr_nll = objective(constrained_pars, data, pdf)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/infer/mle.py:47: in twice_nll
    return -2 * pdf.logpdf(pars, data)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/pdf.py:726: in logpdf
    result = self.make_pdf(pars).log_prob(data)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py:282: in log_prob
    pdfvals = [p.log_prob(d) for p, d in zip(self, constituent_data)]
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py:282: in <listcomp>
    pdfvals = [p.log_prob(d) for p, d in zip(self, constituent_data)]
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py:180: in log_prob
    result = super().log_prob(value)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py:19: in log_prob
    return self._pdf.log_prob(value)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py:19: in log_prob
    return self._pdf.log_prob(value)
/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/torch/distributions/poisson.py:61: in log_prob
    self._validate_sample(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = Poisson(rate: torch.Size([100]))
value = tensor([50.1045, 50.0000, 50.0649, 50.0649, 50.1326, 50.1769, 50.0649, 50.1045,
        50.0420, 50.0672, 50.1326, 50....   50.0000, 50.0173, 50.1045, 50.1769, 50.0649, 50.0000, 50.1045, 50.0000,
        50.0173, 50.0420, 50.0672, 50.0420])

    def _validate_sample(self, value):
        """
        Argument validation for distribution methods such as `log_prob`,
        `cdf` and `icdf`. The rightmost dimensions of a value to be
        scored via these methods must agree with the distribution's batch
        and event shapes.

        Args:
            value (Tensor): the tensor whose log probability is to be
                computed by the `log_prob` method.
        Raises
            ValueError: when the rightmost dimensions of `value` do not match the
                distribution's batch and event shapes.
        """
        if not isinstance(value, torch.Tensor):
            raise ValueError('The value argument to log_prob must be a Tensor')

        event_dim_start = len(value.size()) - len(self._event_shape)
        if value.size()[event_dim_start:] != self._event_shape:
            raise ValueError('The right-most size of value must match event_shape: {} vs {}.'.
                             format(value.size(), self._event_shape))

        actual_shape = value.size()
        expected_shape = self._batch_shape + self._event_shape
        for i, j in zip(reversed(actual_shape), reversed(expected_shape)):
            if i != 1 and j != 1 and i != j:
                raise ValueError('Value is not broadcastable with batch_shape+event_shape: {} vs {}.'.
                                 format(actual_shape, expected_shape))
        try:
            support = self.support
        except NotImplementedError:
            warnings.warn(f'{self.__class__} does not define `support` to enable ' +
                          'sample validation. Please initialize the distribution with ' +
                          '`validate_args=False` to turn off validation.')
            return
        assert support is not None
        if not support.check(value).all():
>           raise ValueError('The value argument must be within the support')
E           ValueError: The value argument must be within the support

/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/torch/distributions/distribution.py:277: ValueError
------------------------------ Captured log call -------------------------------
ERROR    pyhf.pdf:pdf.py:734 Eval failed for data [50.104469299316406, 50.0, 50.064884185791016, 50.064884185791016, 50.13261413574219, 50.176876068115234, 50.064884185791016, 50.104469299316406, 50.04202651977539, 50.0671501159668, 50.13261413574219, 50.11567306518555, 50.1575813293457, 50.1575813293457, 50.01729202270508, 50.11567306518555, 50.13261413574219, 50.13261413574219, 50.1575813293457, 50.01729202270508, 50.104469299316406, 50.176876068115234, 50.1575813293457, 50.176876068115234, 50.0671501159668, 50.064884185791016, 50.0, 50.064884185791016, 50.104469299316406, 50.0, 50.04202651977539, 50.064884185791016, 50.1575813293457, 50.01729202270508, 50.064884185791016, 50.064884185791016, 50.064884185791016, 50.13261413574219, 50.0, 50.01729202270508, 50.176876068115234, 50.176876068115234, 50.0, 50.0671501159668, 50.13261413574219, 50.064884185791016, 50.04202651977539, 50.13261413574219, 50.04202651977539, 50.0, 50.0, 50.0671501159668, 50.104469299316406, 50.104469299316406, 50.11567306518555, 50.1575813293457, 50.0671501159668, 50.01729202270508, 50.0671501159668, 50.176876068115234, 50.1575813293457, 50.01729202270508, 50.01729202270508, 50.13261413574219, 50.176876068115234, 50.176876068115234, 50.064884185791016, 50.11567306518555, 50.13261413574219, 50.04202651977539, 50.0, 50.064884185791016, 50.104469299316406, 50.176876068115234, 50.0671501159668, 50.0671501159668, 50.11567306518555, 50.0671501159668, 50.0671501159668, 50.064884185791016, 50.0671501159668, 50.0671501159668, 50.1575813293457, 50.0671501159668, 50.064884185791016, 50.13261413574219, 50.104469299316406, 50.104469299316406, 50.0, 50.01729202270508, 50.104469299316406, 50.176876068115234, 50.064884185791016, 50.0, 50.104469299316406, 50.0, 50.01729202270508, 50.04202651977539, 50.0671501159668, 50.04202651977539, 2505.223388671875, 2500.0, 2503.244384765625, 2503.244384765625, 2506.630615234375, 2508.84375, 2503.244384765625, 2505.223388671875, 2502.101318359375, 2503.357421875, 2506.630615234375, 2505.78369140625, 2507.879150390625, 2507.879150390625, 2500.864501953125, 2505.78369140625, 2506.630615234375, 2506.630615234375, 2507.879150390625, 2500.864501953125, 2505.223388671875, 2508.84375, 2507.879150390625, 2508.84375, 2503.357421875, 2503.244384765625, 2500.0, 2503.244384765625, 2505.223388671875, 2500.0, 2502.101318359375, 2503.244384765625, 2507.879150390625, 2500.864501953125, 2503.244384765625, 2503.244384765625, 2503.244384765625, 2506.630615234375, 2500.0, 2500.864501953125, 2508.84375, 2508.84375, 2500.0, 2503.357421875, 2506.630615234375, 2503.244384765625, 2502.101318359375, 2506.630615234375, 2502.101318359375, 2500.0, 2500.0, 2503.357421875, 2505.223388671875, 2505.223388671875, 2505.78369140625, 2507.879150390625, 2503.357421875, 2500.864501953125, 2503.357421875, 2508.84375, 2507.879150390625, 2500.864501953125, 2500.864501953125, 2506.630615234375, 2508.84375, 2508.84375, 2503.244384765625, 2505.78369140625, 2506.630615234375, 2502.101318359375, 2500.0, 2503.244384765625, 2505.223388671875, 2508.84375, 2503.357421875, 2503.357421875, 2505.78369140625, 2503.357421875, 2503.357421875, 2503.244384765625, 2503.357421875, 2503.357421875, 2507.879150390625, 2503.357421875, 2503.244384765625, 2506.630615234375, 2505.223388671875, 2505.223388671875, 2500.0, 2500.864501953125, 2505.223388671875, 2508.84375, 2503.244384765625, 2500.0, 2505.223388671875, 2500.0, 2500.864501953125, 2502.101318359375, 2503.357421875, 2502.101318359375] pars: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/pdf.py", line 726, in logpdf
    result = self.make_pdf(pars).log_prob(data)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py", line 282, in log_prob
    pdfvals = [p.log_prob(d) for p, d in zip(self, constituent_data)]
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py", line 282, in <listcomp>
    pdfvals = [p.log_prob(d) for p, d in zip(self, constituent_data)]
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py", line 180, in log_prob
    result = super().log_prob(value)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py", line 19, in log_prob
    return self._pdf.log_prob(value)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/pyhf/probability.py", line 19, in log_prob
    return self._pdf.log_prob(value)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/torch/distributions/poisson.py", line 61, in log_prob
    self._validate_sample(value)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/torch/distributions/distribution.py", line 277, in _validate_sample
##[error]    raise ValueError('The value argument must be within the support')
ValueError: The value argument must be within the support:w
```
</details>

<details>
<summary>CI/CD Workflow Failure:</summary>

```pytb
============================= test session starts ==============================
platform linux -- Python 3.8.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
Matplotlib: 3.3.4
Freetype: 2.6.1
benchmark: 3.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/runner/work/pyhf/pyhf, configfile: pyproject.toml, testpaths: src, tests
plugins: mpl-0.12, cov-2.11.1, mock-3.5.1, console-scripts-1.1.0, benchmark-3.2.3
collected 1400 items

src/pyhf/__init__.py ..                                                  [  0%]
src/pyhf/patchset.py .                                                   [  0%]
src/pyhf/probability.py .......                                          [  0%]
src/pyhf/simplemodels.py .                                               [  0%]
src/pyhf/utils.py ...                                                    [  1%]
src/pyhf/contrib/utils.py .                                              [  1%]
src/pyhf/contrib/viz/brazil.py .                                         [  1%]
src/pyhf/infer/__init__.py .                                             [  1%]
src/pyhf/infer/calculators.py ..............                             [  2%]
src/pyhf/infer/intervals.py .                                            [  2%]
src/pyhf/infer/mle.py ...                                                [  2%]
src/pyhf/infer/test_statistics.py .....                                  [  2%]
src/pyhf/infer/utils.py ..                                               [  3%]
src/pyhf/tensor/jax_backend.py ..............                            [  4%]
src/pyhf/tensor/numpy_backend.py ..............                          [  5%]
src/pyhf/tensor/pytorch_backend.py .....F..F.....                        [  6%]
src/pyhf/tensor/tensorflow_backend.py .................                  [  7%]
tests/test_backend_consistency.py ....                                   [  7%]
tests/test_calculator.py .                                               [  7%]
tests/test_cli.py ..                                                     [  7%]
tests/test_combined_modifiers.py ....................................... [ 10%]
.........                                                                [ 11%]
tests/test_constraints.py .FF.........                                   [ 12%]
tests/test_events.py .....                                               [ 12%]
tests/test_examples.py .                                                 [ 12%]
tests/test_export.py ........................                            [ 14%]
tests/test_import.py ..............                                      [ 15%]
tests/test_infer.py ................FFFF................................ [ 18%]
................                                                         [ 20%]
tests/test_init.py ......                                                [ 20%]
tests/test_interpolate.py .............................................. [ 23%]
...........................................................              [ 27%]
tests/test_jit.py ................................                       [ 30%]
tests/test_mixins.py ..                                                  [ 30%]
tests/test_modifiers.py ............                                     [ 31%]
tests/test_optim.py .sss.s.............................................. [ 34%]
....................................................................FF.. [ 40%]
..FF...sssss.sssss...................                                    [ 42%]
tests/test_paramsets.py .....                                            [ 43%]
tests/test_paramviewer.py .............                                  [ 44%]
tests/test_patchset.py .........................                         [ 45%]
tests/test_pdf.py ..FF..................FF....sssss...................ss [ 49%]
sss.......sssss..........                                                [ 51%]
tests/test_probability.py .........................                      [ 53%]
tests/test_public_api.py ..........................................FF... [ 56%]
.......FF...                                                             [ 57%]
tests/test_regression.py .....                                           [ 57%]
tests/test_schema.py ................................................    [ 61%]
tests/test_scripts.py ..............F................................... [ 64%]
.........                                                                [ 65%]
tests/test_tensor.py ................................................... [ 69%]
..................................FF......................x............. [ 74%]
...............sss.ss....................................                [ 78%]
tests/test_tensorviewer.py ......                                        [ 78%]
tests/test_teststats.py .........                                        [ 79%]
tests/test_toys.py ......                                                [ 79%]
tests/test_utils.py ........................                             [ 81%]
tests/test_validation.py ............................                    [ 83%]
tests/test_workspace.py ................................................ [ 86%]
........................................................................ [ 92%]
........................................................................ [ 97%]
.......................................                                  [100%]

=================================== FAILURES ===================================
_________ [doctest] pyhf.tensor.pytorch_backend.pytorch_backend.normal _________
357 
358         The probability density function of the Normal distribution evaluated
359         at :code:`x` given parameters of mean of :code:`mu` and standard deviation
360         of :code:`sigma`.
361 
362         Example:
363 
364             >>> import pyhf
365             >>> pyhf.set_backend("pytorch")
366             >>> pyhf.tensorlib.normal(0.5, 0., 1.)
UNEXPECTED EXCEPTION: ValueError('The value argument to log_prob must be a Tensor')
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/doctest.py", line 1336, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest pyhf.tensor.pytorch_backend.pytorch_backend.normal[2]>", line 1, in <module>
  File "/home/runner/work/pyhf/pyhf/src/pyhf/tensor/pytorch_backend.py", line 383, in normal
    return self.exp(normal.log_prob(x))
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/torch/distributions/normal.py", line 73, in log_prob
    self._validate_sample(value)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/torch/distributions/distribution.py", line 255, in _validate_sample
Error:     raise ValueError('The value argument to log_prob must be a Tensor')
ValueError: The value argument to log_prob must be a Tensor
/home/runner/work/pyhf/pyhf/src/pyhf/tensor/pytorch_backend.py:366: UnexpectedException
```

</details>

# Expected Behavior

CI passes with `torch` `v1.8.0`

# Actual Behavior

Failure

# Steps to Reproduce

Run CI

# Checklist

- [x] Run `git fetch` to get the most up to date version of `master`
- [x] Searched through existing Issues to confirm this is not a duplicate issue
- [x] Filled out the Description, Expected Behavior, Actual Behavior, and Steps to Reproduce sections above or have edited/removed them in a way that fully describes the issue



Discussion:
In the [`torch` `v1.8.0` release notes](https://github.com/pytorch/pytorch/releases/tag/v1.8.0) under there is a change in "Backwards Incompatible changes" for

> ## Enable distribution validation by default for `torch.distributions`
>
> This may slightly slow down some models. Concerned users may disable validation by using `torch.distributions.Distribution.set_default_validate_args(False)` or by disabling individual distribution validation via `MyDistribution(..., validate_args=False)`.
>
> This may cause new `ValueErrors` in models that rely on unsupported behavior, e.g. `Categorical.log_prob()` applied to continuous-valued tensors (only {0,1}-valued tensors are supported).
Such models should be fixed but the previous behavior can be recovered by disabling argument validation using the methods mentioned above.

I don't think this is related, but I'm going to start there.

Resolving patch:
diff --git a/src/pyhf/tensor/pytorch_backend.py b/src/pyhf/tensor/pytorch_backend.py
--- a/src/pyhf/tensor/pytorch_backend.py
+++ b/src/pyhf/tensor/pytorch_backend.py
@@ -319,7 +319,8 @@ def einsum(self, subscripts, *operands):
         return torch.einsum(subscripts, operands)
 
     def poisson_logpdf(self, n, lam):
-        return torch.distributions.Poisson(lam).log_prob(n)
+        # validate_args=True disallows continuous approximation
+        return torch.distributions.Poisson(lam, validate_args=False).log_prob(n)
 
     def poisson(self, n, lam):
         r"""
@@ -347,9 +348,16 @@ def poisson(self, n, lam):
         Returns:
             PyTorch FloatTensor: Value of the continuous approximation to Poisson(n|lam)
         """
-        return torch.exp(torch.distributions.Poisson(lam).log_prob(n))
+        # validate_args=True disallows continuous approximation
+        return torch.exp(
+            torch.distributions.Poisson(lam, validate_args=False).log_prob(n)
+        )
 
     def normal_logpdf(self, x, mu, sigma):
+        x = self.astensor(x)
+        mu = self.astensor(mu)
+        sigma = self.astensor(sigma)
+
         normal = torch.distributions.Normal(mu, sigma)
         return normal.log_prob(x)
 
@@ -379,6 +387,10 @@ def normal(self, x, mu, sigma):
         Returns:
             PyTorch FloatTensor: Value of Normal(x|mu, sigma)
         """
+        x = self.astensor(x)
+        mu = self.astensor(mu)
+        sigma = self.astensor(sigma)
+
         normal = torch.distributions.Normal(mu, sigma)
         return self.exp(normal.log_prob(x))
 
@@ -433,7 +445,8 @@ def poisson_dist(self, rate):
             PyTorch Poisson distribution: The Poisson distribution class
 
         """
-        return torch.distributions.Poisson(rate)
+        # validate_args=True disallows continuous approximation
+        return torch.distributions.Poisson(rate, validate_args=False)
 
     def normal_dist(self, mu, sigma):
         r"""


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -247,6 +247,8 @@ def test_shape(backend):
         )
 
 
+@pytest.mark.skip_pytorch
+@pytest.mark.skip_pytorch64
 def test_pdf_calculations(backend):
     tb = pyhf.tensorlib
     assert tb.tolist(tb.normal_cdf(tb.astensor([0.8]))) == pytest.approx(
@@ -286,7 +288,53 @@ def test_pdf_calculations(backend):
 
     # Ensure continuous approximation is valid
     assert tb.tolist(
-        tb.poisson(tb.astensor([0.5, 1.1, 1.5]), tb.astensor(1.0))
+        tb.poisson(n=tb.astensor([0.5, 1.1, 1.5]), lam=tb.astensor(1.0))
+    ) == pytest.approx([0.4151074974205947, 0.3515379040027489, 0.2767383316137298])
+
+
+# validate_args in torch.distributions raises ValueError not nan
+@pytest.mark.only_pytorch
+@pytest.mark.only_pytorch64
+def test_pdf_calculations_pytorch(backend):
+    tb = pyhf.tensorlib
+
+    values = tb.astensor([0, 0, 1, 1])
+    mus = tb.astensor([0, 1, 0, 1])
+    sigmas = tb.astensor([0, 0, 0, 0])
+    for x, mu, sigma in zip(values, mus, sigmas):
+        with pytest.raises(ValueError):
+            _ = tb.normal_logpdf(x, mu, sigma)
+    assert tb.tolist(
+        tb.normal_logpdf(
+            tb.astensor([0, 0, 1, 1]),
+            tb.astensor([0, 1, 0, 1]),
+            tb.astensor([1, 1, 1, 1]),
+        )
+    ) == pytest.approx(
+        [
+            -0.91893853,
+            -1.41893853,
+            -1.41893853,
+            -0.91893853,
+        ],
+    )
+
+    # poisson(lambda=0) is not defined, should return NaN
+    assert tb.tolist(
+        tb.poisson(tb.astensor([0, 0, 1, 1]), tb.astensor([0, 1, 0, 1]))
+    ) == pytest.approx(
+        [np.nan, 0.3678794503211975, 0.0, 0.3678794503211975], nan_ok=True
+    )
+    assert tb.tolist(
+        tb.poisson_logpdf(tb.astensor([0, 0, 1, 1]), tb.astensor([0, 1, 0, 1]))
+    ) == pytest.approx(
+        np.log([np.nan, 0.3678794503211975, 0.0, 0.3678794503211975]).tolist(),
+        nan_ok=True,
+    )
+
+    # Ensure continuous approximation is valid
+    assert tb.tolist(
+        tb.poisson(n=tb.astensor([0.5, 1.1, 1.5]), lam=tb.astensor(1.0))
     ) == pytest.approx([0.4151074974205947, 0.3515379040027489, 0.2767383316137298])