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

feat: support runtime activity for enzyme #38

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project since the release of v1 will be documented i
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2024-09-22

### Added

- Adds a kwarg `enzyme_set_runtime_activity` to `test_gradients` to allow users to set
the runtime activity of Enzyme tests.

## [1.2.0] - 2024-09-18

### Added
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LuxTestUtils"
uuid = "ac9de150-d08f-4546-94fb-7472b5760531"
authors = ["Avik Pal <[email protected]>"]
version = "1.2.1"
version = "1.3.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
9 changes: 8 additions & 1 deletion src/autodiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Test the gradients of `f` with respect to `args` using the specified backends.
- `soft_fail`: If `true`, then the test will be recorded as a `soft_fail` test. This
overrides any `broken` kwargs. Alternatively, a list of backends can be passed to
`soft_fail` to allow soft_fail tests for only those backends.
- `enzyme_set_runtime_activity`: If `true`, then activate runtime activity for Enzyme.
- `kwargs`: Additional keyword arguments to pass to `check_approx`.

## Example
Expand All @@ -129,6 +130,7 @@ julia> test_gradients(f, 1.0, x, nothing)
"""
function test_gradients(f, args...; skip_backends=[], broken_backends=[],
soft_fail::Union{Bool, Vector}=false,
enzyme_set_runtime_activity::Bool=false,
# Internal kwargs start
source::LineNumberNode=LineNumberNode(0, nothing),
test_expr::Expr=:(check_approx(∂args, ∂args_gt; kwargs...)),
Expand All @@ -146,7 +148,12 @@ function test_gradients(f, args...; skip_backends=[], broken_backends=[],
total_length ≤ 100 && push!(backends, AutoForwardDiff())
total_length ≤ 100 && push!(backends, AutoFiniteDiff())
# TODO: Move Enzyme out of here once it supports GPUs
ENZYME_TESTING_ENABLED && push!(backends, AutoEnzyme())
if ENZYME_TESTING_ENABLED
mode = enzyme_set_runtime_activity ?
Enzyme.set_runtime_activity(Enzyme.Reverse) :
Enzyme.Reverse
push!(backends, AutoEnzyme(; mode))
end
end
push!(backends, AutoTracker())

Expand Down
Loading