Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow complex for NNODE #839

Merged
merged 5 commits into from
Mar 29, 2024

Conversation

sathvikbhagavan
Copy link
Member

It works with all except QuadratureTraining.

First I get this error:

ERROR: ArgumentError: Cannot create a dual over scalar type ComplexF64. If the type behaves as a scalar, define ForwardDiff.can_dual(::Type{ComplexF64}) = true.

After setting ForwardDiff.can_dual(::Type{ComplexF64}) = true, I get:

ERROR: MethodError: no method matching typemax(::Type{ComplexF64})

Closest candidates are:
  typemax(::Type{Num})
   @ Symbolics ~/.julia/packages/Symbolics/VkJPk/src/num.jl:33
  typemax(::Type{Base.TCSETATTR_FLAGS})
   @ Base Enums.jl:216
  typemax(::Type{ModelingToolkit.BipartiteGraphs.VertType})
   @ ModelingToolkit Enums.jl:216
  ...

Stacktrace:
  [1] (::Cubature.var"#17#18"{Bool, Bool, Int64, Float64, Float64, Int64, Int32, Ptr{}, Cubature.IntegrandData{}, Vector{}, Vector{}, Vector{}, Vector{}, Int64})()
    @ Cubature ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:215
  [2] disable_sigint
    @ ./c.jl:473 [inlined]
  [3] cubature(xscalar::Bool, fscalar::Bool, vectorized::Bool, padaptive::Bool, fdim::Int64, f::IntegralsCubatureExt.var"#3#10"{}, xmin_::Float64, xmax_::Float64, reqRelError::Float64, reqAbsError::Float64, maxEval::Int64, error_norm::Int32)
    @ Cubature ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:169
  [4] hquadrature_v
    @ ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:230 [inlined]
  [5] #__solvebp_call#1
    @ ~/.julia/packages/Integrals/tvunm/ext/IntegralsCubatureExt.jl:43 [inlined]
  [6] __solvebp_call
    @ ~/.julia/packages/Integrals/tvunm/ext/IntegralsCubatureExt.jl:7 [inlined]
  [7] #__solvebp_call#4
    @ ~/.julia/packages/Integrals/tvunm/src/common.jl:115 [inlined]
  [8] __solvebp_call
    @ ~/.julia/packages/Integrals/tvunm/src/common.jl:114 [inlined]
  [9] __solvebp(cache::Integrals.IntegralCache{…}, alg::Integrals.CubatureJLh, sensealg::Integrals.ReCallVJP{…}, domain::Tuple{…}, p::ComponentArrays.ComponentVector{…}; kwargs::@Kwargs{})
    @ IntegralsForwardDiffExt ~/.julia/packages/Integrals/tvunm/ext/IntegralsForwardDiffExt.jl:99
 [10] solve!(cache::Integrals.IntegralCache{…})
    @ Integrals ~/.julia/packages/Integrals/tvunm/src/common.jl:105
 [11] solve(prob::IntegralProblem{…}, alg::Integrals.CubatureJLh; kwargs::@Kwargs{})
    @ Integrals ~/.julia/packages/Integrals/tvunm/src/common.jl:101
 [12] (::NeuralPDE.var"#loss#188"{})(θ::ComponentArrays.ComponentVector{…}, ::NeuralPDE.ODEPhi{…})
    @ NeuralPDE ~/NeuralPDE.jl/src/ode_solve.jl:231
 [13] total_loss
    @ ~/NeuralPDE.jl/src/ode_solve.jl:400 [inlined]
 [14] (::OptimizationForwardDiffExt.var"#37#55"{})(::ComponentArrays.ComponentVector{…})
    @ OptimizationForwardDiffExt ~/.julia/packages/OptimizationBase/rRpJs/ext/OptimizationForwardDiffExt.jl:98
 [15] #39
    @ ~/.julia/packages/OptimizationBase/rRpJs/ext/OptimizationForwardDiffExt.jl:102 [inlined]
 [16] chunk_mode_gradient!(result::ComponentArrays.ComponentVector{…}, f::OptimizationForwardDiffExt.var"#39#57"{}, x::ComponentArrays.ComponentVector{…}, cfg::ForwardDiff.GradientConfig{…})
    @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/gradient.jl:123
 [17] gradient!
    @ ~/.julia/packages/ForwardDiff/PcZ48/src/gradient.jl:39 [inlined]
 [18] (::OptimizationForwardDiffExt.var"#38#56"{})(::ComponentArrays.ComponentVector{…}, ::ComponentArrays.ComponentVector{…})
    @ OptimizationForwardDiffExt ~/.julia/packages/OptimizationBase/rRpJs/ext/OptimizationForwardDiffExt.jl:102
 [19] macro expansion
    @ ~/.julia/packages/OptimizationOptimisers/AOkbT/src/OptimizationOptimisers.jl:68 [inlined]
 [20] macro expansion
    @ ~/.julia/packages/Optimization/5DEdF/src/utils.jl:32 [inlined]
 [21] __solve(cache::OptimizationBase.OptimizationCache{…})
    @ OptimizationOptimisers ~/.julia/packages/OptimizationOptimisers/AOkbT/src/OptimizationOptimisers.jl:66
 [22] solve!(cache::OptimizationBase.OptimizationCache{…})
    @ SciMLBase ~/.julia/packages/SciMLBase/NjslX/src/solve.jl:180
 [23] solve(::OptimizationProblem{…}, ::Optimisers.Adam; kwargs::@Kwargs{})
    @ SciMLBase ~/.julia/packages/SciMLBase/NjslX/src/solve.jl:96
 [24] __solve(::ODEProblem{…}, ::NNODE{…}; dt::Nothing, timeseries_errors::Bool, save_everystep::Bool, adaptive::Bool, abstol::Float32, reltol::Float32, verbose::Bool, saveat::Float64, maxiters::Int64, tstops::Nothing)
    @ NeuralPDE ~/NeuralPDE.jl/src/ode_solve.jl:440
 [25] solve_call(_prob::ODEProblem{…}, args::NNODE{…}; merge_callbacks::Bool, kwargshandle::Nothing, kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/8vI1R/src/solve.jl:612
 [26] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::Vector{…}, p::Vector{…}, args::NNODE{…}; kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/8vI1R/src/solve.jl:1080
 [27] solve(prob::ODEProblem{…}, args::NNODE{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/8vI1R/src/solve.jl:1003
 [28] top-level scope
    @ REPL[22]:1
Some type information was truncated. Use `show(err)` to see complete types.

I am not sure how to fix this.

@ChrisRackauckas
Copy link
Member

For now, make it throw a good high level error and get it merged. Document the caveat. I think solving that is a much bigger detail.

@ChrisRackauckas ChrisRackauckas merged commit 0856525 into SciML:master Mar 29, 2024
26 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants