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

model.deployment to target compressed deployment directory #373

Merged
merged 5 commits into from
Oct 17, 2023

Conversation

bfineran
Copy link
Contributor

@bfineran bfineran commented Oct 12, 2023

to land with neuralmagic/deepsparse#1318

updates Model to target the compressed deployment directory tarball instead of the loose directory
includes a helper function for downloading/unzipping the tarball

simple test:

from sparsezoo import Model

model = Model("zoo:nlg/text_generation/mpt-7b/pytorch/huggingface/mpt_chat/base-none")

model.deployment_directory_path

This PR adds a AliasedSelectDirectory class that can be used to download a different file, but point to the actual expected directory.

Now, the deployment folder is always downloaded as a tar ball and extracted instead of downloading all files.

Test:

# local_test.py
from sparsezoo import Model

stub = "zoo:resnet_v1-50-imagenet-pruned95_quantized"

model = Model(stub)

print(model.deployment.path)

Case 1: When model is not already downloaded:

rahul at office-desktop in ~/projects/sparsezoo (deployment-tar●●) (.venv) 
$ rm -rf ~/.cache/sparsezoo                                                                                                   (deployment-tar|✚3…3)

rahul at office-desktop in ~/projects/sparsezoo (deployment-tar●●) (.venv) 
$ python local_test.py                                                                                                        (deployment-tar|✚3…3)
Downloading (…)eployment/model.onnx: 100%|█████████████████████████████████████████████████████████████████████| 30.3M/30.3M [00:02<00:00, 12.5MB/s]
Downloading (…)quantized/model.onnx: 100%|█████████████████████████████████████████████████████████████████████| 30.3M/30.3M [00:02<00:00, 12.3MB/s]
/home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized/deployment

rahul at office-desktop in ~/projects/sparsezoo (deployment-tar●●) (.venv) 
$ tree /home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized                                      (deployment-tar|✚3…3)
/home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized
├── deployment
│   └── model.onnx
└── model.onnx

Case 2: When the files are already downloaded

rahul at office-desktop in ~/projects/sparsezoo (deployment-tar●●) (.venv) 
$ tree /home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized                                      (deployment-tar|✚3…3)
/home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized
├── deployment
│   └── model.onnx
└── model.onnx

1 directory, 2 files

rahul at office-desktop in ~/projects/sparsezoo (deployment-tar●●) (.venv) 
$ python local_test.py                                                                                                        (deployment-tar|✚3…3)
/home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized/deployment

rahul at office-desktop in ~/projects/sparsezoo (deployment-tar●●) (.venv) 
$ tree /home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized                                      (deployment-tar|✚3…3)
/home/rahul/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized
├── deployment
│   └── model.onnx
└── model.onnx

1 directory, 2 files

mgoin
mgoin previously approved these changes Oct 12, 2023
Satrat
Satrat previously approved these changes Oct 13, 2023
@Satrat Satrat self-requested a review October 13, 2023 13:47
@Satrat
Copy link
Contributor

Satrat commented Oct 13, 2023

Looks like this is causing a failing unit test:

ERROR tests/sparsezoo/analyze/test_model_analysis_creation.py - NotADirectoryError: [Errno 20] Not a directory: 
'/home/runner/.cache/sparsezoo/neuralmagic/resnet_v1-50-imagenet-pruned95_quantized/deployment.tar.gz/model.onnx'

@rahul-tuli rahul-tuli self-assigned this Oct 13, 2023
@rahul-tuli rahul-tuli marked this pull request as draft October 13, 2023 15:33
Use this class for deployment directory
@rahul-tuli rahul-tuli dismissed stale reviews from Satrat and mgoin via 441d440 October 16, 2023 11:19
@rahul-tuli rahul-tuli marked this pull request as ready for review October 16, 2023 12:17
@bfineran bfineran merged commit e9ad485 into main Oct 17, 2023
8 checks passed
@bfineran bfineran deleted the deployment-tar branch October 17, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants