-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add regression test for graceful error for wrong number of activities #139591
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
base: master
Are you sure you want to change the base?
Conversation
You'll need to rebase it, since there are some conflicts. |
The high-level idea is that if we have multiple functions and multiple autodiff macros per function, then we want to continue parsing all other macros and functions, even if one is incorrect. This way we can report errors in multiple autodiff macros in a single cargo invocation. To achieve that we only use emit_err instead of emit_fatal_err. Also, if we have to return a dummy function from an incorrect autodiff macro, then we just return any (parsing) body and stop caring if it follows enzyme/autodiff rules. After all we'll never reach our llvm backend if there is any autodiff error in the frontend. Where possible, we also try to find multiple bugs in a broken autodiff macro, even beyond the first error. That's also what's motivating the comment. If you look at your example, this is an incorrect application (missing one activity).
So we don't try to rewrite the function header of d_ignore at all, we just copy the one from ignore_one_arg. This would completely break at the enzyme/llvm backend, but as said we'll never reach it since we raised an error, so that's fine. We just want to finish parsing. #[rustc_autodiff]
#[inline(never)]
fn ignore_one_arg(x: i32, _y: i32) -> i32 {
x
}
#[rustc_autodiff(Forward, 1, Dual, Dual)]
#[inline(never)]
fn d_ignore(x: i32, _y: i32) -> i32 {
unsafe {
asm!("NOP", options(pure, nomem));
};
::core::hint::black_box(());
::core::hint::black_box(<i32>::default())
} |
dee4857
to
78e17e7
Compare
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
b0afdd1
to
baec6cc
Compare
@vayunbiyani This doesn't include any changes to autodiff files, only to tests. Did you forget to include the fix? |
Yes, it's intentional. One of your commits handled this(I'm not exactly sure at what point tho) leading to no ICEs for the updated case. |
@rustbot ready |
baec6cc
to
467fd58
Compare
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
oh interesting. Sure, then it's fine to just add the test to make sure we don't regress. For the future, just force-pushing the same code with a different hash should trigger a CI re-run if you have unrelated failures. We try to have a reliable CI, but every once in a while random failures happen, just due to the size of the rust CI. |
4fcb159
to
e52c76c
Compare
Hmm, I didn't change anything in the lock file. The commit just reverted to the cargo in the master since it was showing up as a change |
Can you squash your two commits, instead of adding and undoing the changes in the cargo.lock? |
Blessed tests
841eb29
to
f3172aa
Compare
#[autodiff(df5, Forward, Dual, Dual)] | ||
fn f5(x: f32, y: f32) -> f32 { | ||
//~^^ ERROR expected 3 activities, but found 2 | ||
x + y | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid such churn, if you want to insert it here in between and keep the naming scheme use something like f4_1
Fix for: #139590
Edit: one of @ZuseZ4 's commits fixed it. This PR just adds the test case to avoid regressions.