Skip to content

Error with docs example on nested loops #595

@brendanjohnharris

Description

@brendanjohnharris

I'm new to Dagger and making my way through the docs; using the code given in this section, I encounter a KeyError.
I've tried a few variations using simpler/slower functions, non-nested loops, Dagger v0.18.14 and Dagger#master, but always encounter the same error, copied below

using Distributed
using Dagger
@everywhere begin
    using Random
    using Dagger
    Random.seed!(0)

    # Some "expensive" functions that complete at different speeds
    const crn = abs.(randn(20, 7))
    f(i) = sleep(crn[i, 7])
    g(i, j, y) = sleep(crn[i, j])
end
function nested_dagger()
    @sync for i in 1:20
        y = Dagger.@spawn f(i)
        for j in 1:6
            z = Dagger.@spawn g(i, j, y)
        end
    end
end
nested_dagger()
ERROR: Error in eager scheduler:
KeyError: key Thunk[135](f, ...) not found
Stacktrace:
 [1] pop!
   @ ./set.jl:153
 [2] finish_task!
   @ ~/.julia/packages/Dagger/S6BGT/src/sch/Sch.jl:943
 [3] (::Dagger.Sch.var"#113#114"{Context, Dagger.Sch.ComputeState, OSProc, @NamedTuple{time_pressure::UInt64, storage_pressure::UInt64, storage_capacity::UInt64, loadavg::Tuple{Float64, Float64, Float64}, threadtime::UInt64, gc_allocd::UInt64, transfer_rate::Nothing}, Dagger.Chunk{Nothing, MemPool.DRef, Dagger.ThreadProc, AnyScope}, Int64, Dagger.ThreadProc, Int64})()
   @ Dagger.Sch ~/.julia/packages/Dagger/S6BGT/src/sch/Sch.jl:613
 [4] lock(f::Dagger.Sch.var"#113#114"{Context, Dagger.Sch.ComputeState, OSProc, @NamedTuple{time_pressure::UInt64, storage_pressure::UInt64, storage_capacity::UInt64, loadavg::Tuple{Float64, Float64, Float64}, threadtime::UInt64, gc_allocd::UInt64, transfer_rate::Nothing}, Dagger.Chunk{Nothing, MemPool.DRef, Dagger.ThreadProc, AnyScope}, Int64, Dagger.ThreadProc, Int64}, l::ReentrantLock)
   @ Base ./lock.jl:232
 [5] scheduler_run(ctx::Context, state::Dagger.Sch.ComputeState, d::Thunk, options::Dagger.Sch.SchedulerOptions)
   @ Dagger.Sch ~/.julia/packages/Dagger/S6BGT/src/sch/Sch.jl:564
 [6] compute_dag(ctx::Context, d::Thunk; options::Dagger.Sch.SchedulerOptions)
   @ Dagger.Sch ~/.julia/packages/Dagger/S6BGT/src/sch/Sch.jl:483
 [7] compute_dag
   @ ~/.julia/packages/Dagger/S6BGT/src/sch/Sch.jl:448 [inlined]
 [8] compute
   @ ~/.julia/packages/Dagger/S6BGT/src/compute.jl:22 [inlined]
 [9] (::Dagger.Sch.var"#60#62"{Context})()
   @ Dagger.Sch ~/.julia/packages/Dagger/S6BGT/src/sch/eager.jl:30
TaskFailedException

    nested task error: SchedulingException (Scheduler exited)
    Stacktrace:
     [1] fetch(t::Dagger.ThunkFuture; proc::OSProc, raw::Bool)
       @ Dagger ~/.julia/packages/Dagger/S6BGT/src/dtask.jl:19
     [2] fetch
       @ ~/.julia/packages/Dagger/S6BGT/src/dtask.jl:14 [inlined]
     [3] #fetch#84
       @ ~/.julia/packages/Dagger/S6BGT/src/dtask.jl:86 [inlined]
     [4] fetch
       @ ~/.julia/packages/Dagger/S6BGT/src/dtask.jl:82 [inlined]
     [5] (::var"#12#14"{DTask})()
       @ Main ~/.julia/packages/Dagger/S6BGT/src/thunk.jl:436

...and 130 more exceptions.

Stacktrace:
 [1] sync_end(c::Channel{Any})
   @ Base ./task.jl:466
 [2] macro expansion
   @ ./task.jl:499 [inlined]
 [3] nested_dagger()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions