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

adding debug mode to inferer #248

Merged
merged 3 commits into from
Oct 4, 2024
Merged

adding debug mode to inferer #248

merged 3 commits into from
Oct 4, 2024

Conversation

arik-shurygin
Copy link
Collaborator

as mentioned in #244 it is helpful to have sanity checks on our likelihood functions. This function added to the mechanistic_inferer shows off a basic example of how to implement such a sanity check. Any changes to self.likelihood must also be added to the _debug_likelihood function.

Due to the layout of how self.likelihood function we can not just pass it alone into bx_model.mcmc.numpyro_nuts.debug so overrides are needed separately.

@kokbent
Copy link
Collaborator

kokbent commented Sep 6, 2024

wait i don't understand what it means any changes to likelihood must also be made to _debug_likelihood... they seem to just be calling self.likelihood anyway?

Copy link
Contributor

@SamuelBrand1 SamuelBrand1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way to weave bayeux into the MechanisticInferer class.

My request is to add a test which checks if we would have picked up the issue we had when abstol/reltol wasn't aggressive enough, e.g. would this debug mode have captured potential problems without having to run chains etc.

@arik-shurygin
Copy link
Collaborator Author

@SamuelBrand1 added a test and passed kwargs so that _debug_inferer does not need to be updated every time likelihood is changed

@SamuelBrand1
Copy link
Contributor

@SamuelBrand1 added a test and passed kwargs so that _debug_inferer does not need to be updated every time likelihood is changed

Looks good.

Running it locally give:

Checking test_point shape ✓
Computing test point log density ✓
Loading keyword arguments... ✓
Checking it is possible to compute an initial state ✓
Checking initial state is has no NaN ✓
Computing initial state log density ×
Transforming model to R^n ×
Computing transformed state log density shape ×
Computing gradients of transformed log density ×

Should I be interested in the fails here?

@arik-shurygin
Copy link
Collaborator Author

@SamuelBrand1 added a test and passed kwargs so that _debug_inferer does not need to be updated every time likelihood is changed

Looks good.

Running it locally give:

Checking test_point shape ✓
Computing test point log density ✓
Loading keyword arguments... ✓
Checking it is possible to compute an initial state ✓
Checking initial state is has no NaN ✓
Computing initial state log density ×
Transforming model to R^n ×
Computing transformed state log density shape ×
Computing gradients of transformed log density ×

Should I be interested in the fails here?

to be honest I am not sure. @kokbent @tjhladish I am curious your thoughts

@SamuelBrand1
Copy link
Contributor

Upon reflection whether the specific test model has debug fails is not in scope for this PR.

Copy link
Contributor

@SamuelBrand1 SamuelBrand1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handy extra functionality. If the debug fails on the test version of the model are relevant is another issue.

@arik-shurygin arik-shurygin merged commit ffb4380 into main Oct 4, 2024
2 checks passed
@arik-shurygin arik-shurygin deleted the debug-inferer branch October 4, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants