Skip to content

Example does not work #506

Closed
Closed

Description

@arthur-bizzi

Hi, thanks for the package. Is it still actively maintained?

Describe the issue

The example script (example/usage.jl) throws a gigantic error regarding converting between two types of ODESolution. Had to omit type information due to character limit.

Expected behavior

The script should run as is.

Error & Stacktrace

Caused by: MethodError: Cannot `convert` an object of type ODESolution{...} to an object of type 
ODESolution{...}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
(::Type{ODESolution{T, N, uType, uType2, DType, tType, rateType, discType, P, A, IType, S, AC, R, O, V}} where {T, N, uType, uType2, DType, tType, rateType, discType, P, A, IType, S, AC<:Union{Nothing, Vector{Int64}}, R, O, V})(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
 @ SciMLBase ~/.julia/packages/SciMLBase/rvXrA/src/solutions/ode_solutions.jl:111
convert(::Type{T}, ::T) where T
 @ Base Base.jl:126

Stacktrace:
[1] setproperty!(x::SciMLSensitivity.GaussIntegrand{…}, f::Symbol, v::ODESolution{…})
  @ Base ./Base.jl:52
[2] SciMLSensitivity.ODEGaussAdjointSensitivityFunction(g::Nothing, sensealg::GaussAdjoint{…}, gaussint::SciMLSensitivity.GaussIntegrand{…}, discrete::Bool, sol::ODESolution{…}, dgdu::Nothing, dgdp::Nothing, f::ODEFunction{…}, alg::OrdinaryDiffEqCore.CompositeAlgorithm{…}, checkpoints::Vector{…}, integrating_cb::DiscreteCallback{…}, tols::@NamedTuple{…}, tstops::Nothing; tspan::Tuple{…})
  @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/KLsRs/src/gauss_adjoint.jl:59
[3] ODEAdjointProblem(sol::ODESolution{…}, sensealg::GaussAdjoint{…}, alg::OrdinaryDiffEqCore.CompositeAlgorithm{…}, GaussInt::SciMLSensitivity.GaussIntegrand{…}, integrating_cb::DiscreteCallback{…}, t::Vector{…}, dgdu_discrete::SciMLSensitivity.var"#df_iip#320"{…}, dgdp_discrete::Nothing, dgdu_continuous::Nothing, dgdp_continuous::Nothing, g::Nothing, ::Val{…}; checkpoints::Vector{…}, callback::Nothing, no_start::Bool, reltol::Float64, abstol::Float64, kwargs::@Kwargs{…})
  @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/KLsRs/src/gauss_adjoint.jl:278
[4] _adjoint_sensitivities(sol::ODESolution{…}, sensealg::GaussAdjoint{…}, alg::OrdinaryDiffEqCore.CompositeAlgorithm{…}; t::Vector{…}, dgdu_discrete::Function, dgdp_discrete::Nothing, dgdu_continuous::Nothing, dgdp_continuous::Nothing, g::Nothing, abstol::Float64, reltol::Float64, checkpoints::Vector{…}, corfunc_analytical::Bool, callback::Nothing, no_start::Bool, kwargs::@Kwargs{…})
  @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/KLsRs/src/gauss_adjoint.jl:596
[5] _adjoint_sensitivities
  @ ~/.julia/packages/SciMLSensitivity/KLsRs/src/gauss_adjoint.jl:562 [inlined]
[6] adjoint_sensitivities(sol::ODESolution{…}, args::OrdinaryDiffEqCore.CompositeAlgorithm{…}; sensealg::GaussAdjoint{…}, verbose::Bool, kwargs::@Kwargs{…})
  @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/KLsRs/src/sensitivity_interface.jl:398
[7] (::SciMLSensitivity.var"#adjoint_sensitivity_backpass#319"{…})(Δ::ChainRulesCore.Tangent{…})
  @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/KLsRs/src/concrete_solve.jl:679
[8] ZBack
  @ ~/.julia/packages/Zygote/wfLOG/src/compiler/chainrules.jl:222 [inlined]
[9] (::Zygote.var"#kw_zpullback#58"{…})(dy::@NamedTuple{…})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/chainrules.jl:248
[10] #305
  @ ~/.julia/packages/Zygote/wfLOG/src/lib/lib.jl:202 [inlined]
[11] (::Zygote.var"#2189#back#307"{…})(Δ::@NamedTuple{…})
  @ Zygote ~/.julia/packages/ZygoteRules/CkVIK/src/adjoint.jl:72
[12] #solve#43
  @ ~/.julia/packages/DiffEqBase/AfBQT/src/solve.jl:1083 [inlined]
[13] (::Zygote.Pullback{…})(Δ::@NamedTuple{…})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[14] #305
  @ ~/.julia/packages/Zygote/wfLOG/src/lib/lib.jl:202 [inlined]
[15] (::Zygote.var"#2189#back#307"{…})(Δ::@NamedTuple{…})
  @ Zygote ~/.julia/packages/ZygoteRules/CkVIK/src/adjoint.jl:72
[16] solve
  @ ~/.julia/packages/DiffEqBase/AfBQT/src/solve.jl:1073 [inlined]
[17] (::Zygote.Pullback{…})(Δ::@NamedTuple{…})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[18] base_sol
  @ ~/.julia/packages/ContinuousNormalizingFlows/PSZ6d/src/core/base_icnf.jl:121 [inlined]
[19] (::Zygote.Pullback{Tuple{typeof(ContinuousNormalizingFlows.base_sol), ICNF{…}, ODEProblem{…}}, Any})(Δ::Matrix{Float32})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[20] inference_sol
  @ ~/.julia/packages/ContinuousNormalizingFlows/PSZ6d/src/core/base_icnf.jl:153 [inlined]
[21] (::Zygote.Pullback{Tuple{…}, Any})(Δ::Tuple{Vector{…}, Vector{…}})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[22] inference
  @ ~/.julia/packages/ContinuousNormalizingFlows/PSZ6d/src/core/base_icnf.jl:410 [inlined]
[23] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Tuple{Vector{…}, Vector{…}})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[24] loss
  @ ~/.julia/packages/ContinuousNormalizingFlows/PSZ6d/src/core/icnf.jl:610 [inlined]
