-
Notifications
You must be signed in to change notification settings - Fork 29
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
Introduction of model_typed
and model_warntype
in DebugUtils
#708
base: master
Are you sure you want to change the base?
Conversation
`model_warntype` for the checking of the model's evaluator
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #708 +/- ##
==========================================
- Coverage 82.14% 77.67% -4.47%
==========================================
Files 30 30
Lines 4200 3919 -281
==========================================
- Hits 3450 3044 -406
- Misses 750 875 +125 ☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 11684382988Details
💛 - Coveralls |
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.
I think it is very helpful. Also happy to depend on InteractiveUtils
.
@willtebbutt you might want to help review this PR too.
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.
I really like this, and agree that InteractiveUtils is a perfectly fine dep to have.
So, I think that the concept is basically fine. Will this stuff automatically appear in the docs, or do we need to add it in manually?
While I think you should feel free to merge this PR without this, could I ask whether you would consider exposing a function which returns the function + arguments that you pass to fargs, kwargs = get_args_for_analysis(model, varinfo, context)) with the same default values for I guess the implementation would be something like function get_args_for_analysis(model, varinfo=default_thing, context=default_thing)
args, kargs = DynamicPPL.make_evaluate_args_and_kwargs(model, varinfo, context)
return (f, args...), kwargs
end The reason to want this, is that
|
Yep, can do @willtebbutt ! |
Wait; why is that function you defined simpler than just doing |
Added |
…rfjelde/code-warntype
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
It's a simpler interface, rather than implementation. It's about ensuring that we have a single source of truth that you can point people towards (and put in the docs) that says "here is everything you need -- we promise that this is the thing that you should profile for performance", as opposed to having to know that the edit: having now looked at this a bit more closely, am I correct that you can always do: fargs, kwargs = DynamicPPL.make_evaluate_args_and_kwargs(model, varinfo, context)
fargs[1](fargs[2:end]...; kwargs...) in order to evaluate the correct thing? |
Also, I've just realised that this functionality is not tested, and doesn't appear in the docs. It would be good to add a unit test which just runs Also, could you please add these to a debug section in the docs? |
end | ||
|
||
""" | ||
model_typed(model[, varinfo, context]; optimize=true) |
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.
Same here -- needs to specify what the defaults are.
Nah, it's model.f(args...; kwargs...) The evaluator |
Added docs and testing @willtebbutt |
…rfjelde/code-warntype
I don't feel especially strongly either way. Personally, I like having it with the arguments because for Mooncake.jl-related stuff, where the distinction between function and argument is not really there (e.g. when using |
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.
This is ready to go once the patch version has been bumped.
As I said, I don't want my other request to get in the way of getting this released. I'm happy to re-review if you do want to implement that as part of this PR though @torfjelde . I'll open an issue about it if you don't fancy doing it as part of this PR.
I wanted to do some checking of type-stability for a model. Unfortunately, this is quite annoying to do in a way where you can inspect the inferred types of the model's evaluator function.
Hence I was thinking it might be useful to have a few simple methods which just does the set up + calls
@code_warntype
onmodel.f
(and similarly for@code_typed
). This PR therefore introducesmodel_warntype
andmodel_typed
in theDebugUtils
module which does exactly this.I think this is particularly useful for users who wants to check type-stability of their model, which IMO should be able to do so without extensive knowledge of DynamicPPL internals.
The downside: have to add InteractiveUtils.jl as a direct dep (though it's part of base, so should be fine).
Thoughts?