aesara-devs / aehmc

An HMC/NUTS implementation in Aesara
MIT License
33 stars 6 forks source link

Example notebook has old Aesara warnings #50

Closed brandonwillard closed 2 years ago

brandonwillard commented 2 years ago

The example notebook still has numerous warnings for an old Aesara bug, so it looks like it needs to be rerun with an up-to-date version.

rlouf commented 2 years ago

I reran the notebook with aesara 2.3.3, aeppl 0.0.20 and aehmc 0.0.2, and I still get the following warning when compiling:

Trace

``` WARNING (aesara.tensor.basic_opt): Failed to infer_shape from Op normal_rv{0, (0, 0), floatX, False}. Input shapes: [None, (Shape_i{0}.0,), (), (), ()] Exception encountered during infer_shape: Exception message: Traceback: Traceback (most recent call last): File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/op.py", line 282, in infer_shape size_len = get_vector_length(size) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/__init__.py", line 77, in get_vector_length return _get_vector_length(getattr(v.owner, "op", v), v) File "/usr/lib/python3.9/functools.py", line 877, in wrapper return dispatch(args[0].__class__)(*args, **kw) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/__init__.py", line 83, in _get_vector_length raise ValueError(f"Length of {var} cannot be determined") ValueError: Length of cannot be determined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/basic_opt.py", line 831, in get_node_infer_shape o_shapes = shape_infer( File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/op.py", line 284, in infer_shape size_len = get_scalar_constant_value(size_shape[0]) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/basic.py", line 551, in get_scalar_constant_value raise NotScalarConstantError() aesara.tensor.exceptions.NotScalarConstantError WARNING (aesara.tensor.basic_opt): Failed to infer_shape from Op normal_rv{0, (0, 0), floatX, False}. Input shapes: [None, (Shape_i{0}.0,), (), (), ()] Exception encountered during infer_shape: Exception message: Traceback: Traceback (most recent call last): File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/op.py", line 282, in infer_shape size_len = get_vector_length(size) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/__init__.py", line 77, in get_vector_length return _get_vector_length(getattr(v.owner, "op", v), v) File "/usr/lib/python3.9/functools.py", line 877, in wrapper return dispatch(args[0].__class__)(*args, **kw) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/__init__.py", line 83, in _get_vector_length raise ValueError(f"Length of {var} cannot be determined") ValueError: Length of cannot be determined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/basic_opt.py", line 831, in get_node_infer_shape o_shapes = shape_infer( File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/op.py", line 284, in infer_shape size_len = get_scalar_constant_value(size_shape[0]) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/basic.py", line 551, in get_scalar_constant_value raise NotScalarConstantError() aesara.tensor.exceptions.NotScalarConstantError ERROR (aesara.graph.opt): Optimization failure due to: random_make_inplace ERROR (aesara.graph.opt): node: normal_rv{0, (0, 0), floatX, False}(, , TensorConstant{11}, TensorConstant{0}, TensorConstant{1}) ERROR (aesara.graph.opt): TRACEBACK: ERROR (aesara.graph.opt): Traceback (most recent call last): File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/graph/opt.py", line 1992, in process_node replacements = lopt.transform(fgraph, node) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/graph/opt.py", line 1203, in transform return self.fn(fgraph, node) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/opt.py", line 49, in random_make_inplace return new_op.make_node(*node.inputs).outputs File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/op.py", line 324, in make_node size = normalize_size_param(size) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/random/utils.py", line 131, in normalize_size_param size = specify_shape(size, (get_vector_length(size),)) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/__init__.py", line 77, in get_vector_length return _get_vector_length(getattr(v.owner, "op", v), v) File "/usr/lib/python3.9/functools.py", line 877, in wrapper return dispatch(args[0].__class__)(*args, **kw) File "/home/remi/.virtualenvs/aehmc/lib/python3.9/site-packages/aesara/tensor/__init__.py", line 83, in _get_vector_length raise ValueError(f"Length of {var} cannot be determined") ValueError: Length of cannot be determined ```

The code runs, but still we should not get these warnings. Part of an increasingly long list of details I need to iron when the warmup is released.

brandonwillard commented 2 years ago

@rlouf, try running it with Aesara main. Now that https://github.com/aesara-devs/aesara/pull/711 is merged, the issue should be resolved—or, at the very least, fully resolvable.

rlouf commented 2 years ago

That was on my list for tomorrow!

rlouf commented 2 years ago

aesara-devs/aesara#711 solves the infer_shape warning, I'll open a PR. We still have the When the number of steps is fixed and equal to 1, the provided stopping condition, Elemwise{eq,no_inplace}.0 is ignored warning, which will disappear once aesara-devs/aesara#741 is merged.