Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Conversation

@dbogunowicz
Copy link
Contributor

@dbogunowicz dbogunowicz commented Oct 26, 2023

Because we now (see PR #379) have Model attributes for both directory and directory.tar.gz, it is a bad idea to download those models by default when we call Model(...).path or Model(...).download(). With LLMs, downloading two identical deployment directories (one tar'ed another in the form of loose files) can take a lot of time. Let's disable downloading the deployment directory while keeping the appropriate references intact.

Manual testing:

from sparsezoo import Model
import shutil
import os

path_where_models_are = "/home/ubuntu/.cache/sparsezoo/neuralmagic/mobilebert-squad_wikipedia_bookcorpus-14layer_pruned50.4block_quantized"
if os.path.exists(path_where_models_are):
    shutil.rmtree(path_where_models_are)
    print(f"The path {path_where_models_are} has been cleaned up")
else:
    print(f"The path {path_where_models_are} does not exist")

print("1: Creating the model from stub")
model = Model("zoo:mobilebert-squad_wikipedia_bookcorpus-14layer_pruned50.4block_quantized")
model_path = model.path
print("Deployment directory path: ", model.deployment._path)
print("Deployment directory tar path: ", model.deployment_tar.path)
model.deployment_directory_path
print("Deployment directory path: ", model.deployment._path)
print("Contents of the deployment directory: ", os.listdir(model.deployment._path))
print("Contents of the model directory: ", os.listdir(model.path))

print("2: Creating the model from local path")
model = Model("zoo:mobilebert-squad_wikipedia_bookcorpus-14layer_pruned50.4block_quantized")
model_path = model.path
print("Deployment directory path: ", model.deployment._path)
print("Deployment directory tar path: ", model.deployment_tar.path)
model.deployment_directory_path
print("Deployment directory path: ", model.deployment._path)
print("Contents of the deployment directory: ", os.listdir(model.deployment._path))
print("Contents of the model directory: ", os.listdir(model.path))

out:

```bash
path_where_models_are = "/home/ubuntu/.cache/sparsezoo/neuralmagic/mobilebert-squad_wikipedia_bookcorpus-14layer_pruned50.4block_quantized"
if os.path.exists(path_where_models_are):
    shutil.rmtree(path_where_models_are)
    print(f"The path {path_where_models_are} has been cleaned up")
else:
    print(f"The path {path_where_models_are} does not exist")


print("1: Creating the model from stub")
model = Model("zoo:mobilebert-squad_wikipedia_bookcorpus-14layer_pruned50.4block_quantized")
model_path = model.path
print("Deployment directory path: ", model.deployment._path) # should be None initially
print("Deployment directory tar path: ", model.deployment_tar.path) # should be `deployment.tar.gz`
model.deployment_directory_path # unpack the tar
print("Deployment directory path: ", model.deployment._path) # should be `deployment`
print("Contents of the deployment directory: ", os.listdir(model.deployment._path))
print("Contents of the model directory: ", os.listdir(model.path))

print("2: Creating the model from local path")
model = Model("zoo:mobilebert-squad_wikipedia_bookcorpus-14layer_pruned50.4block_quantized")
model_path = model.path
print("Deployment directory path: ", model.deployment._path) # should be None initially
print("Deployment directory tar path: ", model.deployment_tar.path) # should be `deployment.tar.gz`
model.deployment_directory_path
print("Deployment directory path: ", model.deployment._path) # should be `deployment`
print("Contents of the deployment directory: ", os.listdir(model.deployment._path))
print("Contents of the model directory: ", os.listdir(model.path))

@dbogunowicz dbogunowicz changed the title [WiP] Disable downloading deployment directory Disable the download of the deployment directory Oct 26, 2023
@dbogunowicz dbogunowicz changed the title Disable the download of the deployment directory Disable downloading deployment directory Oct 26, 2023
Copy link
Member

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

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

I have a question; are we sure all stubs WILL always have a deployment.tar.gz?

@bfineran bfineran merged commit 7b614c8 into feature/damian/simplify Nov 6, 2023
@bfineran bfineran deleted the feature/damian/disable_downloading_deployment branch November 6, 2023 15:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants