-
Notifications
You must be signed in to change notification settings - Fork 820
Added support for i4 Const-eval for Tensors #16321
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
Conversation
Max191
left a comment
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.
I think there is still some more needed support (or bitcasting tricks) for subbyte non-tensor types before we can flip the switch in const-eval.
| if (auto integerType = llvm::dyn_cast<IntegerType>( | ||
| getElementTypeOrSelf(info->constValue.getType()))) { | ||
| if (integerType.getWidth() % 8 != 0) { | ||
| // Allow i4 hoisting. |
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.
AFAIK, we still don't have support through the runtime for evaluating subbyte single elements (see the comments following #15682 (comment)). Has this changed since that discussion? If not, then we need to support that (or maybe do some bitcasting) before flipping this switch.
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.
Fixed!
compiler/src/iree/compiler/GlobalOptimization/test/flow_hoist_into_globals.mlir
Outdated
Show resolved
Hide resolved
80bc76a to
6e50365
Compare
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.
Thanks! This looks good to me now. I added my email to the PR so the cla will stop failing.
EDIT: Hmm, that seems to have not fixed it. I'm not sure why it is failing then
|
I am not sure how to fix this conflict. I tried all these steps mentionedin this list and still having this issue. @Max191 or @dcaballe Can you please tell me what I could be doing wrong? |
The CLA check is looking at the commits, not the PR description. The co-authored fields on each commit need some specific syntax.
You should at least revert the changes to |
d052033 to
88ed355
Compare
| // the `eval_i4_tensor` test in `jit_globals.mlir` to fail. | ||
| // TODO: Remove this if-statement and the one wrapping around | ||
| // addElementType for i4 when the support is enabled. | ||
| if (requestedTargetBackend != "vmvx" && hasRequestedTargetBackend) |
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.
Since backends require specific support, should we enable this only for llvmcpu instead? I'm not sure if other backend beyond vmvx have the proper support.
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.
Fixed.
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.
+1 to this. I think it would probably work on the GPU backends, but I'm also not sure. Let's only enable for llvmcpu and leave it as a TODO to test and enable i4 on other backends. Let's open up an issue to track this as well and you can leave a TODO comment like:
// TODO(#12345): Enable on other backends once this has been tested outside llvm-cpu.
Max191
left a comment
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.
Let's just enable for llvm-cpu for now, and then we can follow up by adding other backends.
| // the `eval_i4_tensor` test in `jit_globals.mlir` to fail. | ||
| // TODO: Remove this if-statement and the one wrapping around | ||
| // addElementType for i4 when the support is enabled. | ||
| if (requestedTargetBackend != "vmvx" && hasRequestedTargetBackend) |
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.
+1 to this. I think it would probably work on the GPU backends, but I'm also not sure. Let's only enable for llvmcpu and leave it as a TODO to test and enable i4 on other backends. Let's open up an issue to track this as well and you can leave a TODO comment like:
// TODO(#12345): Enable on other backends once this has been tested outside llvm-cpu.
This patch mostly included work of Max Dawkins in this draft iree-org#15682 Co-authored-by: Max191 <maximilian@nod-labs.com>
f99341e to
ef55557
Compare
| if (requestedTargetBackend == "llvm-cpu" && hasRequestedTargetBackend) | ||
| s.addElementType(b.getIntegerType(4)); |
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.
I'm finding on #17075 that this is broken (crashes, ASan error reports, etc. when trying to run basic unit tests). There were also no relevant test cases changed in jit_globals.mlir. Might revert this full PR.
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.
See also the discussion on Discord here
when I flip the test to use llvm-cpu, I get buffer.c:449: OUT_OF_RANGE; attempted to access an address outside of the valid buffer range (offset=0, adjusted_length=30, end=29, buffer byte_length=15); on the eval_i4_tensor test case from code around here: https://github.com/openxla/iree/blob/fdfe344a8b7f3ab0bad14b6cc543f301da0d0acd/compiler/src/iree/compiler/ConstEval/Runtime.cpp#L399-L409
and ASan logs here: https://github.com/openxla/iree/actions/runs/8727055167/job/23943706482?pr=17075#step:4:12961
* Fixed #17070 by updating the CMake options needed for ConstEval * Replaced `IREE_CHECK_OK` usage with error handling * Refactored `test/jit_globals.mlir`, adding coverage for llvm-cpu (since that is actually running by default) * I tried to keep all test cases in one file, but `--verify-diagnostics` isn't compatible with that style of lit testing AFAICT * This uncovered some bugs in #16321 / missing support for i4 types
…rg#17075) * Fixed iree-org#17070 by updating the CMake options needed for ConstEval * Replaced `IREE_CHECK_OK` usage with error handling * Refactored `test/jit_globals.mlir`, adding coverage for llvm-cpu (since that is actually running by default) * I tried to keep all test cases in one file, but `--verify-diagnostics` isn't compatible with that style of lit testing AFAICT * This uncovered some bugs in iree-org#16321 / missing support for i4 types
…rg#17075) * Fixed iree-org#17070 by updating the CMake options needed for ConstEval * Replaced `IREE_CHECK_OK` usage with error handling * Refactored `test/jit_globals.mlir`, adding coverage for llvm-cpu (since that is actually running by default) * I tried to keep all test cases in one file, but `--verify-diagnostics` isn't compatible with that style of lit testing AFAICT * This uncovered some bugs in iree-org#16321 / missing support for i4 types Signed-off-by: Lubo Litchev <lubol@google.com>
This patch mostly included work of Max Dawkins in
this draft #15682
Co-authored-by: Max191 maximilian@nod-labs.com