Open femtomc opened 4 years ago
@MikeInnes I ended up developing a workaround which prevents the dynamo
from wrapping calls to Base
.
unwrap(gr::GlobalRef) = gr.name
unwrap(gr) = gr
# Whitelist includes vectorized calls.
whitelist = [:rand, :learnable, :foldr, :map, :soss_fmi, :gen_fmi, :turing_fmi]
# Fix for specialized tracing.
function recur!(ir, to = self)
for (x, st) in ir
isexpr(st.expr, :call) && begin
ref = unwrap(st.expr.args[1])
ref in whitelist ||
!(unwrap(st.expr.args[1]) in names(Base)) ||
continue
ir[x] = Expr(:call, to, st.expr.args...)
end
end
return ir
end
The issue turns out to be a call in Base
somewhere, because this fixed the problem. It also greatly increased performance on programs which could have type stability issues. I had to do something similar for Cassette
at one point.
This is a bizarro bug, I'm not even sure what to call it - but I know it's something in
IRTools
because when I turn my dynamo off, the program runs correctly. So it's possible I'm doing something crazy in my dynamo, but I don't think so. This isJulia v.1.4.2
withIRTools 0.4
.This error occurs seemingly randomly during program execution - it sometimes makes it all the way through, sometimes it breaks.
This call occurs here:
Here is the core part of my dynamo,
ExecutionContext
is abstractbut I define dispatch on a concrete sub-instance
HierarchicalTrace
which does track the calls, if I run the program:
which shows the
printout
line from above. So the equality check ingetindex
randomly fails for keys, even though the key (at least, what I think is the key) is present in theKeySet
. I cannot for the life of me figure out what could cause this.This also doesn't just occur in this call, but in other calls where
getindex
is called e.g.where a
getindex
call occurs in another part of my codebase. And just to be totally transparent, that method is defined:which, at least to me, shows that it's not some weird type thing with list comprehension. The same thing occurs -
Symbol
is "apparently" in theKeySet
but thegetindex
equality check fails and throws aKeyError
.