Skip to content

Conversation

@mohamed82008
Copy link
Contributor

This PR fixes support for distributions with stochastic support in models. I just want to add some more tests.

@codecov
Copy link

codecov bot commented May 13, 2020

Codecov Report

Merging #115 into master will decrease coverage by 4.18%.
The diff coverage is 60.14%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/DynamicPPL.jl 100.00% <ø> (ø)
src/compat/ad.jl 0.00% <0.00%> (ø)
src/prob_macro.jl 92.30% <ø> (-0.08%) ⬇️
src/threadsafe.jl 22.64% <0.00%> (-5.93%) ⬇️
src/context_implementations.jl 54.28% <47.61%> (-1.35%) ⬇️
src/varinfo/utils.jl 72.51% <55.71%> (-10.44%) ⬇️
src/varinfo/linking.jl 69.73% <62.90%> (-18.73%) ⬇️
src/varinfo/indexing.jl 77.51% <68.67%> (-14.59%) ⬇️
src/varinfo/ad.jl 100.00% <100.00%> (ø)
src/varinfo/types.jl 73.68% <100.00%> (+3.09%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ab6615...4d881ea. Read the comment docs.

@mohamed82008 mohamed82008 requested a review from devmotion May 13, 2020 17:45
Copy link
Member

@devmotion devmotion left a 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 value for 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?

Comment on lines +1 to +16
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
Copy link
Member

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.

@mohamed82008
Copy link
Contributor Author

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)?

Thanks for your comments @devmotion. I will split the files first in a PR.

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.

The DynamicPPL.value function is needed by DynamicPPL. Putting it in a separate package means we would have to depend on that other package which depends on Requires so it means more rather than less dependencies.

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?

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 :)

@mohamed82008 mohamed82008 force-pushed the mt/fix_stochastic_support branch from 7fd78f1 to 4d881ea Compare May 13, 2020 20:43
@yebai yebai closed this May 13, 2020
@mohamed82008
Copy link
Contributor Author

@yebai did you close this on purpose?

@yebai yebai reopened this May 13, 2020
@yebai
Copy link
Member

yebai commented May 13, 2020

@yebai did you close this on purpose?

yes, sorry, I have do temporarily close this PR to revert some changes on the master.

@mohamed82008
Copy link
Contributor Author

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?

@yebai
Copy link
Member

yebai commented May 13, 2020

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.

@mohamed82008
Copy link
Contributor Author

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.

@yebai
Copy link
Member

yebai commented May 13, 2020

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.

@yebai
Copy link
Member

yebai commented Jan 28, 2021

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.

@yebai yebai closed this Jan 28, 2021
@yebai yebai deleted the mt/fix_stochastic_support branch January 28, 2022 20:29
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.

4 participants