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

Remove use of eval in tests #116

Merged
merged 4 commits into from Jun 22, 2020
Merged

Conversation

devmotion
Copy link
Member

This PR removes the use of eval in the tests, simplifies their structure, and avoids some symmetries and "nice" specially chosen values in the AD tests by using random parameters and samples.

@codecov
Copy link

codecov bot commented Jun 21, 2020

Codecov Report

Merging #116 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #116   +/-   ##
=======================================
  Coverage   57.22%   57.22%           
=======================================
  Files          23       23           
  Lines        1169     1169           
=======================================
  Hits          669      669           
  Misses        500      500           

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 951ac54...8e7cb59. Read the comment docs.

@yebai yebai requested a review from torfjelde June 21, 2020 12:23
@devmotion
Copy link
Member Author

With this PR Zygote tests finish in around 25 minutes instead of > 3h on master. It seems that Julia 1.0 requires some additional adjoints for Tracker and ReverseDiff though.

@devmotion
Copy link
Member Author

devmotion commented Jun 21, 2020

Travis tests fail probably due some change introduced in Tracker 0.2.7 (the previous commit passed on Tracker 0.2.6, and the last commit did not change anything that affects the Travis tests).

@devmotion
Copy link
Member Author

@torfjelde Any idea what change in Tracker (or some other dependency) might cause the issues on Travis?

Otherwise the tests pass and are extremely fast now 🎉 I guess, the tests in DistributionsAD should be changed in the same/similar way.

@devmotion
Copy link
Member Author

BTW if someone enables codecov for this repo, then the codecov comments in the PRs provide some more meaningful information about coverage changes.

@yebai
Copy link
Member

yebai commented Jun 21, 2020

BTW if someone enables codecov for this repo, then the codecov comments in the PRs provide some more meaningful information about coverage changes.

Isn't Codecov already enabled?

@devmotion
Copy link
Member Author

Hmm maybe it is actually. I was confused that the report states that the coverage diff is "n/a" but maybe that's not relevant.

@yebai
Copy link
Member

yebai commented Jun 21, 2020

Hmm maybe it is actually. I was confused that the report states that the coverage diff is "n/a" but maybe that's not relevant.

It's indeed strange. Codecov page says there aren't sufficient commits for this repo yet.

@torfjelde Please add a code review, or proceed with merging if everything looks good.

@devmotion
Copy link
Member Author

I assume the issues on Travis are the same as in FluxML/Tracker.jl#71. It seems the latest Tracker release is declared to be compatible with Adapt 2 but was only tested with Adapt 1.

@devmotion
Copy link
Member Author

Tests on master fail due to the same problem.

Copy link
Member

@torfjelde torfjelde left a comment

Choose a reason for hiding this comment

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

This is great @devmotion ! Looks much better; thank you!:)

Have a couple of questions, but overall looks good 👍

EDIT: Don't merge until my comments have been addressed! Shouldn't have "approved" before we've removed the redundant comments and discussed the matrix-case a bit.

test/ad/distributions.jl Outdated Show resolved Hide resolved
Comment on lines +489 to +493
# Matrix case doesn't work for continuous distributions for some reason
# now but not too important (?!)
if length(sz) == 2 && Distributions.value_support(typeof(d)) === Continuous
continue
end
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why? I.e. what's the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I can check it. That's why I added "(?!)" to the comment 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW I think it's pretty bad to just state arrays of distributions for which tests are broken because we won't notice if some change (in Bijectors or some other package) fixes a broken test. IMO we should explicitly test whatever behaviour is broken. I just didn't want to put too many changes in this PR and wanted to check if it actually helps to reduce testing times first.

Copy link
Member Author

@devmotion devmotion Jun 22, 2020

Choose a reason for hiding this comment

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

It seems it's mainly an issue with Tracker (yields

MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type SubArray{Float64,1,Array{Float64,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}

already for the first distribution), although Zygote also yields errors for some distributions such as arraydist with GeneralizedExtremeValue (but works fine for all distributions above, i.e., Arcsine to Gamma).

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like a good idea, but how would we do this in practice when checking PRs and stuff? Should have a one test-suite which tests broken tests and is allowed to fail? Doesn't seem like that will helps us discover if tests are fixed by upstream packages since there will be too much noise.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we would have to state explicitly for which AD backends tests don't pass, and then use @test_broken instead of @test for these inside of test_ad. Probably would need an additional argument to DistSpec, e.g., a field broken with default value () that could be set to ("Zygote",), ("Zygote", "ReverseDiff") etc. Would be tedious to set up initially, but should work quite reliably I assume.

Copy link
Member

Choose a reason for hiding this comment

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

Aaaah, pfft I haven't read the docs of @test_broken before; that makes complete sense. But should we maybe just get this PR merged now and then we can add this later? Unless you're really keen on just getting it done immediately, in which case I won't stop you:)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, actually I'm not very keen on going through the lists and figuring out why these tests are broken right now 😛 So I'm fine with adding this later.

Project.toml Show resolved Hide resolved
@torfjelde torfjelde merged commit 446968d into TuringLang:master Jun 22, 2020
@torfjelde
Copy link
Member

Merged; thanks @devmotion !:)

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.

None yet

3 participants