-
Notifications
You must be signed in to change notification settings - Fork 74.7k
TFLITE: Benchmarking failure on GPT2 quantized autocomplete.tflite #62506
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
Comments
@suyash-narain Could you please make sure you have included the necessary libraries for the "RegexSplitWithOffsets" op, such as the TFLite Text library and try to rebuild the runtime with appropriate flag enabled? |
Hi @sushreebarsa, RegexSplitWithOffsets op error comes into picture when I use benchmark model with flex delegate. Is using flex delegate a necessity with autocomplete.tflite model? Why is general tflite nightly benchmark model not able to execute this tflite model? does the prebuilt benchmark model from tflite not have support for tensorflow text libraries? which flag do i need to enable while building tflite runtime for tflite text library as i cannot find any references on either tensorflow github or tflite documentation. |
@suyash-narain Using the Flex delegate is not strictly necessary with the autocomplete.tflite model, but it is highly recommended for two primary reasons such as for unsupported operations and high performance. Due to some missing dependencies or incompatible versions. General TFLite nightly benchmark model not able to execute the tflite model due to missing dependencies. You don't need to explicitly enable the TensorFlow Lite Task Library in most cases. It is automatically included in the TFLite runtime and utilizes the same inference infrastructure as the standard TFLite API. Unfortunately, the prebuilt benchmark model from TFLite currently does not have native support for TensorFlow Text libraries. Thank you! |
Hi @sushreebarsa, thanks for your reply. |
Hi @LakshmiKalaKadali any updates? |
Hi @pkgoogle, Please look into the issue. Thank You |
I was able to replicate on linux x86_64:
@yijie-yang can you please take a look? Thanks. |
Yes, to benchmark the gpt2 model you need some extra dependencies. There are 2 steps needed:
Then you should be good to go! |
@suyash-narain, can you try the above and let us know if your issue is resolved? Thanks. |
let me try this and get back to you. thanks |
I was trying to build the benchmark_model_plus_flex binary using the mentioned changes and ran into an error.
I downloaded tensorflow-text from the mentioned link and put it inside my workspace. I am not sure what the '@local_config_tf' error pertains to here. the log is below:
|
Hmmm...could you try adding deps |
Hi @yijie-yang This time i get the error:
the BUILD snippet is as below:
|
Sorry my mistakes.
It's likely an error with your repository rules or directory structure. Could you reference to this discussion and make the changes to WORKSPACE and BUILD? https://stackoverflow.com/questions/53254061/failing-to-bazel-build-c-project-with-tensorflow-as-a-dependency |
Hi @yijie-yang |
Hi @yijie-yang,
I get the below error log. What other changes am I missing here in WORKSPACE file?
|
Did you build and intall both tensorflow and tensorflow_text properly?
|
I have both TF and Tensorflow_text installed via pip. The build from source also simply builds the pip file which is then installed. Is there anything else I need to add to workspace file? |
Let me reproduce your error in my local later today. |
thanks |
Hi @suyash-narain, Sorry I'm too busy with the current work and don't have enough time to repro your error. Could you refer to this doc (https://bazel.build/reference/be/workspace) for workspace setup? |
Hi @yijie-yang |
Hi @broken, Could you provide some insights to this? |
The cause of the issue is that TF Text tries to link with the tensorflow shared library, but since you are building this inside TF, this isn't needed. I think you should use the tensorflow serving (model server) library as an example. After viewing its workspace.bzl file, instead of local_repository, try:
you can then link in tf text ops with: serving also has patches, edit:
|
Hi @broken , I am not sure what I am doing wrong here.
on trying to build the benchmark_model_plus_flex binary, i get the error:
my file structure is:
Edit: |
Hi @broken |
Apologies, I actually had edited my comment, and maybe you viewed it before the edit. The patch file is necessary, but not tf serving. In your file structure, add a third_party directory, and copy the tf_text directory that I had linked above that contains the patch file. Then update your workspace to include that patch to tf text. |
Hi @broken, I tried your suggestions and am no longer getting the @org_tensorflow_text errors. But i started getting build failures related to eigen I am not sure how to proceed with. i get errors like:
my workspace file has the following changes:
the complete error log is attached. Do you have any suggestions for these eigen related errors? |
Hi @broken, i am not getting eigen issues now, I had to hide /usr/include/Eigen and that solved the error. But i am getting some weird sentencepiece errors as below
any suggestions? |
Hi @broken, @yijie-yang I cleaned and did a fresh build but this time i get the following unicode errors:
this is interesting because the file unistr.h already has <unicode/utypes.h> declared. i have no issues building a simple benchmark model without tf-text, but benchmark_model_plus_flex with tf-text is giving me issues. Are you able to build on your end? |
Hi @broken @pkgoogle @yijie-yang |
Hi, @suyash-narain Thanks for raising this issue. Are you aware of the migration to LiteRT? This transition is aimed at enhancing our project's capabilities and providing improved support and focus for our users. As we believe this issue is still relevant to LiteRT we are moving your issue there. Please follow progress here: google-ai-edge/LiteRT#94 Let us know if you have any questions. Thanks. |
System information
Have I written custom code (as opposed to using a stock example script
provided in TensorFlow): No
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): aarch64 linux
TensorFlow installed from (source or binary): binary
TensorFlow version (use command below): tf 2.15
Python version: python3.10.9
Exact command to reproduce:
linux_aarch64_benchmark_model --graph=autocomplete.tflite --num_threads=1 --num_runs=10
Describe the problem
I am using an aarch64 device like raspberry pi. I created the gpt2 autocomplete.tflite model using the official colab tutorial https://colab.research.google.com/github/tensorflow/codelabs/blob/main/KerasNLP/io2023_workshop.ipynb#scrollTo=uLsz2IcN46eb
I was able to create both the quantized and unquantized tflite model. I then tried to benchmark these models on the aarch64 device using the official nightly tflite benchmark model linux_aarch64 using tf 2.15 sourced from https://www.tensorflow.org/lite/performance/measurement#native_benchmark_binary
On running the benchmark model using the command:
linux_aarch64_benchmark_model --graph=autocomplete.tflite --num_threads=1 --num_runs=10
I get benchmarking failure errors. I am running the model on CPU itself but it seems the ops are unsupported. I get same benchmarking failure on running the unquantized version of it as well. The logs are below.
How do I benchmark this model correctly? Since its a tflite model I should be able to benchmark it using tflite benchmark model.
On trying the model with flex delegate benchmark model, it doesn't seem like benchmarking is failing but it does give a lot of error messages along with the INFO last line giving some avg values and exits soon after. the logs are below:
The text was updated successfully, but these errors were encountered: