[Feature] Add Muse Glimmer model support (#34262)
Co-authored-by: sglang-bot <232288953+sglang-bot@users.noreply.github.com> Co-authored-by: Brayden Zhong <brayden.zhong@radixark.ai> Co-authored-by: Jimmy Shong <69131491+Jiminator@users.noreply.github.com> Co-authored-by: hnyls2002 <lsyincs@gmail.com> Co-authored-by: Alex Nails <alex.nails@radixark.ai> Co-authored-by: Liangsheng Yin <hnyls2002@gmail.com>
This commit is contained in:
co-authored by
sglang-bot
Brayden Zhong
Jimmy Shong
hnyls2002
Alex Nails
Liangsheng Yin
parent
9c1517df4a
commit
fde9ad2531
@@ -311,6 +311,80 @@ class ReasoningRequestForwardingTestCase(unittest.TestCase):
|
||||
self.assertFalse(parser_cls.call_args.kwargs["force_reasoning"])
|
||||
|
||||
|
||||
class SkipSpecialTokensForwardingTestCase(CustomTestCase):
|
||||
"""The skip_special_tokens override from _process_messages must reach the
|
||||
engine sampling params; muse's channel markers die in detok otherwise."""
|
||||
|
||||
def _create_responses_sampling_params(self, serving):
|
||||
serving.default_chat_template_kwargs = None
|
||||
rendered = MessageProcessingResult(
|
||||
prompt="prompt",
|
||||
prompt_ids=[1, 2, 3],
|
||||
image_data=None,
|
||||
audio_data=None,
|
||||
video_data=None,
|
||||
modalities=[],
|
||||
stop=[],
|
||||
)
|
||||
captured = {}
|
||||
|
||||
async def fake_generate(
|
||||
request_id,
|
||||
request_prompt,
|
||||
adapted_request,
|
||||
sampling_params,
|
||||
context,
|
||||
**kwargs,
|
||||
):
|
||||
captured["sampling_params"] = sampling_params
|
||||
context.append_output(
|
||||
{
|
||||
"text": "done",
|
||||
"meta_info": {
|
||||
"prompt_tokens": 3,
|
||||
"completion_tokens": 1,
|
||||
"cached_tokens": 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
yield context
|
||||
|
||||
serving._generate_with_builtin_tools = fake_generate
|
||||
request = ResponsesRequest(
|
||||
model="x",
|
||||
input="answer",
|
||||
request_id="resp_skip_special",
|
||||
store=False,
|
||||
)
|
||||
|
||||
with (
|
||||
patch.object(
|
||||
serving, "_apply_conversation_template", return_value=rendered
|
||||
),
|
||||
patch(
|
||||
"sglang.srt.entrypoints.openai.serving_responses.ReasoningParser"
|
||||
) as parser_cls,
|
||||
):
|
||||
parser_cls.return_value.parse_non_stream.return_value = (None, "done")
|
||||
response = asyncio.run(serving.create_responses(request))
|
||||
|
||||
self.assertEqual(response.status, "completed")
|
||||
return captured["sampling_params"]
|
||||
|
||||
def test_marker_preserving_parser_disables_skip_special_tokens(self):
|
||||
serving = make_serving()
|
||||
serving.reasoning_parser = "muse"
|
||||
params = self._create_responses_sampling_params(serving)
|
||||
self.assertFalse(params["skip_special_tokens"])
|
||||
|
||||
def test_default_parser_keeps_skip_special_tokens(self):
|
||||
serving = make_serving()
|
||||
params = self._create_responses_sampling_params(serving)
|
||||
# The chat request's True is a synthesized default (ResponsesRequest has
|
||||
# no such field), so leave it unset for --preferred-sampling-params.
|
||||
self.assertNotIn("skip_special_tokens", params)
|
||||
|
||||
|
||||
class InputItemNormalizationTestCase(CustomTestCase):
|
||||
def test_function_call_becomes_assistant_tool_call(self):
|
||||
normalized = OpenAIServingResponses._normalize_response_message_for_chat(
|
||||
|
||||
@@ -167,6 +167,7 @@ class NonHarmonyStreamTestCase(CustomTestCase):
|
||||
parser_cls.return_value.parse_stream_chunk.side_effect = (
|
||||
fake_parse_stream_chunk
|
||||
)
|
||||
parser_cls.return_value.parse_stream_end.return_value = ("", [])
|
||||
fixture = StreamFixture(serving, request)
|
||||
events = fixture.run(chunks)
|
||||
|
||||
@@ -178,6 +179,35 @@ class NonHarmonyStreamTestCase(CustomTestCase):
|
||||
self.assertEqual(output[1]["name"], "get_weather")
|
||||
self.assertEqual(output[2]["content"][0]["text"], "It's sunny.")
|
||||
|
||||
def test_reasoning_parser_flushed_at_stream_end(self):
|
||||
"""Bug regression: the stream loop never drained text the reasoning
|
||||
parser held back as a possible marker prefix, so a response whose text
|
||||
genuinely ends with e.g. "<|e" lost that tail on /v1/responses (chat
|
||||
flushes via parse_stream_end; responses did not)."""
|
||||
serving = make_serving()
|
||||
serving.reasoning_parser = "muse"
|
||||
serving.tool_call_parser = None
|
||||
|
||||
request = ResponsesRequest(model="x", input="hi", stream=True, store=False)
|
||||
text = (
|
||||
" to=self<|message|>think<|eom|>"
|
||||
"<|start|>assistant to=user<|message|>Answer<|e"
|
||||
)
|
||||
fixture = StreamFixture(serving, request)
|
||||
events = fixture.run(
|
||||
[
|
||||
engine_chunk(text[:30], 4),
|
||||
engine_chunk(text, 9, finish=True),
|
||||
]
|
||||
)
|
||||
|
||||
streamed = "".join(
|
||||
p["delta"]
|
||||
for ev, p in zip(event_types(events), event_payloads(events))
|
||||
if ev == "response.output_text.delta"
|
||||
)
|
||||
self.assertEqual(streamed, "Answer<|e")
|
||||
|
||||
|
||||
class MultiToolCallStreamingOrderTestCase(CustomTestCase):
|
||||
"""The wire order of message / function_call items across tool-call deltas."""
|
||||
|
||||
Reference in New Issue
Block a user