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

DOC: HSGP.prior_linearized example raises error #7000

Closed
wd60622 opened this issue Nov 8, 2023 · 5 comments · Fixed by #7111
Closed

DOC: HSGP.prior_linearized example raises error #7000

wd60622 opened this issue Nov 8, 2023 · 5 comments · Fixed by #7111
Labels

Comments

@wd60622
Copy link
Contributor

wd60622 commented Nov 8, 2023

Issue with current documentation:

I'm running into issue with the example of the HSGP.prior_linearized
https://www.pymc.io/projects/docs/en/stable/api/gp/generated/classmethods/pymc.gp.HSGP.prior_linearized.html#pymc.gp.HSGP.prior_linearized

There is a pymc.exceptions.NotConstantValueError raised on the following line

phi, sqrt_psd = gp.prior_linearized(Xs=Xs)
Traceback (most recent call last):
  File "~/.../pymc/gp/hsgp_approx.py", line 290, in prior_linearized
    Xs, _ = self.cov_func._slice(Xs)
  File "~/.../pymc/gp/cov.py", line 189, in _slice
    [xdims] = constant_fold([xdims])
  File "~/.../pymc/pytensorf.py", line 1225, in constant_fold
    raise NotConstantValueError
pymc.exceptions.NotConstantValueError

I am running it with the latest main branch.

Idea or request for content:

Maybe I am missing some context in the example that could be added within the page or the functionality has changed and the example should be removed

@wd60622 wd60622 added the docs label Nov 8, 2023
@wd60622 wd60622 changed the title DOC: <Please write a comprehensive title after the 'DOC: ' prefix> DOC: HSGP.prior_linearized example raises error Nov 8, 2023
@twiecki
Copy link
Member

twiecki commented Nov 8, 2023

CC @bwengals

@bwengals
Copy link
Contributor

Looks like recent update to PyMC here broke this. We can't use constant_fold there when X is passed as a mutable variable, the use case for that example.

Previously I just had .eval() there, since the values of X can mutate but not the dimensions (and if they do, the warning will show). @ricardoV94, is the constant_fold needed here or is there another way?

Also, x_dims is only actually used here to maybe give a warning. This warning has come in handy for me from time, but would prioritize the HSGP example working over the warning. So another option is to get rid of this bit of code.

@ricardoV94
Copy link
Member

ricardoV94 commented Nov 16, 2023

You can put it in a try/except an skip the warning if it didn't manage to constant_fold. But it seems like it causes more trouble than it helps?

@ricardoV94
Copy link
Member

ricardoV94 commented Nov 16, 2023

Alternatively you could be more strict and add a PyTensor assert, and don't support the "partial use of columns" case at all? If you think that's very likely to be a bug in most cases?

@wmbelk
Copy link

wmbelk commented Jan 4, 2024

FYI; When I changed cov.py line 188, from:
def _slice(self, X, Xs=None):
xdims = X.shape[-1]
if isinstance(xdims, Variable):
[xdims] = constant_fold([xdims])

To be:
def _slice(self, X, Xs=None):
xdims = X.shape[-1]
if isinstance(xdims, Variable):
[xdims] = constant_fold([xdims], raise_not_constant=False)

Overriding the default True on raise_not_constant... It seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants