Signed-off-by: Krishnan Prashanth <kprashanth@nvidia.com> Co-authored-by: Shangming Cai <csmthu@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Unit tests for the encode-disaggregation receiver."""
|
|
|
|
import unittest
|
|
from array import array
|
|
from types import SimpleNamespace
|
|
|
|
from sglang.srt.disaggregation.encoder.receiver import _select_mm_processor_prompt
|
|
from sglang.test.ci.ci_register import register_cpu_ci
|
|
from sglang.test.test_utils import CustomTestCase
|
|
|
|
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
|
|
|
|
|
|
class TestSelectMMProcessorPrompt(CustomTestCase):
|
|
def test_tokens_in_prompt_is_list(self):
|
|
"""A tokens-in prompt reaches the processor as list[int], not array("q");
|
|
HTTP sends input_text=None and the gRPC servicer sends ""."""
|
|
processor = SimpleNamespace(prefer_tokenized_input=False)
|
|
for input_text in (None, ""):
|
|
with self.subTest(input_text=input_text):
|
|
recv_req = SimpleNamespace(
|
|
input_text=input_text, input_ids=array("q", [1, 2, 3])
|
|
)
|
|
|
|
prompt = _select_mm_processor_prompt(recv_req, processor)
|
|
|
|
self.assertIsInstance(prompt, list)
|
|
self.assertEqual(prompt, [1, 2, 3])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|