Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 10488cd

Browse files
committed
feat: support runtime activity for enzyme
1 parent 23dfb36 commit 10488cd

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project since the release of v1 will be documented i
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.0] - 2024-09-22
9+
10+
### Added
11+
12+
- Adds a kwarg `enzyme_set_runtime_activity` to `test_gradients` to allow users to set
13+
the runtime activity of Enzyme tests.
14+
815
## [1.2.0] - 2024-09-18
916

1017
### Added

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LuxTestUtils"
22
uuid = "ac9de150-d08f-4546-94fb-7472b5760531"
33
authors = ["Avik Pal <avikpal@mit.edu>"]
4-
version = "1.2.1"
4+
version = "1.3.0"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/autodiff.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Test the gradients of `f` with respect to `args` using the specified backends.
114114
- `soft_fail`: If `true`, then the test will be recorded as a `soft_fail` test. This
115115
overrides any `broken` kwargs. Alternatively, a list of backends can be passed to
116116
`soft_fail` to allow soft_fail tests for only those backends.
117+
- `enzyme_set_runtime_activity`: If `true`, then activate runtime activity for Enzyme.
117118
- `kwargs`: Additional keyword arguments to pass to `check_approx`.
118119
119120
## Example
@@ -129,6 +130,7 @@ julia> test_gradients(f, 1.0, x, nothing)
129130
"""
130131
function test_gradients(f, args...; skip_backends=[], broken_backends=[],
131132
soft_fail::Union{Bool, Vector}=false,
133+
enzyme_set_runtime_activity::Bool=false,
132134
# Internal kwargs start
133135
source::LineNumberNode=LineNumberNode(0, nothing),
134136
test_expr::Expr=:(check_approx(∂args, ∂args_gt; kwargs...)),
@@ -146,7 +148,12 @@ function test_gradients(f, args...; skip_backends=[], broken_backends=[],
146148
total_length 100 && push!(backends, AutoForwardDiff())
147149
total_length 100 && push!(backends, AutoFiniteDiff())
148150
# TODO: Move Enzyme out of here once it supports GPUs
149-
ENZYME_TESTING_ENABLED && push!(backends, AutoEnzyme())
151+
if ENZYME_TESTING_ENABLED
152+
mode = enzyme_set_runtime_activity ?
153+
Enzyme.set_runtime_activity(Enzyme.Reverse) :
154+
Enzyme.Reverse
155+
push!(backends, AutoEnzyme(; mode))
156+
end
150157
end
151158
push!(backends, AutoTracker())
152159

0 commit comments

Comments
 (0)