Update realtime invalid-request fixtures and reserve Moss encoder memory

Signed-off-by: tzhouam <tzhouam@connect.ust.hk>
This commit is contained in:
tzhouam committed 2026-10-03 23:05:51 +08:00
1 parent 757dd3b2c4
commit 37803a8a41
2 files changed
+18 -38

No files matched your search

@@ -216,44 +216,39 @@ def test_video_chat_stream_invalid_requests(
# WS /v1/realtime # WS /v1/realtime
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
# Resolved in ``test_realtime_invalid_requests`` after the initial handshake.
_REALTIME_WS_MODEL_MISMATCH = object()
_REALTIME_WS_INVALID_AUDIO_APPEND = object()
@hardware_test(res={"cuda": "H100", "rocm": "MI325"}, num_cards=2) @hardware_test(res={"cuda": "H100", "rocm": "MI325"}, num_cards=2)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"send_frames_spec, ws_error_code, err_message", "send_frames_spec, ws_error_code, err_message",
[ [
pytest.param("{not-json", "invalid_json", "Invalid JSON", id="invalid_json"), pytest.param("{not-json", "invalid_event", "Invalid or unrecognized client event", id="invalid_json"),
pytest.param( pytest.param(
json.dumps({"type": "session.update"}), json.dumps({"type": "session.update"}),
"invalid_event", "invalid_event",
("model", "Missing required field"), "Invalid or unrecognized client event",
id="session_update_missing_model", id="session_update_missing_session",
), ),
pytest.param( pytest.param(
_REALTIME_WS_MODEL_MISMATCH, json.dumps({"type": "session.update", "session": []}),
"model_not_found", "invalid_event",
("model", "does not exist"), "Invalid or unrecognized client event",
id="session_update_model_mismatch", id="session_update_invalid_session",
), ),
pytest.param( pytest.param(
json.dumps({"type": "input_audio_buffer.commit", "final": False}), json.dumps({"type": "input_audio_buffer.commit"}),
"model_not_validated", "invalid_request_error",
("session.update", "validate the model"), "Input audio buffer is empty",
id="commit_without_model_validation", id="commit_without_audio",
), ),
pytest.param( pytest.param(
json.dumps({"type": "unknown.event"}), json.dumps({"type": "unknown.event"}),
"unknown_event", "invalid_event",
"Unknown event type", "Invalid or unrecognized client event",
id="unknown_event_type", id="unknown_event_type",
), ),
pytest.param( pytest.param(
_REALTIME_WS_INVALID_AUDIO_APPEND, json.dumps({"type": "input_audio_buffer.append", "audio": "not-valid-base64!!!"}),
"invalid_audio", "invalid_request_error",
"Invalid audio data", "Invalid base64 audio data",
id="invalid_audio_append", id="invalid_audio_append",
), ),
], ],
@@ -266,24 +261,9 @@ def test_realtime_invalid_requests(
ws_error_code: str, ws_error_code: str,
err_message: str | tuple[str, ...], err_message: str | tuple[str, ...],
) -> None: ) -> None:
send_frames: Any
if send_frames_spec is _REALTIME_WS_MODEL_MISMATCH:
send_frames = json.dumps(
{
"type": "session.update",
"model": "this-model-is-not-served-on-this-instance",
}
)
elif send_frames_spec is _REALTIME_WS_INVALID_AUDIO_APPEND:
send_frames = [
json.dumps({"type": "session.update", "model": omni_server.model}),
json.dumps({"type": "input_audio_buffer.append", "audio": "not-valid-base64!!!"}),
]
else:
send_frames = send_frames_spec
online_client.send_realtime_ws_request( online_client.send_realtime_ws_request(
{ {
"send_frames": send_frames, "send_frames": send_frames_spec,
"timeout": 120, "timeout": 120,
"ws_max_size": None, "ws_max_size": None,
"ws_skip_types": ["session.created", "conversation.created"], "ws_skip_types": ["session.created", "conversation.created"],
@@ -88,7 +88,7 @@ tts_server_params = [
get_deploy_config_path("moss_tts_realtime.yaml"), get_deploy_config_path("moss_tts_realtime.yaml"),
# Leave room on the single L4 for the codec weights, reference # Leave room on the single L4 for the codec weights, reference
# encoder, and speech-serving activations in addition to KV. # encoder, and speech-serving activations in addition to KV.
updates={"stages": {0: {"gpu_memory_utilization": 0.45}}}, updates={"stages": {0: {"gpu_memory_utilization": 0.35}}},
), ),
server_args=["--disable-log-stats"], server_args=["--disable-log-stats"],
), ),