mirror of
https://github.com/wassname/ray.git
synced 2026-07-25 13:30:52 +08:00
change filenames and directory structure to use halo (#81)
This commit is contained in:
committed by
Philipp Moritz
parent
b58eaf84ee
commit
67086f663e
+43
-43
@@ -1,8 +1,8 @@
|
||||
import unittest
|
||||
import orchpy
|
||||
import orchpy.serialization as serialization
|
||||
import orchpy.services as services
|
||||
import orchpy.worker as worker
|
||||
import halo
|
||||
import halo.serialization as serialization
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
import numpy as np
|
||||
import time
|
||||
import subprocess32 as subprocess
|
||||
@@ -14,7 +14,7 @@ import arrays.dist as dist
|
||||
from google.protobuf.text_format import *
|
||||
|
||||
from grpc.beta import implementations
|
||||
import orchestra_pb2
|
||||
import halo_pb2
|
||||
import types_pb2
|
||||
|
||||
class ArraysSingleTest(unittest.TestCase):
|
||||
@@ -26,27 +26,27 @@ class ArraysSingleTest(unittest.TestCase):
|
||||
|
||||
# test eye
|
||||
ref = single.eye(3)
|
||||
val = orchpy.pull(ref)
|
||||
val = halo.pull(ref)
|
||||
self.assertTrue(np.alltrue(val == np.eye(3)))
|
||||
|
||||
# test zeros
|
||||
ref = single.zeros([3, 4, 5])
|
||||
val = orchpy.pull(ref)
|
||||
val = halo.pull(ref)
|
||||
self.assertTrue(np.alltrue(val == np.zeros([3, 4, 5])))
|
||||
|
||||
# test qr - pass by value
|
||||
val_a = np.random.normal(size=[10, 13])
|
||||
ref_q, ref_r = single.linalg.qr(val_a)
|
||||
val_q = orchpy.pull(ref_q)
|
||||
val_r = orchpy.pull(ref_r)
|
||||
val_q = halo.pull(ref_q)
|
||||
val_r = halo.pull(ref_r)
|
||||
self.assertTrue(np.allclose(np.dot(val_q, val_r), val_a))
|
||||
|
||||
# test qr - pass by objref
|
||||
a = single.random.normal([10, 13])
|
||||
ref_q, ref_r = single.linalg.qr(a)
|
||||
val_a = orchpy.pull(a)
|
||||
val_q = orchpy.pull(ref_q)
|
||||
val_r = orchpy.pull(ref_r)
|
||||
val_a = halo.pull(a)
|
||||
val_q = halo.pull(ref_q)
|
||||
val_r = halo.pull(ref_r)
|
||||
self.assertTrue(np.allclose(np.dot(val_q, val_r), val_a))
|
||||
|
||||
services.cleanup()
|
||||
@@ -57,7 +57,7 @@ class ArraysDistTest(unittest.TestCase):
|
||||
[w] = services.start_singlenode_cluster(return_drivers=True)
|
||||
|
||||
x = dist.DistArray()
|
||||
x.construct([2, 3, 4], np.array([[[orchpy.push(0, w)]]]))
|
||||
x.construct([2, 3, 4], np.array([[[halo.push(0, w)]]]))
|
||||
capsule, _ = serialization.serialize(w.handle, x) # TODO(rkn): THIS REQUIRES A WORKER_HANDLE
|
||||
y = serialization.deserialize(w.handle, capsule) # TODO(rkn): THIS REQUIRES A WORKER_HANDLE
|
||||
self.assertEqual(x.shape, y.shape)
|
||||
@@ -85,33 +85,33 @@ class ArraysDistTest(unittest.TestCase):
|
||||
|
||||
x = dist.zeros([9, 25, 51], "float")
|
||||
y = dist.assemble(x)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(y) == np.zeros([9, 25, 51])))
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == np.zeros([9, 25, 51])))
|
||||
|
||||
x = dist.ones([11, 25, 49], dtype_name="float")
|
||||
y = dist.assemble(x)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(y) == np.ones([11, 25, 49])))
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == np.ones([11, 25, 49])))
|
||||
|
||||
x = dist.random.normal([11, 25, 49])
|
||||
y = dist.copy(x)
|
||||
z = dist.assemble(x)
|
||||
w = dist.assemble(y)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(z) == orchpy.pull(w)))
|
||||
self.assertTrue(np.alltrue(halo.pull(z) == halo.pull(w)))
|
||||
|
||||
x = dist.eye(25, dtype_name="float")
|
||||
y = dist.assemble(x)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(y) == np.eye(25)))
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == np.eye(25)))
|
||||
|
||||
x = dist.random.normal([25, 49])
|
||||
y = dist.triu(x)
|
||||
z = dist.assemble(y)
|
||||
w = dist.assemble(x)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(z) == np.triu(orchpy.pull(w))))
|
||||
self.assertTrue(np.alltrue(halo.pull(z) == np.triu(halo.pull(w))))
|
||||
|
||||
x = dist.random.normal([25, 49])
|
||||
y = dist.tril(x)
|
||||
z = dist.assemble(y)
|
||||
w = dist.assemble(x)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(z) == np.tril(orchpy.pull(w))))
|
||||
self.assertTrue(np.alltrue(halo.pull(z) == np.tril(halo.pull(w))))
|
||||
|
||||
x = dist.random.normal([25, 49])
|
||||
y = dist.random.normal([49, 18])
|
||||
@@ -119,8 +119,8 @@ class ArraysDistTest(unittest.TestCase):
|
||||
w = dist.assemble(z)
|
||||
u = dist.assemble(x)
|
||||
v = dist.assemble(y)
|
||||
np.allclose(orchpy.pull(w), np.dot(orchpy.pull(u), orchpy.pull(v)))
|
||||
self.assertTrue(np.allclose(orchpy.pull(w), np.dot(orchpy.pull(u), orchpy.pull(v))))
|
||||
np.allclose(halo.pull(w), np.dot(halo.pull(u), halo.pull(v)))
|
||||
self.assertTrue(np.allclose(halo.pull(w), np.dot(halo.pull(u), halo.pull(v))))
|
||||
|
||||
# test add
|
||||
x = dist.random.normal([23, 42])
|
||||
@@ -129,7 +129,7 @@ class ArraysDistTest(unittest.TestCase):
|
||||
z_full = dist.assemble(z)
|
||||
x_full = dist.assemble(x)
|
||||
y_full = dist.assemble(y)
|
||||
self.assertTrue(np.allclose(orchpy.pull(z_full), orchpy.pull(x_full) + orchpy.pull(y_full)))
|
||||
self.assertTrue(np.allclose(halo.pull(z_full), halo.pull(x_full) + halo.pull(y_full)))
|
||||
|
||||
# test subtract
|
||||
x = dist.random.normal([33, 40])
|
||||
@@ -138,14 +138,14 @@ class ArraysDistTest(unittest.TestCase):
|
||||
z_full = dist.assemble(z)
|
||||
x_full = dist.assemble(x)
|
||||
y_full = dist.assemble(y)
|
||||
self.assertTrue(np.allclose(orchpy.pull(z_full), orchpy.pull(x_full) - orchpy.pull(y_full)))
|
||||
self.assertTrue(np.allclose(halo.pull(z_full), halo.pull(x_full) - halo.pull(y_full)))
|
||||
|
||||
# test transpose
|
||||
x = dist.random.normal([234, 432])
|
||||
y = dist.transpose(x)
|
||||
x_full = dist.assemble(x)
|
||||
y_full = dist.assemble(y)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(x_full).T == orchpy.pull(y_full)))
|
||||
self.assertTrue(np.alltrue(halo.pull(x_full).T == halo.pull(y_full)))
|
||||
|
||||
# test numpy_to_dist
|
||||
x = dist.random.normal([23, 45])
|
||||
@@ -154,8 +154,8 @@ class ArraysDistTest(unittest.TestCase):
|
||||
w = dist.assemble(z)
|
||||
x_full = dist.assemble(x)
|
||||
z_full = dist.assemble(z)
|
||||
self.assertTrue(np.alltrue(orchpy.pull(x_full) == orchpy.pull(z_full)))
|
||||
self.assertTrue(np.alltrue(orchpy.pull(y) == orchpy.pull(w)))
|
||||
self.assertTrue(np.alltrue(halo.pull(x_full) == halo.pull(z_full)))
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == halo.pull(w)))
|
||||
|
||||
# test dist.tsqr
|
||||
for shape in [[123, dist.BLOCK_SIZE], [7, dist.BLOCK_SIZE], [dist.BLOCK_SIZE, dist.BLOCK_SIZE], [dist.BLOCK_SIZE, 7], [10 * dist.BLOCK_SIZE, dist.BLOCK_SIZE]]:
|
||||
@@ -163,10 +163,10 @@ class ArraysDistTest(unittest.TestCase):
|
||||
K = min(shape)
|
||||
q, r = dist.linalg.tsqr(x)
|
||||
x_full = dist.assemble(x)
|
||||
x_val = orchpy.pull(x_full)
|
||||
x_val = halo.pull(x_full)
|
||||
q_full = dist.assemble(q)
|
||||
q_val = orchpy.pull(q_full)
|
||||
r_val = orchpy.pull(r)
|
||||
q_val = halo.pull(q_full)
|
||||
r_val = halo.pull(r)
|
||||
self.assertTrue(r_val.shape == (K, shape[1]))
|
||||
self.assertTrue(np.alltrue(r_val == np.triu(r_val)))
|
||||
self.assertTrue(np.allclose(x_val, np.dot(q_val, r_val)))
|
||||
@@ -180,12 +180,12 @@ class ArraysDistTest(unittest.TestCase):
|
||||
m = single.random.normal([d1, d2])
|
||||
q, r = single.linalg.qr(m)
|
||||
l, u, s = dist.linalg.modified_lu(dist.numpy_to_dist(q))
|
||||
q_val = orchpy.pull(q)
|
||||
r_val = orchpy.pull(r)
|
||||
q_val = halo.pull(q)
|
||||
r_val = halo.pull(r)
|
||||
l_full = dist.assemble(l)
|
||||
l_val = orchpy.pull(l_full)
|
||||
u_val = orchpy.pull(u)
|
||||
s_val = orchpy.pull(s)
|
||||
l_val = halo.pull(l_full)
|
||||
u_val = halo.pull(u)
|
||||
s_val = halo.pull(s)
|
||||
s_mat = np.zeros((d1, d2))
|
||||
for i in range(len(s_val)):
|
||||
s_mat[i, i] = s_val[i]
|
||||
@@ -202,17 +202,17 @@ class ArraysDistTest(unittest.TestCase):
|
||||
a = dist.random.normal([d1, d2])
|
||||
y, t, y_top, r = dist.linalg.tsqr_hr(a)
|
||||
a_full = dist.assemble(a)
|
||||
a_val = orchpy.pull(a_full)
|
||||
a_val = halo.pull(a_full)
|
||||
y_full = dist.assemble(y)
|
||||
y_val = orchpy.pull(y_full)
|
||||
t_val = orchpy.pull(t)
|
||||
y_top_val = orchpy.pull(y_top)
|
||||
r_val = orchpy.pull(r)
|
||||
y_val = halo.pull(y_full)
|
||||
t_val = halo.pull(t)
|
||||
y_top_val = halo.pull(y_top)
|
||||
r_val = halo.pull(r)
|
||||
tall_eye = np.zeros((d1, min(d1, d2)))
|
||||
np.fill_diagonal(tall_eye, 1)
|
||||
q = tall_eye - np.dot(y_val, np.dot(t_val, y_top_val.T))
|
||||
self.assertTrue(np.allclose(np.dot(q.T, q), np.eye(min(d1, d2)))) # check that q.T * q = I
|
||||
self.assertTrue(np.allclose(np.dot(q, r_val), a_val)) # check that a = (I - y * t * y_top.T) * r
|
||||
self.assertTrue(np.allclose(np.dot(q, r_val), a_val)) # check that a = (I - y * t * y_thalo.T) * r
|
||||
|
||||
for d1, d2 in [(123, dist.BLOCK_SIZE), (7, dist.BLOCK_SIZE), (dist.BLOCK_SIZE, dist.BLOCK_SIZE), (dist.BLOCK_SIZE, 7), (10 * dist.BLOCK_SIZE, dist.BLOCK_SIZE)]:
|
||||
test_dist_tsqr_hr(d1, d2)
|
||||
@@ -225,9 +225,9 @@ class ArraysDistTest(unittest.TestCase):
|
||||
a_full = dist.assemble(a)
|
||||
q_full = dist.assemble(q)
|
||||
r_full = dist.assemble(r)
|
||||
a_val = orchpy.pull(a_full)
|
||||
q_val = orchpy.pull(q_full)
|
||||
r_val = orchpy.pull(r_full)
|
||||
a_val = halo.pull(a_full)
|
||||
q_val = halo.pull(q_full)
|
||||
r_val = halo.pull(r_full)
|
||||
|
||||
self.assertTrue(q_val.shape == (d1, K))
|
||||
self.assertTrue(r_val.shape == (K, d2))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# For running the python tests
|
||||
|
||||
protoc -I ../protos/ --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../protos/orchestra.proto
|
||||
protoc -I ../protos/ --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../protos/halo.proto
|
||||
protoc -I ../protos/ --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../protos/types.proto
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
import orchpy
|
||||
import orchpy.services as services
|
||||
import halo
|
||||
import halo.services as services
|
||||
import time
|
||||
import os
|
||||
import numpy as np
|
||||
@@ -51,7 +51,7 @@ class MicroBenchmarkTest(unittest.TestCase):
|
||||
for _ in range(1000):
|
||||
start_time = time.time()
|
||||
x = test_functions.trivial_function()
|
||||
orchpy.pull(x)
|
||||
halo.pull(x)
|
||||
end_time = time.time()
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
@@ -67,7 +67,7 @@ class MicroBenchmarkTest(unittest.TestCase):
|
||||
elapsed_times = []
|
||||
for _ in range(1000):
|
||||
start_time = time.time()
|
||||
orchpy.push(1)
|
||||
halo.push(1)
|
||||
end_time = time.time()
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
|
||||
+49
-49
@@ -1,8 +1,8 @@
|
||||
import unittest
|
||||
import orchpy
|
||||
import orchpy.serialization as serialization
|
||||
import orchpy.services as services
|
||||
import orchpy.worker as worker
|
||||
import halo
|
||||
import halo.serialization as serialization
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
import numpy as np
|
||||
import time
|
||||
import subprocess32 as subprocess
|
||||
@@ -10,7 +10,7 @@ import os
|
||||
|
||||
from google.protobuf.text_format import *
|
||||
|
||||
import orchestra_pb2
|
||||
import halo_pb2
|
||||
import types_pb2
|
||||
|
||||
import test_functions
|
||||
@@ -61,10 +61,10 @@ class SerializationTest(unittest.TestCase):
|
||||
self.numpyTypeTest(w, 'float32')
|
||||
self.numpyTypeTest(w, 'float64')
|
||||
|
||||
ref0 = orchpy.push(0, w)
|
||||
ref1 = orchpy.push(0, w)
|
||||
ref2 = orchpy.push(0, w)
|
||||
ref3 = orchpy.push(0, w)
|
||||
ref0 = halo.push(0, w)
|
||||
ref1 = halo.push(0, w)
|
||||
ref2 = halo.push(0, w)
|
||||
ref3 = halo.push(0, w)
|
||||
a = np.array([[ref0, ref1], [ref2, ref3]])
|
||||
capsule, _ = serialization.serialize(w.handle, a)
|
||||
result = serialization.deserialize(w.handle, capsule)
|
||||
@@ -80,8 +80,8 @@ class ObjStoreTest(unittest.TestCase):
|
||||
|
||||
# pushing and pulling an object shouldn't change it
|
||||
for data in ["h", "h" * 10000, 0, 0.0]:
|
||||
objref = orchpy.push(data, w1)
|
||||
result = orchpy.pull(objref, w1)
|
||||
objref = halo.push(data, w1)
|
||||
result = halo.pull(objref, w1)
|
||||
self.assertEqual(result, data)
|
||||
|
||||
# pushing an object, shipping it to another worker, and pulling it shouldn't change it
|
||||
@@ -134,7 +134,7 @@ class SchedulerTest(unittest.TestCase):
|
||||
|
||||
time.sleep(0.2)
|
||||
|
||||
value_after = orchpy.pull(objref[0], w)
|
||||
value_after = halo.pull(objref[0], w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
time.sleep(0.1)
|
||||
@@ -148,26 +148,26 @@ class WorkerTest(unittest.TestCase):
|
||||
|
||||
for i in range(100):
|
||||
value_before = i * 10 ** 6
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = i * 10 ** 6 * 1.0
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = "h" * i
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = [1] * i
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
services.cleanup()
|
||||
@@ -180,11 +180,11 @@ class APITest(unittest.TestCase):
|
||||
[w] = services.start_singlenode_cluster(return_drivers=True, num_workers_per_objstore=3, worker_path=test_path)
|
||||
|
||||
objref = w.submit_task("test_functions.test_alias_f", [])
|
||||
self.assertTrue(np.alltrue(orchpy.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
objref = w.submit_task("test_functions.test_alias_g", [])
|
||||
self.assertTrue(np.alltrue(orchpy.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
objref = w.submit_task("test_functions.test_alias_h", [])
|
||||
self.assertTrue(np.alltrue(orchpy.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
|
||||
services.cleanup()
|
||||
|
||||
@@ -193,35 +193,35 @@ class APITest(unittest.TestCase):
|
||||
test_path = os.path.join(test_dir, "testrecv.py")
|
||||
services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path)
|
||||
x = test_functions.keyword_fct1(1)
|
||||
self.assertEqual(orchpy.pull(x), "1 hello")
|
||||
self.assertEqual(halo.pull(x), "1 hello")
|
||||
x = test_functions.keyword_fct1(1, "hi")
|
||||
self.assertEqual(orchpy.pull(x), "1 hi")
|
||||
self.assertEqual(halo.pull(x), "1 hi")
|
||||
x = test_functions.keyword_fct1(1, b="world")
|
||||
self.assertEqual(orchpy.pull(x), "1 world")
|
||||
self.assertEqual(halo.pull(x), "1 world")
|
||||
|
||||
x = test_functions.keyword_fct2(a="w", b="hi")
|
||||
self.assertEqual(orchpy.pull(x), "w hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
x = test_functions.keyword_fct2(b="hi", a="w")
|
||||
self.assertEqual(orchpy.pull(x), "w hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
x = test_functions.keyword_fct2(a="w")
|
||||
self.assertEqual(orchpy.pull(x), "w world")
|
||||
self.assertEqual(halo.pull(x), "w world")
|
||||
x = test_functions.keyword_fct2(b="hi")
|
||||
self.assertEqual(orchpy.pull(x), "hello hi")
|
||||
self.assertEqual(halo.pull(x), "hello hi")
|
||||
x = test_functions.keyword_fct2("w")
|
||||
self.assertEqual(orchpy.pull(x), "w world")
|
||||
self.assertEqual(halo.pull(x), "w world")
|
||||
x = test_functions.keyword_fct2("w", "hi")
|
||||
self.assertEqual(orchpy.pull(x), "w hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
|
||||
x = test_functions.keyword_fct3(0, 1, c="w", d="hi")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 w hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 w hi")
|
||||
x = test_functions.keyword_fct3(0, 1, d="hi", c="w")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 w hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 w hi")
|
||||
x = test_functions.keyword_fct3(0, 1, c="w")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 w world")
|
||||
self.assertEqual(halo.pull(x), "0 1 w world")
|
||||
x = test_functions.keyword_fct3(0, 1, d="hi")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 hello hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 hello hi")
|
||||
x = test_functions.keyword_fct3(0, 1)
|
||||
self.assertEqual(orchpy.pull(x), "0 1 hello world")
|
||||
self.assertEqual(halo.pull(x), "0 1 hello world")
|
||||
|
||||
services.cleanup()
|
||||
|
||||
@@ -233,48 +233,48 @@ class ReferenceCountingTest(unittest.TestCase):
|
||||
services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path)
|
||||
|
||||
x = test_functions.test_alias_f()
|
||||
orchpy.pull(x)
|
||||
halo.pull(x)
|
||||
time.sleep(0.1)
|
||||
objref_val = x.val
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val] == 1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val] == 1)
|
||||
|
||||
del x
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val] == -1) # -1 indicates deallocated
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val] == -1) # -1 indicates deallocated
|
||||
|
||||
y = test_functions.test_alias_h()
|
||||
orchpy.pull(y)
|
||||
halo.pull(y)
|
||||
time.sleep(0.1)
|
||||
objref_val = y.val
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 0, 0])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 0, 0])
|
||||
|
||||
del y
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
z = dist.zeros([dist.BLOCK_SIZE, 2 * dist.BLOCK_SIZE], "float")
|
||||
time.sleep(0.1)
|
||||
objref_val = z.val
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
|
||||
del z
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
x = single.zeros([10, 10], "float")
|
||||
y = single.zeros([10, 10], "float")
|
||||
z = single.dot(x, y)
|
||||
objref_val = x.val
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
|
||||
del x
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, 1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, 1, 1])
|
||||
del y
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, 1])
|
||||
del z
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
services.cleanup()
|
||||
|
||||
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
import argparse
|
||||
import numpy as np
|
||||
|
||||
import orchpy
|
||||
import orchpy.services as services
|
||||
import orchpy.worker as worker
|
||||
import halo
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
|
||||
import test_functions
|
||||
import arrays.single as single
|
||||
import arrays.dist as dist
|
||||
|
||||
from grpc.beta import implementations
|
||||
import orchestra_pb2
|
||||
import halo_pb2
|
||||
import types_pb2
|
||||
|
||||
TIMEOUT_SECONDS = 5
|
||||
|
||||
+11
-11
@@ -1,54 +1,54 @@
|
||||
import orchpy
|
||||
import halo
|
||||
|
||||
import numpy as np
|
||||
|
||||
# Test simple functionality
|
||||
|
||||
@orchpy.distributed([str], [str])
|
||||
@halo.distributed([str], [str])
|
||||
def print_string(string):
|
||||
print "called print_string with", string
|
||||
f = open("asdfasdf.txt", "w")
|
||||
f.write("successfully called print_string with argument {}.".format(string))
|
||||
return string
|
||||
|
||||
@orchpy.distributed([int, int], [int, int])
|
||||
@halo.distributed([int, int], [int, int])
|
||||
def handle_int(a, b):
|
||||
return a + 1, b + 1
|
||||
|
||||
# Test aliasing
|
||||
|
||||
@orchpy.distributed([], [np.ndarray])
|
||||
@halo.distributed([], [np.ndarray])
|
||||
def test_alias_f():
|
||||
return np.ones([3, 4, 5])
|
||||
|
||||
@orchpy.distributed([], [np.ndarray])
|
||||
@halo.distributed([], [np.ndarray])
|
||||
def test_alias_g():
|
||||
return test_alias_f()
|
||||
|
||||
@orchpy.distributed([], [np.ndarray])
|
||||
@halo.distributed([], [np.ndarray])
|
||||
def test_alias_h():
|
||||
return test_alias_g()
|
||||
|
||||
# Test timing
|
||||
|
||||
@orchpy.distributed([], [])
|
||||
@halo.distributed([], [])
|
||||
def empty_function():
|
||||
return ()
|
||||
|
||||
@orchpy.distributed([], [int])
|
||||
@halo.distributed([], [int])
|
||||
def trivial_function():
|
||||
return 1
|
||||
|
||||
# Test keyword arguments
|
||||
|
||||
@orchpy.distributed([int, str], [str])
|
||||
@halo.distributed([int, str], [str])
|
||||
def keyword_fct1(a, b="hello"):
|
||||
return "{} {}".format(a, b)
|
||||
|
||||
@orchpy.distributed([str, str], [str])
|
||||
@halo.distributed([str, str], [str])
|
||||
def keyword_fct2(a="hello", b="world"):
|
||||
return "{} {}".format(a, b)
|
||||
|
||||
@orchpy.distributed([int, int, str, str], [str])
|
||||
@halo.distributed([int, int, str, str], [str])
|
||||
def keyword_fct3(a, b, c="hello", d="world"):
|
||||
return "{} {} {} {}".format(a, b, c, d)
|
||||
|
||||
+11
-11
@@ -6,9 +6,9 @@ import test_functions
|
||||
import arrays.single as single
|
||||
import arrays.dist as dist
|
||||
|
||||
import orchpy
|
||||
import orchpy.services as services
|
||||
import orchpy.worker as worker
|
||||
import halo
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
|
||||
parser = argparse.ArgumentParser(description='Parse addresses for the worker to connect to.')
|
||||
parser.add_argument("--scheduler-address", default="127.0.0.1:10001", type=str, help="the scheduler's address")
|
||||
@@ -19,13 +19,13 @@ if __name__ == '__main__':
|
||||
args = parser.parse_args()
|
||||
worker.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
|
||||
orchpy.register_module(test_functions)
|
||||
orchpy.register_module(single)
|
||||
orchpy.register_module(single.random)
|
||||
orchpy.register_module(single.linalg)
|
||||
orchpy.register_module(dist)
|
||||
orchpy.register_module(dist.random)
|
||||
orchpy.register_module(dist.linalg)
|
||||
orchpy.register_module(sys.modules[__name__])
|
||||
halo.register_module(test_functions)
|
||||
halo.register_module(single)
|
||||
halo.register_module(single.random)
|
||||
halo.register_module(single.linalg)
|
||||
halo.register_module(dist)
|
||||
halo.register_module(dist.random)
|
||||
halo.register_module(dist.linalg)
|
||||
halo.register_module(sys.modules[__name__])
|
||||
|
||||
worker.main_loop()
|
||||
|
||||
Reference in New Issue
Block a user