From 6f2b101018a772fa7a5b1ac87f7b76245bcd34ae Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Thu, 13 Mar 2025 11:15:06 +0000 Subject: [PATCH 1/4] Update utils.jl --- test/ad/utils.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ad/utils.jl b/test/ad/utils.jl index 8b073c47..65e18300 100644 --- a/test/ad/utils.jl +++ b/test/ad/utils.jl @@ -72,13 +72,13 @@ function test_ad(f, x, broken=(); rtol=1e-6, atol=1e-6) if !(:EnzymeReverseCrash in broken) if reverse_broken @test_broken( - Enzyme.gradient(Enzyme.Reverse, f, x)[1] ≈ finitediff, + Enzyme.gradient(Enzyme.Reverse, Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) else @test( - Enzyme.gradient(Enzyme.Reverse, f, x)[1] ≈ finitediff, + Enzyme.gradient(Enzyme.Reverse, Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) From f91b1dbc29ca1336645a73a0881b00f996b466bd Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Thu, 13 Mar 2025 11:45:27 +0000 Subject: [PATCH 2/4] fix Enzyme interface --- test/ad/utils.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/ad/utils.jl b/test/ad/utils.jl index 65e18300..78879822 100644 --- a/test/ad/utils.jl +++ b/test/ad/utils.jl @@ -56,13 +56,13 @@ function test_ad(f, x, broken=(); rtol=1e-6, atol=1e-6) if !(:EnzymeForwardCrash in broken) if forward_broken @test_broken( - Enzyme.gradient(Enzyme.Forward, f, x)[1] ≈ finitediff, + Enzyme.gradient(set_runtime_activity(Forward), Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) else @test( - Enzyme.gradient(Enzyme.Forward, f, x)[1] ≈ finitediff, + Enzyme.gradient(set_runtime_activity(Forward), Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) @@ -72,13 +72,13 @@ function test_ad(f, x, broken=(); rtol=1e-6, atol=1e-6) if !(:EnzymeReverseCrash in broken) if reverse_broken @test_broken( - Enzyme.gradient(Enzyme.Reverse, Enzyme.Const(f), x)[1] ≈ finitediff, + Enzyme.gradient(set_runtime_activity(Reverse), Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) else @test( - Enzyme.gradient(Enzyme.Reverse, Enzyme.Const(f), x)[1] ≈ finitediff, + Enzyme.gradient(set_runtime_activity(Reverse), Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) From 75b10fdfde59a1cab356223287db8224c91d577c Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:09:29 +0000 Subject: [PATCH 3/4] change forward back --- test/ad/utils.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ad/utils.jl b/test/ad/utils.jl index 78879822..6d9e3f45 100644 --- a/test/ad/utils.jl +++ b/test/ad/utils.jl @@ -56,13 +56,13 @@ function test_ad(f, x, broken=(); rtol=1e-6, atol=1e-6) if !(:EnzymeForwardCrash in broken) if forward_broken @test_broken( - Enzyme.gradient(set_runtime_activity(Forward), Enzyme.Const(f), x)[1] ≈ finitediff, + Enzyme.gradient(Forward, Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) else @test( - Enzyme.gradient(set_runtime_activity(Forward), Enzyme.Const(f), x)[1] ≈ finitediff, + Enzyme.gradient(Forward, Enzyme.Const(f), x)[1] ≈ finitediff, rtol = rtol, atol = atol ) From 858aeab9315c672bdb32f7f1b583a99581a2ed10 Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:11:44 +0000 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/ad/utils.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/ad/utils.jl b/test/ad/utils.jl index 6d9e3f45..c36ce2dd 100644 --- a/test/ad/utils.jl +++ b/test/ad/utils.jl @@ -72,13 +72,15 @@ function test_ad(f, x, broken=(); rtol=1e-6, atol=1e-6) if !(:EnzymeReverseCrash in broken) if reverse_broken @test_broken( - Enzyme.gradient(set_runtime_activity(Reverse), Enzyme.Const(f), x)[1] ≈ finitediff, + Enzyme.gradient(set_runtime_activity(Reverse), Enzyme.Const(f), x)[1] ≈ + finitediff, rtol = rtol, atol = atol ) else @test( - Enzyme.gradient(set_runtime_activity(Reverse), Enzyme.Const(f), x)[1] ≈ finitediff, + Enzyme.gradient(set_runtime_activity(Reverse), Enzyme.Const(f), x)[1] ≈ + finitediff, rtol = rtol, atol = atol )