Skip to content
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

[docs] microTVM model training tutorial with Colab support #10921

Merged
merged 14 commits into from
Jun 3, 2022

Conversation

guberti
Copy link
Member

@guberti guberti commented Apr 6, 2022

This PR adds a new tutorial to the microTVM how_to gallery, showing how a MobileNet V1 model can be trained with transfer learning and modified to fit on embedded devices (in this case, the Arduino Nano 33 BLE). This tutorial also addresses #10706 by showing what it would take to allow tutorials to be opened using Google Colab. See the below screenshot, or view the HTML page at the link below:

image

Alternatively, to make it easier I've also copied the output HTML file, and hosted it at the following link:

https://guberti.github.io/tvm-docs-proof-of-concept/

@guberti
Copy link
Member Author

guberti commented Apr 15, 2022

How does "Open in Colab" work?

Google Colab has a feature where using a URL, .ipynb files can be loaded from GitHub links. It just so happens that TVM's doc files are already held at https://github.com/apache/tvm-site/tree/asf-site, so we only need to point Google Colab to that. Since this tutorial is not yet merged, all the "Open in Colab" button is is a link to the following address:

https://colab.research.google.com/github/guberti/tvm-site/blob/asf-site/docs/_downloads/a7c7ea4b5017ae70db1f51dd8e6dcd82/micro_train.ipynb

What had to be changed to get this working?

In theory, nothing about Sphinx Gallery would have to be changed to make this work. However, in practice the generation of .ipynb files is extremely buggy, so the output Python notebooks do not work anyway. I made two pull requests to add features to Sphinx Gallery to make this possible:

These have all been merged, but a new version of sphinx-gallery has not yet been released yet. Until then, I had to set pip to install "git+https://github.com/sphinx-gallery/sphinx-gallery.git". Updating this version will also fix #11117.


I also needed some new data files and graphics for this tutorial. Those can be found at:

Currently, the URLs in the tutorial point to my fork of the web-data repo, but once tlc-pack/web-data#15 is merged those can be updated to just point to standard web-data.

I did a similar thing for tvm-site, where this tutorial currently points to my fork. This is just so the tutorial works before being merged - once this PR lands, the URL can be updated to the regular tvm-site repo (the asf-site branch will be auto updated by @tvm-bot).


Lastly, #11164 was needed so that microTVM template projects could be used in the CI.

@guberti guberti changed the title Model training tutorial for microTVM [WIP] Proof of concept for Google Colab compatible tutorials Apr 15, 2022
@driazati
Copy link
Member

driazati commented Apr 15, 2022

This is fantastic, I’ll try it out today! Colab will be great to have in the docs. If the sphinx-gallery PRs don’t get merged in a timely manner we can apply your patches and build it from source in the Docker images so we don’t need to wait

driazati added a commit to driazati/tvm that referenced this pull request Apr 15, 2022
To enable apache#10921 this builds sphinx-gallery using @guberti's changes
driazati added a commit to driazati/tvm that referenced this pull request Apr 15, 2022
To enable apache#10921 this builds sphinx-gallery using @guberti's changes
driazati added a commit to driazati/tvm that referenced this pull request Apr 15, 2022
To enable apache#10921 this builds sphinx-gallery using @guberti's changes
driazati added a commit to driazati/tvm that referenced this pull request Apr 15, 2022
To enable apache#10921 this builds sphinx-gallery using @guberti's changes
@guberti guberti changed the title [WIP] Proof of concept for Google Colab compatible tutorials [docs] Google Colab compatible microTVM model training tutorial Apr 28, 2022
@areusch
Copy link
Contributor

areusch commented Apr 29, 2022

retriggered now that #11164 has landed

@areusch
Copy link
Contributor

areusch commented May 2, 2022

@guberti could you try pushing an empty commit? i think retriggering somehow didn't pick up the right Jenkinsfile changes.

@guberti guberti marked this pull request as ready for review May 2, 2022 20:59
@guberti guberti changed the title [docs] Google Colab compatible microTVM model training tutorial [docs] microTVM model training tutorial with Colab support May 2, 2022
Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

thanks @guberti, few questions

cc @jwfromm @junrushao1994 @tqchen @Mousius in case you would like to have a look over this

gallery/how_to/work_with_microtvm/micro_train.py Outdated Show resolved Hide resolved
gallery/how_to/work_with_microtvm/micro_train.py Outdated Show resolved Hide resolved
gallery/how_to/work_with_microtvm/micro_train.py Outdated Show resolved Hide resolved
@@ -267,7 +267,7 @@ def docs(
"tlcpack-sphinx-addon==0.2.1",
"synr==0.5.0",
"image==1.5.33",
"sphinx-gallery==0.4.0",
"git+https://github.com/guberti/sphinx-gallery.git@ipynb-include-bash",
Copy link
Contributor

Choose a reason for hiding this comment

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

should we update docker/install scripts too if we're going to go this route? also, is this based off 0.4.0? may need to backport or verify it won't break anything to update.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this is based on the latest sphinx-gallery version. You're right that this could potentially cause problems, but I haven't ran into any. We should definitely verify nothing breaks, and if there is an issue we can discuss backporting.

@guberti
Copy link
Member Author

guberti commented May 4, 2022

thanks @guberti, few questions

Thanks for taking a look! Addressed your comments and merged main into this branch to fix the tests.

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

Ahh sorry I didn't notice we weren't pinning. Aside from that I think we can merge.

apps/microtvm/pyproject.toml Outdated Show resolved Hide resolved
@@ -84,6 +84,7 @@ IGNORED_WARNINGS=(
'autotvm:Cannot find config for target=llvm -keys=cpu -link-params=0'
'autotvm:One or more operators have not been tuned. Please tune your model for better performance. Use DEBUG logging level to see more details.'
'autotvm:Cannot find config for target=cuda -keys=cuda,gpu'
'absl:For model inputs containing unsupported operations'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you link me to an example log line?

Copy link
Member Author

@guberti guberti May 27, 2022

Choose a reason for hiding this comment

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

The full error is:

WARNING:absl:For model inputs containing unsupported operations which cannot be quantized, the `inference_input_type` attribute will default to the original type.

This warning also occurs in the official TensorFlow tutorial - https://www.tensorflow.org/lite/performance/post_training_integer_quant.

@guberti guberti force-pushed the micro-train-tutorial branch 2 times, most recently from 2599fb7 to 14ece0b Compare June 3, 2022 04:29
Changes from code review

Use official sphinx-gallery repo

Correctly specify version

Import pyserial only when necessary
Try to avoid throwing warning

Fix linting, try verbosity filter

Try adding to ignore file

Remove fix attempts
Include full git hashes
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.

3 participants