Skip to content

Commit 8f7e8b9

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: format of the input to GetPublisherModelRequest for Hugging Face models.
PiperOrigin-RevId: 738211073
1 parent 5c60d95 commit 8f7e8b9

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

tests/unit/vertexai/model_garden/test_model_garden.py

+34
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@
3333
_TEST_MODEL_FULL_RESOURCE_NAME = (
3434
"publishers/google/models/paligemma@paligemma-224-float32"
3535
)
36+
_TEST_HUGGING_FACE_MODEL_FULL_RESOURCE_NAME = (
37+
"publishers/meta-llama/models/llama-3.3-70b-instruct"
38+
)
3639
_TEST_PUBLISHER_MODEL_NAME = "publishers/google/models/paligemma"
3740
_TEST_HUGGING_FACE_PUBLISHER_MODEL_NAME = "publishers/hf-google/models/gemma-2-2b"
3841
_TEST_MODEL_SIMPLIFIED_RESOURCE_NAME = "google/paligemma@paligemma-224-float32"
3942
_TEST_MODEL_HUGGING_FACE_ID = "meta-llama/Llama-3.3-70B-Instruct"
43+
_TEST_MODEL_HUGGING_FACE_RESOURCE_NAME = (
44+
"publishers/hf-meta-llama/models/llama-3.3-70b-instruct"
45+
)
4046
# Note: The full resource name is in lower case.
4147
_TEST_MODEL_HUGGING_FACE_FULL_RESOURCE_NAME = (
4248
"publishers/hf-meta-llama/models/llama-3.3-70b-instruct@001"
@@ -120,6 +126,24 @@ def get_publisher_model_mock():
120126
)
121127
),
122128
),
129+
types.PublisherModel(
130+
name=_TEST_MODEL_HUGGING_FACE_RESOURCE_NAME,
131+
supported_actions=types.PublisherModel.CallToAction(
132+
multi_deploy_vertex=types.PublisherModel.CallToAction.DeployVertex(
133+
multi_deploy_vertex=[
134+
types.PublisherModel.CallToAction.Deploy(
135+
dedicated_resources=types.DedicatedResources(
136+
machine_spec=types.MachineSpec(
137+
machine_type="g2-standard-16",
138+
accelerator_type="NVIDIA_L4",
139+
accelerator_count=1,
140+
)
141+
)
142+
)
143+
]
144+
)
145+
),
146+
),
123147
]
124148
yield get_publisher_model_mock
125149

@@ -758,6 +782,16 @@ def test_list_deploy_options(self, get_publisher_model_mock):
758782
)
759783
)
760784

785+
hf_model = model_garden.OpenModel(_TEST_MODEL_HUGGING_FACE_ID)
786+
hf_model.list_deploy_options()
787+
get_publisher_model_mock.assert_called_with(
788+
types.GetPublisherModelRequest(
789+
name=_TEST_HUGGING_FACE_MODEL_FULL_RESOURCE_NAME,
790+
is_hugging_face_model=True,
791+
include_equivalent_model_garden_model_deployment_configs=True,
792+
)
793+
)
794+
761795
def test_list_deployable_models(self, list_publisher_models_mock):
762796
"""Tests getting the supported deploy options for a model."""
763797
aiplatform.init(

vertexai/model_garden/_model_garden.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ def _reconcile_model_name(model_name: str) -> str:
147147
)
148148
else:
149149
return _get_publisher_model_resource_name(
150-
publisher="hf-" + simplified_name_match.group("publisher"),
151-
model=simplified_name_match.group("model") + "@001",
150+
publisher=simplified_name_match.group("publisher"),
151+
model=simplified_name_match.group("model"),
152152
)
153153
else:
154154
raise ValueError(f"`{model_name}` is not a valid Open Model name")
@@ -594,7 +594,7 @@ def list_deploy_options(
594594
"""Lists the verified deploy options for the model."""
595595
request = types.GetPublisherModelRequest(
596596
name=self._publisher_model_name,
597-
is_hugging_face_model="@" not in self._publisher_model_name,
597+
is_hugging_face_model=bool(self._is_hugging_face_model),
598598
include_equivalent_model_garden_model_deployment_configs=True,
599599
)
600600
response = self._us_central1_model_garden_client.get_publisher_model(request)

0 commit comments

Comments
 (0)