mirror of
https://github.com/wassname/ray.git
synced 2026-08-08 11:25:28 +08:00
Remove local/global_scheduler from code and doc. (#4549)
This commit is contained in:
committed by
Philipp Moritz
parent
51dae23d5c
commit
c2349cf12d
@@ -873,7 +873,7 @@ def test_actor_load_balancing(ray_start_cluster):
|
||||
num_attempts = 20
|
||||
minimum_count = 5
|
||||
|
||||
# Make sure that actors are spread between the local schedulers.
|
||||
# Make sure that actors are spread between the raylets.
|
||||
attempts = 0
|
||||
while attempts < num_attempts:
|
||||
actors = [Actor1.remote() for _ in range(num_actors)]
|
||||
@@ -1363,7 +1363,7 @@ def test_exception_raised_when_actor_node_dies(ray_start_cluster_head):
|
||||
self.x += 1
|
||||
return self.x
|
||||
|
||||
# Create an actor that is not on the local scheduler.
|
||||
# Create an actor that is not on the raylet.
|
||||
actor = Counter.remote()
|
||||
while (ray.get(actor.local_plasma.remote()) !=
|
||||
remote_node.plasma_store_socket_name):
|
||||
@@ -1496,7 +1496,7 @@ def setup_counter_actor(test_checkpoint=False,
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# Create an actor that is not on the local scheduler.
|
||||
# Create an actor that is not on the raylet.
|
||||
actor = Counter.remote(save_exception)
|
||||
while ray.get(actor.local_plasma.remote()) == local_plasma:
|
||||
actor = Counter.remote(save_exception)
|
||||
@@ -1531,7 +1531,7 @@ def test_distributed_handle(ray_start_cluster_2_nodes):
|
||||
count += num_incs * num_iters
|
||||
|
||||
# Kill the second plasma store to get rid of the cached objects and
|
||||
# trigger the corresponding local scheduler to exit.
|
||||
# trigger the corresponding raylet to exit.
|
||||
cluster.list_all_nodes()[1].kill_plasma_store(wait=True)
|
||||
|
||||
# Check that the actor did not restore from a checkpoint.
|
||||
@@ -1570,7 +1570,7 @@ def test_remote_checkpoint_distributed_handle(ray_start_cluster_2_nodes):
|
||||
count += num_incs * num_iters
|
||||
|
||||
# Kill the second plasma store to get rid of the cached objects and
|
||||
# trigger the corresponding local scheduler to exit.
|
||||
# trigger the corresponding raylet to exit.
|
||||
cluster.list_all_nodes()[1].kill_plasma_store(wait=True)
|
||||
|
||||
# Check that the actor restored from a checkpoint.
|
||||
@@ -1610,7 +1610,7 @@ def test_checkpoint_distributed_handle(ray_start_cluster_2_nodes):
|
||||
count += num_incs * num_iters
|
||||
|
||||
# Kill the second plasma store to get rid of the cached objects and
|
||||
# trigger the corresponding local scheduler to exit.
|
||||
# trigger the corresponding raylet to exit.
|
||||
cluster.list_all_nodes()[1].kill_plasma_store(wait=True)
|
||||
|
||||
# Check that the actor restored from a checkpoint.
|
||||
@@ -1638,7 +1638,7 @@ def _test_nondeterministic_reconstruction(
|
||||
def read(self):
|
||||
return self.queue
|
||||
|
||||
# Schedule the shared queue onto the remote local scheduler.
|
||||
# Schedule the shared queue onto the remote raylet.
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
actor = Queue.remote()
|
||||
while ray.get(actor.local_plasma.remote()) == local_plasma:
|
||||
@@ -1673,7 +1673,7 @@ def _test_nondeterministic_reconstruction(
|
||||
queue = ray.get(actor.read.remote())
|
||||
|
||||
# Kill the second plasma store to get rid of the cached objects and
|
||||
# trigger the corresponding local scheduler to exit.
|
||||
# trigger the corresponding raylet to exit.
|
||||
cluster.list_all_nodes()[1].kill_plasma_store(wait=True)
|
||||
|
||||
# Read the queue again and check for deterministic reconstruction.
|
||||
@@ -2267,7 +2267,7 @@ def test_multiple_actor_reconstruction(ray_start_cluster_head):
|
||||
result_ids = collections.defaultdict(lambda: [])
|
||||
|
||||
# In a loop we are going to create some actors, run some methods, kill
|
||||
# a local scheduler, and run some more methods.
|
||||
# a raylet, and run some more methods.
|
||||
for node in worker_nodes:
|
||||
# Create some actors.
|
||||
actors.extend(
|
||||
|
||||
@@ -1406,9 +1406,8 @@ def test_free_objects_multi_node(ray_start_cluster):
|
||||
# This test will do following:
|
||||
# 1. Create 3 raylets that each hold an actor.
|
||||
# 2. Each actor creates an object which is the deletion target.
|
||||
# 3. Invoke 64 methods on each actor to flush plasma client.
|
||||
# 4. After flushing, the plasma client releases the targets.
|
||||
# 5. Check that the deletion targets have been deleted.
|
||||
# 3. Wait 0.1 second for the objects to be deleted.
|
||||
# 4. Check that the deletion targets have been deleted.
|
||||
# Caution: if remote functions are used instead of actor methods,
|
||||
# one raylet may create more than one worker to execute the
|
||||
# tasks, so the flushing operations may be executed in different
|
||||
@@ -1423,20 +1422,13 @@ def test_free_objects_multi_node(ray_start_cluster):
|
||||
_internal_config=config)
|
||||
ray.init(redis_address=cluster.redis_address)
|
||||
|
||||
@ray.remote(resources={"Custom0": 1})
|
||||
class ActorOnNode0(object):
|
||||
class RawActor(object):
|
||||
def get(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
@ray.remote(resources={"Custom1": 1})
|
||||
class ActorOnNode1(object):
|
||||
def get(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
@ray.remote(resources={"Custom2": 1})
|
||||
class ActorOnNode2(object):
|
||||
def get(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
ActorOnNode0 = ray.remote(resources={"Custom0": 1})(RawActor)
|
||||
ActorOnNode1 = ray.remote(resources={"Custom1": 1})(RawActor)
|
||||
ActorOnNode2 = ray.remote(resources={"Custom2": 1})(RawActor)
|
||||
|
||||
def create(actors):
|
||||
a = actors[0].get.remote()
|
||||
@@ -1447,15 +1439,6 @@ def test_free_objects_multi_node(ray_start_cluster):
|
||||
assert len(l2) == 0
|
||||
return (a, b, c)
|
||||
|
||||
def flush(actors):
|
||||
# Flush the Release History.
|
||||
# Current Plasma Client Cache will maintain 64-item list.
|
||||
# If the number changed, this will fail.
|
||||
logger.info("Start Flush!")
|
||||
for i in range(64):
|
||||
ray.get([actor.get.remote() for actor in actors])
|
||||
logger.info("Flush finished!")
|
||||
|
||||
def run_one_test(actors, local_only):
|
||||
(a, b, c) = create(actors)
|
||||
# The three objects should be generated on different object stores.
|
||||
@@ -1463,7 +1446,8 @@ def test_free_objects_multi_node(ray_start_cluster):
|
||||
assert ray.get(a) != ray.get(c)
|
||||
assert ray.get(c) != ray.get(b)
|
||||
ray.internal.free([a, b, c], local_only=local_only)
|
||||
flush(actors)
|
||||
# Wait for the objects to be deleted.
|
||||
time.sleep(0.1)
|
||||
return (a, b, c)
|
||||
|
||||
actors = [
|
||||
@@ -1819,7 +1803,7 @@ def test_zero_cpus_actor(ray_start_cluster):
|
||||
def method(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# Make sure tasks and actors run on the remote local scheduler.
|
||||
# Make sure tasks and actors run on the remote raylet.
|
||||
a = Foo.remote()
|
||||
assert ray.get(a.method.remote()) != local_plasma
|
||||
|
||||
@@ -1875,10 +1859,10 @@ def test_fractional_resources(shutdown_only):
|
||||
Foo2._remote([], {}, resources={"Custom": 1.5})
|
||||
|
||||
|
||||
def test_multiple_local_schedulers(ray_start_cluster):
|
||||
def test_multiple_raylets(ray_start_cluster):
|
||||
# This test will define a bunch of tasks that can only be assigned to
|
||||
# specific local schedulers, and we will check that they are assigned
|
||||
# to the correct local schedulers.
|
||||
# specific raylets, and we will check that they are assigned
|
||||
# to the correct raylets.
|
||||
cluster = ray_start_cluster
|
||||
cluster.add_node(num_cpus=11, num_gpus=0)
|
||||
cluster.add_node(num_cpus=5, num_gpus=5)
|
||||
@@ -1888,20 +1872,20 @@ def test_multiple_local_schedulers(ray_start_cluster):
|
||||
|
||||
# Define a bunch of remote functions that all return the socket name of
|
||||
# the plasma store. Since there is a one-to-one correspondence between
|
||||
# plasma stores and local schedulers (at least right now), this can be
|
||||
# used to identify which local scheduler the task was assigned to.
|
||||
# plasma stores and raylets (at least right now), this can be
|
||||
# used to identify which raylet the task was assigned to.
|
||||
|
||||
# This must be run on the zeroth local scheduler.
|
||||
# This must be run on the zeroth raylet.
|
||||
@ray.remote(num_cpus=11)
|
||||
def run_on_0():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# This must be run on the first local scheduler.
|
||||
# This must be run on the first raylet.
|
||||
@ray.remote(num_gpus=2)
|
||||
def run_on_1():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# This must be run on the second local scheduler.
|
||||
# This must be run on the second raylet.
|
||||
@ray.remote(num_cpus=6, num_gpus=1)
|
||||
def run_on_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
@@ -1911,12 +1895,12 @@ def test_multiple_local_schedulers(ray_start_cluster):
|
||||
def run_on_0_1_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# This must be run on the first or second local scheduler.
|
||||
# This must be run on the first or second raylet.
|
||||
@ray.remote(num_gpus=1)
|
||||
def run_on_1_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# This must be run on the zeroth or second local scheduler.
|
||||
# This must be run on the zeroth or second raylet.
|
||||
@ray.remote(num_cpus=8)
|
||||
def run_on_0_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
@@ -2022,15 +2006,15 @@ def test_custom_resources(ray_start_cluster):
|
||||
ray.get([f.remote() for _ in range(5)])
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# The f tasks should be scheduled on both local schedulers.
|
||||
# The f tasks should be scheduled on both raylets.
|
||||
assert len(set(ray.get([f.remote() for _ in range(50)]))) == 2
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# The g tasks should be scheduled only on the second local scheduler.
|
||||
local_scheduler_ids = set(ray.get([g.remote() for _ in range(50)]))
|
||||
assert len(local_scheduler_ids) == 1
|
||||
assert list(local_scheduler_ids)[0] != local_plasma
|
||||
# The g tasks should be scheduled only on the second raylet.
|
||||
raylet_ids = set(ray.get([g.remote() for _ in range(50)]))
|
||||
assert len(raylet_ids) == 1
|
||||
assert list(raylet_ids)[0] != local_plasma
|
||||
|
||||
# Make sure that resource bookkeeping works when a task that uses a
|
||||
# custom resources gets blocked.
|
||||
@@ -2076,16 +2060,16 @@ def test_two_custom_resources(ray_start_cluster):
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# The f and g tasks should be scheduled on both local schedulers.
|
||||
# The f and g tasks should be scheduled on both raylets.
|
||||
assert len(set(ray.get([f.remote() for _ in range(50)]))) == 2
|
||||
assert len(set(ray.get([g.remote() for _ in range(50)]))) == 2
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# The h tasks should be scheduled only on the second local scheduler.
|
||||
local_scheduler_ids = set(ray.get([h.remote() for _ in range(50)]))
|
||||
assert len(local_scheduler_ids) == 1
|
||||
assert list(local_scheduler_ids)[0] != local_plasma
|
||||
# The h tasks should be scheduled only on the second raylet.
|
||||
raylet_ids = set(ray.get([h.remote() for _ in range(50)]))
|
||||
assert len(raylet_ids) == 1
|
||||
assert list(raylet_ids)[0] != local_plasma
|
||||
|
||||
# Make sure that tasks with unsatisfied custom resource requirements do
|
||||
# not get scheduled.
|
||||
@@ -2242,8 +2226,8 @@ def attempt_to_load_balance(remote_function,
|
||||
|
||||
|
||||
def test_load_balancing(ray_start_cluster):
|
||||
# This test ensures that tasks are being assigned to all local
|
||||
# schedulers in a roughly equal manner.
|
||||
# This test ensures that tasks are being assigned to all raylets
|
||||
# in a roughly equal manner.
|
||||
cluster = ray_start_cluster
|
||||
num_nodes = 3
|
||||
num_cpus = 7
|
||||
@@ -2261,9 +2245,8 @@ def test_load_balancing(ray_start_cluster):
|
||||
|
||||
|
||||
def test_load_balancing_with_dependencies(ray_start_cluster):
|
||||
# This test ensures that tasks are being assigned to all local
|
||||
# schedulers in a roughly equal manner even when the tasks have
|
||||
# dependencies.
|
||||
# This test ensures that tasks are being assigned to all raylets in a
|
||||
# roughly equal manner even when the tasks have dependencies.
|
||||
cluster = ray_start_cluster
|
||||
num_nodes = 3
|
||||
for _ in range(num_nodes):
|
||||
@@ -2275,9 +2258,8 @@ def test_load_balancing_with_dependencies(ray_start_cluster):
|
||||
time.sleep(0.010)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
|
||||
# This object will be local to one of the local schedulers. Make sure
|
||||
# this doesn't prevent tasks from being scheduled on other local
|
||||
# schedulers.
|
||||
# This object will be local to one of the raylets. Make sure
|
||||
# this doesn't prevent tasks from being scheduled on other raylets.
|
||||
x = ray.put(np.zeros(1000000))
|
||||
|
||||
attempt_to_load_balance(f, [x], 100, num_nodes, 25)
|
||||
|
||||
@@ -315,7 +315,7 @@ def check_components_alive(cluster, component_type, check_component_alive):
|
||||
}], indirect=True)
|
||||
def test_raylet_failed(ray_start_cluster):
|
||||
cluster = ray_start_cluster
|
||||
# Kill all local schedulers on worker nodes.
|
||||
# Kill all raylets on worker nodes.
|
||||
_test_component_failed(cluster, ray_constants.PROCESS_TYPE_RAYLET)
|
||||
|
||||
# The plasma stores should still be alive on the worker nodes.
|
||||
|
||||
@@ -278,7 +278,7 @@ def test_incorrect_method_calls(ray_start_regular):
|
||||
def test_worker_raising_exception(ray_start_regular):
|
||||
@ray.remote
|
||||
def f():
|
||||
ray.worker.global_worker._get_next_task_from_local_scheduler = None
|
||||
ray.worker.global_worker._get_next_task_from_raylet = None
|
||||
|
||||
# Running this task should cause the worker to raise an exception after
|
||||
# the task has successfully completed.
|
||||
|
||||
Reference in New Issue
Block a user