TransferQueue 0.1.3.dev5__py3-none-any.whl → 0.1.4.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
performance_test.py CHANGED
@@ -137,8 +137,8 @@ class RayBandwidthTester:
137
137
  RemoteDataStore = RemoteDataStoreRemote
138
138
 
139
139
  self.remote_store = RemoteDataStore.options(
140
- num_cpus=0.01,
141
- resources={f"node:{WORKER_NODE_IP}": 0.001}
140
+ num_cpus=1,
141
+ resources={f"node:{WORKER_NODE_IP}": 1}
142
142
  ).remote()
143
143
 
144
144
  logger.info(f"Remote data store created on worker node {WORKER_NODE_IP}")
@@ -232,15 +232,15 @@ class TQBandwidthTester:
232
232
  # 限制在远程节点
233
233
  for storage_unit_rank in range(self.config.num_data_storage_units):
234
234
  storage_node = SimpleStorageUnit.options(
235
- num_cpus=0.01,
236
- resources={f"node:{WORKER_NODE_IP}": 0.001},
235
+ num_cpus=1,
236
+ resources={f"node:{WORKER_NODE_IP}": 1},
237
237
  runtime_env={"env_vars": {"OMP_NUM_THREADS": "2"}},
238
238
  ).remote(
239
239
  storage_unit_size=math.ceil(total_storage_size / self.config.num_data_storage_units)
240
240
  )
241
241
  self.data_system_storage_units[storage_unit_rank] = storage_node
242
242
  else:
243
- storage_placement_group = get_placement_group(self.config.num_data_storage_units, num_cpus_per_actor=0.01)
243
+ storage_placement_group = get_placement_group(self.config.num_data_storage_units, num_cpus_per_actor=1)
244
244
  for storage_unit_rank in range(self.config.num_data_storage_units):
