- 
                Notifications
    
You must be signed in to change notification settings  - Fork 37
 
[WIP] Fix support for distributions with stochastic support #115
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
Conversation
          Codecov Report
 @@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage   74.83%   70.65%   -4.19%     
==========================================
  Files          17       18       +1     
  Lines         906     1046     +140     
==========================================
+ Hits          678      739      +61     
- Misses        228      307      +79     
 Continue to review full report at Codecov. 
  | 
    
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'm sorry but I don't think I'm able to review this PR properly, due to the new file structure it is very difficult to figure out which parts of the VarInfo implementation are actually modified and which are just moved to some other file. Can you please keep the VarInfo implementation in varinfo.jl for now and split it in a separate PR (I'm very much in favour of this refactoring but it should be done separately)?
Some general comments so far:
- It seems this PR adds a bunch of new functions to the VarInfo and ThreadedVarInfo interface. As discussed before, I think we should rather try to simplify the implementation and reduce the number of functions, so we should evaluate carefully if all of them are needed.
 - I don't think the definition of 
valuefor the AD backends belongs to DynamicPPL (and hence Requires is not needed, see my comment below). - I think we should perform some detailed benchmarking, just to ensure that there are no performance regressions. I'm not sure if we have some standard benchmarking suite set up for Turing? Isn't there a bot for it?
 
| function __init__() | ||
| @require ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" begin | ||
| value(x::ForwardDiff.Dual) = ForwardDiff.value(x) | ||
| value(x::AbstractArray{<:ForwardDiff.Dual}) = ForwardDiff.value.(x) | ||
| end | ||
| @require ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" begin | ||
| value(x::ReverseDiff.TrackedReal) = ReverseDiff.value(x) | ||
| value(x::ReverseDiff.TrackedArray) = ReverseDiff.value(x) | ||
| value(x::AbstractArray{<:ReverseDiff.TrackedReal}) = ReverseDiff.value.(x) | ||
| end | ||
| @require Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" begin | ||
| value(x::Tracker.TrackedReal) = Tracker.data(x) | ||
| value(x::Tracker.TrackedArray) = Tracker.data(x) | ||
| value(x::AbstractArray{<:Tracker.TrackedReal}) = Tracker.data.(x) | ||
| end | ||
| end No newline at end of file | 
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.
These definitions should not be part of DynamicPPL but moved to some other package. The only AD-related part in DynamicPPL should be custom adjoints for functions defined in DynamicPPL if required, which should be implemented without depending on the AD packages if possible (by using, e.g., ZygoteRules or ChainRulesCore). If these definitions are removed, there's also no need for adding Requires as a dependency, AFAICT.
          
 Thanks for your comments @devmotion. I will split the files first in a PR. 
 The  
 I did some benchmarking on my machine and there was no regression as far as I can tell. I will do more and report here. There is a benchmarking bot last modified by @KDr2 I believe. Unfortunately, I don't think it's exhaustive so I will use the benchmarks from TuringExamples for now. As for the added complexity, I am not sure what I can do about that. I can rethink the need for some functions by trying to update the internals' docs. While doing that, I might either justify each and every function or find some to be replaceable. Either way, we would be in a better situation than we are now :)  | 
    
7fd78f1    to
    4d881ea      
    Compare
  
    | 
           @yebai did you close this on purpose?  | 
    
          
 yes, sorry, I have do temporarily close this PR to revert some changes on the master.  | 
    
          
 Hmm I don't see how they are related. What changes do you want to revert? The files reorganization?  | 
    
          
 yes, Github does not seem to allow reverting changes on master with open PRs.  | 
    
          
 You can reset the last commit and force push to master if you really want. May I ask why you want to revert them? The varinfo file is getting unwieldy. I am really in favor of that reorganization.  | 
    
          
 I commented on this in another PR. I got your point for reorganisation. I think it's better to stick with the single-file organisation for now. I discussed with Kai in AdvancedHMC about this too. I feel it is easier to track changes with all functionalities related to one data structure in one file; it is ok to separate code by sections if needed. I am happy to revisit this organisation issue in the future if necessary, but better to have some team-wide discussions first.  | 
    
| 
           I'm closing this PR for now since we don't intend to support distributions with stochastic support for now - it might change in the future if there is a strong case. We'll revisit when that happens.  | 
    
This PR fixes support for distributions with stochastic support in models. I just want to add some more tests.