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

bug: Jitting objectives. #409

Open
daniel-dodd opened this issue Nov 6, 2023 · 1 comment
Open

bug: Jitting objectives. #409

daniel-dodd opened this issue Nov 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@daniel-dodd
Copy link
Member

Bug Report

GPJax version: 0.7.2

Tagging @henrymoss.

As noted in #402 there is issue with jitting objective. This functionality should be removed.

Option (a)

Remove these following lines of code on AbstractObjective:

    ...
    def __hash__(self):
        return hash(tuple(jtu.tree_leaves(self)))  # Probably put this on the Module!

    def __call__(self, *args, **kwargs) -> ScalarFloat:
        return self.step(*args, **kwargs)

So that jax.jit(gpx.ConjugateMLL(negative=True)) errors. This code is dodgy.

Objectives could still be passed as objective=gpx.ConjugateMLL(negative=True) without the jit which is not really needed in the first place, as code is traced with the lax.scan.

Option (b)

Revert back to the previous objective design in GPJax that comprised an outer and inner function:

# e.g.,
def elbo(negative: bool ...) -> callable:
      def elbo_fun(model, batch) -> Float[Array, ""]:
             ...
      return elbo_fun

Or even just have objectives defined from a minimisation perspective.

def negative_elbo(model, batch) -> Float[Array, ""]:
       ...

def negative_log_likelihood(model, batch) -> Float[Array, ""]:
      ...
@daniel-dodd daniel-dodd added the bug Something isn't working label Nov 6, 2023
@daniel-dodd
Copy link
Member Author

Update: going for the design of option (b)(i), i.e.,

# e.g.,
def elbo(negative: bool ...) -> callable:
      def elbo_fun(model, batch) -> Float[Array, ""]:
             ...
      return elbo_fun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant