-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Add support for Prithvi in Online serving mode #21518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vllm-bot
merged 9 commits into
vllm-project:main
from
mgazz:online_prithvi_no_tokenizer
Jul 25, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
17b4fb2
Enable Prithvi execution in online mode
mgazz b75966a
Add test case for an online model skipping tokenizer initialization
mgazz c2339d1
Update vllm/model_executor/models/prithvi_geospatial_mae.py
mgazz a944927
keep consistent prompt_inputs type
mgazz 3f69541
fix pre-commit
mgazz 437f528
clean up
mgazz cfcabe5
Restore logic handling when tokenizer is none
mgazz 98d58fd
limit number sequences to avoid OOM during warmup
mgazz 276c144
fix pre-commit
mgazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
||
import base64 | ||
import io | ||
|
||
import numpy as np | ||
import pytest | ||
import requests | ||
import torch | ||
|
||
from ...utils import RemoteOpenAIServer | ||
|
||
MODEL_NAME = "christian-pinto/Prithvi-EO-2.0-300M-TL-VLLM" | ||
DTYPE = "float16" | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def v1(run_with_both_engines): | ||
# Simple autouse wrapper to run both engines for each test | ||
# This can be promoted up to conftest.py to run for every | ||
# test in a package | ||
pass | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def server(): | ||
args = [ | ||
"--task", | ||
"embed", | ||
# use half precision for speed and memory savings in CI environment | ||
"--dtype", | ||
DTYPE, | ||
"--enforce-eager", | ||
"--trust-remote-code", | ||
"--skip-tokenizer-init", | ||
"--max-num-seqs", | ||
"32" | ||
] | ||
|
||
with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: | ||
yield remote_server | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize("model_name", [MODEL_NAME]) | ||
async def test_single_request(server: RemoteOpenAIServer, model_name: str): | ||
|
||
pixel_values = torch.full((6, 512, 512), 1.0, dtype=torch.float16) | ||
location_coords = torch.full((1, 2), 1.0, dtype=torch.float16) | ||
|
||
buffer_tiff = io.BytesIO() | ||
torch.save(pixel_values, buffer_tiff) | ||
buffer_tiff.seek(0) | ||
binary_data = buffer_tiff.read() | ||
base64_tensor_embedding = base64.b64encode(binary_data).decode('utf-8') | ||
|
||
buffer_coord = io.BytesIO() | ||
torch.save(location_coords, buffer_coord) | ||
buffer_coord.seek(0) | ||
binary_data = buffer_coord.read() | ||
base64_coord_embedding = base64.b64encode(binary_data).decode('utf-8') | ||
|
||
prompt = { | ||
"model": | ||
model_name, | ||
"additional_data": { | ||
"prompt_token_ids": [1] | ||
}, | ||
"encoding_format": | ||
"base64", | ||
"messages": [{ | ||
"role": | ||
"user", | ||
"content": [{ | ||
"type": "image_embeds", | ||
"image_embeds": { | ||
"pixel_values": base64_tensor_embedding, | ||
"location_coords": base64_coord_embedding, | ||
}, | ||
}], | ||
}] | ||
} | ||
|
||
# test single pooling | ||
response = requests.post(server.url_for("pooling"), json=prompt) | ||
response.raise_for_status() | ||
|
||
output = response.json()["data"][0]['data'] | ||
|
||
np_response = np.frombuffer(base64.b64decode(output), dtype=np.float32) | ||
|
||
assert len(np_response) == 524288 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
self.tokenizer
is None, this will raise an AttributeError. It's critical to ensureself.tokenizer
is checked for None before being used here to prevent a crash. Consider adding a condition to skip this line ifself.tokenizer
is None.