[25] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Float32)
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[26] opt_loss
  @ ~/.julia/packages/ContinuousNormalizingFlows/PSZ6d/src/exts/mlj_ext/core.jl:11 [inlined]
[27] (::Zygote.Pullback{Tuple{…}, Tuple{…}})(Δ::Float32)
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[28] (::Zygote.var"#88#89"{Zygote.Pullback{Tuple{…}, Tuple{…}}})(Δ::Float32)
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface.jl:97
[29] withgradient(::Function, ::ComponentArrays.ComponentVector{Float32, Vector{…}, Tuple{…}}, ::Vararg{Any})
  @ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface.jl:0
[30] value_and_gradient
  @ ~/.julia/packages/DifferentiationInterface/cZ1tI/ext/DifferentiationInterfaceZygoteExt/DifferentiationInterfaceZygoteExt.jl:115 [inlined]
[31] value_and_gradient!(f::Function, grad::ComponentArrays.ComponentVector{…}, prep::DifferentiationInterface.NoGradientPrep{…}, backend::AutoZygote, x::ComponentArrays.ComponentVector{…}, contexts::DifferentiationInterface.Constant{…})
  @ DifferentiationInterfaceZygoteExt ~/.julia/packages/DifferentiationInterface/cZ1tI/ext/DifferentiationInterfaceZygoteExt/DifferentiationInterfaceZygoteExt.jl:131
[32] (::OptimizationZygoteExt.var"#fg!#16"{…})(res::ComponentArrays.ComponentVector{…}, θ::ComponentArrays.ComponentVector{…}, p::Tuple{…})
  @ OptimizationZygoteExt ~/.julia/packages/OptimizationBase/rQcC0/ext/OptimizationZygoteExt.jl:58
[33] macro expansion
  @ ~/.julia/packages/OptimizationOptimisers/xC7Ic/src/OptimizationOptimisers.jl:90 [inlined]
[34] macro expansion
  @ ~/.julia/packages/ProgressLogging/EktJo/src/ProgressLogging.jl:328 [inlined]
[35] (::OptimizationOptimisers.var"#6#7"{OptimizationCache{…}, ComponentArrays.ComponentVector{…}})()
  @ OptimizationOptimisers ~/.julia/packages/Optimization/e1Lg1/src/utils.jl:29
[36] maybe_with_logger(f::OptimizationOptimisers.var"#6#7"{…}, logger::Nothing)
  @ Optimization ~/.julia/packages/Optimization/e1Lg1/src/utils.jl:7
[37] macro expansion
  @ ~/.julia/packages/Optimization/e1Lg1/src/utils.jl:28 [inlined]
[38] __solve(cache::OptimizationCache{…})
  @ OptimizationOptimisers ~/.julia/packages/OptimizationOptimisers/xC7Ic/src/OptimizationOptimisers.jl:83
[39] solve!(cache::OptimizationCache{…})
  @ SciMLBase ~/.julia/packages/SciMLBase/rvXrA/src/solve.jl:226
