Skip to content

Conversation

@sethaxen
Copy link
Collaborator

@sethaxen sethaxen commented Apr 26, 2023

This PR adds functions test_forward and test_reverse, which support testing results of autodiff against FiniteDifferences. Fixes #780

Edit: test_forward and test_reverse are patterned off of test_frule and test_rrule in ChainRulesTestUtils.

@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2023

Codecov Report

Patch coverage: 94.58% and project coverage change: +0.49% 🎉

Comparison is base (5d310e8) 77.41% compared to head (1d53572) 77.91%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #782      +/-   ##
==========================================
+ Coverage   77.41%   77.91%   +0.49%     
==========================================
  Files          19       27       +8     
  Lines        8897     9137     +240     
==========================================
+ Hits         6888     7119     +231     
- Misses       2009     2018       +9     
Files Changed Coverage Δ
lib/EnzymeTestUtils/src/generate_tangent.jl 87.09% <87.09%> (ø)
lib/EnzymeTestUtils/src/test_approx.jl 87.09% <87.09%> (ø)
lib/EnzymeTestUtils/src/output_control.jl 92.85% <92.85%> (ø)
lib/EnzymeTestUtils/src/test_forward.jl 93.10% <93.10%> (ø)
lib/EnzymeTestUtils/src/test_reverse.jl 97.82% <97.82%> (ø)
lib/EnzymeTestUtils/src/finite_difference_calls.jl 98.63% <98.63%> (ø)
lib/EnzymeTestUtils/src/EnzymeTestUtils.jl 100.00% <100.00%> (ø)
lib/EnzymeTestUtils/src/compatible_activities.jl 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sethaxen
Copy link
Collaborator Author

test_forward and its test suite are now finished, and I'll start on test_reverse.

@sethaxen
Copy link
Collaborator Author

@wsmoses @vchuravy the tests now pass on v1.7 and v1.9. I had to add a lot of exceptions (tests marked as skip or broken) to work around version-specific errors and failures that occur when Enzyme differentiates Julia code. Not all are captured by issues, but I don't really have time right now to open issues with MWEs and errors for them all.

Reverse-mode tests could use more tests for batch mode, but these could be added in a later PR.

I suggest that this is ready for merge and initial package registration.

@wsmoses wsmoses merged commit 4cc19dc into EnzymeAD:main Aug 31, 2023
@sethaxen
Copy link
Collaborator Author

sethaxen commented Sep 1, 2023

Thanks @wsmoses! Looks like it stilled needs a registration with @JuliaRegistrator register subdir="lib/EnzymeTestUtils"

@JuliaRegistrator
Copy link

Error while trying to register: Register Failed
@sethaxen, it looks like you are not a publicly listed member/owner in the parent organization (EnzymeAD).
If you are a member/owner, you will need to change your membership to public. See GitHub Help

@sethaxen sethaxen deleted the testers branch September 1, 2023 11:33
michel2323 pushed a commit that referenced this pull request Nov 7, 2023
* Add initial forward-mode tester

* Rework auto_forward_activity

* Refactor to pass activities to _make_jvp_call

* Generalize rand_tangent

* Update test_approx

* Add zero_tangent

* Don't return tuple if return argument is not a tuple

* Support batched activities

* Update test_forward

* Update comments and docstring

* Add all_or_no_batch utility

* Return NamedTuple

* Return zero tangent instead of nothing

* Add zero_tangent and rand_tangent for (Named)Tuples

* Add test_forward tests

* Test multi-argument function

* Don't call autodiff with kwargs

* Add meta-testing functions

* Test kwargs correctly forwarded

* Test different types of errors are caught

* Deactivate failing test

* Reformat

* Use MetaTesting code

* Test complex cases

* Remove redundant test

* Remove redundant comment

* Update docstring

* Add ConstructionBase as a test dependency

* Fix construction

* Rename function

* Rename function

* Add test_reverse

* Add test_reverse tests

* Avoid trig functions

* Only pass adjoint for Active

* Resolve comment

* Add docstring

* Test multi-arg mutating function

* Avoid exp

* Test multi-arg function separately

* Generalize test_reverse

* Remove limitation

* Fix map

* Test mutated callable

* Add broken test for mutated callable

* Run formatter

* Update f_kwargs rules

* Test that testers catch incorrect reverse-mode rules

* Add missing import

* Add and update docstrings

* Update Project.toml

* Test tester tests

* Rename Foo

* Clarify limitations

* Add more clarification

* Add EnzymeTestUtils package

* Remove module file

* Move testers to module file

* Make EnzymeTestUtils module

* Add package deps and extras

* Create runtests.jl

* Add Random to Project.toml

* Remove duplicated code

* Add missing include

* Remove unneeded import

* Duplicate code

* Remove redundant code

* Duplicate code

* Remove redundant code

* Add more useful function name

* Rename file

* Add EnzymeTestUtils to the API docs

* Add docs example for EnzymeTestUtils

* Turn docstrings for private functions into comments

* Dev EnzymeTestUtils for docs build

* Uncomment test

* Reformat

* Limit what's imported to namespace

* Copy tests

* Remove redundant code

* Add EnzymeTestUtils workflow stage

* Set project globally

* Run in Julia shell

* Remove test deps

* Handle nonnumeric types in test_approx

* Add tests for test_approx

* Add tests for compatible activities

* Add tests for tangent generation

* Test auto_activity

* Reuse test helper

* Adapt output_control from ChainRulesTestUtils

* Add messages to test_approx

* Make test failures more informative

* Improve test messages

* Bump EnzymeCore version bound

* Rename functions

* Define _any_batch utility

* Remove use of invoke

* Mark broken tests as broken

* Avoid constructor with types

* Skip ComplexF32 for mutated callable tests

* Remove broken annotation

* Simplify broken annotation

* Simplify CI code

* Fix string generation

* Avoid more complicated elementary functions

* Fix tests for v1.7

* Fix tests for v1.9

* Fixes for batch in reverse-mode

* Expand examples in docstrings

* Add batch size computation

* Batchify zero tangent vectors

* Make batch cotangents if necessary

* Add batch array test

* Avoid broadcast

* Define f_mut_nothing!

* Avoid error caused by runtime activity

* Test batch mutating cases

* Test mutated callable in batch mode

* Update documented constraints

* Copy code

* Split testers into two files

* Split testers tests across files

* Support Active combined with batch activities

* Test more compatible activities

* Update function call

* Remove NamedTuple wrapping

* Run formatter

* Update function name

* Add exception for v1.7

---------

Co-authored-by: Valentin Churavy <[email protected]>
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.

Adding testing utilities

5 participants