[BUG]: Getting some "juliacall.JuliaError" errors since the update to v1.0.0
What happened?
Since the update to v1.0.0, I already had a job crash twice, while I did not have such problems before. I'm adding the stacktrace from the logs of both jobs.
Version
v1.0.0
Operating System
Linux
Package Manager
pip
Interface
Script (i.e., python my_script.py)
Relevant log output
juliacall.JuliaError: TaskFailedException
Stacktrace:
[1] wait(t::Task)
@ Base ./task.jl:370
[2] fetch
@ ./task.jl:390 [inlined]
[3] _main_search_loop!(state::SymbolicRegression.SearchUtilsModule.SearchState{Float32, Float32, Expression{Float32, Node{Float32}, @NamedTuple{operators::Nothing, variable_names::Nothing}}, Distributed.Future, Distributed.RemoteChannel}, datasets::Vector{Dataset{Float32, Float32, Matrix{Float32}, Vector{Float32}, Nothing, @NamedTuple{}, Nothing, Nothing, Nothing, Nothing}}, ropt::SymbolicRegression.SearchUtilsModule.RuntimeOptions{:multiprocessing, 1, true, Nothing}, options::Options{SymbolicRegression.CoreModule.OptionsStructModule.ComplexityMapping{Int64, Int64}, DynamicExpressions.OperatorEnumModule.OperatorEnum, Node, Expression, @NamedTuple{}, MutationWeights, false, false, nothing, Nothing, 5})
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:833
[4] _equation_search(datasets::Vector{Dataset{Float32, Float32, Matrix{Float32}, Vector{Float32}, Nothing, @NamedTuple{}, Nothing, Nothing, Nothing, Nothing}}, ropt::SymbolicRegression.SearchUtilsModule.RuntimeOptions{:multiprocessing, 1, true, Nothing}, options::Options{SymbolicRegression.CoreModule.OptionsStructModule.ComplexityMapping{Int64, Int64}, DynamicExpressions.OperatorEnumModule.OperatorEnum, Node, Expression, @NamedTuple{}, MutationWeights, false, false, nothing, Nothing, 5}, saved_state::Nothing)
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:535
[5] equation_search(datasets::Vector{Dataset{Float32, Float32, Matrix{Float32}, Vector{Float32}, Nothing, @NamedTuple{}, Nothing, Nothing, Nothing, Nothing}}; options::Options{SymbolicRegression.CoreModule.OptionsStructModule.ComplexityMapping{Int64, Int64}, DynamicExpressions.OperatorEnumModule.OperatorEnum, Node, Expression, @NamedTuple{}, MutationWeights, false, false, nothing, Nothing, 5}, saved_state::Nothing, runtime_options::Nothing, runtime_options_kws::@Kwargs{niterations::Int64, parallelism::String, numprocs::Int64, procs::Nothing, addprocs_function::typeof(addprocs_slurm), heap_size_hint_in_bytes::Nothing, runtests::Bool, return_state::Bool, run_id::String, verbosity::Int64, logger::Nothing, progress::Bool, v_dim_out::Val{1}})
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:525
[6] equation_search
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:506 [inlined]
[7] #equation_search#20
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:476 [inlined]
[8] equation_search
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:422 [inlined]
[9] #equation_search#21
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:499 [inlined]
[10] pyjlany_call(self::typeof(equation_search), args_::Py, kwargs_::Py)
@ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/any.jl:40
[11] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
@ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/base.jl:73
[12] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
@ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:63
nested task error: On worker 3:
DomainError with Inf:
sin(x) is only defined for finite x.
Stacktrace:
[1] sin_domain_error
@ ./special/trig.jl:28
[2] sin
@ ./special/trig.jl:39
[3] deg1_eval_constant
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:632
[4] macro expansion
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:585 [inlined]
[5] dispatch_constant_tree
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:574
[6] deg1_eval_constant
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:630
[7] macro expansion
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:585 [inlined]
[8] dispatch_constant_tree
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:574
[9] _eval_tree_array
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:199
[10] macro expansion
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:290 [inlined]
[11] dispatch_deg2_eval
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:246
[12] _eval_tree_array
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:209
[13] #eval_tree_array#2
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:156
[14] eval_tree_array
@ ~/.julia/packages/DynamicExpressions/LMkFg/src/Evaluate.jl:131 [inlined]
[15] #eval_tree_array#1
@ ~/.julia/packages/SymbolicRegression/44X04/src/InterfaceDynamicExpressions.jl:62 [inlined]
[16] eval_tree_array
@ ~/.julia/packages/SymbolicRegression/44X04/src/InterfaceDynamicExpressions.jl:55 [inlined]
[17] mape_mse_no_const_loss
@ ./none:10
[18] evaluator
@ ~/.julia/packages/SymbolicRegression/44X04/src/LossFunctions.jl:133
[19] #eval_loss#3
@ ~/.julia/packages/SymbolicRegression/44X04/src/LossFunctions.jl:149
[20] eval_loss
@ ~/.julia/packages/SymbolicRegression/44X04/src/LossFunctions.jl:138 [inlined]
[21] #_#1
@ ~/.julia/packages/SymbolicRegression/44X04/src/ConstantOptimization.jl:115 [inlined]
[22] Evaluator
@ ~/.julia/packages/SymbolicRegression/44X04/src/ConstantOptimization.jl:113 [inlined]
[23] #finite_difference_gradient!#10
@ ~/.julia/packages/FiniteDiff/uMUWB/src/gradients.jl:373
[24] finite_difference_gradient!
@ ~/.julia/packages/FiniteDiff/uMUWB/src/gradients.jl:313 [inlined]
[25] g!
@ ~/.julia/packages/NLSolversBase/kavn7/src/objective_types/oncedifferentiable.jl:57
[26] fg!
@ ~/.julia/packages/NLSolversBase/kavn7/src/objective_types/oncedifferentiable.jl:61
[27] value_gradient!!
@ ~/.julia/packages/NLSolversBase/kavn7/src/interface.jl:82
[28] initial_state
@ ~/.julia/packages/Optim/fBdaz/src/multivariate/solvers/first_order/bfgs.jl:94
[29] optimize
@ ~/.julia/packages/Optim/fBdaz/src/multivariate/optimize/optimize.jl:36 [inlined]
[30] #optimize#91
@ ~/.julia/packages/Optim/fBdaz/src/multivariate/optimize/interface.jl:143 [inlined]
[31] optimize
@ ~/.julia/packages/Optim/fBdaz/src/multivariate/optimize/interface.jl:139 [inlined]
[32] _optimize_constants
@ ~/.julia/packages/SymbolicRegression/44X04/src/ConstantOptimization.jl:82
[33] dispatch_optimize_constants
@ ~/.julia/packages/SymbolicRegression/44X04/src/ConstantOptimization.jl:46
[34] optimize_constants
@ ~/.julia/packages/SymbolicRegression/44X04/src/ConstantOptimization.jl:27 [inlined]
[35] #mutate!#20
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:598
[36] mutate!
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:588 [inlined]
[37] macro expansion
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:361 [inlined]
[38] #_dispatch_mutations!#6
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:346
[39] _dispatch_mutations!
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:346 [inlined]
[40] #next_generation#5
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:198
[41] next_generation
@ ~/.julia/packages/SymbolicRegression/44X04/src/Mutate.jl:157 [inlined]
[42] reg_evol_cycle
@ ~/.julia/packages/SymbolicRegression/44X04/src/RegularizedEvolution.jl:36
[43] #s_r_cycle#1
@ ~/.julia/packages/SymbolicRegression/44X04/src/SingleIteration.jl:47
[44] s_r_cycle
@ ~/.julia/packages/SymbolicRegression/44X04/src/SingleIteration.jl:19 [inlined]
[45] #_dispatch_s_r_cycle#66
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:1076
[46] _dispatch_s_r_cycle
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:1059 [inlined]
[47] macro expansion
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:920 [inlined]
[48] #58
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/macros.jl:83
[49] #invokelatest#2
@ ./essentials.jl:1055 [inlined]
[50] invokelatest
@ ./essentials.jl:1052
[51] #107
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:283
[52] run_work_thunk
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:70
[53] run_work_thunk
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:79
Stacktrace:
[1] remotecall_fetch(f::Function, w::Distributed.Worker, args::Distributed.RRID; kwargs::@Kwargs{})
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:465
[2] remotecall_fetch(f::Function, w::Distributed.Worker, args::Distributed.RRID)
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:454
[3] remotecall_fetch
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:492 [inlined]
[4] call_on_owner
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:565 [inlined]
[5] fetch
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:619
[6] (::SymbolicRegression.var"#60#65"{SymbolicRegression.SearchUtilsModule.SearchState{Float32, Float32, Expression{Float32, Node{Float32}, @NamedTuple{operators::Nothing, variable_names::Nothing}}, Distributed.Future, Distributed.RemoteChannel}, Int64, Int64})()
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:936
juliacall.JuliaError: TaskFailedException
Stacktrace:
[1] wait(t::Task)
@ Base ./task.jl:370
[2] fetch
@ ./task.jl:390 [inlined]
[3] _main_search_loop!(state::SymbolicRegression.SearchUtilsModule.SearchState{Float32, Float32, Expression{Float32, Node{Float32}, @NamedTuple{operators::Nothing, variable_names::Nothing}}, Distributed.Future, Distributed.RemoteChannel}, datasets::Vector{Dataset{Float32, Float32, Matrix{Float32}, Vector{Float32}, Nothing, @NamedTuple{}, Nothing, Nothing, Nothing, Nothing}}, ropt::SymbolicRegression.SearchUtilsModule.RuntimeOptions{:multiprocessing, 1, true, Nothing}, options::Options{SymbolicRegression.CoreModule.OptionsStructModule.ComplexityMapping{Int64, Int64}, DynamicExpressions.OperatorEnumModule.OperatorEnum, Node, Expression, @NamedTuple{}, MutationWeights, false, false, nothing, Nothing, 5})
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:833
[4] _equation_search(datasets::Vector{Dataset{Float32, Float32, Matrix{Float32}, Vector{Float32}, Nothing, @NamedTuple{}, Nothing, Nothing, Nothing, Nothing}}, ropt::SymbolicRegression.SearchUtilsModule.RuntimeOptions{:multiprocessing, 1, true, Nothing}, options::Options{SymbolicRegression.CoreModule.OptionsStructModule.ComplexityMapping{Int64, Int64}, DynamicExpressions.OperatorEnumModule.OperatorEnum, Node, Expression, @NamedTuple{}, MutationWeights, false, false, nothing, Nothing, 5}, saved_state::Nothing)
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:535
[5] equation_search(datasets::Vector{Dataset{Float32, Float32, Matrix{Float32}, Vector{Float32}, Nothing, @NamedTuple{}, Nothing, Nothing, Nothing, Nothing}}; options::Options{SymbolicRegression.CoreModule.OptionsStructModule.ComplexityMapping{Int64, Int64}, DynamicExpressions.OperatorEnumModule.OperatorEnum, Node, Expression, @NamedTuple{}, MutationWeights, false, false, nothing, Nothing, 5}, saved_state::Nothing, runtime_options::Nothing, runtime_options_kws::@Kwargs{niterations::Int64, parallelism::String, numprocs::Int64, procs::Nothing, addprocs_function::typeof(addprocs_slurm), heap_size_hint_in_bytes::Nothing, runtests::Bool, return_state::Bool, run_id::String, verbosity::Int64, logger::Nothing, progress::Bool, v_dim_out::Val{1}})
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:525
[6] equation_search
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:506 [inlined]
[7] #equation_search#20
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:476 [inlined]
[8] equation_search
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:422 [inlined]
[9] #equation_search#21
@ ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:499 [inlined]
[10] pyjlany_call(self::typeof(equation_search), args_::Py, kwargs_::Py)
@ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/any.jl:40
[11] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
@ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/base.jl:73
[12] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
@ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:63
nested task error: Distributed.ProcessExitedException(29)
Stacktrace:
[1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
@ Base ./task.jl:958
[2] wait()
@ Base ./task.jl:1022
[3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
@ Base ./condition.jl:130
[4] wait
@ ./condition.jl:125 [inlined]
[5] take_buffered(c::Channel{Any})
@ Base ./channels.jl:493
[6] take!(c::Channel{Any})
@ Base ./channels.jl:487
[7] take!(::Distributed.RemoteValue)
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:726
[8] remotecall_fetch(f::Function, w::Distributed.Worker, args::Distributed.RRID; kwargs::@Kwargs{})
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:461
[9] remotecall_fetch(f::Function, w::Distributed.Worker, args::Distributed.RRID)
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:454
[10] remotecall_fetch
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:492 [inlined]
[11] call_on_owner
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:565 [inlined]
[12] fetch
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:619
[13] (::SymbolicRegression.var"#60#65"{SymbolicRegression.SearchUtilsModule.SearchState{Float32, Float32, Expression{Float32, Node{Float32}, @NamedTuple{operators::Nothing, variable_names::Nothing}}, Distributed.Future, Distributed.RemoteChannel}, Int64, Int64})()
@ SymbolicRegression ~/.julia/packages/SymbolicRegression/44X04/src/SymbolicRegression.jl:936
Worker 29 terminated.
UNHANDLED TASK ERROR: IOError: read: connection reset by peer (ECONNRESET)
Stacktrace:
[1] wait_readnb(x::Sockets.TCPSocket, nb::Int64)
@ Base ./stream.jl:410
[2] (::Base.var"#wait_locked#832")(s::Sockets.TCPSocket, buf::IOBuffer, nb::Int64)
@ Base ./stream.jl:972
[3] unsafe_read(s::Sockets.TCPSocket, p::Ptr{UInt8}, nb::UInt64)
@ Base ./stream.jl:978
[4] unsafe_read
@ ./io.jl:891 [inlined]
[5] unsafe_read(s::Sockets.TCPSocket, p::Base.RefValue{NTuple{4, Int64}}, n::Int64)
@ Base ./io.jl:890
[6] read!
@ ./io.jl:895 [inlined]
[7] deserialize_hdr_raw
@ ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/messages.jl:167 [inlined]
[8] message_handler_loop(r_stream::Sockets.TCPSocket, w_stream::Sockets.TCPSocket, incoming::Bool)
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:172
[9] process_tcp_streams(r_stream::Sockets.TCPSocket, w_stream::Sockets.TCPSocket, incoming::Bool)
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:133
[10] (::Distributed.var"#103#104"{Sockets.TCPSocket, Sockets.TCPSocket, Bool})()
@ Distributed ~/.julia/environments/pyjuliapkg/pyjuliapkg/install/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:121
Extra Info
In both cases I was running in distributed mode (cluster_manager='slurm'), with 30 CPU cores. The dataset has around 2500 records, but only two features. It's unfortunately not possible to share the full Python script I'm using, but here are the main parameters used when calling PySRRegressor:
niterations=10000000, binary_operators=["+", "-", "*", "/"], unary_operators=["exp", "sin", "square", "cube", "sqrt"], procs=30, populations=450, cluster_manager='slurm', ncycles_per_iteration=20000, batching=False, weight_optimize=0.35, parsimony=1, adaptive_parsimony_scaling=1000, maxsize=35, parallelism='multiprocessing', bumper=False
Interesting. If you have time do you think you could check whether removing the sin operator makes the error go away?
If yes (and the error goes away), then I think I know how to solve it. (I think deg0_eval_constant(tree::AbstractExpressionNode{T}) in DynamicExpressions needs to change from true to is_valid(output) - which would catch Inf stored in .val, meaning the optimizer/mutation generated an infinite value and stored it in the tree)
If no, then it's probably more challenging.
As a temp workaround you could just use this instead:
"safe_sin(x) = isfinite(x) ? sin(x) : convert(typeof(x), NaN)"
Which should fix it. Although it’s not ideal.
(and for the sympy mapping just put regular sin)
Thanks for the quick reply! Yes, sure I'll try running without the sin operator and see if the error goes away, and also try running again with the sin operator to see if the error occurs again.
And I'll also try the safe_sin(x) to see if that runs without errors.
I'll report back when I have some findings, I'll have to let it run for quite a while though to have some degree of certainty that no errors occur.
Looking at it again though, only the first stacktrace I included above mentions sin(x) is only defined for finite x., while the second stacktrace (another run, with identical script and parameters) doesn't mention anything related to sin as far as I can see, but instead mentions UNHANDLED TASK ERROR: IOError: read: connection reset by peer (ECONNRESET), isn't that a different problem?
I think that error is just because the DomainError occurred in a worker, causing the worker to exit prematurely, which causes the main node to also exit.
Right, ok let me run the various tests and report back once I have some results.
Should be fixed by https://github.com/SymbolicML/DynamicExpressions.jl/pull/110