[40] solve(::OptimizationProblem{…}, ::Adam{…}; kwargs::@Kwargs{…})
  @ SciMLBase ~/.julia/packages/SciMLBase/rvXrA/src/solve.jl:128
[41] fit(model::ICNFModel{ICNF{…}}, verbosity::Int64, X::DataFrame)
  @ ContinuousNormalizingFlows ~/.julia/packages/ContinuousNormalizingFlows/PSZ6d/src/exts/mlj_ext/core_icnf.jl:43
[42] fit_only!(mach::Machine{…}; rows::Nothing, verbosity::Int64, force::Bool, composite::Nothing)
  @ MLJBase ~/.julia/packages/MLJBase/yVJvJ/src/machines.jl:693
[43] fit_only!
  @ ~/.julia/packages/MLJBase/yVJvJ/src/machines.jl:617 [inlined]
[44] #fit!#66
  @ ~/.julia/packages/MLJBase/yVJvJ/src/machines.jl:790 [inlined]
[45] fit!(mach::Machine{ICNFModel{ICNF{…}}, ICNFModel{ICNF{…}}, true})
  @ MLJBase ~/.julia/packages/MLJBase/yVJvJ/src/machines.jl:787
[46] top-level scope
  @ ~/IMOS/Julia/Kolmogorov jl/normalizing_flow/example.jl:61
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  • Output of versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 14 × Apple M4 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 10 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1
  • Output of using Pkg; Pkg.status()
  [47edcb42] ADTypes v1.21.0
⌃ [b0b7db55] ComponentArrays v0.15.27
  [00b1973d] ContinuousNormalizingFlows v0.29.4
  [a93c6f00] DataFrames v1.8.1
⌃ [aae7a2af] DiffEqFlux v4.3.0
⌃ [071ae1c0] DiffEqGPU v3.7.0
⌃ [0c46a032] DifferentialEquations v7.16.1
⌃ [31c24e10] Distributions v0.25.122
⌃ [da5c29d0] EllipsisNotation v1.8.0
  [5b4e93c8] Flowfusion v0.1.5 `https://github.com/MurrellGroup/Flowfusion.jl#main`
⌃ [587475ba] Flux v0.16.4
⌃ [e879419d] ForwardBackward v0.1.4
⌃ [b2108857] Lux v1.13.3
⌃ [23992714] MAT v0.11.4
⌃ [7e8f7934] MLDataDevices v1.16.0
  [a7f614a8] MLJBase v1.12.1
⌃ [dde4c033] Metal v1.6.0
  [3bd65402] Optimisers v0.4.7
⌅ [7f7a1694] Optimization v4.3.0
⌃ [36348300] OptimizationOptimJL v0.4.3
⌃ [42dfb2eb] OptimizationOptimisers v0.3.7
⌃ [1dea7af3] OrdinaryDiffEq v6.98.0
⌃ [50262376] OrdinaryDiffEqDefault v1.7.0
⌃ [91a5bcdd] Plots v1.40.13
  [780baa95] RandomFeatureMaps v0.2.3
  [295af30f] Revise v3.13.2
⌃ [1ed8b502] SciMLSensitivity v7.84.0
⌃ [90137ffa] StaticArrays v1.9.13
⌃ [789caeaf] StochasticDiffEq v6.81.0
  [5d786b92] TerminalLoggers v0.1.7
⌃ [e88e6eb3] Zygote v0.7.7
  [9a3f8284] Random v1.11.0

Activity

  1. prbzrg commented on Feb 11, 2026

    @prbzrg
    Member

    Oh, I'll look into it. I see you have other packages in your environment, did you change any part of the example?

  2. prbzrg commented on Feb 11, 2026

    @prbzrg
    Member

    Yes, there was a problem. Changing the solver algorithm fixed it.
    For now, use the updated usage.jl.
    I will try to find the actual bug next week.

  3. prbzrg commented on Feb 18, 2026

    @prbzrg
    Member

    the actual error is:

      MethodError: Cannot `convert` an object of type 
        SciMLOperators.WOperator{false,Float32,LinearAlgebra.UniformScaling{Bool},Float32,Array{Float32,2},Array{Float32,2},Array{Float32,2},OrdinaryDiffEqDifferentiation.JVPCache{Float32}} to an object of type 
        SciMLOperators.WOperator{false,Float32,LinearAlgebra.UniformScaling{Bool},Float32,Array{Float32,2},Array{Float32,1},Array{Float32,2},OrdinaryDiffEqDifferentiation.JVPCache{Float32}}
      
      Closest candidates are:
        convert(::Type{T}, ::T) where T
         @ Base Base.jl:84

    it's a upstream problem caused by the polyalgorithm. I will report it when I isolate the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions