TensorRT-LLMs/tests/hlapi/test_mpi_session.py
Kaiyu Xie e06f537e08
Update TensorRT-LLM (#1019)
* Update TensorRT-LLM

---------

Co-authored-by: erenup <ping.nie@pku.edu.cn>
Co-authored-by: Shixiaowei02 <39303645+Shixiaowei02@users.noreply.github.com>
2024-01-31 21:55:32 +08:00

42 lines
707 B
Python

from dataclasses import dataclass
from typing import List
from tensorrt_llm.hlapi.mpi_session import SocketListener
@dataclass
class ComplexData:
a: str
b: int
c: List[int]
def test_SocketServer():
messages = [
"hello", # str
123, # int
ComplexData("hello", 123, [1, 2, 3]) # complex
]
offset = 0
def callback(data):
nonlocal offset
print('get data', data)
assert data == messages[offset]
offset += 1
server = SocketListener(callback=callback)
client = server.get_client()
for data in messages:
client.send(data)
server.shutdown()
if __name__ == '__main__':
test_SocketServer()