Skip to content

Commit 9d6739a

Browse files
authored
CM v2.0.4 release with the universal Python loadgen harness improvements (#1191)
2 parents 29cdfd1 + 9c66150 commit 9d6739a

File tree

12 files changed

+430
-355
lines changed

12 files changed

+430
-355
lines changed

cm-mlops/script/app-loadgen-generic-python/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ ___
119119
<details>
120120
<summary>Click here to expand this section.</summary>
121121

122+
* `_cmc`
123+
- Environment variables:
124+
- *CM_CUSTOM_MODEL_CMC*: `True`
125+
- Workflow:
126+
* `_custom,cmc`
127+
- Workflow:
128+
1. ***Read "deps" on other CM scripts***
129+
* get,ml-model,cmc
130+
- *Warning: no scripts found*
122131
* `_custom,huggingface`
123132
- Workflow:
124133
1. ***Read "deps" on other CM scripts***

cm-mlops/script/app-loadgen-generic-python/_cm.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ variations:
252252
CM_ML_MODEL_STUB: "#"
253253

254254

255+
cmc:
256+
env:
257+
CM_CUSTOM_MODEL_CMC: yes
258+
259+
260+
custom,cmc:
261+
deps:
262+
- tags: get,ml-model,cmc
263+
names:
264+
- cmc-model
265+
255266

256267
input_description:
257268
modelpath:

cm-mlops/script/app-loadgen-generic-python/src/backend_pytorch.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def create(self) -> Model:
5959
print ('')
6060
print ('Loading model: {}'.format(self.model_path))
6161

62-
6362
if self.execution_provider == 'CPUExecutionProvider':
6463
torch_provider = 'cpu'
6564
elif self.execution_provider == 'CUDAExecutionProvider':
@@ -87,17 +86,25 @@ def create(self) -> Model:
8786
if not os.path.isfile(cm_model_module):
8887
raise Exception('cm.py interface for a PyTorch model was not found in {}'.format(self.model_code))
8988

89+
print ('')
90+
print ('Collective Mind Connector for the model found: {}'.format(cm_model_module))
91+
92+
9093
# Load CM interface for the model
9194
import sys
9295
sys.path.insert(0, self.model_code)
93-
model_module=importlib.import_module('cm')
96+
model_module=importlib.import_module('cmc')
9497
del(sys.path[0])
9598

9699
# Init model
97100
if len(self.model_cfg)>0:
98101
print ('Model cfg: {}'.format(self.model_cfg))
99102

100-
model = model_module.model_init(checkpoint, self.model_cfg)
103+
r = model_module.model_init(checkpoint, self.model_cfg)
104+
if r['return']>0:
105+
raise Exception('Error: {}'.format(r['error']))
106+
107+
model = r['model']
101108

102109
if torch_provider=='cuda':
103110
model.cuda()

cm-mlops/script/get-generic-python-lib/README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ Maintainers: [Public MLCommons Task Force on Automation and Reproducibility](htt
4040

4141
`cm run script --tags=get,generic-python-lib`
4242

43-
`cm run script --tags=get,generic-python-lib[,variations] `
43+
`cm run script --tags=get,generic-python-lib[,variations] [--input_flags]`
4444

4545
*or*
4646

4747
`cmr "get generic-python-lib"`
4848

49-
`cmr "get generic-python-lib [variations]" `
49+
`cmr "get generic-python-lib [variations]" [--input_flags]`
5050

5151

5252
* *See the list of `variations` [here](#variations) and check the [Gettings Started Guide](https://github.com/mlcommons/ck/blob/dev/docs/getting-started.md) for more details.*
@@ -85,7 +85,7 @@ Use this [online GUI](https://cKnowledge.org/cm-gui/?tags=get,generic-python-lib
8585

8686
#### Run this script via Docker (beta)
8787

88-
`cm docker script "get generic-python-lib[variations]" `
88+
`cm docker script "get generic-python-lib[variations]" [--input_flags]`
8989

9090
___
9191
### Customization
@@ -487,8 +487,8 @@ ___
487487
- Workflow:
488488
* `_torch,rocm`
489489
- Environment variables:
490-
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/rocm5.6`
491490
- *CM_GENERIC_PYTHON_PACKAGE_NAME*: `torch`
491+
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/rocm5.6`
492492
- *CM_GENERIC_PYTHON_PIP_UNINSTALL_DEPS*: `torch`
493493
- Workflow:
494494
1. ***Read "post_deps" on other CM scripts***
@@ -509,8 +509,8 @@ ___
509509
* `_torch_cuda,pre`
510510
- Environment variables:
511511
- *CM_GENERIC_PYTHON_PACKAGE_NAME*: `torch`
512-
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/<<<CM_CUDA_VERSION_STRING>>>`
513512
- *CM_GENERIC_PYTHON_PIP_EXTRA*: ` --pre`
513+
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/<<<CM_CUDA_VERSION_STRING>>>`
514514
- *CM_TORCH_VERSION_EXTRA*: `CUDA`
515515
- Workflow:
516516
1. ***Read "deps" on other CM scripts***
@@ -532,8 +532,8 @@ ___
532532
- Workflow:
533533
* `_torchaudio,rocm`
534534
- Environment variables:
535-
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/rocm5.6`
536535
- *CM_GENERIC_PYTHON_PACKAGE_NAME*: `torchaudio`
536+
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/rocm5.6`
537537
- *CM_GENERIC_PYTHON_PIP_UNINSTALL_DEPS*: `torchaudio`
538538
- Workflow:
539539
* `_torchaudio_cuda`
@@ -553,8 +553,8 @@ ___
553553
- Workflow:
554554
* `_torchvision,rocm`
555555
- Environment variables:
556-
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/rocm5.6`
557556
- *CM_GENERIC_PYTHON_PACKAGE_NAME*: `torchvision`
557+
- *CM_GENERIC_PYTHON_PIP_INDEX_URL*: `https://download.pytorch.org/whl/rocm5.6`
558558
- *CM_GENERIC_PYTHON_PIP_UNINSTALL_DEPS*: `torchvision`
559559
- Workflow:
560560
* `_torchvision_cuda`
@@ -614,6 +614,23 @@ ___
614614

615615
</details>
616616

617+
618+
#### Script flags mapped to environment
619+
<details>
620+
<summary>Click here to expand this section.</summary>
621+
622+
* `--extra_index_url=value` &rarr; `CM_GENERIC_PYTHON_PIP_EXTRA_INDEX_URL=value`
623+
* `--force_install=value` &rarr; `CM_TMP_PYTHON_PACKAGE_FORCE_INSTALL=value`
624+
* `--index_url=value` &rarr; `CM_GENERIC_PYTHON_PIP_INDEX_URL=value`
625+
626+
**Above CLI flags can be used in the Python CM API as follows:**
627+
628+
```python
629+
r=cm.access({... , "extra_index_url":...}
630+
```
631+
632+
</details>
633+
617634
#### Default environment
618635

619636
<details>
@@ -655,7 +672,7 @@ ___
655672

656673
___
657674
### Script output
658-
`cmr "get generic-python-lib [,variations]" -j`
675+
`cmr "get generic-python-lib [,variations]" [--input_flags] -j`
659676
#### New environment keys (filter)
660677

661678
* `CM_PYTHONLIB_*`

0 commit comments

Comments
 (0)