Skip to content

CTest support for integration tests - #5101

Merged
GMNGeoffrey merged 26 commits into
iree-org:mainfrom
GMNGeoffrey:cmake-integration-tests
Mar 17, 2021
Merged

GMNGeoffrey merged 26 commits into
iree-org:mainfrom
GMNGeoffrey:cmake-integration-tests

Conversation

@GMNGeoffrey

@GMNGeoffrey GMNGeoffrey commented Mar 13, 2021 •

Copy link
Copy Markdown
Member

Add CTest support for integration tests. This is our interim solution
for integration testing support while we find a long-term solution. It
results from tests that were previously Bazel-only (because TF) and now
are CMake-only (because maintaining support for Python in Bazel was
determined to be not worth the effort).

The approach is to open-source our internal BUILD files for Blaze
(Google's internal version of Bazel, which happens to do some rather
different things with Python). These rely on a Starlark rule for
expanding a test matrix that is pretty painful to implement in CMake.
The author apologizes.

This enables 1317 new test targets.

Incidentally, it makes the tests run in parallel, which should speed
things up quite a bit...

@google-cla google-cla Bot added the cla: yes label Mar 13, 2021
@GMNGeoffrey GMNGeoffrey changed the title cmake integration tests CMake support for integration tests Mar 13, 2021
@GMNGeoffrey GMNGeoffrey changed the title CMake support for integration tests CTest support for integration tests Mar 13, 2021
@GMNGeoffrey

Copy link
Copy Markdown
Member Author

Note that the BUILD files included here will actually be open-sourced from the google branch in approximately the same form. They're included with this PR for reference.

@GMNGeoffrey
GMNGeoffrey marked this pull request as ready for review March 13, 2021 03:08
def _normalize_dictionary(dictionary):
"""Wraps every value of dictionary in a list if it isn't one already."""
for key, value in dictionary.items():
if type(value) != type([]):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not isinstance(value, list)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are directly copied from Starlark, so have some Starlark-oddities. Since it was copy-paste, I figured it wasn't worth updating unless they would actually cause an issue.

@stellaraccident

Copy link
Copy Markdown
Collaborator

If i were doing this, I probably would have done the expansion to individual tests in the bazel_to_cmake side vs materializing the cartesian product macro and then implementing it in cmake. It'd be less layering of weird list munging and less cmake code.

@GMNGeoffrey

Copy link
Copy Markdown
Member Author

If i were doing this, I probably would have done the expansion to individual tests in the bazel_to_cmake side vs materializing the cartesian product macro and then implementing it in cmake. It'd be less layering of weird list munging and less cmake code.

Yeah I looked at that as well and it certainly would've been easier. Scott voted strongly against additional logic in Bazel->CMake so I tried to maintain that (although I was not ultimately totally successful at representing a list of dicts of lists in CMake...)

@stellaraccident

Copy link
Copy Markdown
Collaborator

If i were doing this, I probably would have done the expansion to individual tests in the bazel_to_cmake side vs materializing the cartesian product macro and then implementing it in cmake. It'd be less layering of weird list munging and less cmake code.

Yeah I looked at that as well and it certainly would've been easier. Scott voted strongly against additional logic in Bazel->CMake so I tried to maintain that (although I was not ultimately totally successful at representing a list of dicts of lists in CMake...)

I'm not going to push either way - what you have works. Maybe get Scott to look at how this turned out and see if he feels the balance is worth the extra complexity.

I'd evaluate this as: let's say we dropped bazel compatibility tomorrow. Would what we emit to the cmake files be what we want to edit and own thing forward. I would argue that the discrete tests are what we want and not a super complicated macro.

@GMNGeoffrey

GMNGeoffrey commented Mar 13, 2021 •

Copy link
Copy Markdown
Member Author

If i were doing this, I probably would have done the expansion to individual tests in the bazel_to_cmake side vs materializing the cartesian product macro and then implementing it in cmake. It'd be less layering of weird list munging and less cmake code.

Yeah I looked at that as well and it certainly would've been easier. Scott voted strongly against additional logic in Bazel->CMake so I tried to maintain that (although I was not ultimately totally successful at representing a list of dicts of lists in CMake...)

I'm not going to push either way - what you have works. Maybe get Scott to look at how this turned out and see if he feels the balance is worth the extra complexity.

I'd evaluate this as: let's say we dropped bazel compatibility tomorrow. Would what we emit to the cmake files be what we want to edit and own thing forward. I would argue that the discrete tests are what we want and not a super complicated macro.

I don't disagree with any of that :-) Let's see how Scott feels.

Edit: Although I also think "Bazel->CMake is purely mechanical" is also a good line to draw. I see it as similar to me preferring additional build system complexity to Copybara complexity. The build system is at least an established tool that has documentation and such whereas Bazel->CMake is just our special custom thing. And having to reason about what something would look like after being transformed means you have to apply the transformations in your head. That said, iterating on Bazel->CMake is about 1000 times easier than Copybara, so I wouldn't mind doing the matrix expansion there, where it would also be much easier to do.

@GMNGeoffrey

GMNGeoffrey commented Mar 13, 2021 •

Copy link
Copy Markdown
Member Author

There are a few failing tests here that don't fail for me locally:

	1300 - integrations/tensorflow/e2e/keras/layers/layers_full_api_tests__layers__tflite__layer__Conv2DTranspose (Failed)
	1304 - integrations/tensorflow/e2e/keras/layers/layers_full_api_tests__layers__tflite__layer__MaxPool1D (Failed)
	1485 - integrations/tensorflow/e2e/keras/layers/layers_dynamic_dims_tests__layers__iree_vmla__layer__BatchNormalization (Failed)
	1547 - integrations/tensorflow/e2e/keras/layers/layers_training_tests__layers__iree_vmla__layer__BatchNormalization (Failed)
	1548 - integrations/tensorflow/e2e/keras/layers/layers_training_tests__layers__iree_llvmaot__layer__BatchNormalization (Failed)
	1549 - integrations/tensorflow/e2e/keras/layers/layers_training_tests__layers__iree_vulkan__layer__BatchNormalization (Failed)
	1747 - integrations/tensorflow/e2e/math/math_tests__math__tflite__functions__xdivy (Failed)
	1748 - integrations/tensorflow/e2e/math/math_tests__math__tflite__functions__xlogy (Failed)

My best guess would be that those are because of tf-nightly version (I just updated mine today to fix some other failing tests). My inclination would be to disable them for now and then go back and update tf-nightly. We need to do a pass through all the passing/failing configuration anyway as it hasn't been updated for months and more things should work now

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If i were doing this, I probably would have done the expansion to individual tests in the bazel_to_cmake side vs materializing the cartesian product macro and then implementing it in cmake. It'd be less layering of weird list munging and less cmake code.

Yeah I looked at that as well and it certainly would've been easier. Scott voted strongly against additional logic in Bazel->CMake so I tried to maintain that (although I was not ultimately totally successful at representing a list of dicts of lists in CMake...)

I'm not going to push either way - what you have works. Maybe get Scott to look at how this turned out and see if he feels the balance is worth the extra complexity.
I'd evaluate this as: let's say we dropped bazel compatibility tomorrow. Would what we emit to the cmake files be what we want to edit and own thing forward. I would argue that the discrete tests are what we want and not a super complicated macro.

I don't disagree with any of that :-) Let's see how Scott feels.

Edit: Although I also think "Bazel->CMake is purely mechanical" is also a good line to draw. I see it as similar to me preferring additional build system complexity to Copybara complexity. The build system is at least an established tool that has documentation and such whereas Bazel->CMake is just our special custom thing. And having to reason about what something would look like after being transformed means you have to apply the transformations in your head. That said, iterating on Bazel->CMake is about 1000 times easier than Copybara, so I wouldn't mind doing the matrix expansion there, where it would also be much easier to do.

+1 to "what you have works". I'm not particularly happy with either approach here, but agree that getting the test coverage back is a higher priority than designing and building out a setup we're all satisfied with.

I also like Stella's point about discrete tests over complicated macros. The question is then: how do we author (tool-assisted generation or by hand) those discrete tests? I have some nebulous thoughts about using python to expand from python, .txt, or .csv -> cmake targets (python + python -> cmake is basically what we have here with bazel+bazel_to_cmake->cmake). I think any approach we take needs to start with what we actually want to test, in the test files. Any complexity we let leak out into the build system is going to get messy.

