Comments (3)
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.
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.
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)
- Something with tagging is broken in 1.4 HOT 1
- Inference issues with accessing hcat-ed arrays
- Tag new version HOT 5
- Internal error when overdubbing HTTP.request HOT 1
- Open discussion - support for dynamic pass creation HOT 3
- Overdubbing not working when function called from within `@threads for` loop HOT 2
- Code using Cassette fails for nightly builds HOT 2
- Discriminating overdub calls for "same" function/args HOT 1
- Is there a way to bail out of overdubbing? HOT 2
- TagBot trigger issue HOT 10
- Errors on Julia v1.6 HOT 3
- less helpful stacktraces on 1.6 HOT 3
- Error compiling Cubature.hcubature in context Traceur.Trace
- Default value to `reflect` should be `Base.current_world` HOT 1
- Cassette and AbstractInterpeter
- Cassette compilation fails as of Julia commit 6ce28008ba6db324b171909fa8e641fe8bce9db4 HOT 1
- Error in overdub with StaticArrays.jl HOT 5
- Error on ColorTypes HOT 2
- Very high TTFX HOT 1
- nightly failing to precompile with `ERROR: LoadError: invalid struct allocation` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cassette.jl.