mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 06:30:44 +08:00
renaming project, halo -> ray (#95)
This commit is contained in:
committed by
Philipp Moritz
parent
44ae1788ee
commit
4cc024ae36
+44
-44
@@ -1,15 +1,15 @@
|
||||
import unittest
|
||||
import halo
|
||||
import halo.serialization as serialization
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
import ray
|
||||
import ray.serialization as serialization
|
||||
import ray.services as services
|
||||
import ray.worker as worker
|
||||
import numpy as np
|
||||
import time
|
||||
import subprocess32 as subprocess
|
||||
import os
|
||||
|
||||
import halo.arrays.remote as ra
|
||||
import halo.arrays.distributed as da
|
||||
import ray.arrays.remote as ra
|
||||
import ray.arrays.distributed as da
|
||||
|
||||
class ArraysSingleTest(unittest.TestCase):
|
||||
|
||||
@@ -20,27 +20,27 @@ class ArraysSingleTest(unittest.TestCase):
|
||||
|
||||
# test eye
|
||||
ref = ra.eye(3)
|
||||
val = halo.pull(ref)
|
||||
val = ray.pull(ref)
|
||||
self.assertTrue(np.alltrue(val == np.eye(3)))
|
||||
|
||||
# test zeros
|
||||
ref = ra.zeros([3, 4, 5])
|
||||
val = halo.pull(ref)
|
||||
val = ray.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 = ra.linalg.qr(val_a)
|
||||
val_q = halo.pull(ref_q)
|
||||
val_r = halo.pull(ref_r)
|
||||
val_q = ray.pull(ref_q)
|
||||
val_r = ray.pull(ref_r)
|
||||
self.assertTrue(np.allclose(np.dot(val_q, val_r), val_a))
|
||||
|
||||
# test qr - pass by objref
|
||||
a = ra.random.normal([10, 13])
|
||||
ref_q, ref_r = ra.linalg.qr(a)
|
||||
val_a = halo.pull(a)
|
||||
val_q = halo.pull(ref_q)
|
||||
val_r = halo.pull(ref_r)
|
||||
val_a = ray.pull(a)
|
||||
val_q = ray.pull(ref_q)
|
||||
val_r = ray.pull(ref_r)
|
||||
self.assertTrue(np.allclose(np.dot(val_q, val_r), val_a))
|
||||
|
||||
services.cleanup()
|
||||
@@ -51,7 +51,7 @@ class ArraysDistTest(unittest.TestCase):
|
||||
[w] = services.start_singlenode_cluster(return_drivers=True)
|
||||
|
||||
x = da.DistArray()
|
||||
x.construct([2, 3, 4], np.array([[[halo.push(0, w)]]]))
|
||||
x.construct([2, 3, 4], np.array([[[ray.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)
|
||||
@@ -79,33 +79,33 @@ class ArraysDistTest(unittest.TestCase):
|
||||
|
||||
x = da.zeros([9, 25, 51], "float")
|
||||
y = da.assemble(x)
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == np.zeros([9, 25, 51])))
|
||||
self.assertTrue(np.alltrue(ray.pull(y) == np.zeros([9, 25, 51])))
|
||||
|
||||
x = da.ones([11, 25, 49], dtype_name="float")
|
||||
y = da.assemble(x)
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == np.ones([11, 25, 49])))
|
||||
self.assertTrue(np.alltrue(ray.pull(y) == np.ones([11, 25, 49])))
|
||||
|
||||
x = da.random.normal([11, 25, 49])
|
||||
y = da.copy(x)
|
||||
z = da.assemble(x)
|
||||
w = da.assemble(y)
|
||||
self.assertTrue(np.alltrue(halo.pull(z) == halo.pull(w)))
|
||||
self.assertTrue(np.alltrue(ray.pull(z) == ray.pull(w)))
|
||||
|
||||
x = da.eye(25, dtype_name="float")
|
||||
y = da.assemble(x)
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == np.eye(25)))
|
||||
self.assertTrue(np.alltrue(ray.pull(y) == np.eye(25)))
|
||||
|
||||
x = da.random.normal([25, 49])
|
||||
y = da.triu(x)
|
||||
z = da.assemble(y)
|
||||
w = da.assemble(x)
|
||||
self.assertTrue(np.alltrue(halo.pull(z) == np.triu(halo.pull(w))))
|
||||
self.assertTrue(np.alltrue(ray.pull(z) == np.triu(ray.pull(w))))
|
||||
|
||||
x = da.random.normal([25, 49])
|
||||
y = da.tril(x)
|
||||
z = da.assemble(y)
|
||||
w = da.assemble(x)
|
||||
self.assertTrue(np.alltrue(halo.pull(z) == np.tril(halo.pull(w))))
|
||||
self.assertTrue(np.alltrue(ray.pull(z) == np.tril(ray.pull(w))))
|
||||
|
||||
x = da.random.normal([25, 49])
|
||||
y = da.random.normal([49, 18])
|
||||
@@ -113,8 +113,8 @@ class ArraysDistTest(unittest.TestCase):
|
||||
w = da.assemble(z)
|
||||
u = da.assemble(x)
|
||||
v = da.assemble(y)
|
||||
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))))
|
||||
np.allclose(ray.pull(w), np.dot(ray.pull(u), ray.pull(v)))
|
||||
self.assertTrue(np.allclose(ray.pull(w), np.dot(ray.pull(u), ray.pull(v))))
|
||||
|
||||
# test add
|
||||
x = da.random.normal([23, 42])
|
||||
@@ -123,7 +123,7 @@ class ArraysDistTest(unittest.TestCase):
|
||||
z_full = da.assemble(z)
|
||||
x_full = da.assemble(x)
|
||||
y_full = da.assemble(y)
|
||||
self.assertTrue(np.allclose(halo.pull(z_full), halo.pull(x_full) + halo.pull(y_full)))
|
||||
self.assertTrue(np.allclose(ray.pull(z_full), ray.pull(x_full) + ray.pull(y_full)))
|
||||
|
||||
# test subtract
|
||||
x = da.random.normal([33, 40])
|
||||
@@ -132,14 +132,14 @@ class ArraysDistTest(unittest.TestCase):
|
||||
z_full = da.assemble(z)
|
||||
x_full = da.assemble(x)
|
||||
y_full = da.assemble(y)
|
||||
self.assertTrue(np.allclose(halo.pull(z_full), halo.pull(x_full) - halo.pull(y_full)))
|
||||
self.assertTrue(np.allclose(ray.pull(z_full), ray.pull(x_full) - ray.pull(y_full)))
|
||||
|
||||
# test transpose
|
||||
x = da.random.normal([234, 432])
|
||||
y = da.transpose(x)
|
||||
x_full = da.assemble(x)
|
||||
y_full = da.assemble(y)
|
||||
self.assertTrue(np.alltrue(halo.pull(x_full).T == halo.pull(y_full)))
|
||||
self.assertTrue(np.alltrue(ray.pull(x_full).T == ray.pull(y_full)))
|
||||
|
||||
# test numpy_to_dist
|
||||
x = da.random.normal([23, 45])
|
||||
@@ -148,8 +148,8 @@ class ArraysDistTest(unittest.TestCase):
|
||||
w = da.assemble(z)
|
||||
x_full = da.assemble(x)
|
||||
z_full = da.assemble(z)
|
||||
self.assertTrue(np.alltrue(halo.pull(x_full) == halo.pull(z_full)))
|
||||
self.assertTrue(np.alltrue(halo.pull(y) == halo.pull(w)))
|
||||
self.assertTrue(np.alltrue(ray.pull(x_full) == ray.pull(z_full)))
|
||||
self.assertTrue(np.alltrue(ray.pull(y) == ray.pull(w)))
|
||||
|
||||
# test da.tsqr
|
||||
for shape in [[123, da.BLOCK_SIZE], [7, da.BLOCK_SIZE], [da.BLOCK_SIZE, da.BLOCK_SIZE], [da.BLOCK_SIZE, 7], [10 * da.BLOCK_SIZE, da.BLOCK_SIZE]]:
|
||||
@@ -157,10 +157,10 @@ class ArraysDistTest(unittest.TestCase):
|
||||
K = min(shape)
|
||||
q, r = da.linalg.tsqr(x)
|
||||
x_full = da.assemble(x)
|
||||
x_val = halo.pull(x_full)
|
||||
x_val = ray.pull(x_full)
|
||||
q_full = da.assemble(q)
|
||||
q_val = halo.pull(q_full)
|
||||
r_val = halo.pull(r)
|
||||
q_val = ray.pull(q_full)
|
||||
r_val = ray.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)))
|
||||
@@ -174,12 +174,12 @@ class ArraysDistTest(unittest.TestCase):
|
||||
m = ra.random.normal([d1, d2])
|
||||
q, r = ra.linalg.qr(m)
|
||||
l, u, s = da.linalg.modified_lu(da.numpy_to_dist(q))
|
||||
q_val = halo.pull(q)
|
||||
r_val = halo.pull(r)
|
||||
q_val = ray.pull(q)
|
||||
r_val = ray.pull(r)
|
||||
l_full = da.assemble(l)
|
||||
l_val = halo.pull(l_full)
|
||||
u_val = halo.pull(u)
|
||||
s_val = halo.pull(s)
|
||||
l_val = ray.pull(l_full)
|
||||
u_val = ray.pull(u)
|
||||
s_val = ray.pull(s)
|
||||
s_mat = np.zeros((d1, d2))
|
||||
for i in range(len(s_val)):
|
||||
s_mat[i, i] = s_val[i]
|
||||
@@ -196,17 +196,17 @@ class ArraysDistTest(unittest.TestCase):
|
||||
a = da.random.normal([d1, d2])
|
||||
y, t, y_top, r = da.linalg.tsqr_hr(a)
|
||||
a_full = da.assemble(a)
|
||||
a_val = halo.pull(a_full)
|
||||
a_val = ray.pull(a_full)
|
||||
y_full = da.assemble(y)
|
||||
y_val = halo.pull(y_full)
|
||||
t_val = halo.pull(t)
|
||||
y_top_val = halo.pull(y_top)
|
||||
r_val = halo.pull(r)
|
||||
y_val = ray.pull(y_full)
|
||||
t_val = ray.pull(t)
|
||||
y_top_val = ray.pull(y_top)
|
||||
r_val = ray.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_thalo.T) * r
|
||||
self.assertTrue(np.allclose(np.dot(q, r_val), a_val)) # check that a = (I - y * t * y_top.T) * r
|
||||
|
||||
for d1, d2 in [(123, da.BLOCK_SIZE), (7, da.BLOCK_SIZE), (da.BLOCK_SIZE, da.BLOCK_SIZE), (da.BLOCK_SIZE, 7), (10 * da.BLOCK_SIZE, da.BLOCK_SIZE)]:
|
||||
test_dist_tsqr_hr(d1, d2)
|
||||
@@ -219,9 +219,9 @@ class ArraysDistTest(unittest.TestCase):
|
||||
a_full = da.assemble(a)
|
||||
q_full = da.assemble(q)
|
||||
r_full = da.assemble(r)
|
||||
a_val = halo.pull(a_full)
|
||||
q_val = halo.pull(q_full)
|
||||
r_val = halo.pull(r_full)
|
||||
a_val = ray.pull(a_full)
|
||||
q_val = ray.pull(q_full)
|
||||
r_val = ray.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/halo.proto
|
||||
protoc -I ../protos/ --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../protos/ray.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 halo
|
||||
import halo.services as services
|
||||
import ray
|
||||
import ray.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()
|
||||
halo.pull(x)
|
||||
ray.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()
|
||||
halo.push(1)
|
||||
ray.push(1)
|
||||
end_time = time.time()
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
|
||||
+52
-52
@@ -1,16 +1,16 @@
|
||||
import unittest
|
||||
import halo
|
||||
import halo.serialization as serialization
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
import ray
|
||||
import ray.serialization as serialization
|
||||
import ray.services as services
|
||||
import ray.worker as worker
|
||||
import numpy as np
|
||||
import time
|
||||
import subprocess32 as subprocess
|
||||
import os
|
||||
|
||||
import test_functions
|
||||
import halo.arrays.remote as ra
|
||||
import halo.arrays.distributed as da
|
||||
import ray.arrays.remote as ra
|
||||
import ray.arrays.distributed as da
|
||||
|
||||
class SerializationTest(unittest.TestCase):
|
||||
|
||||
@@ -56,10 +56,10 @@ class SerializationTest(unittest.TestCase):
|
||||
self.numpyTypeTest(w, 'float32')
|
||||
self.numpyTypeTest(w, 'float64')
|
||||
|
||||
ref0 = halo.push(0, w)
|
||||
ref1 = halo.push(0, w)
|
||||
ref2 = halo.push(0, w)
|
||||
ref3 = halo.push(0, w)
|
||||
ref0 = ray.push(0, w)
|
||||
ref1 = ray.push(0, w)
|
||||
ref2 = ray.push(0, w)
|
||||
ref3 = ray.push(0, w)
|
||||
a = np.array([[ref0, ref1], [ref2, ref3]])
|
||||
capsule, _ = serialization.serialize(w.handle, a)
|
||||
result = serialization.deserialize(w.handle, capsule)
|
||||
@@ -75,8 +75,8 @@ class ObjStoreTest(unittest.TestCase):
|
||||
|
||||
# pushing and pulling an object shouldn't change it
|
||||
for data in ["h", "h" * 10000, 0, 0.0]:
|
||||
objref = halo.push(data, w1)
|
||||
result = halo.pull(objref, w1)
|
||||
objref = ray.push(data, w1)
|
||||
result = ray.pull(objref, w1)
|
||||
self.assertEqual(result, data)
|
||||
|
||||
# pushing an object, shipping it to another worker, and pulling it shouldn't change it
|
||||
@@ -129,7 +129,7 @@ class SchedulerTest(unittest.TestCase):
|
||||
|
||||
time.sleep(0.2)
|
||||
|
||||
value_after = halo.pull(objref[0], w)
|
||||
value_after = ray.pull(objref[0], w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
time.sleep(0.1)
|
||||
@@ -143,26 +143,26 @@ class WorkerTest(unittest.TestCase):
|
||||
|
||||
for i in range(100):
|
||||
value_before = i * 10 ** 6
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
objref = ray.push(value_before, w)
|
||||
value_after = ray.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = i * 10 ** 6 * 1.0
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
objref = ray.push(value_before, w)
|
||||
value_after = ray.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = "h" * i
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
objref = ray.push(value_before, w)
|
||||
value_after = ray.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = [1] * i
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
objref = ray.push(value_before, w)
|
||||
value_after = ray.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
services.cleanup()
|
||||
@@ -175,11 +175,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(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(ray.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
objref = w.submit_task("test_functions.test_alias_g", [])
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(ray.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
objref = w.submit_task("test_functions.test_alias_h", [])
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(ray.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
|
||||
services.cleanup()
|
||||
|
||||
@@ -189,35 +189,35 @@ class APITest(unittest.TestCase):
|
||||
services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=test_path)
|
||||
|
||||
x = test_functions.keyword_fct1(1)
|
||||
self.assertEqual(halo.pull(x), "1 hello")
|
||||
self.assertEqual(ray.pull(x), "1 hello")
|
||||
x = test_functions.keyword_fct1(1, "hi")
|
||||
self.assertEqual(halo.pull(x), "1 hi")
|
||||
self.assertEqual(ray.pull(x), "1 hi")
|
||||
x = test_functions.keyword_fct1(1, b="world")
|
||||
self.assertEqual(halo.pull(x), "1 world")
|
||||
self.assertEqual(ray.pull(x), "1 world")
|
||||
|
||||
x = test_functions.keyword_fct2(a="w", b="hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
self.assertEqual(ray.pull(x), "w hi")
|
||||
x = test_functions.keyword_fct2(b="hi", a="w")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
self.assertEqual(ray.pull(x), "w hi")
|
||||
x = test_functions.keyword_fct2(a="w")
|
||||
self.assertEqual(halo.pull(x), "w world")
|
||||
self.assertEqual(ray.pull(x), "w world")
|
||||
x = test_functions.keyword_fct2(b="hi")
|
||||
self.assertEqual(halo.pull(x), "hello hi")
|
||||
self.assertEqual(ray.pull(x), "hello hi")
|
||||
x = test_functions.keyword_fct2("w")
|
||||
self.assertEqual(halo.pull(x), "w world")
|
||||
self.assertEqual(ray.pull(x), "w world")
|
||||
x = test_functions.keyword_fct2("w", "hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
self.assertEqual(ray.pull(x), "w hi")
|
||||
|
||||
x = test_functions.keyword_fct3(0, 1, c="w", d="hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 w hi")
|
||||
self.assertEqual(ray.pull(x), "0 1 w hi")
|
||||
x = test_functions.keyword_fct3(0, 1, d="hi", c="w")
|
||||
self.assertEqual(halo.pull(x), "0 1 w hi")
|
||||
self.assertEqual(ray.pull(x), "0 1 w hi")
|
||||
x = test_functions.keyword_fct3(0, 1, c="w")
|
||||
self.assertEqual(halo.pull(x), "0 1 w world")
|
||||
self.assertEqual(ray.pull(x), "0 1 w world")
|
||||
x = test_functions.keyword_fct3(0, 1, d="hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 hello hi")
|
||||
self.assertEqual(ray.pull(x), "0 1 hello hi")
|
||||
x = test_functions.keyword_fct3(0, 1)
|
||||
self.assertEqual(halo.pull(x), "0 1 hello world")
|
||||
self.assertEqual(ray.pull(x), "0 1 hello world")
|
||||
|
||||
services.cleanup()
|
||||
|
||||
@@ -227,9 +227,9 @@ class APITest(unittest.TestCase):
|
||||
services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=test_path)
|
||||
|
||||
x = test_functions.varargs_fct1(0, 1, 2)
|
||||
self.assertEqual(halo.pull(x), "0 1 2")
|
||||
self.assertEqual(ray.pull(x), "0 1 2")
|
||||
x = test_functions.varargs_fct2(0, 1, 2)
|
||||
self.assertEqual(halo.pull(x), "1 2")
|
||||
self.assertEqual(ray.pull(x), "1 2")
|
||||
|
||||
self.assertTrue(test_functions.kwargs_exception_thrown)
|
||||
self.assertTrue(test_functions.varargs_and_kwargs_exception_thrown)
|
||||
@@ -244,48 +244,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()
|
||||
halo.pull(x)
|
||||
ray.pull(x)
|
||||
time.sleep(0.1)
|
||||
objref_val = x.val
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val] == 1)
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val] == 1)
|
||||
|
||||
del x
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val] == -1) # -1 indicates deallocated
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val] == -1) # -1 indicates deallocated
|
||||
|
||||
y = test_functions.test_alias_h()
|
||||
halo.pull(y)
|
||||
ray.pull(y)
|
||||
time.sleep(0.1)
|
||||
objref_val = y.val
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 0, 0])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 0, 0])
|
||||
|
||||
del y
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
z = da.zeros([da.BLOCK_SIZE, 2 * da.BLOCK_SIZE], "float")
|
||||
time.sleep(0.1)
|
||||
objref_val = z.val
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
|
||||
del z
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
x = ra.zeros([10, 10], "float")
|
||||
y = ra.zeros([10, 10], "float")
|
||||
z = ra.dot(x, y)
|
||||
objref_val = x.val
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
|
||||
del x
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, 1, 1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, 1, 1])
|
||||
del y
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, 1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, 1])
|
||||
del z
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(ray.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
services.cleanup()
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import argparse
|
||||
import numpy as np
|
||||
|
||||
import halo
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
|
||||
import test_functions
|
||||
import halo.arrays.remote as ra
|
||||
import halo.arrays.distributed as da
|
||||
|
||||
from grpc.beta import implementations
|
||||
import halo_pb2
|
||||
import types_pb2
|
||||
|
||||
TIMEOUT_SECONDS = 5
|
||||
|
||||
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")
|
||||
parser.add_argument("--objstore-address", default="127.0.0.1:20001", type=str, help="the objstore's address")
|
||||
parser.add_argument("--worker-address", default="127.0.0.1:30001", type=str, help="the worker's address")
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = parser.parse_args()
|
||||
worker.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
|
||||
import IPython
|
||||
IPython.embed()
|
||||
+15
-15
@@ -1,70 +1,70 @@
|
||||
import halo
|
||||
import ray
|
||||
|
||||
import numpy as np
|
||||
|
||||
# Test simple functionality
|
||||
|
||||
@halo.remote([str], [str])
|
||||
@ray.remote([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
|
||||
|
||||
@halo.remote([int, int], [int, int])
|
||||
@ray.remote([int, int], [int, int])
|
||||
def handle_int(a, b):
|
||||
return a + 1, b + 1
|
||||
|
||||
# Test aliasing
|
||||
|
||||
@halo.remote([], [np.ndarray])
|
||||
@ray.remote([], [np.ndarray])
|
||||
def test_alias_f():
|
||||
return np.ones([3, 4, 5])
|
||||
|
||||
@halo.remote([], [np.ndarray])
|
||||
@ray.remote([], [np.ndarray])
|
||||
def test_alias_g():
|
||||
return test_alias_f()
|
||||
|
||||
@halo.remote([], [np.ndarray])
|
||||
@ray.remote([], [np.ndarray])
|
||||
def test_alias_h():
|
||||
return test_alias_g()
|
||||
|
||||
# Test timing
|
||||
|
||||
@halo.remote([], [])
|
||||
@ray.remote([], [])
|
||||
def empty_function():
|
||||
return ()
|
||||
|
||||
@halo.remote([], [int])
|
||||
@ray.remote([], [int])
|
||||
def trivial_function():
|
||||
return 1
|
||||
|
||||
# Test keyword arguments
|
||||
|
||||
@halo.remote([int, str], [str])
|
||||
@ray.remote([int, str], [str])
|
||||
def keyword_fct1(a, b="hello"):
|
||||
return "{} {}".format(a, b)
|
||||
|
||||
@halo.remote([str, str], [str])
|
||||
@ray.remote([str, str], [str])
|
||||
def keyword_fct2(a="hello", b="world"):
|
||||
return "{} {}".format(a, b)
|
||||
|
||||
@halo.remote([int, int, str, str], [str])
|
||||
@ray.remote([int, int, str, str], [str])
|
||||
def keyword_fct3(a, b, c="hello", d="world"):
|
||||
return "{} {} {} {}".format(a, b, c, d)
|
||||
|
||||
# Test variable numbers of arguments
|
||||
|
||||
@halo.remote([int], [str])
|
||||
@ray.remote([int], [str])
|
||||
def varargs_fct1(*a):
|
||||
return " ".join(map(str, a))
|
||||
|
||||
@halo.remote([int, int], [str])
|
||||
@ray.remote([int, int], [str])
|
||||
def varargs_fct2(a, *b):
|
||||
return " ".join(map(str, b))
|
||||
|
||||
try:
|
||||
@halo.remote([int], [])
|
||||
@ray.remote([int], [])
|
||||
def kwargs_throw_exception(**c):
|
||||
return ()
|
||||
kwargs_exception_thrown = False
|
||||
@@ -72,7 +72,7 @@ except:
|
||||
kwargs_exception_thrown = True
|
||||
|
||||
try:
|
||||
@halo.remote([int, str, int], [str])
|
||||
@ray.remote([int, str, int], [str])
|
||||
def varargs_and_kwargs_throw_exception(a, b="hi", *c):
|
||||
return "{} {} {}".format(a, b, c)
|
||||
varargs_and_kwargs_exception_thrown = False
|
||||
|
||||
+13
-13
@@ -3,12 +3,12 @@ import argparse
|
||||
import numpy as np
|
||||
|
||||
import test_functions
|
||||
import halo.arrays.remote as ra
|
||||
import halo.arrays.distributed as da
|
||||
import ray.arrays.remote as ra
|
||||
import ray.arrays.distributed as da
|
||||
|
||||
import halo
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
import ray
|
||||
import ray.services as services
|
||||
import ray.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)
|
||||
|
||||
halo.register_module(test_functions)
|
||||
halo.register_module(ra)
|
||||
halo.register_module(ra.random)
|
||||
halo.register_module(ra.linalg)
|
||||
halo.register_module(da)
|
||||
halo.register_module(da.random)
|
||||
halo.register_module(da.linalg)
|
||||
halo.register_module(sys.modules[__name__])
|
||||
ray.register_module(test_functions)
|
||||
ray.register_module(ra)
|
||||
ray.register_module(ra.random)
|
||||
ray.register_module(ra.linalg)
|
||||
ray.register_module(da)
|
||||
ray.register_module(da.random)
|
||||
ray.register_module(da.linalg)
|
||||
ray.register_module(sys.modules[__name__])
|
||||
|
||||
worker.main_loop()
|
||||
|
||||
Reference in New Issue
Block a user