-
Notifications
You must be signed in to change notification settings - Fork 8
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
autodiff: dot product patterns broken in debug #136
Comments
Illegal type analysis usually implies that either invalid metadata is being
provided to Enzyme from this repo or one is differentiating a union with
strict aliasing turned on (the default). It could also imply there is a
bithack somewhere that Enzyme fails to understand.
My guess is that the first is most likely, if you want to check that first.
…On Thu, Jul 18, 2024 at 12:29 PM Manuel Drehwald ***@***.***> wrote:
@jedbrown <https://github.com/jedbrown>
Using the new ENZYME_OPT dbg features as described here
<https://enzyme.mit.edu/index.fcgi/rust/Debugging.html#backend-crashes>,
I just got this mre:
https://fwd.gymni.ch/7x2UOu
—
Reply to this email directly, view it on GitHub
<#136 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJTUXFWMGC2IFSOVEAJIA3ZM7UNZAVCNFSM6AAAAABLDAII4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZXGAZTGMBUGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
It could also imply a bad inductive type propagation rule, but I would recommend checking the inputs first since otherwise “garbage in, garbage out” |
For case two, the union. I don't want to use the enzyme flag since I assume it would prevent Enzyme from catching some type errors. Could you introduce a TA Type for Unions, which disables relevant checks for one specific variable, that I could create during lowering from Rust? Or wouldn't that help? |
Okay a quick way we may be able to mark individual llvm values being unions, by basically forbidding type info to pass through it [just like right now how the strict aliasing disabling works by only propagating values which postdominate]. Maybe you could write a design doc / proposal and we can talk through the implications in a future Enzyme open design meeting? |
Separately @ZuseZ4 something potentially useful here for debugging this. If you turn on -enzyme-print-type we will print all of the type deductions for all values. At the end of the error log here you see the invalid type combination.
e.g. ptr to ptr and ptr to int. Maybe it would be helpful to add another debug tool here. We have the debug info so we could at minimum say "hey this is the source line the type error was deduced at" [which already can let us know if its a union more easily]. But also we can look through the log and see how that int/pointer propagation gets into the variable, so the tool could yell "hey this is path A that knows an int, thoruhg these variables" and "this is path B that knows a pointer". This is, for example, what I would do [and also recommend you] to do to debug this -- so having a tool to automate this to make it easy would be awesome and make finding/fixing things much faster and user-friendly! |
Also fwiw from these logs specifically the error appears to be in |
Thanks for the info, but that's the issue I have with TA for Enzyme. I don't emit these TT myself, I only annotate the outermost function getting differentiated and a few mem* calls. And even there I don't have the context information to ask "is this int also getting used as pointer", that would require more invasive rustc changes for which I probably get rejected (see e.g. https://rust-lang.zulipchat.com/#narrow/stream/435869-project-goals-2024h2/topic/sci-computing/near/452174200 for one rustc dev questioning if we aren't (already) too invasive. And such a change that takes context into consideration would make it much more complex). People probably also wouldn't like it if I go through every Rust std functionality (like with slice implementations here) and decide to add tt to the lowering process here and there. I generally feel like int2ptr/ptr2int are more common in rust, how much would we loose by flipping the Enzyme flag to always treat them the same? It would still be better than treating everying as a union. I assume that type confusions between i.e. float and ptr, or between int and float are much more rare. |
Yes, it's also already exposed, I have 3 |
I dont know where this comes from rust code -- but I kind of assume changing an int to a pointer is unsafe rust. There's probably a lot of reasonable thresholds for when to emit vs not, but maybe unsafe code has less TT emitted? |
Sorry I didn't mean to say we need it for this case specifically [resolved by looking at the debug log alone]. But rather it might be useful to have a tool which takes in the logs generated by ENZYME_PRINT_TA / -enzyme-print-type and then told you the dataflow which caused the error. |
Unsafe Code does mainly exist on a high IR (THIR) not the MIR which we lower into LLVM-IR (and where we add tt). I can try to find a rustc dev who knows more here. |
@jedbrown with the latest updates in enzyme core, the second version (increments sum) now works. |
Should I add that version to the test suite? |
Some common ways to implement a dot product fail to work in debug profile (but work in release).
This yields a huge output ending with
If I switch to the version that increments
sum
, I getMeta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: