Skip to content

Conversation

@bviyer
Copy link
Contributor

@bviyer bviyer commented Feb 5, 2024

This patch mostly included work of Max Dawkins in
this draft #15682

Co-authored-by: Max191 maximilian@nod-labs.com

Copy link
Contributor

@Max191 Max191 left a 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.
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@bviyer bviyer force-pushed the balaji/322157900 branch 2 times, most recently from 80bc76a to 6e50365 Compare February 16, 2024 21:30
@bviyer bviyer requested a review from Max191 February 16, 2024 21:31
Copy link
Contributor

@Max191 Max191 left a 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

@bviyer
Copy link
Contributor Author

bviyer commented Feb 17, 2024

I am not sure how to fix this conflict. I tried all these steps mentionedin this list and still having this issue.

Checkout via command line
If the conflicts on this branch are too complex to resolve in the web editor, you can check it out via command line to resolve the conflicts.

https://github.com/bviyer/iree.git
Step 1: From your project repository, check out a new branch and test the changes.

git checkout -b bviyer-balaji/322157900 main
git pull https://github.com/bviyer/iree.git balaji/322157900
Step 2: Merge the changes and update on GitHub.

git checkout main
git merge --no-ff bviyer-balaji/322157900
git push origin main

@Max191 or @dcaballe Can you please tell me what I could be doing wrong?

@ScottTodd
Copy link
Member

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

The CLA check is looking at the commits, not the PR description. The co-authored fields on each commit need some specific syntax.

I am not sure how to fix this conflict.

You should at least revert the changes to third_party/llvm-project. It might be easier to resolve with an interactive rebase and squashed commits instead of a merge.

// 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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

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.

Copy link
Contributor

@Max191 Max191 left a 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)
Copy link
Contributor

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>
@bviyer bviyer changed the title Added support for i4 Const-eval for Scalars Added support for i4 Const-eval for Tensors Feb 20, 2024
@bviyer bviyer merged commit 218a5e6 into iree-org:main Feb 20, 2024
Comment on lines +386 to +387
if (requestedTargetBackend == "llvm-cpu" && hasRequestedTargetBackend)
s.addElementType(b.getIntegerType(4));
Copy link
Member

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.

Copy link
Member

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

ScottTodd added a commit that referenced this pull request Apr 22, 2024
* 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
IanWood1 pushed a commit to IanWood1/iree that referenced this pull request Apr 23, 2024
…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
LLITCHEV pushed a commit to LLITCHEV/iree that referenced this pull request Jul 30, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants