Repository navigation
Description
According to your current docs - https://google.github.io/iree/developing-iree/e2e-benchmarking - this might just be because you are still refactoring things, but I thought I would raise it as its partially working (for TF and TFLite).
Describe the bug
After following the instructions for building a python environment I have successfully built the e2e integrations for imagenet via the applications.py script, but when trying to use the mobile_bert_squad_test.py I get failures. I have tried building for iree_vmla, iree_llvmaot and iree_vulkan (both float and quantized versions) and they all give me the same error about tf.Const:
< Python traceback from raise CompilerToolError(stage.completed) omitted >
pyiree.compiler2.tools.CompilerToolError: Error invoking IREE compiler tool iree-tf-import
Diagnostics:
2021-02-10 11:00:30.910542: I external/org_tensorflow/tensorflow/cc/saved_model/reader.cc:32] Reading SavedModel from: /home/jjohnson/.keras/datasets/mobilebert_squad_savedmodels/float
2021-02-10 11:00:30.958606: I external/org_tensorflow/tensorflow/cc/saved_model/reader.cc:55] Reading meta graph with tags { serve }
2021-02-10 11:00:30.967015: I external/org_tensorflow/tensorflow/cc/saved_model/reader.cc:93] Reading SavedModel debug info (if present) from: /home/jjohnson/.keras/datasets/mobilebert_squad_savedmodels/float
2021-02-10 11:00:30.971313: I external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-02-10 11:00:31.119514: I external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:206] Restoring SavedModel bundle.
2021-02-10 11:00:31.172361: I external/org_tensorflow/tensorflow/core/platform/profile_utils/cpu_utils.cc:114] CPU Frequency: 3192235000 Hz
2021-02-10 11:00:31.839933: I external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:190] Running initialization op on SavedModel bundle at path: /home/jjohnson/.keras/datasets/mobilebert_squad_savedmodels/float
2021-02-10 11:00:31.904658: I external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:277] SavedModel load for tags { serve }; Status: success: OK. Took 994130 microseconds.
2021-02-10 11:00:32.372562: I external/org_tensorflow/tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:210] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.
loc("bert/embeddings/assert_less_equal/Assert/Assert/data_0"): error: 'tf.Const' op inferred type(s) 'tensor<!tf.string>' are incompatible with return type(s) of operation '!tf_strings.string'
error: A failure has been detected while processing the MLIR module, a reproducer has been generated in '/tmp/iree/modules/MobileBertSquad/reproducer__iree_llvmaot.mlir.import-tf'
Running iree-tf-import pass pipeline failed (see diagnostics)
Invoked with:
/home/jjohnson/ml/mlir/iree-build-python/bindings/python/pyiree/tools/tf/iree-tf-import /home/jjohnson/.keras/datasets/mobilebert_squad_savedmodels/float --tf-import-type=savedmodel_v1 --tf-savedmodel-exported-names=serving_default --tf-savedmodel-tags=serve --save-temp-tf-input=/tmp/iree/modules/MobileBertSquad/tf_input.mlir --save-temp-iree-input=/tmp/iree/modules/MobileBertSquad/iree_input.mlir --pass-pipeline-crash-reproducer=/tmp/iree/modules/MobileBertSquad/reproducer__iree_llvmaot.mlir.import-tf
This same script works fine for the tf or tflite backends.
It has created various reproducer files (as mentioned above) which I can supply if needed.
To Reproduce
Followed https://google.github.io/iree/developing-iree/e2e-benchmarking including setting up the Python environment and successfully running the bindings tests and a few of the e2e tests as well as the imagenet applications.py.
Then tried:
python3 ../iree/integrations/tensorflow/e2e/mobile_bert_squad_test.py --target_backends=iree_llvmaot
Activity
rsuderman commentedon Feb 26, 2021
So it appears you model has some embedded string constants via tf.Const. I still have not implemented their support in the strings module so you will have to remove them from the model.
stellaraccident commentedon Feb 26, 2021
The strings are coming from the assertions, which contain string payloads and are thus not presently supported (also, typically, people authoring models disable assertions for serving, etc, so it is a low priority feature for us).
What I can't see is that this is from one of our examples/unit tests and I wouldn't expect it to be behaving differently for you as an end user. @rsuderman (or someone on the team): can you please try to repro the user flow and find out why the assertions are being enabled?
jjohnson-arm commentedon Mar 2, 2021
Thanks for the info. I don't think I can fix the problem by removing the assert strings as the
integrations/tensorflow/e2e/mobile_bert_squad_test.pytest is downloading the mobilebert model as a protobuf which is contained inhttps://storage.googleapis.com/cloud-tpu-checkpoints/mobilebert/mobilebert_squad_savedmodels.tar.gz. This model presumably contains the asserts, so removing them doesn't sound easy.I have just cleared my downloads folded -
~/.kerasand downloaded the model again and it still happens. Maybe you have a previously cached version without asserts?stellaraccident commentedon Mar 2, 2021
Hi @jjohnson-arm : I'm trying to repro this issue and can do more digging, but can I confirm that you are experiencing the issue when running:
python ../iree/integrations/tensorflow/e2e/mobile_bert_squad_test.py --target_backends=iree_llvmaot(or equiv for your paths)? I'm running that and not encountering the issue.To forestall back and forth, the only salient thing on my machine is that I just installed a fresh
pip install tf-nightlyfor this repro. All of my python deps are here (pip freeze):jjohnson-arm commentedon Mar 3, 2021
Hi @stellaraccident - yes, that is the command line I am using. I have just updated my tf-nightly from previous version
2.5.0.dev20210119and now can't see much difference in my pip/versions to yours. It still fails after installing the new tf-nightly version, though I haven't done a rebuild (yet), just re-issued the test command.stellaraccident commentedon Mar 3, 2021
This is bizarre: on the one hand, I can attest that we do not support tf asserts but I can't see yet how you are getting a model that has them and I am not. Let me try to create a more dedicated reproducer you can run. For what you have built, can you verify approximately where you are synced to/built? Weeks or months behind? (Just trying to scope where to look for the needle)
benvanik commentedon Mar 3, 2021
It's still really good to figure out why as I'm sure there are other effects of this debug mode, but if you find this is something easy for people to trip into then we could add an iree-import-tf pass for stripping the assertions (if they are strippable) that would allow people to move forward. I wouldn't want it enabled by default (as the real solution will be whatever you find to not output them in the first place), but a flag that could be added to at least get something runnable would reduce the blocking nature of the problem.
stellaraccident commentedon Mar 3, 2021
Indeed - my first thought when I went to triage this was "I'll add a pass to strip asserts". That then morphed into "why am I not getting a model with asserts".
The tensorflow story for asserts is quite poor and I would consider stripping them by default and having a switch to enable them. Since there is no consistency in tf codebases on this and no flag at that level, it is just a bunch of special case python level conditions that people have added so they can have test only asserts -- usually when they find out that their training is slow.
benvanik commentedon Mar 3, 2021
Haha that makes sense - asserts should by nature not be load-bearing so stripping them should always be safe - but like you say who knows what kind of behavior is being used in tf-land :)
jjohnson-arm commentedon Mar 3, 2021
I have had 2 builds that I have tried and they both have the same problems (checking out a later version was the first thing I tried):
and
I can try building the latest version with the latest tf-nightly and get back to you.
If it is a model problem, could you have a cached version?
Update - these are the details from my .keras download:
Add StripAsserts pass and handle tf.Identity ops on tensor lists.
Add StripAsserts pass and handle tf.Identity ops on tensor lists.
Add StripAsserts pass and handle tf.Identity ops on tensor lists. (#5294
stellaraccident commentedon Apr 2, 2021
I think that #5294 fixes this. Closing but feel free to re-open.