Skip to content

feature: add support for HF_HOME #4723

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

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sagemaker/serve/builder/djl_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def _djl_model_builder_deploy_wrapper(self, *args, **kwargs) -> Type[PredictorBa
# if has not been built for local container we must use cache
# that hosting has write access to.
self.pysdk_model.env["TRANSFORMERS_CACHE"] = "/tmp"
self.pysdk_model.env["HF_HOME"] = "/tmp"
self.pysdk_model.env["HUGGINGFACE_HUB_CACHE"] = "/tmp"

if "endpoint_logging" not in kwargs:
Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/serve/builder/tei_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def _tei_model_builder_deploy_wrapper(self, *args, **kwargs) -> Type[PredictorBa
# if has not been built for local container we must use cache
# that hosting has write access to.
self.pysdk_model.env["TRANSFORMERS_CACHE"] = "/tmp"
self.pysdk_model.env["HF_HOME"] = "/tmp"
self.pysdk_model.env["HUGGINGFACE_HUB_CACHE"] = "/tmp"

if "endpoint_logging" not in kwargs:
Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/serve/builder/tgi_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def _tgi_model_builder_deploy_wrapper(self, *args, **kwargs) -> Type[PredictorBa
# if has not been built for local container we must use cache
# that hosting has write access to.
self.pysdk_model.env["TRANSFORMERS_CACHE"] = "/tmp"
self.pysdk_model.env["HF_HOME"] = "/tmp"
self.pysdk_model.env["HUGGINGFACE_HUB_CACHE"] = "/tmp"

if "endpoint_logging" not in kwargs:
Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/serve/model_server/djl_serving/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
_DEFAULT_ENV_VARS = {
"SERVING_OPTS": "-Dai.djl.logging.level=debug",
"TRANSFORMERS_CACHE": "/opt/ml/model/",
"HF_HOME": "/opt/ml/model/",
"HUGGINGFACE_HUB_CACHE": "/opt/ml/model/",
}

Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/serve/model_server/tei/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
_SHM_SIZE = "2G"
_DEFAULT_ENV_VARS = {
"TRANSFORMERS_CACHE": "/opt/ml/model/",
"HF_HOME": "/opt/ml/model/",
"HUGGINGFACE_HUB_CACHE": "/opt/ml/model/",
}

Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/serve/model_server/tgi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
_SHM_SIZE = "2G"
_DEFAULT_ENV_VARS = {
"TRANSFORMERS_CACHE": "/opt/ml/model/",
"HF_HOME": "/opt/ml/model/",
"HUGGINGFACE_HUB_CACHE": "/opt/ml/model/",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_start_invoke_destroy_local_tei_server(self, mock_requests):
volumes={PosixPath("model_path/code"): {"bind": "/opt/ml/model/", "mode": "rw"}},
environment={
"TRANSFORMERS_CACHE": "/opt/ml/model/",
"HF_HOME": "/opt/ml/model/",
"HUGGINGFACE_HUB_CACHE": "/opt/ml/model/",
"KEY": "VALUE",
"SAGEMAKER_SERVE_SECRET_KEY": "secret_key",
Expand Down