Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gfursin committed Apr 10, 2024
1 parent 0a24740 commit f92b9f4
Show file tree
Hide file tree
Showing 17 changed files with 1,335 additions and 0 deletions.
160 changes: 160 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
1 change: 1 addition & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright (c) 2024 MLCommons
117 changes: 117 additions & 0 deletions README-test-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# CM automation for ABTF-MLPerf

*Testing ABTF SSD PyTorch model via the [MLCommons CM automation meta-framework](https://github.com/mlcommons/ck).*

## Install CM

Follow [this online guide](https://access.cknowledge.org/playground/?action=install) to install CM for your OS.

## Install virtual environment

We suggest to create a virtual environment to avoid messing up your Python installation:

### Linux

```bash
python3 -m venv ABTF
. ABTF/bin/activate ; export CM_REPOS=$PWD/ABTF/CM
```
### Windows

```bash
python -m venv ABTF
call ABTF\Scripts\activate.bat & set CM_REPOS=%CD%\ABTF\CM
```

## Install all CM automation recipes

Pull [main MLOps automation recipes](https://access.cknowledge.org/playground/?action=scripts) from MLCommons:

```bash
cm pull repo mlcommons@ck --checkout=dev
```

Pull this CM repository with automation recipes for the MLCommons-ABTF benchmark:

```bash
cm pull repo cknowledge@cm4abtf
```

## Clean CM cache

Clean CM cache if you want to start from scratch

```bash
cm rm cache -f
```









Download private test image `0000008766.png` and model `baseline_8mp.pth` to your local directory.


Import `baseline_8mp.pth` to CM:
```bash
cmr "get ml-model abtf-ssd-pytorch _local.baseline_8mp.pth"
```

Get Git repo with ABTF SSD-ResNet50 PyTorch model:

```bash
cmr "get git repo _repo.https://github.com/mlcommons/abtf-ssd-pytorch" --env.CM_GIT_BRANCH=cognata-cm --extra_cache_tags=abtf,ssd,pytorch,cm-model --env.CM_GIT_CHECKOUT_PATH_ENV_NAME=CM_ABTF_SSD_PYTORCH
```

Make test prediction:

```bash
cmr "test abtf ssd-resnet50 cognata pytorch" --input=0000008766.png --output=0000008766_prediction_test.jpg --config=baseline_8MP
```

Export PyTorch model to ONNX:
```bash
cmr "test abtf ssd-resnet50 cognata pytorch" --input=0000008766.png --output=0000008766_prediction_test.jpg --config=baseline_8MP --export_model=baseline_8mp.onnx
```

Test exported ONNX model with LoadGen (performance):
```bash
cm run script "python app loadgen-generic _onnxruntime" --modelpath=baseline_8mp.onnx --samples=1 --quiet
```


Test different versions of PyTorch
```bash
cmr "install python-venv" --name=abtf2
cmr "test abtf ssd-resnet50 cognata pytorch" --adr.python.name=abtf2 --adr.torch.version=1.13.1 --adr.torchvision.version=0.14.1 --input=0000008766.png --output=0000008766_prediction_test.jpg --config=baseline_8MP
```

## TBD

### Main features

* Test PyTorch model with Python LoadGen
* Test PyTorch model with [C++ loadgen](https://github.com/mlcommons/ck/tree/master/cm-mlops/script/app-mlperf-inference-mlcommons-cpp)
* Automate loading of Cognata dataset via CM
* Add Cognata dataset to loadgen
* Process PyTorch model with MLPerf inference infrastructure for SSD-ResNet50
* Add support for MLCommons Croissant

### Testing docker

```bash
cm docker script --tags=test,abtf,ssd-pytorch,_cognata --docker_cm_repo=ctuning@mlcommons-ck --env.CM_GH_TOKEN={TOKEN} --input=road.jpg --output=road_ssd.jpg
```

```bash
cm docker script --tags=test,abtf,ssd-pytorch,_cognata --docker_cm_repo=ctuning@mlcommons-ck --docker_os=ubuntu --docker_os_version=23.04 --input=road.jpg --output=road_ssd.jpg
```
TBD: pass file to CM docker: [meta](https://github.com/mlcommons/ck/blob/master/cm-mlops/script/build-mlperf-inference-server-nvidia/_cm.yaml#L197).

## CM automation developers

* [Grigori Fursin](https://cKnowledge.org/gfursin) (MLCommons Task Force on Automation and Reproducibility)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Collective Mind interface and automation for ABTF
Loading

0 comments on commit f92b9f4

Please sign in to comment.