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

Warnings with pytorch backend and simplemodels #1946

Open
1 task done
alexander-held opened this issue Aug 14, 2022 · 1 comment
Open
1 task done

Warnings with pytorch backend and simplemodels #1946

alexander-held opened this issue Aug 14, 2022 · 1 comment
Labels
bug Something isn't working needs-triage Needs a maintainer to categorize and assign

Comments

@alexander-held
Copy link
Member

alexander-held commented Aug 14, 2022

Summary

I ran into two warnings with the pytorch backend, see below. I have not tried to look at where exactly they come from so far.

OS / Environment

n/a

Steps to Reproduce

Run the following with python -Wd:

import pyhf

pyhf.set_backend("pytorch")
model = pyhf.simplemodels.uncorrelated_background(
    signal=[24.0, 22.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
)

File Upload (optional)

No response

Expected Results

no warnings

Actual Results

[...]/pyhf/src/pyhf/tensor/pytorch_backend.py:201: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
  return torch.as_tensor(tensor_in, dtype=dtype)
[...]/pyhf/src/pyhf/tensor/pytorch_backend.py:201: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at  /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_new.cpp:204.)
  return torch.as_tensor(tensor_in, dtype=dtype)

pyhf Version

pyhf, version 0.7.0rc2.dev18

Code of Conduct

  • I agree to follow the Code of Conduct
@alexander-held alexander-held added bug Something isn't working needs-triage Needs a maintainer to categorize and assign labels Aug 14, 2022
@alexander-held alexander-held changed the title Warnings with pytorch backend Warnings with pytorch backend and simplemodels Aug 14, 2022
@matthewfeickert
Copy link
Member

[...]/pyhf/src/pyhf/tensor/pytorch_backend.py:201: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
  return torch.as_tensor(tensor_in, dtype=dtype)

I need to look if we have an Issue for this. If not, then I should probably make one and update the PyTorch API and also figure out what a new lower bound on torch should be.

[...]/pyhf/src/pyhf/tensor/pytorch_backend.py:201: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at  /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_new.cpp:204.)
  return torch.as_tensor(tensor_in, dtype=dtype)

This is known as it was added to

'ignore:Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with:UserWarning', #FIXME: tests/test_optim.py::test_minimize[no_grad-scipy-pytorch-no_stitch]

in PR #1773. This should get fixed at some point if possible, but isn't a huge pain point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Needs a maintainer to categorize and assign
Projects
None yet
Development

No branches or pull requests

2 participants