245
245
  storage_node = SimpleStorageUnit.options(
246
246
  placement_group=storage_placement_group,
@@ -0,0 +1,110 @@
1
+ import zmq
2
+ import time
3
+ import torch
4
+ from tensordict import TensorDict
5
+ from transfer_queue.utils.zmq_utils import ZMQMessage, ZMQRequestType
6
+ from tensordict.tensorclass import NonTensorData
7
+ import random
8
+ import multiprocessing
9
+
10
+
11
+
12
+ # -------------------------- Server(ROUTER Socket) --------------------------
13
+ def router_server():
14
+ context = zmq.Context()
15
+ router_socket = context.socket(zmq.ROUTER)
16
+ router_socket.bind("tcp://127.0.0.1:5555")
17
+ print("ROUTER Server is ready, binding:tcp://127.0.0.1:5555")
18
+
19
+
20
+ print("\n=== start communication(send_multipart/recv_multipart)===")
21
+ messages = router_socket.recv_multipart()
22
+ id = messages.pop(0)
23
+ response_msg = ZMQMessage.deserialize(messages)
24
+ print(response_msg)
25
+
26
+ # Try to do in-place modification to see if it's allowed
27
+ td = response_msg.body['data']
28
+ print(f"Server解析数据::\n{td['strided']},\n{td['jagged']},\n{td['empty_tensor']},\n{td['nested']},\n{td['non_contiguous']}")
29
+ print(f"Server连续性:{td['non_contiguous'].is_contiguous()}")
30
+ # it's safe to do in-place modification even we set
31
+ # arr = torch.frombuffer(buffer, dtype=torch.uint8)
32
+
33
+ print(f"Server指针{td['strided'].data_ptr()}, {td['jagged'].data_ptr()}, {td['empty_tensor'].data_ptr()}, "
34
+ f"{td['nested'].data_ptr()}, {td['non_contiguous'].data_ptr()}")
35
+ router_socket.send_multipart([
36
+ id,
37
+ b"ack",
38
+ ])
39
+
40
+
41
+ time.sleep(1)
42
+ router_socket.close()
43
+ context.term()
44
+
45
+ # -------------------------- Client(DEALER Socket) --------------------------
46
+ def dealer_client():
47
+ context = zmq.Context()
48
+ dealer_socket = context.socket(zmq.DEALER)
49
+ # set client identity
50
+ dealer_socket.setsockopt_string(zmq.IDENTITY, "client_001")
51
+ dealer_socket.connect("tcp://127.0.0.1:5555")
52
+ print("DEALER Client is ready, connecting:tcp://127.0.0.1:5555")
53
+ time.sleep(0.5)
54
+
55
+ base = torch.randn(2, 10)
56
+ non_contiguous = base[:, ::2]
57
+ print(f"Client非连续张量连续性:{non_contiguous.is_contiguous()}")
58
+
59
+ # Create TensorDict with different layouts
60
+ td = TensorDict(
61
+ {
62
+ "strided": torch.randn(2, 5, 3),
63
+ "jagged": torch.nested.as_nested_tensor([torch.randn(3, 4), torch.randn(2, 4)], layout=torch.jagged),
64
+ "empty_tensor": torch.empty(2, 0),
65
+ "nested": torch.nested.as_nested_tensor([torch.randn(4, 3), torch.randn(2, 4)], layout=torch.strided),
66
+ "non_contiguous": non_contiguous,
67
+ },
68
+ batch_size=2,
69
+ )
70
+ print(f"Client原始数据:\n{td['strided']},\n{td['jagged']},\n{td['empty_tensor']},\n{td['nested']},\n{td['non_contiguous']}")
71
+ print(f"Client连续性:{td['non_contiguous'].is_contiguous()}")
72
+ # 打印原始数据的指针位置
73
+
74
+ print(f"Client指针{td['strided'].data_ptr()}, {td['jagged'].data_ptr()}, {td['empty_tensor'].data_ptr()}, "
75
+ f"{td['nested'].data_ptr()}, {td['non_contiguous'].data_ptr()}")
76
+
77
+
78
+ request_msg = ZMQMessage.create(
79
+ request_type=ZMQRequestType.PUT_DATA,
80
+ sender_id='123',
81
+ receiver_id='456',
82
+ body={"data":td},
83
+ )
84
+
85
+
86
+ dealer_socket.send_multipart(request_msg.serialize(),copy=False)
87
+
88
+
89
+ response_frames = dealer_socket.recv_multipart()
90
+ response_frame1 = response_frames[0]
91
+ print(f"DEALER Receive → Frame: {response_frame1}")
92
+
93
+ dealer_socket.close()
94
+ context.term()
95
+
96
+ # -------------------------- Start all processes --------------------------
97
+ if __name__ == "__main__":
98
+ # Start server process
99
+ server_process = multiprocessing.Process(target=router_server)
100
+ server_process.start()
101
+ time.sleep(0.5)
102
+
103
+ # Start client process
104
+ client_process = multiprocessing.Process(target=dealer_client)
105
+ client_process.start()
106
+
107
+
108
+ server_process.join()
109
+ client_process.join()
110
+ print("Test Finish!")
@@ -1,3 +1,17 @@
1
+ # Copyright 2025 The TransferQueue Team
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  import logging
2
16
  import os
3
17
  import sys
@@ -1,14 +1,30 @@
1
+ # Copyright 2025 The TransferQueue Team
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import sys
1
16
  import unittest
17
+ from pathlib import Path
2
18
 
3
19
  import torch
4
20
  from tensordict import TensorDict
5
21
 
6
- from transfer_queue.metadata import (
7
- BatchMeta,
8
- FieldMeta,
9
- SampleMeta,
10
- )
11
- from transfer_queue.storage.managers.base import KVStorageManager
22
+ # Setup path
23
+ parent_dir = Path(__file__).resolve().parent.parent
24
+ sys.path.append(str(parent_dir))
25
+
26
+ from transfer_queue.metadata import BatchMeta, FieldMeta, SampleMeta # noqa: E402
27
+ from transfer_queue.storage.managers.base import KVStorageManager # noqa: E402
12
28
 
13
29
 
14
30
  class Test(unittest.TestCase):