Comment on lines +62 to +65
"guitar"
"manual"
"nokokoro"
"notap"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any plans to run these sorts of large tests (including the non-hermetic ones) periodically on open source CI?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

especially as IREE gets faster this would probably be a good idea. since these tests (and especially the model tests) end up testing a lot of the same things, one of them not running due to a network or other non-hermetic failure tends to be okay. so we could get around the (rare) possibility of failure at expected flaky points by providing no status (or no status in cmake, and failure in bazel since bazel might re-run the test?).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No specific plans, but it seems like a good idea.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah my main complaint is flakiness that causes spammy failure notifications. Don't want to add yet another source of flakiness to the things the build cop has to monitor.

return _convert_string_list_block(list_name, targets, sort=True, quote=False)


# Copied from integrations/tensorflow/e2e/iree_e2e_cartesian_product_test_suite.bzl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this comment is useful to keep in bazel_to_cmake. The function stands on its own without that context (which isn't sufficient on its own to explain why it exists, and will be outdated if that file is moved/removed).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well except that the function has Starlark weirdness, as Stella commented on :-D. If the file is moved/removed, then someone should update references to it and it will still be in the git history.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, just trying to keep the conversion as generic as possible. Something referencing tensorflow integration tests is particularly not generic :P

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The whole function implemented below is also defined in integrations/tensorflow/e2e/iree_e2e_cartesian_product_test_suite.bzl though...

@ScottTodd ScottTodd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The following tests FAILED:
	1300 - integrations/tensorflow/e2e/keras/layers/layers_full_api_tests__layers__tflite__layer__Conv2DTranspose (Failed)
	1304 - integrations/tensorflow/e2e/keras/layers/layers_full_api_tests__layers__tflite__layer__MaxPool1D (Failed)
	1485 - integrations/tensorflow/e2e/keras/layers/layers_dynamic_dims_tests__layers__iree_vmla__layer__BatchNormalization (Failed)
	1547 - integrations/tensorflow/e2e/keras/layers/layers_training_tests__layers__iree_vmla__layer__BatchNormalization (Failed)
	1548 - integrations/tensorflow/e2e/keras/layers/layers_training_tests__layers__iree_llvmaot__layer__BatchNormalization (Failed)
	1549 - integrations/tensorflow/e2e/keras/layers/layers_training_tests__layers__iree_vulkan__layer__BatchNormalization (Failed)
	1747 - integrations/tensorflow/e2e/math/math_tests__math__tflite__functions__xdivy (Failed)
	1748 - integrations/tensorflow/e2e/math/math_tests__math__tflite__functions__xlogy (Failed)

(logs)

change which tests are enabled? (may need to sync the change, if google and main disagree on which tests pass where)

@GMNGeoffrey

GMNGeoffrey commented Mar 16, 2021 •

Copy link
Copy Markdown
Member Author
The following tests FAILED:
	[...]

change which tests are enabled? (may need to sync the change, if google and main disagree on which tests pass where)

Yeah see my comment about this above. I'm guessing this has to do with the tf-nightly version. I'm waiting for google->main with the exported build files to merge in those and finalize this.

@GMNGeoffrey
GMNGeoffrey merged commit f9cda5a into iree-org:main Mar 17, 2021
@GMNGeoffrey
GMNGeoffrey deleted the cmake-integration-tests branch March 17, 2021 05:18
@not-jenni not-jenni mentioned this pull request Mar 17, 2021
GMNGeoffrey added a commit that referenced this pull request Mar 20, 2021
In #5101 I accidentally removed
bindings/python tests from the CI because I assumed that they would be
covered not in the integrations build. It turns out that we have
tests depending on the TF integrations living under bindings/python
(gross. #5181). So when
#5104 moved MHLO tuple and control
flow legalization out of core, we didn't catch the test failure for
JAX.

This adds passes to convert from MHLO as produced by XLA->MHLO
translation to the form accepted by IREE. As we move more towards
making linalg on tensors our input and push more MHLO out of IREE core
the pipeline here will likely grow.
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