standardizing deep deployment withmax nick...
TRANSCRIPT
![Page 1: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/1.jpg)
Standardizing deep learning model deployment with MAX—Nick PentreathPrincipal Engineer
@MLnick
![Page 2: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/2.jpg)
About
IBM Developer / © 2019 IBM Corporation
– @MLnick on Twitter & Github
– Principal Engineer, IBM CODAIT (Center for Open-Source Data & AI Technologies)
– Machine Learning & AI
– Apache Spark committer & PMC
– Author of Machine Learning with Spark
– Various conferences & meetups
2
![Page 3: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/3.jpg)
CODAIT
Improving the Enterprise AI Lifecycle in Open Source
Center for Open Source Data & AI Technologies
IBM Developer / © 2019 IBM Corporation 3
CODAIT aims to make AI solutions dramatically easier to create, deploy, and manage in the enterprise.
We contribute to and advocate for the open-source technologies that are foundational to IBM’s AI offerings.
30+ open-source developers!
![Page 4: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/4.jpg)
The Machine Learning Workflow
IBM Developer / © 2019 IBM Corporation 4
![Page 5: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/5.jpg)
The workflow spans teams …
IBM Developer / © 2019 IBM Corporation 5
![Page 6: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/6.jpg)
… and tools …
IBM Developer / © 2019 IBM Corporation 6
![Page 7: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/7.jpg)
… and is a small (but critical!) piece of the puzzle
*Source: Hidden Technical Debt in Machine Learning SystemsIBM Developer / © 2019 IBM Corporation 7
![Page 8: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/8.jpg)
Machine Learning Deployment
IBM Developer / © 2019 IBM Corporation 8
![Page 9: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/9.jpg)
What, Where, How?
–What are you deploying?• What is a “model”
–Where are you deploying?• Target environment (cloud, browser, edge)• Batch, streaming, real-time?
–How are you deploying?• “devops” deployment mechanism• Serving framework
We will talk about the what & how
IBM Developer / © 2019 IBM Corporation 9
![Page 10: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/10.jpg)
What is a “model”?
IBM Developer / © 2019 IBM Corporation 10
![Page 11: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/11.jpg)
Deep Learning doesn’t need feature engineering or data processing …
IBM Developer / © 2019 IBM Corporation 11
right?
![Page 12: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/12.jpg)
Deep learning pipeline?
IBM Developer / © 2019 IBM Corporation 12
Source: https://ai.googleblog.com/2016/03/train-your-own-image-classifier-with.html
beagle: 0.82
Input image Inference Prediction
![Page 13: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/13.jpg)
Deep learning pipeline!
IBM Developer / © 2019 IBM Corporation 13
beagle: 0.82
basset: 0.09
bluetick: 0.07
...
Input image Image pre-processing Prediction
Decode image
Resize
Normalization
Convert types / format
Inference Post-processing
[0.2, 0.3, … ]
(label, prob)
Sort
Label map
PIL, OpenCV, tf.image, …
Custom Python
* Logos trademarks of their respective projects
![Page 14: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/14.jpg)
Pipelines, not Models
– Deploying just the model part of the workflow is not enough
– Entire pipeline must be deployed• Data transforms• Feature extraction & pre-processing• DL / ML model• Prediction transformation
– Even ETL is part of the pipeline!
– Pipelines in frameworks• scikit-learn• Spark ML pipelines• TensorFlow Transform• pipeliner (R)
IBM Developer / © 2019 IBM Corporation 14
![Page 15: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/15.jpg)
Many Challenges
IBM Developer / © 2019 IBM Corporation
– Formats• Each framework does things differently
• Proprietary formats: lock-in, not portable
– Lack of standardization leads to custom solutions and extensions
– Need to manage and bridge many different:• Languages - Python, R, Notebooks, Scala / Java / C • Frameworks – too many to count!• Dependencies• Versions
– Friction between teams• Data scientists & researchers – latest & greatest• Production – stability, control, minimize changes,
performance• Business – metrics, business impact, product
must always work!
* Logos trademarks of their respective projects15
![Page 16: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/16.jpg)
Containers for ML Deployment
IBM Developer / © 2019 IBM Corporation 16
![Page 17: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/17.jpg)
Containers for ML Deployment
– But …• What goes in the container is still the most
important factor• Performance can be highly variable across
language, framework, version• Requires devops knowledge, CI / deployment
pipelines, good practices• Does not solve the issue of standardization• Formats
• APIs exposed
• A serving framework is still required on top
– Container-based deployment has significant benefits• Repeatability• Ease of configuration• Separation of concerns – focus on what, not
how• Allow data scientists & researchers to use their
language / framework of choice• Container frameworks take care of (certain)
monitoring, fault tolerance, HA, etc.
IBM Developer / © 2019 IBM Corporation 17
![Page 18: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/18.jpg)
The Model Asset Exchange
IBM Developer / © 2019 IBM Corporation 18
![Page 19: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/19.jpg)
19
ModelAsset
eXchange(MAX)
ibm.biz/model-exchange
IBM Developer / © 2019 IBM Corporation
![Page 20: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/20.jpg)
What is
MAX?
20
- One place for state-of-art open source deep learning models
- Wide variety of domains
- Tested code and IP
- Free and open source
- Both trainable and trained versions
IBM Developer / © 2019 IBM Corporation
![Page 21: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/21.jpg)
21
BehindtheScenes
Find a state-of-art open source deep learning model specific to domain
Validate license terms
Perform model health check &code clean up
Wrap models in MAX framework and provide REST API
Publish the model as Docker images on Docker Hub
Review and Continuous Integration
IBM Developer / © 2019 IBM Corporation
![Page 22: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/22.jpg)
Deployable Asset on MAX
Data ExpertiseComputeModel
REST API specificationPre Trained ModelI/O processing
Deployable Asset on Model Asset Exchange
MetadataInferenceSwagger Specification
22IBM Developer / © 2019 IBM Corporation
![Page 23: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/23.jpg)
23
Accessing the Model – REST API
MODELREST API
flask
Request information from model
Send input to model
GET
POST
MAX Model Consumption – REST API
IBM Developer / © 2019 IBM Corporation
![Page 24: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/24.jpg)
MAX Model Consumption – REST API
24IBM Developer / © 2019 IBM Corporation
![Page 25: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/25.jpg)
MAX Model Consumption - Python
25
2. Python
ibm.biz/max-notebookIBM Developer / © 2019 IBM Corporation
![Page 27: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/27.jpg)
27
- User uses Web UI to send an image to Model API.
- Model API returns object data and Web UI displays detected objects.
3. Web App
IBM Developer / © 2019 IBM Corporation
![Page 28: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/28.jpg)
28
… and a few others
IBM Developer / © 2019 IBM Corporation
![Page 29: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/29.jpg)
MAX-Framework MAX-Skeleton
29
- Template repository to create a deployable MAX model.
- Contains all the code scaffolding and imports MAX Framework.
- A pip installable python library.
- Wrapper around Flask
- Abstracts out all basic functionality of the MAX model into MAXApp and MAXApi abstract classes.
github.com/IBM/MAX-Framework github.com/IBM/MAX-SkeletonIBM Developer / © 2019 IBM Corporation
![Page 30: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/30.jpg)
30
MAX Framework
IBM Developer / © 2019 IBM Corporation
![Page 31: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/31.jpg)
31
MAX Framework
IBM Developer / © 2019 IBM Corporation
![Page 32: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/32.jpg)
32
MAX Framework
IBM Developer / © 2019 IBM Corporation
![Page 33: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/33.jpg)
- Docker
- Python IDE or code editors
- Pre-trained model weights stored in a downloadable location
- List of required python packages
- Input pre-processing code
- Prediction/Inference code
- Output post-processing code
33
Requirements for Wrapping a Model
IBM Developer / © 2019 IBM Corporation
![Page 34: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/34.jpg)
34
Steps to wrap your own model
Use MAX-Skeleton
• Login to GitHub• Click on `Use
this template`• Clone the new
repository
Update Dockerfile
• Update model file location
• Calculate hash value for model files and update md5sum.txt
Requirements update
• Add required python packages along with version number
Update metadata
• Update REST API metadata
• Update model related metadata
Update scripts
• Add pre-processing, prediction and post-processing code.
Test the model
• Build the docker image
• Run the model server
IBM Developer / © 2019 IBM Corporation
![Page 35: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/35.jpg)
Thank you!
IBM Developer / © 2019 IBM Corporation
codait.org
twitter.com/Mlnick & twitter.com/ibmcodait
github.com/MLnick
developer.ibm.com
35
- MAX on IBM Developerhttps://ibm.biz/model-exchange
- DAX on IBM Developerhttps://ibm.biz/data-exchange
- Learning pathhttps://ibm.biz/max-learning-path
- Ecosystem statushttps://ibm.biz/max-status
- MAX Frameworkhttps://ibm.biz/max-framework
- MAX Node Redhttps://ibm.biz/max-node-red
![Page 36: Standardizing deep deployment withMAX Nick …cognitive-science.info/wp-content/uploads/2019/10/MAX...2019/10/10 · workflow is not enough –Entire pipeline must be deployed •Data](https://reader036.vdocuments.site/reader036/viewer/2022081614/5fc7ea66f7433d53106f9a61/html5/thumbnails/36.jpg)
IBM Developer / © 2019 IBM Corporation 36