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

Issue with dummy_run() #114

Closed
keithjlee opened this issue Apr 27, 2022 · 1 comment
Closed

Issue with dummy_run() #114

keithjlee opened this issue Apr 27, 2022 · 1 comment

Comments

@keithjlee
Copy link

I'm running into problems when running Scripts.dummy_run(experiment) on a new game that I've made. Scripts.test_game(experiment) passes fine.

I've been running the dummy run script line by line to investigate, and it seems to boil down to the simulate() function in AlphaZero.Benchmarks. This function seems to return a empty Any vector instead of a process function and a terminate function as required.

It seems like an mcts player does not play well with my game (using a Random Player in play_game runs fine). Specifically, I seem to get an error specific to my game, which requires a sparse matrix solve to return the reward of an action (i'm running construction simulation game where internal forces need to be calculated).

Again, I'm fairly confident this is not an issue of my game environment, as my game rules ensure that the matrix to invert is non-singular, and it works fine in multiple iterations of play_game with a RandomPlayer().

The stack trace is below, but I'm not sure how helpful this will be. Are there any suggestions on how to resolve this? thanks!

Stacktrace:
  [1] SuiteSparseQR_C(ordering::Int32, tol::Float64, econ::Int64, getCTX::Int64, A::SuiteSparse.CHOLMOD.Sparse{Float64}, Bsparse::Ptr{Nothing}, Bdense::Ptr{Nothing}, Zsparse::Ptr{Nothing}, Zdense::Ptr{Nothing}, R::Base.RefValue{Ptr{SuiteSparse.LibSuiteSparse.cholmod_sparse_struct}}, E::Base.RefValue{Ptr{Int64}}, H::Base.RefValue{Ptr{SuiteSparse.LibSuiteSparse.cholmod_sparse_struct}}, HPinv::Base.RefValue{Ptr{Int64}}, HTau::Base.RefValue{Ptr{SuiteSparse.LibSuiteSparse.cholmod_dense_struct}}, cc::Base.RefValue{SuiteSparse.LibSuiteSparse.cholmod_common_struct})
    @ SuiteSparse.LibSuiteSparse /usr/local/share/julia/stdlib/v1.7/SuiteSparse/lib/x86_64-linux-gnu.jl:1496
  [2] _qr!(ordering::Int32, tol::Float64, econ::Int64, getCTX::Int64, A::SuiteSparse.CHOLMOD.Sparse{Float64}, Bsparse::Ptr{Nothing}, Bdense::Ptr{Nothing}, Zsparse::Ptr{Nothing}, Zdense::Ptr{Nothing}, R::Base.RefValue{Ptr{SuiteSparse.LibSuiteSparse.cholmod_sparse_struct}}, E::Base.RefValue{Ptr{Int64}}, H::Base.RefValue{Ptr{SuiteSparse.LibSuiteSparse.cholmod_sparse_struct}}, HPinv::Base.RefValue{Ptr{Int64}}, HTau::Base.RefValue{Ptr{SuiteSparse.LibSuiteSparse.cholmod_dense_struct}})
    @ SuiteSparse.SPQR /usr/local/share/julia/stdlib/v1.7/SuiteSparse/src/spqr.jl:53
  [3] qr(A::SparseMatrixCSC{Float64, Int64}; tol::Float64, ordering::Int32)
    @ SuiteSparse.SPQR /usr/local/share/julia/stdlib/v1.7/SuiteSparse/src/spqr.jl:199
  [4] qr
    @ /usr/local/share/julia/stdlib/v1.7/SuiteSparse/src/spqr.jl:192 [inlined]
  [5] rank
    @ /usr/local/share/julia/stdlib/v1.7/SuiteSparse/src/spqr.jl:325 [inlined]
  [6] singularK(g::GameEnv)
    @ Main ./In[303]:150
  [7] update_status!(g::GameEnv)
    @ Main ./In[303]:250
  [8] play!(g::GameEnv, place::Int64)
    @ Main ./In[303]:138
  [9] run_simulation!(env::AlphaZero.MCTS.Env{Matrix{Float32}, AlphaZero.Batchifier.BatchedOracle{AlphaZero.Batchifier.var"#8#9"}}, game::GameEnv; η::Vector{Float64}, root::Bool)
    @ AlphaZero.MCTS ~/.julia/packages/AlphaZero/p8fyV/src/mcts.jl:214
 [10] run_simulation!(env::AlphaZero.MCTS.Env{Matrix{Float32}, AlphaZero.Batchifier.BatchedOracle{AlphaZero.Batchifier.var"#8#9"}}, game::GameEnv; η::Vector{Float64}, root::Bool) (repeats 11785 times)
    @ AlphaZero.MCTS ~/.julia/packages/AlphaZero/p8fyV/src/mcts.jl:218
 [11] explore!(env::AlphaZero.MCTS.Env{Matrix{Float32}, AlphaZero.Batchifier.BatchedOracle{AlphaZero.Batchifier.var"#8#9"}}, game::GameEnv, nsims::Int64)
    @ AlphaZero.MCTS ~/.julia/packages/AlphaZero/p8fyV/src/mcts.jl:243
 [12] think(p::MctsPlayer{AlphaZero.MCTS.Env{Matrix{Float32}, AlphaZero.Batchifier.BatchedOracle{AlphaZero.Batchifier.var"#8#9"}}}, game::GameEnv)
    @ AlphaZero ~/.julia/packages/AlphaZero/p8fyV/src/play.jl:198
 [13] top-level scope
    @ In[333]:1
 [14] eval
    @ ./boot.jl:373 [inlined]
 [15] include_string(mapexpr::t
@keithjlee
Copy link
Author

I've retested with dense matrices for now, but I'm running into the same higher-level error when running Scripts.dummy_run:

StackOverflowError:
MethodError: no method matching zero(::Type{Any})
Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T at /usr/local/share/julia/base/missing.jl:105
  zero(::Union{Type{P}, P}) where P<:Dates.Period at /usr/local/share/julia/stdlib/v1.7/Dates/src/periods.jl:53
  zero(::Diagonal{T, StaticArrays.SVector{N, T}}) where {N, T} at ~/.julia/packages/StaticArrays/58yy1/src/SDiagonal.jl:41
  ...

Stacktrace:
  [1] zero(#unused#::Type{Any})
    @ Base ./missing.jl:106
  [2] reduce_empty(#unused#::typeof(+), #unused#::Type{Any})
    @ Base ./reduce.jl:313
  [3] reduce_empty(#unused#::typeof(Base.add_sum), #unused#::Type{Any})
    @ Base ./reduce.jl:322
  [4] mapreduce_empty(#unused#::typeof(identity), op::Function, T::Type)
    @ Base ./reduce.jl:345
  [5] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(Base.add_sum)}, #unused#::Type{Any})
    @ Base ./reduce.jl:331
  [6] reduce_empty_iter
    @ ./reduce.jl:357 [inlined]
  [7] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Any}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:353
  [8] _mapreduce(f::typeof(identity), op::typeof(Base.add_sum), #unused#::IndexLinear, A::Vector{Any})
    @ Base ./reduce.jl:402
  [9] _mapreduce_dim
    @ ./reducedim.jl:330 [inlined]
 [10] #mapreduce#725
    @ ./reducedim.jl:322 [inlined]
 [11] mapreduce
    @ ./reducedim.jl:322 [inlined]
 [12] #_sum#735
    @ ./reducedim.jl:894 [inlined]
 [13] _sum
    @ ./reducedim.jl:894 [inlined]
 [14] #sum#733
    @ ./reducedim.jl:890 [inlined]
 [15] _mean(f::typeof(identity), A::Vector{Any}, dims::Colon)
    @ Statistics /usr/local/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:170
 [16] #mean#2
    @ /usr/local/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:164 [inlined]
 [17] mean(A::Vector{Any})
    @ Statistics /usr/local/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:164
 [18] run(env::Env{GameSpec, ResNet, Matrix{Float32}}, eval::AlphaZero.Benchmark.Single, progress::ProgressMeter.Progress)
    @ AlphaZero.Benchmark ~/.julia/packages/AlphaZero/p8fyV/src/benchmark.jl:97

The issue seems to be in the mapreduce function, which I can't execute line-by-line, as there seems to be an issue with the simulator::Simulator that is generated in Benchmark.run. My first benchmark is of type Benchmark.Single, with simulator.make_oracles() calling net() = Network.copy(...), but gives me the error:

type DataType has no field copy

Stacktrace:
 [1] getproperty(x::Type, f::Symbol)
   @ Base ./Base.jl:37
 [2] net()
   @ Main ./In[38]:1
 [3] top-level scope
   @ In[41]:1
 [4] eval
   @ ./boot.jl:373 [inlined]
 [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196

when called in the simulate() function.

Would greatly appreciate some debugging advice!

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

No branches or pull requests

2 participants