mirror of
https://github.com/wassname/ray.git
synced 2026-07-20 12:40:20 +08:00
Add ray.util package and move libraries from experimental (#7100)
This commit is contained in:
+1
-1
@@ -294,7 +294,7 @@ script:
|
||||
- ./ci/suppress_output bazel test --build_tests_only --show_progress_rate_limit=100 --test_output=errors -- //:all -rllib/...
|
||||
|
||||
# ray serve tests
|
||||
- if [ $RAY_CI_SERVE_AFFECTED == "1" ]; then ./ci/keep_alive bazel test --spawn_strategy=local --flaky_test_attempts=3 --nocache_test_results --test_verbose_timeout_warnings --progress_report_interval=100 --show_progress_rate_limit=100 --show_timestamps --test_output=errors --test_tag_filters=-jenkins_only python/ray/experimental/serve/...; fi
|
||||
- if [ $RAY_CI_SERVE_AFFECTED == "1" ]; then ./ci/keep_alive bazel test --spawn_strategy=local --flaky_test_attempts=3 --nocache_test_results --test_verbose_timeout_warnings --progress_report_interval=100 --show_progress_rate_limit=100 --show_timestamps --test_output=errors --test_tag_filters=-jenkins_only python/ray/serve/...; fi
|
||||
|
||||
# ray operator tests
|
||||
- cd ./deploy/ray-operator/
|
||||
|
||||
@@ -1176,6 +1176,7 @@ filegroup(
|
||||
"python/ray/core/generated/ray/protocol/__init__.py",
|
||||
"python/ray/dashboard/dashboard.py",
|
||||
"python/ray/experimental/*.py",
|
||||
"python/ray/util/*.py",
|
||||
"python/ray/internal/*.py",
|
||||
"python/ray/projects/*.py",
|
||||
"python/ray/projects/schema.json",
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ Ray is packaged with the following libraries for accelerating machine learning w
|
||||
|
||||
- `Tune`_: Scalable Hyperparameter Tuning
|
||||
- `RLlib`_: Scalable Reinforcement Learning
|
||||
- `Distributed Training <https://ray.readthedocs.io/en/latest/distributed_training.html>`__
|
||||
- `RaySGD <https://ray.readthedocs.io/en/latest/raysgd/raysgd.html>`__: Distributed Training Wrappers
|
||||
|
||||
Install Ray with: ``pip install ray``. For nightly wheels, see the
|
||||
`Installation page <https://ray.readthedocs.io/en/latest/installation.html>`__.
|
||||
|
||||
@@ -144,49 +144,49 @@ $SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE}
|
||||
######################## SGD TESTS #################################
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python -m pytest /ray/python/ray/experimental/sgd/tests
|
||||
python -m pytest /ray/python/ray/util/sgd/tests
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/doc/examples/doc_code/raysgd_torch_signatures.py
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/train_example.py
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/train_example.py
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/train_example.py --num-replicas=2
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/train_example.py --num-replicas=2
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/tune_example.py
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/tune_example.py
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/tune_example.py --num-replicas=2
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/tune_example.py --num-replicas=2
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/cifar_pytorch_example.py --smoke-test
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/cifar_pytorch_example.py --smoke-test
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/cifar_pytorch_example.py --smoke-test --num-replicas=2
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/cifar_pytorch_example.py --smoke-test --num-replicas=2
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/cifar_pytorch_example.py --smoke-test --tune
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/cifar_pytorch_example.py --smoke-test --tune
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/pytorch/examples/dcgan.py --smoke-test --num-replicas=2
|
||||
python /ray/python/ray/util/sgd/pytorch/examples/dcgan.py --smoke-test --num-replicas=2
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/tf/examples/tensorflow_train_example.py
|
||||
python /ray/python/ray/util/sgd/tf/examples/tensorflow_train_example.py
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/tf/examples/tensorflow_train_example.py --num-replicas=2
|
||||
python /ray/python/ray/util/sgd/tf/examples/tensorflow_train_example.py --num-replicas=2
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/tf/examples/tensorflow_train_example.py --tune
|
||||
python /ray/python/ray/util/sgd/tf/examples/tensorflow_train_example.py --tune
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/tf/examples/cifar_tf_example.py --smoke-test
|
||||
python /ray/python/ray/util/sgd/tf/examples/cifar_tf_example.py --smoke-test
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/tf/examples/cifar_tf_example.py --num-replicas 2 --smoke-test
|
||||
python /ray/python/ray/util/sgd/tf/examples/cifar_tf_example.py --num-replicas 2 --smoke-test
|
||||
|
||||
$SUPPRESS_OUTPUT docker run --rm --shm-size=${SHM_SIZE} --memory=${MEMORY_SIZE} --memory-swap=-1 $DOCKER_SHA \
|
||||
python /ray/python/ray/experimental/sgd/tf/examples/cifar_tf_example.py --num-replicas 2 --smoke-test --augment-data
|
||||
python /ray/python/ray/util/sgd/tf/examples/cifar_tf_example.py --num-replicas 2 --smoke-test --augment-data
|
||||
|
||||
@@ -5,9 +5,9 @@ from subprocess import PIPE
|
||||
import requests
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray import serve
|
||||
from ray.cluster_utils import Cluster
|
||||
from ray.experimental.serve.kv_store_service import RayInternalKVStore
|
||||
from ray.serve.kv_store_service import RayInternalKVStore
|
||||
|
||||
num_redis_shards = 1
|
||||
redis_max_memory = 10**8
|
||||
|
||||
@@ -127,7 +127,7 @@ test_sgd(){
|
||||
|
||||
echo "Try running SGD stress test."
|
||||
{
|
||||
SGD_DIR=$ROOT_DIR/../../python/ray/experimental/sgd/
|
||||
SGD_DIR=$ROOT_DIR/../../python/ray/util/sgd/
|
||||
ray --logging-level=DEBUG up -y "$CLUSTER" &&
|
||||
# TODO: fix submit so that args work
|
||||
ray rsync_up "$CLUSTER" "$SGD_DIR/mnist_example.py" mnist_example.py &&
|
||||
|
||||
@@ -65,7 +65,7 @@ if __name__ == "__main__":
|
||||
RAY_CI_RLLIB_FULL_AFFECTED = 1
|
||||
RAY_CI_LINUX_WHEELS_AFFECTED = 1
|
||||
RAY_CI_MACOS_WHEELS_AFFECTED = 1
|
||||
elif changed_file.startswith("python/ray/experimental/serve"):
|
||||
elif changed_file.startswith("python/ray/serve"):
|
||||
RAY_CI_SERVE_AFFECTED = 1
|
||||
RAY_CI_LINUX_WHEELS_AFFECTED = 1
|
||||
RAY_CI_MACOS_WHEELS_AFFECTED = 1
|
||||
|
||||
@@ -46,7 +46,7 @@ def optimizer_creator(model, config):
|
||||
|
||||
|
||||
# __torch_data_start__
|
||||
from ray.experimental.sgd.pytorch.examples.train_example import LinearDataset
|
||||
from ray.util.sgd.pytorch.examples.train_example import LinearDataset
|
||||
|
||||
def data_creator(config):
|
||||
"""Constructs torch.utils.data.Dataset objects.
|
||||
@@ -108,7 +108,7 @@ ray.init()
|
||||
# __torch_ray_end__
|
||||
|
||||
# __torch_trainer_start__
|
||||
from ray.experimental.sgd import PyTorchTrainer
|
||||
from ray.util.sgd import PyTorchTrainer
|
||||
|
||||
trainer = PyTorchTrainer(
|
||||
model_creator,
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
Examples Overview
|
||||
=================
|
||||
Ray Tutorials and Examples
|
||||
==========================
|
||||
|
||||
Get started with Ray, Tune, and RLlib with these notebooks that you can run online in CoLab or Binder:
|
||||
* `Ray Tutorial Notebooks <https://github.com/ray-project/tutorial>`__
|
||||
|
||||
Example Gallery
|
||||
---------------
|
||||
|
||||
.. customgalleryitem::
|
||||
:tooltip: Build a simple parameter server using Ray.
|
||||
|
||||
@@ -197,19 +197,19 @@ If we instantiate an actor, we can pass the handle around to various tasks.
|
||||
print(ray.get(counter.get_counter.remote()))
|
||||
|
||||
|
||||
Actor Pool (Experimental)
|
||||
-------------------------
|
||||
Actor Pool
|
||||
----------
|
||||
|
||||
The ``ray.experimental`` module contains a utility class, ``ActorPool``.
|
||||
The ``ray.util`` module contains a utility class, ``ActorPool``.
|
||||
This class is similar to multiprocessing.Pool and lets you schedule Ray tasks over a fixed pool of actors.
|
||||
|
||||
.. code-block::
|
||||
|
||||
from ray.experimental import ActorPool
|
||||
from ray.util import ActorPool
|
||||
|
||||
a1, a2 = Actor.remote(), Actor.remote()
|
||||
pool = ActorPool([a1, a2])
|
||||
print(pool.map(lambda a, v: a.double.remote(v), [1, 2, 3, 4]))
|
||||
# [2, 4, 6, 8]
|
||||
|
||||
See the `package reference <package-ref.html#ray.experimental.ActorPool>`_ for more information.
|
||||
See the `package reference <package-ref.html#ray.util.ActorPool>`_ for more information.
|
||||
|
||||
@@ -259,7 +259,7 @@ driver:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
counter = ray.experimental.get_actor("CounterActor")
|
||||
counter = ray.util.get_actor("CounterActor")
|
||||
print(ray.get(counter.get_counter.remote()))
|
||||
|
||||
Note that just creating a named actor is allowed, this actor will be cleaned
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Async API (Experimental)
|
||||
========================
|
||||
AsyncIO / Concurrency for Actors
|
||||
================================
|
||||
|
||||
Since Python 3.5, it is possible to write concurrent code using the
|
||||
``async/await`` `syntax <https://docs.python.org/3/library/asyncio.html>`__.
|
||||
|
||||
@@ -12,3 +12,4 @@ How to setup your cluster and use Ray most effectively.
|
||||
deploy-on-yarn.rst
|
||||
deploy-on-kubernetes.rst
|
||||
deploying-on-slurm.rst
|
||||
projects.rst
|
||||
|
||||
@@ -237,12 +237,8 @@ scripts. Some of the examples include:
|
||||
* ``bazel test --build_tests_only //:all``
|
||||
|
||||
* Ray serving test commands:
|
||||
* ``python -m pytest python/ray/experimental/serve/tests``
|
||||
* ``python python/ray/experimental/serve/examples/echo_full.py``
|
||||
|
||||
* Ray test commands:
|
||||
* ``python/ray/experimental/test/async_test.py``
|
||||
* ``python/ray/tests/py3_test.py``
|
||||
* ``python -m pytest python/ray/serve/tests``
|
||||
* ``python python/ray/serve/examples/echo_full.py``
|
||||
|
||||
If a Travis-CI build exception doesn't appear to be related to your change,
|
||||
please visit `this link <https://ray-travis-tracker.herokuapp.com/>`_ to
|
||||
|
||||
+9
-14
@@ -16,7 +16,7 @@ Ray is packaged with the following libraries for accelerating machine learning w
|
||||
|
||||
- `Tune`_: Scalable Hyperparameter Tuning
|
||||
- `RLlib`_: Scalable Reinforcement Learning
|
||||
- `RaySGD`_: Distributed Training
|
||||
- `RaySGD`_: Distributed Training Wrappers
|
||||
|
||||
|
||||
Star us on `on GitHub`_. You can also get started by visiting our `Tutorials <https://github.com/ray-project/tutorial>`_. For the latest wheels (nightlies), see the `installation page <installation.html>`__.
|
||||
@@ -239,8 +239,7 @@ Getting Involved
|
||||
using-ray.rst
|
||||
configure.rst
|
||||
cluster-index.rst
|
||||
Tutorials <https://github.com/ray-project/tutorial>
|
||||
Examples <auto_examples/overview.rst>
|
||||
Tutorial and Examples <auto_examples/overview.rst>
|
||||
package-ref.rst
|
||||
|
||||
.. toctree::
|
||||
@@ -254,9 +253,9 @@ Getting Involved
|
||||
tune-distributed.rst
|
||||
tune-schedulers.rst
|
||||
tune-searchalg.rst
|
||||
tune-package-ref.rst
|
||||
tune-design.rst
|
||||
tune-examples.rst
|
||||
tune-package-ref.rst
|
||||
tune-contrib.rst
|
||||
|
||||
.. toctree::
|
||||
@@ -272,31 +271,27 @@ Getting Involved
|
||||
rllib-offline.rst
|
||||
rllib-concepts.rst
|
||||
rllib-examples.rst
|
||||
rllib-dev.rst
|
||||
rllib-package-ref.rst
|
||||
rllib-dev.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: -1
|
||||
:caption: RaySGD
|
||||
:caption: Ray SGD
|
||||
|
||||
raysgd/raysgd.rst
|
||||
raysgd/raysgd_pytorch.rst
|
||||
raysgd/raysgd_tensorflow.rst
|
||||
raysgd/raysgd_ref.rst
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: -1
|
||||
:caption: Experimental
|
||||
:caption: Other Libraries
|
||||
|
||||
pandas_on_ray.rst
|
||||
projects.rst
|
||||
signals.rst
|
||||
async_api.rst
|
||||
serve.rst
|
||||
iter.rst
|
||||
multiprocessing.rst
|
||||
joblib.rst
|
||||
iter.rst
|
||||
pandas_on_ray.rst
|
||||
serve.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: -1
|
||||
|
||||
+21
-15
@@ -1,13 +1,19 @@
|
||||
Parallel Iterator API (Experimental)
|
||||
====================================
|
||||
Distributed Iterators
|
||||
=====================
|
||||
|
||||
``ray.experimental.iter`` provides a parallel iterator API for simple data ingest
|
||||
and processing. It can be thought of as syntactic sugar around Ray actors and ``ray.wait`` loops.
|
||||
.. _`issue on GitHub`: https://github.com/ray-project/ray/issues
|
||||
|
||||
``ray.util.iter`` provides a parallel iterator API for simple data ingest and processing. It can be thought of as syntactic sugar around Ray actors and ``ray.wait`` loops.
|
||||
|
||||
Parallel iterators are lazy and can operate over infinite sequences of items. Iterator
|
||||
transformations are only executed when the user calls ``next()`` to fetch the next output
|
||||
item from the iterator.
|
||||
|
||||
.. note::
|
||||
|
||||
This API is new and may be revised in future Ray releases. If you encounter
|
||||
any bugs, please file an `issue on GitHub`_.
|
||||
|
||||
Concepts
|
||||
--------
|
||||
|
||||
@@ -18,20 +24,20 @@ create a worker actor that produces the data for each shard of the iterator:
|
||||
.. code-block:: python
|
||||
|
||||
# Create an iterator with 2 worker actors over the list [1, 2, 3, 4].
|
||||
>>> it = ray.experimental.iter.from_items([1, 2, 3, 4], num_shards=2)
|
||||
>>> it = ray.util.iter.from_items([1, 2, 3, 4], num_shards=2)
|
||||
ParallelIterator[from_items[int, 4, shards=2]]
|
||||
|
||||
# Create an iterator with 32 worker actors over range(1000000).
|
||||
>>> it = ray.experimental.iter.from_range(1000000, num_shards=32)
|
||||
>>> it = ray.util.iter.from_range(1000000, num_shards=32)
|
||||
ParallelIterator[from_range[1000000, shards=32]]
|
||||
|
||||
# Create an iterator over two range(10) generators.
|
||||
>>> it = ray.experimental.iter.from_iterators([range(10), range(10)])
|
||||
>>> it = ray.util.iter.from_iterators([range(10), range(10)])
|
||||
ParallelIterator[from_iterators[shards=2]]
|
||||
|
||||
# Create an iterator from existing worker actors. These actors must
|
||||
# implement the ParallelIteratorWorker interface.
|
||||
>>> it = ray.experimental.iter.from_actors([a1, a2, a3, a4])
|
||||
>>> it = ray.util.iter.from_actors([a1, a2, a3, a4])
|
||||
ParallelIterator[from_actors[shards=4]]
|
||||
|
||||
Simple transformations can be chained on the iterator, such as mapping,
|
||||
@@ -58,7 +64,7 @@ correspond to ``ray.get`` and ``ray.wait`` loops over the actors respectively:
|
||||
.. code-block:: python
|
||||
|
||||
# Gather items synchronously (deterministic round robin across shards):
|
||||
>>> it = ray.experimental.iter.from_range(1000000, 1)
|
||||
>>> it = ray.util.iter.from_range(1000000, 1)
|
||||
>>> it = it.gather_sync()
|
||||
LocalIterator[ParallelIterator[from_range[1000000, shards=1]].gather_sync()]
|
||||
|
||||
@@ -72,7 +78,7 @@ correspond to ``ray.get`` and ``ray.wait`` loops over the actors respectively:
|
||||
[0, 2, 4, 6, 8]
|
||||
|
||||
# Async gather can be used for better performance, but it is non-deterministic.
|
||||
>>> it = ray.experimental.iter.from_range(1000, 4).gather_async()
|
||||
>>> it = ray.util.iter.from_range(1000, 4).gather_async()
|
||||
>>> it.take(5)
|
||||
[0, 250, 500, 750, 1]
|
||||
|
||||
@@ -83,7 +89,7 @@ each shard should only be read by one process at a time:
|
||||
.. code-block:: python
|
||||
|
||||
# Get local iterators representing the shards of this ParallelIterator:
|
||||
>>> it = ray.experimental.iter.from_range(10000, 3)
|
||||
>>> it = ray.util.iter.from_range(10000, 3)
|
||||
>>> [s0, s1, s2] = it.shards()
|
||||
[LocalIterator[from_range[10000, shards=3].shard[0]],
|
||||
LocalIterator[from_range[10000, shards=3].shard[1]],
|
||||
@@ -122,7 +128,7 @@ This means that you can pass a stateful callable to ``.foreach()``:
|
||||
self.total += x
|
||||
return (self.total, x)
|
||||
|
||||
it = ray.experimental.iter.from_range(5, 1)
|
||||
it = ray.util.iter.from_range(5, 1)
|
||||
for x in it.for_each(CumulativeSum()).gather_sync():
|
||||
print(x)
|
||||
|
||||
@@ -150,7 +156,7 @@ streaming grep:
|
||||
|
||||
file_list = glob.glob("/var/log/syslog*.gz")
|
||||
it = (
|
||||
ray.experimental.iter.from_items(file_list, num_shards=4)
|
||||
ray.util.iter.from_items(file_list, num_shards=4)
|
||||
.for_each(lambda f: gzip.open(f).readlines())
|
||||
.flatten()
|
||||
.for_each(lambda line: line.decode("utf-8"))
|
||||
@@ -184,7 +190,7 @@ distributed training:
|
||||
print("train on", batch) # perform model update with batch
|
||||
|
||||
it = (
|
||||
ray.experimental.iter.from_range(1000000, num_shards=4, repeat=True)
|
||||
ray.util.iter.from_range(1000000, num_shards=4, repeat=True)
|
||||
.batch(1024)
|
||||
.for_each(np.array)
|
||||
)
|
||||
@@ -195,7 +201,7 @@ distributed training:
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. automodule:: ray.experimental.iter
|
||||
.. automodule:: ray.util.iter
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members:
|
||||
|
||||
+9
-11
@@ -1,12 +1,5 @@
|
||||
sklearn Ray Backend API (Experimental)
|
||||
=======================================
|
||||
|
||||
.. warning::
|
||||
|
||||
Support for running scikit-learn on Ray is an experimental feature,
|
||||
so it may be changed at any time without warning. If you encounter any
|
||||
bugs/shortcomings/incompatibilities, please file an `issue on GitHub`_.
|
||||
Contributions are always welcome!
|
||||
Distributed Scikit-learn / Joblib
|
||||
=================================
|
||||
|
||||
.. _`issue on GitHub`: https://github.com/ray-project/ray/issues
|
||||
|
||||
@@ -15,6 +8,11 @@ implementing a Ray backend for `joblib`_ using `Ray Actors <actors.html>`__
|
||||
instead of local processes. This makes it easy to scale existing applications
|
||||
that use scikit-learn from a single node to a cluster.
|
||||
|
||||
.. note::
|
||||
|
||||
This API is new and may be revised in future Ray releases. If you encounter
|
||||
any bugs, please file an `issue on GitHub`_.
|
||||
|
||||
.. _`joblib`: https://joblib.readthedocs.io
|
||||
.. _`scikit-learn`: https://scikit-learn.org
|
||||
|
||||
@@ -22,7 +20,7 @@ Quickstart
|
||||
----------
|
||||
|
||||
To get started, first `install Ray <installation.html>`__, then use
|
||||
``from ray.experimental.joblib import register_ray`` and run ``register_ray()``.
|
||||
``from ray.util.joblib import register_ray`` and run ``register_ray()``.
|
||||
This will register Ray as a joblib backend for scikit-learn to use.
|
||||
Then run your original scikit-learn code inside
|
||||
``with joblib.parallel_backend('ray')``. This will start a local Ray cluster.
|
||||
@@ -46,7 +44,7 @@ a multi-node Ray cluster instead.
|
||||
search = RandomizedSearchCV(model, param_space, cv=5, n_iter=300, verbose=10)
|
||||
|
||||
import joblib
|
||||
from ray.experimental.joblib import register_ray
|
||||
from ray.util.joblib import register_ray
|
||||
register_ray()
|
||||
with joblib.parallel_backend('ray'):
|
||||
search.fit(digits.data, digits.target)
|
||||
|
||||
@@ -84,10 +84,11 @@ Heap memory quota
|
||||
|
||||
When Ray starts, it queries the available memory on a node / container not reserved for Redis and the object store or being used by other applications. This is considered "available memory" that actors and tasks can request memory out of. You can also set ``memory=<bytes>`` on Ray init to tell Ray explicitly how much memory is available.
|
||||
|
||||
.. note::
|
||||
.. important::
|
||||
|
||||
Setting available memory for the node does not impose any limits on memory usage
|
||||
of tasks. To set per-task limits, see the following sections.
|
||||
Setting available memory for the node does NOT impose any limits on memory usage
|
||||
unless you specify memory resource requirements in decorators. By default, tasks
|
||||
and actors request no memory (and hence have no limit).
|
||||
|
||||
To tell the Ray scheduler a task or actor requires a certain amount of available memory to run, set the ``memory`` argument. The Ray scheduler will then reserve the specified amount of available memory during scheduling, similar to how it handles CPU and GPU resources:
|
||||
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
multiprocessing.Pool API
|
||||
========================
|
||||
|
||||
.. warning::
|
||||
|
||||
Support for the multiprocessing.Pool API on Ray is an experimental feature,
|
||||
so it may be changed at any time without warning. If you encounter any
|
||||
bugs/shortcomings/incompatibilities, please file an `issue on GitHub`_.
|
||||
Contributions are always welcome!
|
||||
Distributed multiprocessing.Pool
|
||||
================================
|
||||
|
||||
.. _`issue on GitHub`: https://github.com/ray-project/ray/issues
|
||||
|
||||
@@ -15,6 +8,11 @@ using `Ray Actors <actors.html>`__ instead of local processes. This makes it eas
|
||||
to scale existing applications that use ``multiprocessing.Pool`` from a single node
|
||||
to a cluster.
|
||||
|
||||
.. note::
|
||||
|
||||
This API is new and may be revised in future Ray releases. If you encounter
|
||||
any bugs, please file an `issue on GitHub`_.
|
||||
|
||||
.. _`multiprocessing.Pool API`: https://docs.python.org/3/library/multiprocessing.html#module-multiprocessing.pool
|
||||
|
||||
Quickstart
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
RaySGD: Distributed Deep Learning
|
||||
=================================
|
||||
RaySGD: Distributed Training Wrappers
|
||||
=====================================
|
||||
|
||||
.. image:: raysgdlogo.png
|
||||
:scale: 20%
|
||||
:align: center
|
||||
.. _`issue on GitHub`: https://github.com/ray-project/ray/issues
|
||||
|
||||
RaySGD is a lightweight library for distributed deep learning, providing thin wrappers around PyTorch and TensorFlow native modules for data parallel training.
|
||||
|
||||
@@ -13,7 +11,10 @@ The main features are:
|
||||
- **Composability**: RaySGD is built on top of the Ray Actor API, enabling seamless integration with existing Ray applications such as RLlib, Tune, and Ray.Serve.
|
||||
- **Scale up and down**: Start on single CPU. Scale up to multi-node, multi-CPU, or multi-GPU clusters by changing 2 lines of code.
|
||||
|
||||
.. tip:: We need your feedback! RaySGD is currently early in its development, and we're hoping to get feedback from people using or considering it. We'd love `to get in touch <https://forms.gle/26EMwdahdgm7Lscy9>`_!
|
||||
.. note::
|
||||
|
||||
This API is new and may be revised in future Ray releases. If you encounter
|
||||
any bugs, please file an `issue on GitHub`_.
|
||||
|
||||
|
||||
Getting Started
|
||||
@@ -28,8 +29,8 @@ You can start a ``PyTorchTrainer`` with the following:
|
||||
import torch.nn as nn
|
||||
from torch import distributed
|
||||
|
||||
from ray.experimental.sgd import PyTorchTrainer
|
||||
from ray.experimental.sgd.examples.train_example import LinearDataset
|
||||
from ray.util.sgd import PyTorchTrainer
|
||||
from ray.util.sgd.examples.train_example import LinearDataset
|
||||
|
||||
|
||||
def model_creator(config):
|
||||
@@ -61,3 +62,5 @@ You can start a ``PyTorchTrainer`` with the following:
|
||||
print(stats)
|
||||
trainer1.shutdown()
|
||||
print("success!")
|
||||
|
||||
.. tip:: Get in touch with us if you're using or considering using `RaySGD <https://forms.gle/26EMwdahdgm7Lscy9>`_!
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
RaySGD Pytorch
|
||||
==============
|
||||
|
||||
.. image:: raysgd-pytorch.svg
|
||||
:align: center
|
||||
Distributed PyTorch
|
||||
===================
|
||||
|
||||
The RaySGD ``PyTorchTrainer`` simplifies distributed model training for PyTorch. The ``PyTorchTrainer`` is a wrapper around ``torch.distributed.launch`` with a Python API to easily incorporate distributed training into a larger Python application, as opposed to needing to wrap your training code in bash scripts.
|
||||
|
||||
@@ -16,7 +13,7 @@ For end to end examples leveraging RaySGD PyTorchTrainer, jump to :ref:`raysgd-p
|
||||
Setting up training
|
||||
-------------------
|
||||
|
||||
.. tip:: We need your feedback! RaySGD is currently early in its development, and we're hoping to get feedback from people using or considering it. We'd love `to get in touch <https://forms.gle/26EMwdahdgm7Lscy9>`_!
|
||||
.. tip:: Get in touch with us if you're using or considering using `RaySGD <https://forms.gle/26EMwdahdgm7Lscy9>`_!
|
||||
|
||||
The ``PyTorchTrainer`` can be constructed with functions that wrap components of the training script. Specifically, it requires constructors for the Model, Data, Optimizer, Loss, and ``lr_scheduler`` to create replicated copies across different devices and machines.
|
||||
|
||||
@@ -154,8 +151,6 @@ After training, you may want to reappropriate the Ray cluster. To release Ray re
|
||||
Initialization Functions
|
||||
------------------------
|
||||
|
||||
.. warning:: This is still an experimental API and is subject to change without warning.
|
||||
|
||||
You may want to run some initializers on each worker when they are started. This may be something like setting an environment variable or downloading some data. You can do this via the ``initialization_hook`` parameter:
|
||||
|
||||
.. code-block:: python
|
||||
@@ -305,11 +300,9 @@ Users can set ``checkpoint="auto"`` to always checkpoint the current model befor
|
||||
Advanced: Hyperparameter Tuning
|
||||
-------------------------------
|
||||
|
||||
.. warning:: This is still an experimental API and is subject to change without warning.
|
||||
|
||||
``PyTorchTrainer`` naturally integrates with Tune via the ``PyTorchTrainable`` interface. The same arguments to ``PyTorchTrainer`` should be passed into the ``tune.run(config=...)`` as shown below.
|
||||
|
||||
.. literalinclude:: ../../../python/ray/experimental/sgd/pytorch/examples/tune_example.py
|
||||
.. literalinclude:: ../../../python/ray/util/sgd/pytorch/examples/tune_example.py
|
||||
:language: python
|
||||
:start-after: __torch_tune_example__
|
||||
|
||||
@@ -321,7 +314,7 @@ In certain scenarios such as training GANs, you may want to use multiple models
|
||||
|
||||
If multiple models, optimizers, or schedulers are returned, you will need to provide a custom training function (and custom validation function if you plan to call ``validate``).
|
||||
|
||||
You can see the `DCGAN script <https://github.com/ray-project/ray/blob/master/python/ray/experimental/sgd/pytorch/examples/dcgan.py>`_ for an end-to-end example.
|
||||
You can see the `DCGAN script <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/pytorch/examples/dcgan.py>`_ for an end-to-end example.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -362,8 +355,6 @@ You can see the `DCGAN script <https://github.com/ray-project/ray/blob/master/py
|
||||
Custom Training and Validation Functions
|
||||
----------------------------------------
|
||||
|
||||
.. warning:: This is still an experimental API and is subject to change in the near future.
|
||||
|
||||
``PyTorchTrainer`` allows you to run a custom training and validation step in parallel on each worker, providing a flexibility similar to using PyTorch natively. This is done via the ``train_function`` and ``validation_function`` parameters.
|
||||
|
||||
Note that this is needed if the model creator returns multiple models, optimizers, or schedulers.
|
||||
@@ -477,13 +468,13 @@ PyTorchTrainer Examples
|
||||
Here are some examples of using RaySGD for training PyTorch models. If you'd like
|
||||
to contribute an example, feel free to create a `pull request here <https://github.com/ray-project/ray/>`_.
|
||||
|
||||
- `PyTorch training example <https://github.com/ray-project/ray/blob/master/python/ray/experimental/sgd/pytorch/examples/train_example.py>`__:
|
||||
- `PyTorch training example <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/pytorch/examples/train_example.py>`__:
|
||||
Simple example of using Ray's PyTorchTrainer.
|
||||
|
||||
- `CIFAR10 example <https://github.com/ray-project/ray/blob/master/python/ray/experimental/sgd/pytorch/examples/cifar_pytorch_example.py>`__:
|
||||
- `CIFAR10 example <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/pytorch/examples/cifar_pytorch_example.py>`__:
|
||||
Training a ResNet18 model on CIFAR10. It uses a custom training
|
||||
function, a custom validation function, and custom initialization code for each worker.
|
||||
|
||||
- `DCGAN example <https://github.com/ray-project/ray/blob/master/python/ray/experimental/sgd/pytorch/examples/dcgan.py>`__:
|
||||
- `DCGAN example <https://github.com/ray-project/ray/blob/master/python/ray/util/sgd/pytorch/examples/dcgan.py>`__:
|
||||
Training a Deep Convolutional GAN on MNIST. It constructs
|
||||
two models and two optimizers and uses a custom training and validation function.
|
||||
|
||||
@@ -6,7 +6,7 @@ Package Reference
|
||||
PyTorchTrainer
|
||||
--------------
|
||||
|
||||
.. autoclass:: ray.experimental.sgd.pytorch.PyTorchTrainer
|
||||
.. autoclass:: ray.util.sgd.pytorch.PyTorchTrainer
|
||||
:members:
|
||||
|
||||
.. automethod:: __init__
|
||||
@@ -15,13 +15,13 @@ PyTorchTrainer
|
||||
PyTorchTrainable
|
||||
----------------
|
||||
|
||||
.. autoclass:: ray.experimental.sgd.pytorch.PyTorchTrainable
|
||||
.. autoclass:: ray.util.sgd.pytorch.PyTorchTrainable
|
||||
:members:
|
||||
|
||||
TFTrainer
|
||||
---------
|
||||
|
||||
.. autoclass:: ray.experimental.sgd.tf.TFTrainer
|
||||
.. autoclass:: ray.util.sgd.tf.TFTrainer
|
||||
:members:
|
||||
|
||||
.. automethod:: __init__
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
RaySGD TensorFlow
|
||||
=================
|
||||
Distributed TensorFlow
|
||||
======================
|
||||
|
||||
RaySGD's ``TFTrainer`` simplifies distributed model training for Tensorflow. The ``TFTrainer`` is a wrapper around ``MultiWorkerMirroredStrategy`` with a Python API to easily incorporate distributed training into a larger Python application, as opposed to write custom logic of setting environments and starting separate processes.
|
||||
|
||||
.. important:: This API has only been tested with TensorFlow2.0rc and is still highly experimental. Please file bug reports if you run into any - thanks!
|
||||
Under the hood, ``TFTrainer`` will create *replicas* of your model (controlled by ``num_replicas``), each of which is managed by a Ray actor.
|
||||
|
||||
.. image:: raysgd-actors.svg
|
||||
:align: center
|
||||
|
||||
.. tip:: We need your feedback! RaySGD is currently early in its development, and we're hoping to get feedback from people using or considering it. We'd love `to get in touch <https://forms.gle/26EMwdahdgm7Lscy9>`_!
|
||||
|
||||
@@ -69,6 +72,6 @@ TFTrainer Example
|
||||
|
||||
Below is an example of using Ray's TFTrainer. Under the hood, ``TFTrainer`` will create *replicas* of your model (controlled by ``num_replicas``) which are each managed by a worker.
|
||||
|
||||
.. literalinclude:: ../../../python/ray/experimental/sgd/tf/examples/tensorflow_train_example.py
|
||||
.. literalinclude:: ../../../python/ray/util/sgd/tf/examples/tensorflow_train_example.py
|
||||
:language: python
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
RLlib Development
|
||||
=================
|
||||
Contributing to RLlib
|
||||
=====================
|
||||
|
||||
Development Install
|
||||
-------------------
|
||||
|
||||
@@ -442,7 +442,7 @@ Sometimes, it is necessary to coordinate between pieces of code that live in dif
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from ray.experimental import named_actors
|
||||
from ray.util import named_actors
|
||||
|
||||
@ray.remote
|
||||
class Counter:
|
||||
|
||||
+10
-7
@@ -1,20 +1,23 @@
|
||||
Ray Serve (Experimental)
|
||||
========================
|
||||
Ray Serve
|
||||
=========
|
||||
|
||||
.. _`issue on GitHub`: https://github.com/ray-project/ray/issues
|
||||
|
||||
Ray Serve is a serving library that exposes python function/classes to HTTP.
|
||||
It has built-in support for flexible traffic policy. This means you can easy
|
||||
split incoming traffic to multiple implementations.
|
||||
|
||||
With Ray Serve, you can deploy your services at any scale.
|
||||
|
||||
.. warning::
|
||||
Ray Serve is Python 3 only.
|
||||
|
||||
Ray Serve is under development and its API may be revised in future Ray releases. If you encounter any bugs, please file an `issue on GitHub`_.
|
||||
|
||||
With Ray Serve, you can deploy your services at any scale.
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
.. literalinclude:: ../../python/ray/experimental/serve/examples/echo_full.py
|
||||
.. literalinclude:: ../../python/ray/serve/examples/echo_full.py
|
||||
|
||||
API
|
||||
---
|
||||
.. automodule:: ray.experimental.serve
|
||||
.. automodule:: ray.serve
|
||||
:members:
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
Signal API (Experimental)
|
||||
=========================
|
||||
|
||||
This experimental API allows tasks and actors to generate signals which can
|
||||
be received by other tasks and actors. In addition, task failures and actor
|
||||
method failures generate error signals. The error signals enable applications
|
||||
to detect failures and potentially recover from failures.
|
||||
|
||||
.. autofunction:: ray.experimental.signal.send
|
||||
|
||||
Here is a simple example of a remote function that sends a user-defined signal.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import ray.experimental.signal as signal
|
||||
|
||||
# Define an application level signal.
|
||||
class UserSignal(signal.Signal):
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
def get_value(self):
|
||||
return self.value
|
||||
|
||||
# Define a remote function that sends a user-defined signal.
|
||||
@ray.remote
|
||||
def send_signal(value):
|
||||
signal.send(UserSignal(value))
|
||||
|
||||
.. autofunction:: ray.experimental.signal.receive
|
||||
|
||||
Here is a simple example of how to receive signals from an actor or task identified
|
||||
by ``a``. Note that an actor is identified by its handle, and a task by one of its
|
||||
object ID return values.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import ray.experimental.signal as signal
|
||||
|
||||
# This returns a possibly empty list of all signals that have been sent by 'a'
|
||||
# since the last invocation of signal.receive from within this process. If 'a'
|
||||
# did not send any signals, then this will wait for up to 10 seconds to receive
|
||||
# a signal from 'a'.
|
||||
signal_list = signal.receive([a], timeout=10)
|
||||
|
||||
.. autofunction:: ray.experimental.signal.reset
|
||||
|
||||
|
||||
Example: sending a user signal
|
||||
------------------------------
|
||||
|
||||
The code below show a simple example in which a task, called ``send_signal()``
|
||||
sends a user signal and the driver gets it by invoking ``signal.receive()``.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import ray.experimental.signal as signal
|
||||
|
||||
# Define a user signal.
|
||||
class UserSignal(signal.Signal):
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
def get_value(self):
|
||||
return self.value
|
||||
|
||||
@ray.remote
|
||||
def send_signal(value):
|
||||
signal.send(UserSignal(value))
|
||||
return
|
||||
|
||||
signal_value = 'simple signal'
|
||||
object_id = send_signal.remote(signal_value)
|
||||
# Wait up to 10sec to receive a signal from the task. Note the task is
|
||||
# identified by the object_id it returns.
|
||||
result_list = signal.receive([object_id], timeout=10)
|
||||
# Print signal values. This should print "simple_signal".
|
||||
# Note that result_list[0] is the signal we expect from the task.
|
||||
# The signal is a tuple where the first element is the first object ID
|
||||
# returned by the task and the second element is the signal object.
|
||||
print(result_list[0][1].get_value())
|
||||
|
||||
Example: Getting an error signals
|
||||
---------------------------------
|
||||
|
||||
This is a simple example in which a driver gets an error signal caused
|
||||
by the failure of ``task()``.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@ray.remote
|
||||
def task():
|
||||
raise Exception('exception message')
|
||||
|
||||
object_id = task.remote()
|
||||
try:
|
||||
ray.get(object_id)
|
||||
except Exception as e:
|
||||
pass
|
||||
finally:
|
||||
result_list = signal.receive([object_id], timeout=10)
|
||||
# Expected signal is 'ErrorSignal'.
|
||||
assert type(result_list[0][1]) == signal.ErrorSignal
|
||||
# Print the error.
|
||||
print(result_list[0][1].get_error())
|
||||
|
||||
|
||||
Example: Sending signals between multiple actors
|
||||
------------------------------------------------
|
||||
|
||||
This is a more involved example in which two actors ``a1`` and ``a2`` each
|
||||
generate five signals, and another actor ``b`` waits to receive all signals
|
||||
generated by ``a1`` and ``a2``, respectively. Note that ``b`` recursively calls
|
||||
its own method ``get_signals()`` until it gets all signals it expects.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@ray.remote
|
||||
class ActorSendSignals(object):
|
||||
def send_signals(self, value, count):
|
||||
for i in range(count):
|
||||
signal.send(UserSignal(value + str(i)))
|
||||
|
||||
@ray.remote
|
||||
class ActorGetAllSignals(object):
|
||||
def __init__(self, num_expected_signals, *source_ids):
|
||||
self.received_signals = []
|
||||
self.num_expected_signals = num_expected_signals
|
||||
self.source_ids = source_ids
|
||||
|
||||
def register_handle(self, handle):
|
||||
self.this_actor = handle
|
||||
|
||||
def get_signals(self):
|
||||
new_signals = signal.receive(self.source_ids, timeout=10)
|
||||
self.received_signals.extend(new_signals)
|
||||
if len(self.received_signals) < self.num_expected_signals:
|
||||
self.this_actor.get_signals.remote()
|
||||
|
||||
def get_count(self):
|
||||
return len(self.received_signals)
|
||||
|
||||
# Create two actors to send signals.
|
||||
a1 = ActorSendSignals.remote()
|
||||
a2 = ActorSendSignals.remote()
|
||||
signal_value = 'simple signal'
|
||||
count = 5
|
||||
# Each actor sends five signals.
|
||||
a1.send_signals.remote(signal_value, count)
|
||||
a2.send_signals.remote(signal_value, count)
|
||||
|
||||
# Create an actor that waits for all five signals sent by each actor.
|
||||
b = ActorGetAllSignals.remote(2 * count, *[a1, a2])
|
||||
# Provide actor to its own handle, so it can recursively call itself
|
||||
# to get all signals from a1, and a2, respectively. This enables the actor
|
||||
# execute other methods if needed.
|
||||
ray.get(b.register_handle.remote(b))
|
||||
b.get_signals.remote()
|
||||
# Print total number of signals. This should be 2*count = 10.
|
||||
print(ray.get(b.get_count.remote()))
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
A failed actor (e.g., an actor that crashed) generates an error message only
|
||||
when another actor or task invokes one of its methods.
|
||||
|
||||
Please `let us know <https://github.com/ray-project/ray/issues>`__ any issues you encounter.
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
Tune: A Scalable Hyperparameter Tuning Library
|
||||
==============================================
|
||||
Tune: Scalable Hyperparameter Tuning
|
||||
====================================
|
||||
|
||||
.. image:: images/tune.png
|
||||
:scale: 30%
|
||||
:align: center
|
||||
|
||||
Tune is a Python library for hyperparameter tuning at any scale. Core features:
|
||||
Tune is a Python library for experiment execution and hyperparameter tuning at any scale. Core features:
|
||||
|
||||
* Launch a multi-node `distributed hyperparameter sweep <tune-distributed.html>`_ in less than 10 lines of code.
|
||||
* Supports any machine learning framework, including PyTorch, XGBoost, MXNet, and Keras. See `examples here <tune-examples.html>`_.
|
||||
|
||||
@@ -12,6 +12,7 @@ Finally, we've also included some content on using core Ray APIs with `Tensorflo
|
||||
|
||||
starting-ray.rst
|
||||
actors.rst
|
||||
async_api.rst
|
||||
using-ray-with-gpus.rst
|
||||
serialization.rst
|
||||
memory-management.rst
|
||||
|
||||
@@ -96,6 +96,7 @@ import ray.actor # noqa: F401
|
||||
from ray.actor import method # noqa: E402
|
||||
from ray.runtime_context import _get_runtime_context # noqa: E402
|
||||
from ray.cross_language import java_function, java_actor_class # noqa: E402
|
||||
from ray import util # noqa: E402
|
||||
|
||||
# Ray version string.
|
||||
__version__ = "0.9.0.dev0"
|
||||
@@ -140,6 +141,7 @@ __all__ = [
|
||||
"Language",
|
||||
"java_function",
|
||||
"java_actor_class",
|
||||
"util",
|
||||
]
|
||||
|
||||
# ID types
|
||||
|
||||
+3
-3
@@ -483,14 +483,14 @@ class ActorClass:
|
||||
# Check whether the name is already taken.
|
||||
if name is not None:
|
||||
try:
|
||||
ray.experimental.get_actor(name)
|
||||
ray.util.get_actor(name)
|
||||
except ValueError: # name is not taken, expected.
|
||||
pass
|
||||
else:
|
||||
raise ValueError(
|
||||
"The name {name} is already taken. Please use "
|
||||
"a different name or get existing actor using "
|
||||
"ray.experimental.get_actor('{name}')".format(name=name))
|
||||
"ray.util.get_actor('{name}')".format(name=name))
|
||||
|
||||
# Set the actor's default resources if not already set. First three
|
||||
# conditions are to check that no resources were specified in the
|
||||
@@ -585,7 +585,7 @@ class ActorClass:
|
||||
original_handle=True)
|
||||
|
||||
if name is not None:
|
||||
ray.experimental.register_actor(name, actor_handle)
|
||||
ray.util.register_actor(name, actor_handle)
|
||||
|
||||
return actor_handle
|
||||
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
from .gcs_flush_policy import (set_flushing_policy, GcsFlushPolicy,
|
||||
SimpleGcsFlushPolicy)
|
||||
from .named_actors import get_actor, register_actor
|
||||
from .api import get, wait
|
||||
from .actor_pool import ActorPool
|
||||
from .dynamic_resources import set_resource
|
||||
from . import iter
|
||||
|
||||
|
||||
def TensorFlowVariables(*args, **kwargs):
|
||||
raise DeprecationWarning(
|
||||
"'ray.experimental.TensorFlowVariables' is deprecated. Instead, please"
|
||||
" do 'from ray.experimental.tf_utils import TensorFlowVariables'.")
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TensorFlowVariables",
|
||||
"get_actor",
|
||||
"register_actor",
|
||||
"get",
|
||||
"wait",
|
||||
"set_flushing_policy",
|
||||
"GcsFlushPolicy",
|
||||
"SimpleGcsFlushPolicy",
|
||||
"set_resource",
|
||||
"ActorPool",
|
||||
"iter",
|
||||
]
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import ray
|
||||
import ray.cloudpickle as pickle
|
||||
|
||||
|
||||
class GcsFlushPolicy:
|
||||
"""Experimental: a policy to control GCS flushing.
|
||||
|
||||
Used by Monitor to enable automatic control of memory usage.
|
||||
"""
|
||||
|
||||
def should_flush(self, redis_client):
|
||||
"""Returns a bool, whether a flush request should be issued."""
|
||||
pass
|
||||
|
||||
def num_entries_to_flush(self):
|
||||
"""Returns an upper bound for number of entries to flush next."""
|
||||
pass
|
||||
|
||||
def record_flush(self):
|
||||
"""Must be called after a flush has been performed."""
|
||||
pass
|
||||
|
||||
|
||||
class SimpleGcsFlushPolicy(GcsFlushPolicy):
|
||||
"""A simple policy with constant flush rate, after a warmup period.
|
||||
|
||||
Example policy values:
|
||||
|
||||
flush_when_at_least_bytes 2GB
|
||||
|
||||
flush_period_secs 10s
|
||||
|
||||
flush_num_entries_each_time 10k
|
||||
|
||||
This means: (1) If the GCS shard uses less than 2GB of memory,
|
||||
no flushing would take place. This should cover most Ray runs. (2) The
|
||||
GCS shard will only honor a flush request, if it's issued after 10
|
||||
seconds since the last processed flush. In particular this means it's
|
||||
okay for the Monitor to issue requests more frequently than this param.
|
||||
(3) When processing a flush, the shard will flush at most 10k entries.
|
||||
This is to control the latency of each request.
|
||||
|
||||
Note, flush rate == (flush period) * (num entries each time). So
|
||||
applications that have a heavier GCS load can tune these params.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
flush_when_at_least_bytes=(1 << 31),
|
||||
flush_period_secs=10,
|
||||
flush_num_entries_each_time=10000):
|
||||
self.flush_when_at_least_bytes = flush_when_at_least_bytes
|
||||
self.flush_period_secs = flush_period_secs
|
||||
self.flush_num_entries_each_time = flush_num_entries_each_time
|
||||
self.last_flush_timestamp = time.time()
|
||||
|
||||
def should_flush(self, redis_client):
|
||||
if time.time() - self.last_flush_timestamp < self.flush_period_secs:
|
||||
return False
|
||||
|
||||
used_memory = redis_client.info("memory")["used_memory"]
|
||||
assert used_memory > 0
|
||||
|
||||
return used_memory >= self.flush_when_at_least_bytes
|
||||
|
||||
def num_entries_to_flush(self):
|
||||
return self.flush_num_entries_each_time
|
||||
|
||||
def record_flush(self):
|
||||
self.last_flush_timestamp = time.time()
|
||||
|
||||
def serialize(self):
|
||||
return pickle.dumps(self)
|
||||
|
||||
|
||||
def set_flushing_policy(flushing_policy):
|
||||
"""Serialize this policy for Monitor to pick up."""
|
||||
if "RAY_USE_NEW_GCS" not in os.environ:
|
||||
raise Exception(
|
||||
"set_flushing_policy() is only available when environment "
|
||||
"variable RAY_USE_NEW_GCS is present at both compile and run time."
|
||||
)
|
||||
ray.worker.global_worker.check_connected()
|
||||
redis_client = ray.worker.global_worker.redis_client
|
||||
|
||||
serialized = pickle.dumps(flushing_policy)
|
||||
redis_client.set("gcs_flushing_policy", serialized)
|
||||
@@ -1,4 +0,0 @@
|
||||
from ray.experimental.sgd.pytorch import PyTorchTrainer
|
||||
from ray.experimental.sgd.tf import TFTrainer
|
||||
|
||||
__all__ = ["PyTorchTrainer", "TFTrainer"]
|
||||
@@ -1,3 +0,0 @@
|
||||
from ray.experimental.sgd.tf.tf_trainer import (TFTrainer, TFTrainable)
|
||||
|
||||
__all__ = ["TFTrainer", "TFTrainable"]
|
||||
@@ -5,11 +5,8 @@ import time
|
||||
import traceback
|
||||
import json
|
||||
|
||||
import redis
|
||||
|
||||
import ray
|
||||
from ray.autoscaler.autoscaler import LoadMetrics, StandardAutoscaler
|
||||
import ray.cloudpickle as pickle
|
||||
import ray.gcs_utils
|
||||
import ray.utils
|
||||
import ray.ray_constants as ray_constants
|
||||
@@ -54,34 +51,6 @@ class Monitor:
|
||||
self.autoscaler = None
|
||||
self.autoscaling_config = None
|
||||
|
||||
# Experimental feature: GCS flushing.
|
||||
self.issue_gcs_flushes = "RAY_USE_NEW_GCS" in os.environ
|
||||
self.gcs_flush_policy = None
|
||||
if self.issue_gcs_flushes:
|
||||
# Data is stored under the first data shard, so we issue flushes to
|
||||
# that redis server.
|
||||
addr_port = self.redis.lrange("RedisShards", 0, -1)
|
||||
if len(addr_port) > 1:
|
||||
logger.warning(
|
||||
"Monitor: "
|
||||
"TODO: if launching > 1 redis shard, flushing needs to "
|
||||
"touch shards in parallel.")
|
||||
self.issue_gcs_flushes = False
|
||||
else:
|
||||
addr_port = addr_port[0].split(b":")
|
||||
self.redis_shard = redis.StrictRedis(
|
||||
host=addr_port[0],
|
||||
port=addr_port[1],
|
||||
password=redis_password)
|
||||
try:
|
||||
self.redis_shard.execute_command("HEAD.FLUSH 0")
|
||||
except redis.exceptions.ResponseError as e:
|
||||
logger.info(
|
||||
"Monitor: "
|
||||
"Turning off flushing due to exception: {}".format(
|
||||
str(e)))
|
||||
self.issue_gcs_flushes = False
|
||||
|
||||
def __del__(self):
|
||||
"""Destruct the monitor object."""
|
||||
# We close the pubsub client to avoid leaking file descriptors.
|
||||
@@ -288,37 +257,6 @@ class Monitor:
|
||||
ip_address += ":" + str(raylet_info["NodeManagerPort"])
|
||||
self.raylet_id_to_ip_map[node_id] = ip_address
|
||||
|
||||
def _maybe_flush_gcs(self):
|
||||
"""Experimental: issue a flush request to the GCS.
|
||||
|
||||
The purpose of this feature is to control GCS memory usage.
|
||||
|
||||
To activate this feature, Ray must be compiled with the flag
|
||||
RAY_USE_NEW_GCS set, and Ray must be started at run time with the flag
|
||||
as well.
|
||||
"""
|
||||
if not self.issue_gcs_flushes:
|
||||
return
|
||||
if self.gcs_flush_policy is None:
|
||||
serialized = self.redis.get("gcs_flushing_policy")
|
||||
if serialized is None:
|
||||
# Client has not set any policy; by default flushing is off.
|
||||
return
|
||||
self.gcs_flush_policy = pickle.loads(serialized)
|
||||
|
||||
if not self.gcs_flush_policy.should_flush(self.redis_shard):
|
||||
return
|
||||
|
||||
max_entries_to_flush = self.gcs_flush_policy.num_entries_to_flush()
|
||||
num_flushed = self.redis_shard.execute_command(
|
||||
"HEAD.FLUSH {}".format(max_entries_to_flush))
|
||||
logger.info("Monitor: num_flushed {}".format(num_flushed))
|
||||
|
||||
# This flushes event log and log files.
|
||||
ray.experimental.flush_redis_unsafe(self.redis)
|
||||
|
||||
self.gcs_flush_policy.record_flush()
|
||||
|
||||
def _run(self):
|
||||
"""Run the monitor.
|
||||
|
||||
@@ -346,8 +284,6 @@ class Monitor:
|
||||
if self.autoscaler:
|
||||
self.autoscaler.update()
|
||||
|
||||
self._maybe_flush_gcs()
|
||||
|
||||
# Process a round of messages.
|
||||
self.process_messages()
|
||||
|
||||
|
||||
@@ -977,7 +977,7 @@ cli.add_command(project_cli)
|
||||
cli.add_command(session_cli)
|
||||
|
||||
try:
|
||||
from ray.experimental.serve.scripts import serve_cli
|
||||
from ray.serve.scripts import serve_cli
|
||||
cli.add_command(serve_cli)
|
||||
except Exception as e:
|
||||
logger.debug(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from ray.experimental.serve.backend_config import BackendConfig
|
||||
from ray.experimental.serve.policy import RoutePolicy
|
||||
from ray.experimental.serve.api import (
|
||||
from ray.serve.backend_config import BackendConfig
|
||||
from ray.serve.policy import RoutePolicy
|
||||
from ray.serve.api import (
|
||||
init, create_backend, create_endpoint, link, split, get_handle, stat,
|
||||
set_backend_config, get_backend_config, accept_batch, route) # noqa: E402
|
||||
|
||||
@@ -7,18 +7,17 @@ from multiprocessing import cpu_count
|
||||
import numpy as np
|
||||
|
||||
import ray
|
||||
from ray.experimental.serve.constants import (
|
||||
DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT, SERVE_NURSERY_NAME)
|
||||
from ray.experimental.serve.global_state import (GlobalState,
|
||||
start_initial_state)
|
||||
from ray.experimental.serve.kv_store_service import SQLiteKVStore
|
||||
from ray.experimental.serve.task_runner import RayServeMixin, TaskRunnerActor
|
||||
from ray.experimental.serve.utils import (block_until_http_ready,
|
||||
get_random_letters, expand)
|
||||
from ray.experimental.serve.exceptions import RayServeException
|
||||
from ray.experimental.serve.backend_config import BackendConfig
|
||||
from ray.experimental.serve.policy import RoutePolicy
|
||||
from ray.experimental.serve.queues import Query
|
||||
from ray.serve.constants import (DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT,
|
||||
SERVE_NURSERY_NAME)
|
||||
from ray.serve.global_state import (GlobalState, start_initial_state)
|
||||
from ray.serve.kv_store_service import SQLiteKVStore
|
||||
from ray.serve.task_runner import RayServeMixin, TaskRunnerActor
|
||||
from ray.serve.utils import (block_until_http_ready, get_random_letters,
|
||||
expand)
|
||||
from ray.serve.exceptions import RayServeException
|
||||
from ray.serve.backend_config import BackendConfig
|
||||
from ray.serve.policy import RoutePolicy
|
||||
from ray.serve.queues import Query
|
||||
global_state = None
|
||||
|
||||
|
||||
@@ -114,7 +113,7 @@ def init(kv_store_connector=None,
|
||||
|
||||
# Try to get serve nursery if there exists
|
||||
try:
|
||||
ray.experimental.get_actor(SERVE_NURSERY_NAME)
|
||||
ray.util.get_actor(SERVE_NURSERY_NAME)
|
||||
global_state = GlobalState()
|
||||
return
|
||||
except ValueError:
|
||||
@@ -440,7 +439,7 @@ def get_handle(endpoint_name, relative_slo_ms=None, absolute_slo_ms=None):
|
||||
global_state.route_table.list_service(include_headless=True).values())
|
||||
|
||||
# Delay import due to it's dependency on global_state
|
||||
from ray.experimental.serve.handle import RayServeHandle
|
||||
from ray.serve.handle import RayServeHandle
|
||||
|
||||
return RayServeHandle(global_state.init_or_get_router(), endpoint_name,
|
||||
relative_slo_ms, absolute_slo_ms)
|
||||
@@ -1,6 +1,6 @@
|
||||
from enum import IntEnum
|
||||
|
||||
from ray.experimental.serve.exceptions import RayServeException
|
||||
from ray.serve.exceptions import RayServeException
|
||||
|
||||
|
||||
class TaskContext(IntEnum):
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.constants import DEFAULT_HTTP_ADDRESS
|
||||
from ray import serve
|
||||
from ray.serve.constants import DEFAULT_HTTP_ADDRESS
|
||||
import requests
|
||||
import time
|
||||
import pandas as pd
|
||||
@@ -6,8 +6,8 @@ import time
|
||||
|
||||
import requests
|
||||
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
|
||||
def echo(flask_request):
|
||||
+2
-2
@@ -10,8 +10,8 @@ import time
|
||||
import requests
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
|
||||
class MagicCounter:
|
||||
+3
-3
@@ -10,9 +10,9 @@ import time
|
||||
import requests
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray.experimental.serve import BackendConfig
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
from ray.serve import BackendConfig
|
||||
|
||||
|
||||
class MagicCounter:
|
||||
+2
-2
@@ -3,8 +3,8 @@ This example has backend which has batching functionality enabled.
|
||||
"""
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve import BackendConfig
|
||||
from ray import serve
|
||||
from ray.serve import BackendConfig
|
||||
|
||||
|
||||
class MagicCounter:
|
||||
+2
-2
@@ -18,8 +18,8 @@ import time
|
||||
import requests
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
|
||||
def echo(_):
|
||||
+2
-2
@@ -10,8 +10,8 @@ import time
|
||||
|
||||
import requests
|
||||
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
|
||||
def echo_v1(_):
|
||||
+2
-2
@@ -7,8 +7,8 @@ import time
|
||||
import requests
|
||||
|
||||
import ray
|
||||
import ray.experimental.serve as serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
import ray.serve as serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
# initialize ray serve system.
|
||||
# blocking=True will wait for HTTP server to be ready to serve request.
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
Ray serve pipeline example
|
||||
"""
|
||||
import ray
|
||||
import ray.experimental.serve as serve
|
||||
import ray.serve as serve
|
||||
import time
|
||||
|
||||
# initialize ray serve system.
|
||||
+2
-2
@@ -6,8 +6,8 @@ import time
|
||||
|
||||
import requests
|
||||
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
|
||||
def echo_v1(_):
|
||||
+1
-1
@@ -7,7 +7,7 @@ import time
|
||||
import requests
|
||||
|
||||
import ray
|
||||
import ray.experimental.serve as serve
|
||||
import ray.serve as serve
|
||||
|
||||
# initialize ray serve system.
|
||||
# blocking=True will wait for HTTP server to be ready to serve request.
|
||||
+2
-2
@@ -6,8 +6,8 @@ import time
|
||||
|
||||
import requests
|
||||
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.utils import pformat_color_json
|
||||
from ray import serve
|
||||
from ray.serve.utils import pformat_color_json
|
||||
|
||||
|
||||
def echo_v1(_):
|
||||
@@ -1,19 +1,18 @@
|
||||
import ray
|
||||
from ray.experimental.serve.constants import (
|
||||
BOOTSTRAP_KV_STORE_CONN_KEY, DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT,
|
||||
SERVE_NURSERY_NAME, ASYNC_CONCURRENCY)
|
||||
from ray.experimental.serve.kv_store_service import (
|
||||
BackendTable, RoutingTable, TrafficPolicyTable)
|
||||
from ray.experimental.serve.metric import (MetricMonitor,
|
||||
start_metric_monitor_loop)
|
||||
from ray.serve.constants import (BOOTSTRAP_KV_STORE_CONN_KEY,
|
||||
DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT,
|
||||
SERVE_NURSERY_NAME, ASYNC_CONCURRENCY)
|
||||
from ray.serve.kv_store_service import (BackendTable, RoutingTable,
|
||||
TrafficPolicyTable)
|
||||
from ray.serve.metric import (MetricMonitor, start_metric_monitor_loop)
|
||||
|
||||
from ray.experimental.serve.policy import RoutePolicy
|
||||
from ray.experimental.serve.server import HTTPActor
|
||||
from ray.serve.policy import RoutePolicy
|
||||
from ray.serve.server import HTTPActor
|
||||
|
||||
|
||||
def start_initial_state(kv_store_connector):
|
||||
nursery_handle = ActorNursery.remote()
|
||||
ray.experimental.register_actor(SERVE_NURSERY_NAME, nursery_handle)
|
||||
ray.util.register_actor(SERVE_NURSERY_NAME, nursery_handle)
|
||||
|
||||
ray.get(
|
||||
nursery_handle.store_bootstrap_state.remote(
|
||||
@@ -92,8 +91,7 @@ class GlobalState:
|
||||
def __init__(self, actor_nursery_handle=None):
|
||||
# Get actor nursery handle
|
||||
if actor_nursery_handle is None:
|
||||
actor_nursery_handle = ray.experimental.get_actor(
|
||||
SERVE_NURSERY_NAME)
|
||||
actor_nursery_handle = ray.util.get_actor(SERVE_NURSERY_NAME)
|
||||
self.actor_nursery_handle = actor_nursery_handle
|
||||
|
||||
# Connect to all the table
|
||||
@@ -126,7 +124,7 @@ class GlobalState:
|
||||
return_policy = default_policy
|
||||
# check if there is already a queue_actor running
|
||||
# with policy as p.name for the case where
|
||||
# serve nursery exists: ray.experimental.get_actor(SERVE_NURSERY_NAME)
|
||||
# serve nursery exists: ray.util.get_actor(SERVE_NURSERY_NAME)
|
||||
for p in RoutePolicy:
|
||||
queue_actor_tag = "queue_actor::" + p.name
|
||||
if queue_actor_tag in self.actor_handle_cache:
|
||||
@@ -1,8 +1,8 @@
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve.context import TaskContext
|
||||
from ray.experimental.serve.exceptions import RayServeException
|
||||
from ray.experimental.serve.constants import DEFAULT_HTTP_ADDRESS
|
||||
from ray.experimental.serve.request_params import RequestMetadata
|
||||
from ray import serve
|
||||
from ray.serve.context import TaskContext
|
||||
from ray.serve.exceptions import RayServeException
|
||||
from ray.serve.constants import DEFAULT_HTTP_ADDRESS
|
||||
from ray.serve.request_params import RequestMetadata
|
||||
|
||||
|
||||
class RayServeHandle:
|
||||
+3
-4
@@ -1,13 +1,12 @@
|
||||
import json
|
||||
import sqlite3
|
||||
from abc import ABC
|
||||
from typing import Union
|
||||
|
||||
from ray import cloudpickle as pickle
|
||||
|
||||
import ray.experimental.internal_kv as ray_kv
|
||||
from ray.experimental.serve.utils import logger
|
||||
from typing import Union
|
||||
from ray.experimental.serve.constants import NO_ROUTE_KEY
|
||||
from ray.serve.utils import logger
|
||||
from ray.serve.constants import NO_ROUTE_KEY
|
||||
|
||||
|
||||
class NamespacedKVStore(ABC):
|
||||
@@ -4,8 +4,8 @@ import itertools
|
||||
import numpy as np
|
||||
|
||||
import ray
|
||||
from ray.experimental.serve.queues import (CentralizedQueues)
|
||||
from ray.experimental.serve.utils import logger
|
||||
from ray.serve.queues import (CentralizedQueues)
|
||||
from ray.serve.utils import logger
|
||||
|
||||
|
||||
class RandomPolicyQueue(CentralizedQueues):
|
||||
@@ -13,7 +13,7 @@ import pickle
|
||||
import blist
|
||||
|
||||
import ray
|
||||
from ray.experimental.serve.utils import logger
|
||||
from ray.serve.utils import logger
|
||||
|
||||
|
||||
class Query:
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import time
|
||||
from ray.experimental.serve.constants import DEFAULT_LATENCY_SLO_MS
|
||||
from ray.serve.constants import DEFAULT_LATENCY_SLO_MS
|
||||
|
||||
|
||||
class RequestMetadata:
|
||||
@@ -3,7 +3,7 @@ import json
|
||||
import click
|
||||
|
||||
import ray
|
||||
import ray.experimental.serve as serve
|
||||
import ray.serve as serve
|
||||
|
||||
|
||||
@click.group("serve", help="Commands working with ray serve")
|
||||
@@ -5,10 +5,10 @@ import uvicorn
|
||||
|
||||
import ray
|
||||
from ray.experimental.async_api import _async_init
|
||||
from ray.experimental.serve.constants import HTTP_ROUTER_CHECKER_INTERVAL_S
|
||||
from ray.experimental.serve.context import TaskContext
|
||||
from ray.experimental.serve.utils import BytesEncoder
|
||||
from ray.experimental.serve.request_params import RequestMetadata
|
||||
from ray.serve.constants import HTTP_ROUTER_CHECKER_INTERVAL_S
|
||||
from ray.serve.context import TaskContext
|
||||
from ray.serve.utils import BytesEncoder
|
||||
from ray.serve.request_params import RequestMetadata
|
||||
|
||||
from urllib.parse import parse_qs
|
||||
|
||||
@@ -62,7 +62,7 @@ class HTTPProxy:
|
||||
assert ray.is_initialized()
|
||||
|
||||
# Delay import due to GlobalState depends on HTTP actor
|
||||
from ray.experimental.serve.global_state import GlobalState
|
||||
from ray.serve.global_state import GlobalState
|
||||
self.serve_global_state = GlobalState()
|
||||
self.route_table_cache = dict()
|
||||
|
||||
@@ -2,11 +2,11 @@ import time
|
||||
import traceback
|
||||
|
||||
import ray
|
||||
from ray.experimental.serve import context as serve_context
|
||||
from ray.experimental.serve.context import FakeFlaskRequest
|
||||
from ray.serve import context as serve_context
|
||||
from ray.serve.context import FakeFlaskRequest
|
||||
from collections import defaultdict
|
||||
from ray.experimental.serve.utils import parse_request_item
|
||||
from ray.experimental.serve.exceptions import RayServeException
|
||||
from ray.serve.utils import parse_request_item
|
||||
from ray.serve.exceptions import RayServeException
|
||||
|
||||
|
||||
class TaskRunner:
|
||||
+1
-1
@@ -4,7 +4,7 @@ import tempfile
|
||||
import pytest
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray import serve
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
+3
-3
@@ -2,10 +2,10 @@ import time
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from ray.experimental import serve
|
||||
from ray.experimental.serve import BackendConfig
|
||||
from ray import serve
|
||||
from ray.serve import BackendConfig
|
||||
import ray
|
||||
from ray.experimental.serve.constants import NO_ROUTE_KEY
|
||||
from ray.serve.constants import NO_ROUTE_KEY
|
||||
|
||||
|
||||
def test_e2e(serve_instance):
|
||||
+1
-1
@@ -2,7 +2,7 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
import ray
|
||||
from ray.experimental.serve.metric import MetricMonitor
|
||||
from ray.serve.metric import MetricMonitor
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
+2
-2
@@ -3,7 +3,7 @@ import subprocess
|
||||
import tempfile
|
||||
|
||||
import ray
|
||||
from ray.experimental import serve
|
||||
from ray import serve
|
||||
|
||||
|
||||
def test_new_driver(serve_instance):
|
||||
@@ -11,7 +11,7 @@ def test_new_driver(serve_instance):
|
||||
import ray
|
||||
ray.init(address="auto")
|
||||
|
||||
from ray.experimental import serve
|
||||
from ray import serve
|
||||
serve.init()
|
||||
|
||||
@serve.route("/driver")
|
||||
+2
-2
@@ -3,10 +3,10 @@ import asyncio
|
||||
import pytest
|
||||
import ray
|
||||
|
||||
from ray.experimental.serve.policy import (
|
||||
from ray.serve.policy import (
|
||||
RandomPolicyQueue, RandomPolicyQueueActor, RoundRobinPolicyQueueActor,
|
||||
PowerOfTwoPolicyQueueActor, FixedPackingPolicyQueueActor)
|
||||
from ray.experimental.serve.request_params import RequestMetadata
|
||||
from ray.serve.request_params import RequestMetadata
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from ray.experimental.serve.kv_store_service import (
|
||||
InMemoryKVStore, RayInternalKVStore, SQLiteKVStore)
|
||||
from ray.serve.kv_store_service import (InMemoryKVStore, RayInternalKVStore,
|
||||
SQLiteKVStore)
|
||||
|
||||
|
||||
def test_default_in_memory_kv():
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
import pytest
|
||||
|
||||
import ray
|
||||
import ray.experimental.serve.context as context
|
||||
from ray.experimental.serve.policy import RoundRobinPolicyQueueActor
|
||||
from ray.experimental.serve.task_runner import (
|
||||
RayServeMixin, TaskRunner, TaskRunnerActor, wrap_to_ray_error)
|
||||
from ray.experimental.serve.request_params import RequestMetadata
|
||||
import ray.serve.context as context
|
||||
from ray.serve.policy import RoundRobinPolicyQueueActor
|
||||
from ray.serve.task_runner import (RayServeMixin, TaskRunner, TaskRunnerActor,
|
||||
wrap_to_ray_error)
|
||||
from ray.serve.request_params import RequestMetadata
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
|
||||
from ray.experimental.serve.utils import BytesEncoder
|
||||
from ray.serve.utils import BytesEncoder
|
||||
|
||||
|
||||
def test_bytes_encoder():
|
||||
@@ -8,8 +8,8 @@ import os
|
||||
|
||||
import requests
|
||||
from pygments import formatters, highlight, lexers
|
||||
from ray.experimental.serve.context import FakeFlaskRequest, TaskContext
|
||||
from ray.experimental.serve.http_util import build_flask_request
|
||||
from ray.serve.context import FakeFlaskRequest, TaskContext
|
||||
from ray.serve.http_util import build_flask_request
|
||||
import itertools
|
||||
|
||||
|
||||
@@ -628,22 +628,22 @@ def test_register_and_get_named_actors(ray_start_regular):
|
||||
|
||||
f1 = Foo.remote()
|
||||
# Test saving f.
|
||||
ray.experimental.register_actor("f1", f1)
|
||||
ray.util.register_actor("f1", f1)
|
||||
# Test getting f.
|
||||
f2 = ray.experimental.get_actor("f1")
|
||||
f2 = ray.util.get_actor("f1")
|
||||
assert f1._actor_id == f2._actor_id
|
||||
|
||||
# Test same name register shall raise error.
|
||||
with pytest.raises(ValueError):
|
||||
ray.experimental.register_actor("f1", f2)
|
||||
ray.util.register_actor("f1", f2)
|
||||
|
||||
# Test register with wrong object type.
|
||||
with pytest.raises(TypeError):
|
||||
ray.experimental.register_actor("f3", 1)
|
||||
ray.util.register_actor("f3", 1)
|
||||
|
||||
# Test getting a nonexistent actor.
|
||||
with pytest.raises(ValueError):
|
||||
ray.experimental.get_actor("nonexistent")
|
||||
ray.util.get_actor("nonexistent")
|
||||
|
||||
# Test method
|
||||
assert ray.get(f1.method.remote()) == 1
|
||||
@@ -682,7 +682,7 @@ ray.get(actor.ping.remote())
|
||||
""".format(redis_address, actor_name)
|
||||
|
||||
run_string_as_driver(driver_script)
|
||||
detached_actor = ray.experimental.get_actor(actor_name)
|
||||
detached_actor = ray.util.get_actor(actor_name)
|
||||
assert ray.get(detached_actor.ping.remote()) == "pong"
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import time
|
||||
import pytest
|
||||
|
||||
import ray
|
||||
from ray.experimental import ActorPool
|
||||
from ray.util import ActorPool
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -2,7 +2,7 @@ import time
|
||||
from collections import Counter
|
||||
|
||||
import ray
|
||||
from ray.experimental.iter import from_items, from_iterators, from_range, \
|
||||
from ray.util.iter import from_items, from_iterators, from_range, \
|
||||
from_actors, ParallelIteratorWorker
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ from sklearn.linear_model import LogisticRegression
|
||||
from sklearn.neural_network import MLPClassifier
|
||||
from sklearn.model_selection import cross_val_score
|
||||
|
||||
from ray.experimental.joblib import register_ray
|
||||
from ray.util.joblib import register_ray
|
||||
import ray
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_register_ray():
|
||||
|
||||
def test_ray_backend(shutdown_only):
|
||||
register_ray()
|
||||
from ray.experimental.joblib.ray_backend import RayBackend
|
||||
from ray.util.joblib.ray_backend import RayBackend
|
||||
with joblib.parallel_backend("ray"):
|
||||
assert type(joblib.parallel.get_active_backend()[0]) == RayBackend
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ class Counter:
|
||||
self.count += 1
|
||||
return self.count
|
||||
counter = Counter.remote()
|
||||
ray.experimental.register_actor("Counter", counter)
|
||||
ray.util.register_actor("Counter", counter)
|
||||
time.sleep(100)
|
||||
""".format(address)
|
||||
|
||||
@@ -199,7 +199,7 @@ import time
|
||||
ray.init(address="{}")
|
||||
while True:
|
||||
try:
|
||||
counter = ray.experimental.get_actor("Counter")
|
||||
counter = ray.util.get_actor("Counter")
|
||||
break
|
||||
except ValueError:
|
||||
time.sleep(1)
|
||||
|
||||
@@ -61,7 +61,6 @@ def setup_monitor(address):
|
||||
monitor.subscribe(ray.gcs_utils.XRAY_HEARTBEAT_BATCH_CHANNEL)
|
||||
monitor.subscribe(ray.gcs_utils.XRAY_JOB_CHANNEL) # TODO: Remove?
|
||||
monitor.update_raylet_map(_append_port=True)
|
||||
monitor._maybe_flush_gcs()
|
||||
return monitor
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from .named_actors import get_actor, register_actor
|
||||
from .actor_pool import ActorPool
|
||||
from . import iter
|
||||
|
||||
__all__ = [
|
||||
"ActorPool",
|
||||
"iter",
|
||||
"get_actor",
|
||||
"register_actor",
|
||||
]
|
||||
|
||||
@@ -112,7 +112,7 @@ class ParallelIterator(Generic[T]):
|
||||
|
||||
Examples:
|
||||
>>> # Applying a function over items in parallel.
|
||||
>>> it = ray.experimental.iter.from_items([1, 2, 3], num_shards=2)
|
||||
>>> it = ray.util.iter.from_items([1, 2, 3], num_shards=2)
|
||||
... <__main__.ParallelIterator object>
|
||||
>>> it = it.for_each(lambda x: x * 2).gather_sync()
|
||||
... <__main__.LocalIterator object>
|
||||
@@ -120,13 +120,13 @@ class ParallelIterator(Generic[T]):
|
||||
... [2, 4, 6]
|
||||
|
||||
>>> # Creating from generators.
|
||||
>>> it = ray.experimental.iter.from_iterators([range(3), range(3)])
|
||||
>>> it = ray.util.iter.from_iterators([range(3), range(3)])
|
||||
... <__main__.ParallelIterator object>
|
||||
>>> print(list(it.gather_sync()))
|
||||
... [0, 0, 1, 1, 2, 2]
|
||||
|
||||
>>> # Accessing the individual shards of an iterator.
|
||||
>>> it = ray.experimental.iter.from_range(10, num_shards=2)
|
||||
>>> it = ray.util.iter.from_range(10, num_shards=2)
|
||||
... <__main__.ParallelIterator object>
|
||||
>>> it0 = it.get_shard(0)
|
||||
... <__main__.LocalIterator object>
|
||||
@@ -138,7 +138,7 @@ class ParallelIterator(Generic[T]):
|
||||
... [5, 6, 7, 8, 9]
|
||||
|
||||
>>> # Gathering results from actors synchronously in parallel.
|
||||
>>> it = ray.experimental.iter.from_actors(workers)
|
||||
>>> it = ray.util.iter.from_actors(workers)
|
||||
... <__main__.ParallelIterator object>
|
||||
>>> it = it.batch_across_shards()
|
||||
... <__main__.LocalIterator object>
|
||||
@@ -4,7 +4,7 @@ from joblib.parallel import register_parallel_backend
|
||||
def register_ray():
|
||||
""" Register Ray Backend to be called with parallel_backend("ray"). """
|
||||
try:
|
||||
from ray.experimental.joblib.ray_backend import RayBackend
|
||||
from ray.util.joblib.ray_backend import RayBackend
|
||||
register_parallel_backend("ray", RayBackend)
|
||||
except ImportError:
|
||||
msg = ("To use the ray backend you must install ray."
|
||||
+2
-2
@@ -2,7 +2,7 @@ from joblib._parallel_backends import MultiprocessingBackend
|
||||
from joblib.pool import PicklingPool
|
||||
import logging
|
||||
|
||||
from ray.experimental.multiprocessing.pool import Pool
|
||||
from ray.util.multiprocessing.pool import Pool
|
||||
import ray
|
||||
|
||||
RAY_ADDRESS_ENV = "RAY_ADDRESS"
|
||||
@@ -24,7 +24,7 @@ class RayBackend(MultiprocessingBackend):
|
||||
"""Make Ray Pool the father class of PicklingPool. PicklingPool is a
|
||||
father class that inherits Pool from multiprocessing.pool. The next
|
||||
line is a patch, which changes the inheritance of Pool to be from
|
||||
ray.experimental.multiprocessing.pool.
|
||||
ray.util.multiprocessing.pool.
|
||||
"""
|
||||
PicklingPool.__bases__ = (Pool, )
|
||||
"""Use all available resources when n_jobs == -1. Must set RAY_ADDRESS
|
||||
@@ -0,0 +1,4 @@
|
||||
from ray.util.sgd.pytorch import PyTorchTrainer
|
||||
from ray.util.sgd.tf import TFTrainer
|
||||
|
||||
__all__ = ["PyTorchTrainer", "TFTrainer"]
|
||||
+2
-2
@@ -7,8 +7,8 @@ PyTorchTrainable = None
|
||||
try:
|
||||
import torch # noqa: F401
|
||||
|
||||
from ray.experimental.sgd.pytorch.pytorch_trainer import (PyTorchTrainer,
|
||||
PyTorchTrainable)
|
||||
from ray.util.sgd.pytorch.pytorch_trainer import (PyTorchTrainer,
|
||||
PyTorchTrainable)
|
||||
|
||||
__all__ = ["PyTorchTrainer", "PyTorchTrainable"]
|
||||
except ImportError:
|
||||
+1
-1
@@ -7,7 +7,7 @@ import torch.distributed as dist
|
||||
import torch.utils.data
|
||||
from torch.nn.parallel import DistributedDataParallel
|
||||
|
||||
from ray.experimental.sgd.pytorch.pytorch_runner import PyTorchRunner
|
||||
from ray.util.sgd.pytorch.pytorch_runner import PyTorchRunner
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ import torchvision
|
||||
import torchvision.transforms as transforms
|
||||
|
||||
import ray
|
||||
from ray.experimental.sgd.pytorch import (PyTorchTrainer, PyTorchTrainable)
|
||||
from ray.experimental.sgd.pytorch.resnet import ResNet18
|
||||
from ray.experimental.sgd.pytorch.utils import TEST_MODE
|
||||
from ray.util.sgd.pytorch import (PyTorchTrainer, PyTorchTrainable)
|
||||
from ray.util.sgd.pytorch.resnet import ResNet18
|
||||
from ray.util.sgd.pytorch.utils import TEST_MODE
|
||||
|
||||
|
||||
def initialization_hook(runner):
|
||||
+3
-4
@@ -15,8 +15,8 @@ from torch.nn import functional as F
|
||||
from scipy.stats import entropy
|
||||
|
||||
import ray
|
||||
from ray.experimental.sgd import PyTorchTrainer
|
||||
from ray.experimental.sgd.pytorch.utils import TEST_MODE
|
||||
from ray.util.sgd import PyTorchTrainer
|
||||
from ray.util.sgd.pytorch.utils import TEST_MODE
|
||||
|
||||
# Training parameters
|
||||
TRAIN_BATCHES = 5
|
||||
@@ -256,8 +256,7 @@ if __name__ == "__main__":
|
||||
ray.init(address=args.address)
|
||||
|
||||
path = os.path.dirname(ray.__file__)
|
||||
model_path = os.path.join(
|
||||
path, "experimental/sgd/pytorch/examples/mnist_cnn.pt")
|
||||
model_path = os.path.join(path, "util/sgd/pytorch/examples/mnist_cnn.pt")
|
||||
# load the pretrained mnist classification model for inception_score
|
||||
|
||||
trainer = train_example(
|
||||
+1
-1
@@ -13,7 +13,7 @@ import numpy as np
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
|
||||
from ray.experimental.sgd import PyTorchTrainer
|
||||
from ray.util.sgd import PyTorchTrainer
|
||||
|
||||
|
||||
class LinearDataset(torch.utils.data.Dataset):
|
||||
+1
-1
@@ -14,7 +14,7 @@ import torch.nn as nn
|
||||
|
||||
import ray
|
||||
from ray import tune
|
||||
from ray.experimental.sgd.pytorch.pytorch_trainer import PyTorchTrainable
|
||||
from ray.util.sgd.pytorch.pytorch_trainer import PyTorchTrainable
|
||||
|
||||
|
||||
class LinearDataset(torch.utils.data.Dataset):
|
||||
+2
-2
@@ -8,8 +8,8 @@ import torch.utils.data
|
||||
from torch.utils.data import Dataset
|
||||
|
||||
import ray
|
||||
from ray.experimental.sgd.pytorch import utils as pytorch_utils
|
||||
from ray.experimental.sgd import utils
|
||||
from ray.util.sgd.pytorch import utils as pytorch_utils
|
||||
from ray.util.sgd import utils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
amp = None
|
||||
+4
-4
@@ -11,11 +11,11 @@ import ray
|
||||
|
||||
from ray.tune import Trainable
|
||||
from ray.tune.trial import Resources
|
||||
from ray.experimental.sgd.pytorch.distributed_pytorch_runner import (
|
||||
from ray.util.sgd.pytorch.distributed_pytorch_runner import (
|
||||
DistributedPyTorchRunner)
|
||||
from ray.experimental.sgd import utils
|
||||
from ray.experimental.sgd.pytorch.pytorch_runner import PyTorchRunner
|
||||
from ray.experimental.sgd.pytorch import utils as pytorch_utils
|
||||
from ray.util.sgd import utils
|
||||
from ray.util.sgd.pytorch.pytorch_runner import PyTorchRunner
|
||||
from ray.util.sgd.pytorch import utils as pytorch_utils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
RESIZE_COOLDOWN_S = 10
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user