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

Inference issue with CthulhuInterpreter vs NativeInterpreter #590

Closed
willtebbutt opened this issue Aug 30, 2024 · 1 comment
Closed

Inference issue with CthulhuInterpreter vs NativeInterpreter #590

willtebbutt opened this issue Aug 30, 2024 · 1 comment
Labels

Comments

@willtebbutt
Copy link

willtebbutt commented Aug 30, 2024

I've identified a situation in which the CthulhuInterpreter and NativeInterpreter yield different results:

using Cthulhu

# Specify function + args.
fargs = (Base._mapreduce_dim, Base.Fix1(view, [5.0, 4.0]), vcat, Float64[], [1:1, 2:2], :)
tt = typeof(fargs)

# Construct the relevant interpreters.
native_interp = Core.Compiler.NativeInterpreter();
cthulhu_interp = Cthulhu.CthulhuInterpreter();

# Correctly infers `Vector{Float64}`
julia> Base.code_typed_by_type(tt; optimize=true, interp=native_interp)
1-element Vector{Any}:
 CodeInfo(
1%1 = %new(Base.MappingRF{Base.Fix1{typeof(view), Vector{Float64}}, Base.BottomRF{typeof(vcat)}}, f, $(QuoteNode(Base.BottomRF{typeof(vcat)}(vcat))))::Base.MappingRF{Base.Fix1{typeof(view), Vector{Float64}}, Base.BottomRF{typeof(vcat)}}%2 = invoke Base._foldl_impl(%1::Base.MappingRF{Base.Fix1{typeof(view), Vector{Float64}}, Base.BottomRF{typeof(vcat)}}, nt::Vector{Float64}, A::Vector{UnitRange{Int64}})::Vector{Float64}
└──      return %2
) => Vector{Float64}

# Sadly, infers `AbstractVector`:
julia> Base.code_typed_by_type(tt; optimize=true, interp=cthulhu_interp)
1-element Vector{Any}:
 CodeInfo(
1%1 = Base.mapfoldl_impl(f, op, nt, A)::AbstractVector
└──      return %1
) => AbstractVector

Info for reproduction:

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 12 × Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 6 default, 0 interactive, 3 GC (on 12 virtual cores)
Environment:
  JULIA_NUM_THREADS = 6

julia> Pkg.status()
Status `/private/var/folders/z7/0fkyw8ms795b7znc_3vbvrsw0000gn/T/jl_9hQ5av/Project.toml`
  [f68482b8] Cthulhu v2.14.0

Note that this is also an issue for (soon-to-be-renamed) Tapir.jl . I'll be attempting to debug what's going on to cause this in Tapir.jl, and will let you know if I manage to figure out what's going on, but you might figure it out before me!

@willtebbutt willtebbutt changed the title Inference Issues with CthulhuInterpreter vs NativeInterpreter Inference issue with CthulhuInterpreter vs NativeInterpreter Aug 30, 2024
@simeonschaub
Copy link
Collaborator

Probably better tracked in JuliaLang/julia#55638?

@simeonschaub simeonschaub closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants