-
Notifications
You must be signed in to change notification settings - Fork 31
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
Added check_model
and sub-module DebugUtils
#540
Conversation
single record_tilde! + support for dot tilde + return issuccess and additional info in check_model
can further customize
convenient show methods to make displaying the trace nicer
encountering missing
bit more readable
de-conditioning is restricted to univariate distributions
SamplingContext by default since we're using an empty VarInfo by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
Pull Request Test Coverage Report for Build 8750716198Details
💛 - Coveralls |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #540 +/- ##
==========================================
- Coverage 83.65% 79.16% -4.50%
==========================================
Files 28 26 -2
Lines 3219 3197 -22
==========================================
- Hits 2693 2531 -162
- Misses 526 666 +140 ☔ View full report in Codecov by Sentry. |
I went the |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Any thoughts on the implementation @devmotion ? I realize I haven't overloaded |
I'd say the main rules are to avoid type piracy, to absolutely never define |
But then it seems like my current approach is good? |
Btw @yebai you have any thoughts on this? Another aspect I think would be useful with this is to extract the trace from the model a few times to determine if the model is "static" (in some sense) or not. We could then warn the user if, say, they're running HMC on a model which has a non-static number of parameters. EDIT: Added a EDIT 2: Note that after this PR we can immediately improve the user-experience by just adding a |
`has_static_constraints` method to empirically check whether the model has static constraints or if they are indeed changing dependent on realizations
dot-tilde statements
This is pretty much ready to go:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to have some debugging tools!
We can likely introduce some checks performed after each MCMC step in the future, which can help catch additional issues like changing model dimensionality. |
As we're getting more users coming from other languages, who are necessarily not so familiar with Julia, it's becoming more and more important that we avoid the end-user hitting any potentially confusing snags of Turing.jl / DynamicPPL.jl.
Examples are:
missing
and differences between the different ways of conditioning variables.Because of this, I was wondering if it might be a good idea to add some utilities for doing exactly this.
This PR adds a method
check_model
(which is also exported) which executes the model using a special context (DebugUtils.DebugContext
) and performs some checks before, throughout, and after evaluation of the model. See the added tests for some examples.Moreover, once we improve the documentation (I'm going to add a section on "Syntax"), we can then link to those in the warnings/errors to point the user to where they can figure stuff out.
Here's an example:
Thoughts?
As an additional thing, though I'm uncertain if we want this or not, I've added the possibility of saving the tilde-statements as we're going through the model + potentially saving the
varinfo
after every statement. This can be quite useful for both us debugging "remotely" (as in, just ask the user to run the model with this and give us the output) + it makes it quite easy to perform either visual or programmatic checks of the "trace" of a model, which I think will be quite handy.Btw, throughout this I've discovered a few bugs, which have subsequently been fixed:) If we decide against something like this, then I'll make separate PRs for this.