Skip to content

Commit fdaa5a6

Browse files
vertex-mg-botcopybara-github
authored andcommitted
Formatting and refactoring of Qwen2 deployment notebook
PiperOrigin-RevId: 767042986
1 parent 5ba56df commit fdaa5a6

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

notebooks/community/model_garden/model_garden_pytorch_qwen2_deployment.ipynb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"\n",
3535
"<table><tbody><tr>\n",
3636
" <td style=\"text-align: center\">\n",
37+
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/instances\">\n",
38+
" <img alt=\"Workbench logo\" src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" width=\"32px\"><br> Run in Workbench\n",
39+
" </a>\n",
40+
" </td>\n",
41+
" <td style=\"text-align: center\">\n",
3742
" <a href=\"https://console.cloud.google.com/vertex-ai/colab/import/https:%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fvertex-ai-samples%2Fmain%2Fnotebooks%2Fcommunity%2Fmodel_garden%2Fmodel_garden_pytorch_qwen2_deployment.ipynb\">\n",
3843
" <img alt=\"Google Cloud Colab Enterprise logo\" src=\"https://lh3.googleusercontent.com/JmcxdQi-qOpctIvWKgPtrzZdJJK-J3sWE1RsfjZNwshCFgE_9fULcNpuXYTilIR2hjwN\" width=\"32px\"><br> Run in Colab Enterprise\n",
3944
" </a>\n",
@@ -123,7 +128,6 @@
123128
"from google.cloud import aiplatform\n",
124129
"\n",
125130
"models, endpoints = {}, {}\n",
126-
"LABEL = \"vllm_gpu\"\n",
127131
"\n",
128132
"if os.environ.get(\"VERTEX_PRODUCT\") != \"COLAB_ENTERPRISE\":\n",
129133
" ! pip install --upgrade tensorflow\n",
@@ -167,7 +171,6 @@
167171
{
168172
"cell_type": "code",
169173
"execution_count": null,
170-
"language": "python",
171174
"metadata": {
172175
"cellView": "form",
173176
"id": "USB7dvYqvNdu"
@@ -273,6 +276,8 @@
273276
"source": [
274277
"# @title [Option 1] Deploy with Model Garden SDK\n",
275278
"\n",
279+
"LABEL = \"sdk-deploy\"\n",
280+
"\n",
276281
"# @markdown Deploy with Gen AI model-centric SDK. This section uploads the prebuilt model to Model Registry and deploys it to a Vertex AI Endpoint. It takes 15 minutes to 1 hour to finish depending on the size of the model. See [use open models with Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/open-models/use-open-models) for documentation on other use cases.\n",
277282
"from vertexai.preview import model_garden\n",
278283
"\n",
@@ -435,7 +440,8 @@
435440
" return model, endpoint\n",
436441
"\n",
437442
"\n",
438-
"models[\"vllm_gpu\"], endpoints[\"vllm_gpu\"] = deploy_model_vllm(\n",
443+
"LABEL = \"custom-deploy\"\n",
444+
"models[LABEL], endpoints[LABEL] = deploy_model_vllm(\n",
439445
" model_name=common_util.get_job_name_with_datetime(prefix=MODEL_ID),\n",
440446
" model_id=model_id,\n",
441447
" publisher=\"qwen\",\n",
@@ -505,7 +511,7 @@
505511
" \"raw_response\": raw_response,\n",
506512
" },\n",
507513
"]\n",
508-
"response = endpoints[\"vllm_gpu\"].predict(\n",
514+
"response = endpoints[LABEL].predict(\n",
509515
" instances=instances, use_dedicated_endpoint=use_dedicated_endpoint\n",
510516
")\n",
511517
"\n",
@@ -699,7 +705,8 @@
699705
" return model, endpoint\n",
700706
"\n",
701707
"\n",
702-
"models[\"hexllm_tpu\"], endpoints[\"hexllm_tpu\"] = deploy_model_hexllm(\n",
708+
"LABEL = \"hexllm_tpu\"\n",
709+
"models[LABEL], endpoints[LABEL] = deploy_model_hexllm(\n",
703710
" model_name=common_util.get_job_name_with_datetime(prefix=MODEL_ID),\n",
704711
" model_id=model_id,\n",
705712
" publisher=\"qwen\",\n",

0 commit comments

Comments
 (0)