From 410a469396585d3c4682d2143f32b92618a7e6cd Mon Sep 17 00:00:00 2001 From: Frank Schaefer Date: Sun, 8 Jan 2023 18:06:43 -0500 Subject: [PATCH] error message and u0 bug --- src/adjoint_common.jl | 2 +- src/callback_tracking.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adjoint_common.jl b/src/adjoint_common.jl index ffdc743e5..dfd6362d4 100644 --- a/src/adjoint_common.jl +++ b/src/adjoint_common.jl @@ -402,7 +402,7 @@ function get_paramjac_config(autojacvec::EnzymeVJP, p, f, y, _p, _t; numindvar, isRODE = nothing, _W = nothing) if alg !== nothing && SciMLBase.forwarddiffs_model(alg) chunk = if autojacvec.chunksize == 0 - ForwardDiff.pickchunksize(length(u0)) + ForwardDiff.pickchunksize(numindvar) else autojacvec.chunksize end diff --git a/src/callback_tracking.jl b/src/callback_tracking.jl index 63f150766..3f5f32af7 100644 --- a/src/callback_tracking.jl +++ b/src/callback_tracking.jl @@ -205,7 +205,8 @@ function _setup_reverse_callbacks(cb::Union{ContinuousCallback, DiscreteCallback # if save_positions = [1,0] the gradient contribution is added before, and in principle we would need to correct the adjoint state again. Thefore, cb.save_positions == [1, 0] && error("save_positions=[1,0] is currently not supported.") - @assert sensealg.autojacvec isa Union{ReverseDiffVJP, EnzymeVJP} + !(sensealg.autojacvec isa Union{ReverseDiffVJP, EnzymeVJP}) && + error("Only `ReverseDiffVJP` and `EnzymeVJP` are currently compatible with continuous adjoint sensitivity methods for hybrid DEs. Please select `ReverseDiffVJP` or `EnzymeVJP` as `autojacvec`.") # event times times = if typeof(cb) <: DiscreteCallback