From bc91d75c55df4291a757a7b1cf828ef6f22fab09 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Thu, 14 Nov 2024 14:14:50 -0500 Subject: [PATCH 1/3] Update vllm colab to work with asyncio requirements --- .../beam-ml/run_inference_vllm.ipynb | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/examples/notebooks/beam-ml/run_inference_vllm.ipynb b/examples/notebooks/beam-ml/run_inference_vllm.ipynb index e9f1e53a452b..bd7055724b1d 100644 --- a/examples/notebooks/beam-ml/run_inference_vllm.ipynb +++ b/examples/notebooks/beam-ml/run_inference_vllm.ipynb @@ -117,10 +117,35 @@ "source": [ "!pip install openai>=1.52.2\n", "!pip install vllm>=0.6.3\n", - "!pip install apache-beam[gcp]==2.60.0\n", + "!pip install apache-beam[gcp]==2.61.0\n", + "!pip install nest_asyncio # only needed in colab\n" "!pip check" ] }, + { + "cell_type": "markdown", + "source": [ + "## Colab only: allow nested asyncio\n", + "\n", + "The vLLM model handler logic below uses asyncio to feed vLLM records. This only works if we are not already in an asyncio event loop. Most of the time, this is fine, but colab already operates in an event loop. To work around this, we can use nest_asyncio to make things work smoothly in colab. Do not include this step outside of colab." + ], + "metadata": { + "id": "3xz8zuA7vcS3" + } + }, + { + "cell_type": "code", + "source": [ + "# This should not be necessary outside of colab.\n", + "import nest_asyncio\n", + "nest_asyncio.apply()\n", + ], + "metadata": { + "id": "sUqjOzw3wpI3" + }, + "execution_count": null, + "outputs": [] + }, { "cell_type": "markdown", "source": [ From 9200c54e2066172fad4c283e0b700b146eef966b Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Thu, 14 Nov 2024 14:19:13 -0500 Subject: [PATCH 2/3] Format --- examples/notebooks/beam-ml/run_inference_vllm.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/notebooks/beam-ml/run_inference_vllm.ipynb b/examples/notebooks/beam-ml/run_inference_vllm.ipynb index bd7055724b1d..6dcc0e9538a9 100644 --- a/examples/notebooks/beam-ml/run_inference_vllm.ipynb +++ b/examples/notebooks/beam-ml/run_inference_vllm.ipynb @@ -118,7 +118,7 @@ "!pip install openai>=1.52.2\n", "!pip install vllm>=0.6.3\n", "!pip install apache-beam[gcp]==2.61.0\n", - "!pip install nest_asyncio # only needed in colab\n" + "!pip install nest_asyncio # only needed in colab\n", "!pip check" ] }, From 4a6760e3bb688434b95b4ebc6c13161aada8902b Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Thu, 14 Nov 2024 14:20:28 -0500 Subject: [PATCH 3/3] Format --- examples/notebooks/beam-ml/run_inference_vllm.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/notebooks/beam-ml/run_inference_vllm.ipynb b/examples/notebooks/beam-ml/run_inference_vllm.ipynb index 6dcc0e9538a9..bf56b3b922e1 100644 --- a/examples/notebooks/beam-ml/run_inference_vllm.ipynb +++ b/examples/notebooks/beam-ml/run_inference_vllm.ipynb @@ -138,7 +138,7 @@ "source": [ "# This should not be necessary outside of colab.\n", "import nest_asyncio\n", - "nest_asyncio.apply()\n", + "nest_asyncio.apply()\n" ], "metadata": { "id": "sUqjOzw3wpI3"