Issue while using ReverseDiff in turing model

Hello,

In discourse I found out that using reversediff is better for performance when you have high dimensional model. So, I’m trying to switch to reversediff from forwarddiff.

But at the moment I’m facing this issue

nested task error: type TrackedArray has no field retcode

In my code I have this checkpoint

 if SciMLBase.successful_retcode(sol.retcode)  == 1
    predicted[i] = sol'[16,6]
  else 
    Turing.@addlogprob! -Inf
    return nothing
  end

which seems to be cause of error message. Is there any way to resolve this?

It’s a ReverseDiff quirk. Do if sol isa SciMLBase.AbstractSolution && SciMLBase.successful_retcode(sol.retcode) since in the forward pass sol can be represented as a TrackedArray instead of as a solution, given its abstract array status. I think there’s a way to fix that though and I want to try something soon.

I hope, I did it correct.

if sol isa SciMLBase.AbstractSolution && SciMLBase.successful_retcode(sol.retcode)  == 1
    predicted[i] = sol'[16,6]
  else 
    Turing.@addlogprob! -Inf
    return nothing
  end

I’m getting this

nested task error: UndefVarError: AbstractSolution not defined

oops.
SciMLBase.AbstractSciMLSolution

That worked I guess. I don’t see that error anymore.

I will confirm once i have some results.