Skip to content
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
16 changes: 8 additions & 8 deletions sagemaker-serve/src/sagemaker/serve/model_builder_servers.py
Comment thread
aviruthen marked this conversation as resolved.
Comment thread
aviruthen marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _build_for_torchserve(self) -> Model:
if isinstance(self.model, str):
# Configure HuggingFace model support
if not self._is_jumpstart_model_id():
self.env_vars.update({"HF_MODEL_ID": self.model})
self.env_vars.setdefault("HF_MODEL_ID", self.model)
Comment thread
aviruthen marked this conversation as resolved.

# Add HuggingFace token if available
if self.env_vars.get("HUGGING_FACE_HUB_TOKEN"):
Expand Down Expand Up @@ -212,7 +212,7 @@ def _build_for_tgi(self) -> Model:

if isinstance(self.model, str) and not self._is_jumpstart_model_id():
# Configure HuggingFace model for TGI
self.env_vars.update({"HF_MODEL_ID": self.model})
self.env_vars.setdefault("HF_MODEL_ID", self.model)

self.hf_model_config = _get_model_config_properties_from_hf(
self.model, self.env_vars.get("HUGGING_FACE_HUB_TOKEN")
Expand Down Expand Up @@ -319,9 +319,9 @@ def _build_for_djl(self) -> Model:
logger.debug(f"Using detected notebook instance type: {nb_instance}")

if isinstance(self.model, str) and not self._is_jumpstart_model_id():
# Configure HuggingFace model for DJL (preserve user-provided HF_MODEL_ID)
# Configure HuggingFace model for DJL
self.env_vars.setdefault("HF_MODEL_ID", self.model)

# Get model configuration for DJL optimization
self.hf_model_config = _get_model_config_properties_from_hf(
self.model, self.env_vars.get("HUGGING_FACE_HUB_TOKEN")
Expand Down Expand Up @@ -432,7 +432,7 @@ def _build_for_triton(self) -> Model:
self.env_vars.update({"HF_TASK": model_task})

# Configure HuggingFace authentication
self.env_vars.update({"HF_MODEL_ID": self.model})
self.env_vars.setdefault("HF_MODEL_ID", self.model)
if self.env_vars.get("HUGGING_FACE_HUB_TOKEN"):
self.env_vars["HF_TOKEN"] = self.env_vars.get("HUGGING_FACE_HUB_TOKEN")

Expand Down Expand Up @@ -538,7 +538,7 @@ def _build_for_tei(self) -> Model:

if isinstance(self.model, str) and not self._is_jumpstart_model_id():
# Configure HuggingFace model for TEI
self.env_vars.update({"HF_MODEL_ID": self.model})
self.env_vars.setdefault("HF_MODEL_ID", self.model)

self.hf_model_config = _get_model_config_properties_from_hf(
self.model, self.env_vars.get("HUGGING_FACE_HUB_TOKEN")
Expand Down Expand Up @@ -682,7 +682,7 @@ def _build_for_transformers(self) -> Model:
if self.inference_spec is not None:
hf_model_id = self.inference_spec.get_model()
if isinstance(hf_model_id, str): # Only if it's a valid HF model ID
self.env_vars.update({"HF_MODEL_ID": hf_model_id})
self.env_vars.setdefault("HF_MODEL_ID", hf_model_id)
# Get HF config only for string model IDs
if hasattr(self.env_vars, "HF_API_TOKEN"):
self.hf_model_config = _get_model_config_properties_from_hf(
Expand All @@ -701,7 +701,7 @@ def _build_for_transformers(self) -> Model:
if model_task:
self.env_vars.update({"HF_TASK": model_task})

self.env_vars.update({"HF_MODEL_ID": self.model})
self.env_vars.setdefault("HF_MODEL_ID", self.model)

# Add HuggingFace token if available
if self.env_vars.get("HUGGING_FACE_HUB_TOKEN"):
Expand Down
Loading
Loading