@@ -619,14 +619,28 @@ using Turing
619619 @assert get (result, :c ) == (; :c => Array{Float64}[])
620620 end
621621
622- @testset " ADType" for adbackend in ADUtils. adbackends
622+ @testset " ADType test with $adbackend " for adbackend in ADUtils. adbackends
623623 Random. seed! (222 )
624624 m = DynamicPPL. contextualize (
625625 gdemo_default, ADUtils. ADTypeCheckContext (adbackend, gdemo_default. context)
626626 )
627- # These will error if the adbackend being used is not the one set.
628- maximum_likelihood (m; adtype= adbackend)
629- maximum_a_posteriori (m; adtype= adbackend)
627+ if adbackend isa AutoMooncake
628+ # Optimization.jl does not support Mooncake as an AD backend, see
629+ # https://docs.sciml.ai/Optimization/stable/API/ad/#ad
630+ # If it ever does, then we should just run them to make sure they don't error
631+ err_msg = " The passed automatic differentiation backend choice is not available"
632+ @test_throws err_msg maximum_likelihood (m; adtype= adbackend)
633+ @test_throws err_msg maximum_a_posteriori (m; adtype= adbackend)
634+ elseif adbackend isa AutoForwardDiff
635+ # TODO : Figure out why this is happening.
636+ # https://github.com/TuringLang/Turing.jl/issues/2369
637+ @test_throws DivideError maximum_likelihood (m; adtype= adbackend)
638+ @test_throws DivideError maximum_a_posteriori (m; adtype= adbackend)
639+ else
640+ # These will error if the adbackend being used is not the one set.
641+ maximum_likelihood (m; adtype= adbackend)
642+ maximum_a_posteriori (m; adtype= adbackend)
643+ end
630644 end
631645end
632646
0 commit comments