GithubHelp home page GithubHelp logo

Comments (3)

jrevels avatar jrevels commented on July 17, 2024

I think the problem here might just be a bug in the InferenceResult cache - it seems like inference knows the answer here, it's looks like it's just not using that info properly, resulting in ::Any being inferred (maybe not grabbing it due to recursion limiting, though).

Simpler MWE:

julia> f(x) = sin(x)
f (generic function with 1 method)

julia> f2(x) = Cassette.overdub(NoOp(), f, x)
f2 (generic function with 1 method)

julia> f3(x) = Cassette.overdub(NoOp(), f2, x)
f3 (generic function with 1 method)

If you Cthulhu.@descend into this thing, you'll get to the bottom where you hit an invoke typed as:

invoke Cassette.overdub(_2::Cassette.Context{nametype(NoOp),Nothing,Cassette.NoPass,Nothing,Nothing}, Cassette.overdub::typeof(Cassette.overdub), $(QuoteNode(Cassette.Context{nametype(NoOp),Nothing,Cassette.NoPass,Nothing,Nothing}(nametype(NoOp)(), nothing, Cassette.NoPass(), nothing, nothing)))::Cassette.Context{nametype(NoOp),Nothing,Cassette.NoPass,Nothing,Nothing}, Base.AbstractFloat::Type{AbstractFloat}, %9::Int64)::Any

If you then peak into inference's cached result for that by doing one more descent, however, you see that the invoke is actually well-inferred in the cache:

invoke Cassette.overdub(::Cassette.Context{nametype(NoOp),Nothing,Cassette.NoPass,Nothing,Nothing},::typeof(Cassette.overdub),::Cassette.Context{nametype(NoOp),Nothing,Cassette.NoPass,Nothing,Nothing},::Type{AbstractFloat},::Int64)::Float64

Dropping that Float64 for no good reason is what borks inference for the rest of the function call.

@vchuravy is my model of what Cthulhu.jl doing correct - does Cthulhu look at the CodeInfo/InferenceResult that the compiler actually hits in the cache, or is it doing something weirder that would cause my above analysis to be misinformed? EDIT: okay it's calling code_typed recursively, which means this could indeed be just hitting the recursion limiting heuristic

from cassette.jl.

jrevels avatar jrevels commented on July 17, 2024

Okay I think I know how to fix this; just need to leave a note for myself: I need to propagate the primal method_for_inference_limit_heuristics through when overdubbing. Let's try it and see what happens...

from cassette.jl.

jrevels avatar jrevels commented on July 17, 2024

Note that the OP here was actually fixed by #92, which AFAICT is all that was needed for Cassette to fully avoid inference recursion issues.

Extending by one more overdub for this example ends up hitting JuliaLang/julia#28003, though (see the @test_broken here)

from cassette.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.