JuliaLabs / Cassette.jl

Overdub Your Julia Code
Other
371 stars 35 forks source link

Cassette doesn't recurse through into `Core._apply_iterate` #155

Closed KristofferC closed 4 years ago

KristofferC commented 4 years ago

This caused the following downstream issue: https://github.com/triscale-innov/GFlops.jl/issues/6.

JuliaInterpreter also had to deal with this (https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/350).

ffevotte commented 4 years ago

Hi, I'd like to re-open this since the aforementioned downstream issue has not disappeared: triscale-innov/GFlops.jl#6.

Here is a minimal example, which is working with Cassette v0.3.1 and Julia 1.3 but not with Julia nightly:

using Cassette
Cassette.@context Ctx;

function Cassette.prehook(ctx::Ctx,
                          op::Any,
                          a::T1, b::T2) where {T1, T2}
    println((op, T1, T2))
end

ctx = Ctx()
Cassette.overdub(ctx, ()->pi*2.0)

we would expect to see a call to *(::Float64, ::Float64) somewhere in the list of method calls seen by Cassette, but it is not seen (with Julia nightly):

(*, Irrational{:π}, Float64)
(promote, Irrational{:π}, Float64)
(Base._promote, Irrational{:π}, Float64)
(promote_type, DataType, DataType)
(promote_rule, DataType, DataType)
(promote_type, DataType, DataType)
(promote_rule, DataType, DataType)
(promote_type, DataType, Core.TypeofBottom)
(convert, DataType, Irrational{:π})
(convert, DataType, Float64)
(tuple, Float64, Float64)
(Base.indexed_iterate, Tuple{Float64,Float64}, Int64)
(getfield, Tuple{Float64,Float64}, Int64)
(+, Int64, Int64)
(Core.Intrinsics.add_int, Int64, Int64)
(tuple, Float64, Int64)
(getfield, Tuple{Float64,Int64}, Int64)
(getfield, Tuple{Float64,Int64}, Int64)
(getfield, Tuple{Float64,Float64}, Int64)
(+, Int64, Int64)
(Core.Intrinsics.add_int, Int64, Int64)
(tuple, Float64, Int64)
(getfield, Tuple{Float64,Int64}, Int64)
(tuple, Irrational{:π}, Float64)
(tuple, Float64, Float64)
(Base.not_sametype, Tuple{Irrational{:π},Float64}, Tuple{Float64,Float64})
(tuple, Float64, Float64)

I could of course change GFlops.jl tests so that this (admittedly infrequent) case is not tested, but I feel like this might perhaps indicate that there are still deeper issues affecting Cassette with Julia nightly...

Please don't hesitate to tell me if I can do anything to help!

ffevotte commented 4 years ago

Oh, I just noticed that this was fixed in #162 and #163. Sorry for the noise.

Is there a patch release planned for Cassette any time soon?