Comments (5)
It looks like you're reasonably starting with
Lines 59 to 74 in 205eecf
Lines 49 to 56 in 205eecf
@kratsg and I can follow up on this later in the week on PR #2310, but it is currenlty the Labor Day holiday in the US, so we won't get to this today.
from pyhf.
I cannot reproduce this on 3.8+ (where the Cython code for weakref has been updated to fix other stuff). Is this done only on 3.7? If so, this isn't something we can fix.
from pyhf.
Backtracking from my original statement (#2310 (review)) I tried to reproduce in a clean Python 3.11 virtual environment built from the following requirements.txt
pyhf[all,minuit]==0.7.3
pytest==7.4.1
pytest-benchmark==4.0.0
which for context gives
$ python -m pip list | grep 'scipy\|jax\|torch\|tensorflow\|iminuit'
iminuit 2.24.0
jax 0.4.14
jaxlib 0.4.14
scipy 1.11.2
tensorflow 2.13.0
tensorflow-estimator 2.13.0
tensorflow-io-gcs-filesystem 0.33.0
tensorflow-probability 0.21.0
torch 2.0.1
In that environment running
pytest issue-2311.py
passes with no errors.
@wernerd-cern Can you please provide an environment defintion file that is able to reprodue your error?
I earlier didn't test well enough in my rush and was also running into an error coming from jax, not pyhf.tensorlib
so I wasn't reproducing what originally reported.
from pyhf.
This was also not able to be reproduced (originally) with Python 3.7
$ docker run --rm -ti -v $PWD:/work:ro python:3.7 /bin/bash
root@691fb3f949d9:/# python -m venv venv && . venv/bin/activate
(venv) root@691fb3f949d9:/# python -m pip install --upgrade pip setuptools wheel
(venv) root@691fb3f949d9:/# python -m pip install --upgrade -r /work/requirements.txt
(venv) root@691fb3f949d9:/# pytest /work/issue-2311.py # passes
(venv) root@691fb3f949d9:/# python --version --version
Python 3.7.17 (default, Aug 16 2023, 20:32:51)
[GCC 12.2.0]
(venv) root@691fb3f949d9:/# python -m pip list | grep 'pyhf\|scipy\|jax\|torch\|tensorflow\|iminuit'
iminuit 2.18.0
jax 0.3.25
jaxlib 0.3.25
pyhf 0.7.3
scipy 1.7.3
tensorflow 2.11.0
tensorflow-estimator 2.11.0
tensorflow-io-gcs-filesystem 0.33.0
tensorflow-probability 0.19.0
torch 1.13.1
(venv) root@691fb3f949d9:/#
but was reproducible on repeated runs
(venv) root@691fb3f949d9:/# pytest /work/issue-2311.py ..................E.....E........... [100%]
======================================================================================= ERRORS ========================================================================================
_________________________________________________________________ ERROR at setup of test_hypotest[tensorflow-1_bins] __________________________________________________________________
request = <SubRequest 'backend' for <Function test_hypotest[tensorflow-1_bins]>>
@pytest.fixture(
scope="function",
params=[
(pyhf.tensor.numpy_backend(), None),
(pyhf.tensor.pytorch_backend(), None),
(pyhf.tensor.pytorch_backend(precision="64b"), None),
(pyhf.tensor.tensorflow_backend(), None),
(pyhf.tensor.jax_backend(), None),
(
pyhf.tensor.numpy_backend(poisson_from_normal=True),
pyhf.optimize.minuit_optimizer(),
),
],
ids=["numpy", "pytorch", "pytorch64", "tensorflow", "jax", "numpy_minuit"],
)
def backend(request):
# get the ids of all the backends
param_ids = request._fixturedef.ids
# the backend we're using: numpy, tensorflow, etc...
param_id = param_ids[request.param_index]
# name of function being called (with params), the original name is .originalname
func_name = request._pyfuncitem.name
> pyhf.set_backend(*request.param)
work/issue-2311.py:29:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv/lib/python3.7/site-packages/pyhf/events.py:161: in register_wrapper
result = func(*args, **kwargs)
venv/lib/python3.7/site-packages/pyhf/tensor/manager.py:192: in set_backend
events.trigger("tensorlib_changed")()
venv/lib/python3.7/site-packages/pyhf/events.py:70: in __call__
func()(arg(), *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = None
def _precompute(self):
tensorlib, _ = get_backend()
> self.sorted_indices = tensorlib.astensor(self._sorted_indices, dtype='int')
E AttributeError: 'NoneType' object has no attribute '_sorted_indices'
venv/lib/python3.7/site-packages/pyhf/tensor/common.py:33: AttributeError
-------------------------------------------------------------------------------- Captured stderr setup --------------------------------------------------------------------------------
2023-09-06 01:21:44.619013: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2023-09-06 01:21:44.619043: W tensorflow/compiler/xla/stream_executor/cuda/cuda_driver.cc:265] failed call to cuInit: UNKNOWN ERROR (303)
_____________________________________________________________________ ERROR at setup of test_hypotest[jax-1_bins] _____________________________________________________________________
request = <SubRequest 'backend' for <Function test_hypotest[jax-1_bins]>>
@pytest.fixture(
scope="function",
params=[
(pyhf.tensor.numpy_backend(), None),
(pyhf.tensor.pytorch_backend(), None),
(pyhf.tensor.pytorch_backend(precision="64b"), None),
(pyhf.tensor.tensorflow_backend(), None),
(pyhf.tensor.jax_backend(), None),
(
pyhf.tensor.numpy_backend(poisson_from_normal=True),
pyhf.optimize.minuit_optimizer(),
),
],
ids=["numpy", "pytorch", "pytorch64", "tensorflow", "jax", "numpy_minuit"],
)
def backend(request):
# get the ids of all the backends
param_ids = request._fixturedef.ids
# the backend we're using: numpy, tensorflow, etc...
param_id = param_ids[request.param_index]
# name of function being called (with params), the original name is .originalname
func_name = request._pyfuncitem.name
> pyhf.set_backend(*request.param)
work/issue-2311.py:29:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv/lib/python3.7/site-packages/pyhf/events.py:161: in register_wrapper
result = func(*args, **kwargs)
venv/lib/python3.7/site-packages/pyhf/tensor/manager.py:192: in set_backend
events.trigger("tensorlib_changed")()
venv/lib/python3.7/site-packages/pyhf/events.py:70: in __call__
func()(arg(), *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = None
def _precompute(self):
tensorlib, _ = get_backend()
> self.sorted_indices = tensorlib.astensor(self._sorted_indices, dtype='int')
E AttributeError: 'NoneType' object has no attribute '_sorted_indices'
from pyhf.
I set up a clean virtual environment myself with the requirements.txt
given by Matthew. My versions are then the following:
$ python --version --version
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
$ python -m pip list | grep 'scipy\|jax\|torch\|tensorflow\|iminuit'
iminuit 2.24.0
jax 0.4.14
jaxlib 0.4.14
scipy 1.11.2
tensorflow 2.13.0
tensorflow-estimator 2.13.0
tensorflow-io-gcs-filesystem 0.33.0
tensorflow-probability 0.21.0
torch 2.0.1
I then executed pytest issue-2311.py
several times and found that the bug occured about 40% of the time. It is the same bug Error message as shown in your previous reply. The "random" nature of when this error occurs makes it quite hard to narrow down further where exactly it happens.
I hope these details of my environment are sufficient. Otherwise I'm glad to provide any further information.
from pyhf.
Related Issues (20)
- Release v0.7.4 checklist HOT 1
- Default POI name for model construction
- Document / summarize additional tools in the "family" / network
- Allow for disabling the default backend in tests at the command line
- Construction of qmutilde for muhat < 0 HOT 6
- jsonschema cannot find path specified \\1.0.0\\def.json HOT 7
- Add basic testing for Windows
- Use `tmp_path` pytest fixture over `tmpdir`
- Make tests/test_scripts.py that use pytest-console-scripts script_runner fixture OS independent HOT 1
- Release v0.7.5 checklist
- Python 3.12 support tracking HOT 5
- Pruning with logical "and" instead of "or" HOT 2
- Catch 100% normalization uncertainty modifiers
- Remove `InvalidNameReuse` exception in favor of in `InvalidModel`
- Typing for tensor shapes
- `ValueError: The truth value of an array` ... when using `fixed_params` kwarg for `pyhf.infer.hypotest` HOT 4
- Release v0.7.6 checklist
- Using the hessian matrix in optimization HOT 2
- Typo in docs for qmutilde test-statistic
- Implementation of fixed params in scipy minimizer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyhf.