"vscode:/vscode.git/clone" did not exist on "d1537039ce7e6018db510d0c0d9b0c0fccb62b63"
Unverified Commit 6930becd authored by Christian Pinto's avatar Christian Pinto Committed by GitHub
Browse files

(bugfix): Fixed encode in LLM entrypoint for IOProcessr plugin prompts (#34618)


Signed-off-by: default avatarChristian Pinto <christian.pinto@ibm.com>
parent 03a8770a
...@@ -20,13 +20,15 @@ def main(): ...@@ -20,13 +20,15 @@ def main():
torch.set_default_dtype(torch.float16) torch.set_default_dtype(torch.float16)
image_url = "https://huggingface.co/christian-pinto/Prithvi-EO-2.0-300M-TL-VLLM/resolve/main/valencia_example_2024-10-26.tiff" # noqa: E501 image_url = "https://huggingface.co/christian-pinto/Prithvi-EO-2.0-300M-TL-VLLM/resolve/main/valencia_example_2024-10-26.tiff" # noqa: E501
img_prompt = dict( img_data = dict(
data=image_url, data=image_url,
data_format="url", data_format="url",
image_format="tiff", image_format="tiff",
out_data_format="b64_json", out_data_format="b64_json",
) )
prompt = dict(data=img_data)
llm = LLM( llm = LLM(
model="ibm-nasa-geospatial/Prithvi-EO-2.0-300M-TL-Sen1Floods11", model="ibm-nasa-geospatial/Prithvi-EO-2.0-300M-TL-Sen1Floods11",
skip_tokenizer_init=True, skip_tokenizer_init=True,
...@@ -41,7 +43,7 @@ def main(): ...@@ -41,7 +43,7 @@ def main():
enable_mm_embeds=True, enable_mm_embeds=True,
) )
pooler_output = llm.encode(img_prompt, pooling_task="plugin") pooler_output = llm.encode(prompt, pooling_task="plugin")
output = pooler_output[0].outputs output = pooler_output[0].outputs
print(output) print(output)
......
...@@ -120,13 +120,15 @@ async def test_prithvi_mae_plugin_online( ...@@ -120,13 +120,15 @@ async def test_prithvi_mae_plugin_online(
def test_prithvi_mae_plugin_offline( def test_prithvi_mae_plugin_offline(
vllm_runner, model_name: str, image_url: str | dict, plugin: str, expected_hash: str vllm_runner, model_name: str, image_url: str | dict, plugin: str, expected_hash: str
): ):
img_prompt = dict( img_data = dict(
data=image_url, data=image_url,
data_format="url", data_format="url",
image_format="tiff", image_format="tiff",
out_data_format="b64_json", out_data_format="b64_json",
) )
prompt = dict(data=img_data)
with vllm_runner( with vllm_runner(
model_name, model_name,
runner="pooling", runner="pooling",
...@@ -139,7 +141,7 @@ def test_prithvi_mae_plugin_offline( ...@@ -139,7 +141,7 @@ def test_prithvi_mae_plugin_offline(
io_processor_plugin=plugin, io_processor_plugin=plugin,
default_torch_num_threads=1, default_torch_num_threads=1,
) as llm_runner: ) as llm_runner:
pooler_output = llm_runner.get_llm().encode(img_prompt, pooling_task="plugin") pooler_output = llm_runner.get_llm().encode(prompt, pooling_task="plugin")
output = pooler_output[0].outputs output = pooler_output[0].outputs
# verify the output is formatted as expected for this plugin # verify the output is formatted as expected for this plugin
......
...@@ -1135,7 +1135,15 @@ class LLM: ...@@ -1135,7 +1135,15 @@ class LLM:
) )
# Validate the request data is valid for the loaded plugin # Validate the request data is valid for the loaded plugin
validated_prompt = self.io_processor.parse_data(prompts) prompt_data = prompts.get("data")
if prompt_data is None:
raise ValueError(
"The 'data' field of the prompt is expected to contain "
"the prompt data and it cannot be None. "
"Refer to the documentation of the IOProcessor "
"in use for more details."
)
validated_prompt = self.io_processor.parse_data(prompt_data)
# obtain the actual model prompts from the pre-processor # obtain the actual model prompts from the pre-processor
prompts = self.io_processor.pre_process(prompt=validated_prompt) prompts = self.io_processor.pre_process(prompt=validated_prompt)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment