[watermark] compatibility validation (#56801)
Signed-off-by: Raphael Rialland <raphael.rialland@mistral.ai> Signed-off-by: Simon Veitner <sveitner@redhat.com> Co-authored-by: Simon Veitner <sveitner@redhat.com>
This commit is contained in:
co-authored by
Simon Veitner
parent
88f3c601b3
commit
c32495d58f
@@ -4,6 +4,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
import warnings
|
||||
from types import SimpleNamespace
|
||||
|
||||
import numpy as np
|
||||
import pybase64 as base64
|
||||
@@ -12,6 +13,7 @@ import websockets
|
||||
|
||||
from tests.utils import ROCM_EXTRA_ARGS, RemoteOpenAIServer
|
||||
from vllm.assets.audio import AudioAsset
|
||||
from vllm.entrypoints.speech_to_text.realtime.connection import RealtimeConnection
|
||||
from vllm.multimodal.media.audio import load_audio
|
||||
|
||||
MISTRAL_FORMAT_ARGS = [
|
||||
@@ -26,6 +28,46 @@ MISTRAL_FORMAT_ARGS = [
|
||||
MODEL_NAME = "mistralai/Voxtral-Mini-4B-Realtime-2602"
|
||||
|
||||
|
||||
def test_realtime_generation_preserves_watermarking():
|
||||
transcription_outputs = []
|
||||
|
||||
class EngineClient:
|
||||
def generate(self, **kwargs):
|
||||
async def outputs():
|
||||
output = SimpleNamespace(
|
||||
outputs=[],
|
||||
prompt_token_ids=[],
|
||||
is_watermarked=kwargs["sampling_params"].watermarking,
|
||||
)
|
||||
transcription_outputs.append(output)
|
||||
yield output
|
||||
|
||||
return outputs()
|
||||
|
||||
async def streaming_input():
|
||||
chunk: np.ndarray
|
||||
for chunk in ():
|
||||
yield chunk
|
||||
|
||||
async def send(_event):
|
||||
return None
|
||||
|
||||
connection = object.__new__(RealtimeConnection)
|
||||
connection.connection_id = "test"
|
||||
connection.serving = SimpleNamespace(
|
||||
model_cls=SimpleNamespace(realtime_max_tokens=1),
|
||||
engine_client=EngineClient(),
|
||||
)
|
||||
connection.audio_queue = asyncio.Queue()
|
||||
connection._is_connected = True
|
||||
connection.send = send
|
||||
|
||||
asyncio.run(connection._run_generation(streaming_input(), asyncio.Queue()))
|
||||
|
||||
assert len(transcription_outputs) == 1
|
||||
assert transcription_outputs[0].is_watermarked is None
|
||||
|
||||
|
||||
def _get_websocket_url(server: RemoteOpenAIServer) -> str:
|
||||
"""Convert HTTP URL to WebSocket URL for realtime endpoint."""
|
||||
http_url = server.url_root
|
||||
|
||||
@@ -198,4 +198,6 @@ async def test_language_detection_cancel_aborts_engine_request():
|
||||
with pytest.raises(asyncio.CancelledError):
|
||||
await task
|
||||
|
||||
sampling_params = engine_client.generate.call_args.args[1]
|
||||
assert sampling_params.watermarking is False
|
||||
engine_client.abort.assert_awaited_once_with(request_id)
|
||||
|
||||
Reference in New Issue
Block a user