Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyao committed Apr 21, 2023
1 parent fb34fc3 commit 4479f66
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 22 deletions.
19 changes: 19 additions & 0 deletions doc/source/_static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,22 @@ window.onload = function() {
localStorage.removeItem("scroll");
}
};

// When the document is fully loaded
document.addEventListener("DOMContentLoaded", function() {
// find all the code blocks' copy buttons
let codeButtons = document.querySelectorAll(".copybtn");
for (let i = 0; i < codeButtons.length; i++) {
const button = codeButtons[i];
// and add a click event listener to each one for Google Analytics.
button.addEventListener("click", function() {
gtag("event", "code_copy_click", {
"send_to": "UA-110413294-1",
"event_category": "ray_docs_copy_code",
"event_label": "URL: " + document.URL
+ " Button: " + button.getAttribute("data-clipboard-target"),
"value": 1,
});
});
}
});
Binary file added doc/source/images/llm-stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions doc/source/ray-contribute/docs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,27 @@
"cd ray/doc\n",
"```\n",
"\n",
"**Note**: If you are on an Apple Silicon (M1) read the instructions below for installing the dependencies.\n",
"**Note**: If you are using Apple Silicon (M1), follow the instructions below before continuing.\n",
"\n",
"Make sure you activate the Python environment you are using (e.g. venv, conda, etc.) and then to install the documentation dependencies, run the following command:\n",
"Activate the Python environment you are using (e.g., venv, conda, etc.). Install the documentation dependencies, with the following command:\n",
"\n",
"```shell\n",
"pip install -r requirements-doc.txt\n",
"```\n",
"\n",
"Additionally, it's best if you install the dependencies for our linters with\n",
"Install the dependencies for our linters to ensure your changes comply with our style guide.\n",
"\n",
"```shell\n",
"pip install -r ../python/requirements_linters.txt\n",
"```\n",
"\n",
"so that you can make sure your changes comply with our style guide.\n",
"Building the documentation is done by running the following command:\n",
"Build the documentation by running the following command:\n",
"\n",
"```shell\n",
"make develop\n",
"```\n",
"\n",
"which will build the documentation into the `_build` directory.\n",
"Find the documentation build in the `_build` directory.\n",
"After the build finishes, you can simply open the `_build/html/index.html` file in your browser.\n",
"It's considered good practice to check the output of your build to make sure everything is working as expected.\n",
"\n",
Expand Down
95 changes: 88 additions & 7 deletions doc/source/ray-overview/use-cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,94 @@ Ray Use Cases

This page indexes common Ray use cases for scaling ML. It contains highlighted references to blogs, examples, and tutorials also located elsewhere in the Ray documentation.

.. _ref-use-cases-llm:

LLMs and Gen AI
---------------

Large language models (LLMs) and generative AI are rapidly changing industries, and demand compute at an astonishing pace. Ray provides a distributed compute framework for scaling these models, allowing developers to train and deploy models faster and more efficiently. With specialized libraries for data streaming, training, fine-tuning, hyperparameter tuning, and serving, Ray simplifies the process of developing and deploying large-scale AI models.

.. figure:: /images/llm-stack.png

Learn more about how Ray scales LLMs and generative AI with the following resources.

.. panels::
:container: container pb-3
:column: col-md-3 px-1 py-1
:img-top-cls: p-2 w-75 d-block mx-auto fixed-height-img

---
:img-top: /images/ray_logo.png

.. link-button:: https://www.anyscale.com/blog/ray-common-production-challenges-for-generative-ai-infrastructure
:type: url
:text: [Blog] How Ray solves common production challenges for generative AI infrastructure
:classes: btn-link btn-block stretched-link webCrawler

---
:img-top: /images/ray_logo.png

.. link-button:: https://www.anyscale.com/blog/training-175b-parameter-language-models-at-1000-gpu-scale-with-alpa-and-ray
:type: url
:text: [Blog] Training 175B Parameter Language Models at 1000 GPU scale with Alpa and Ray
:classes: btn-link btn-block stretched-link webCrawler

---
:img-top: /images/ray_logo.png

.. link-button:: https://www.anyscale.com/blog/faster-stable-diffusion-fine-tuning-with-ray-air
:type: url
:text: [Blog] Faster stable diffusion fine-tuning with Ray AIR
:classes: btn-link btn-block stretched-link webCrawler

---
:img-top: /images/ray_logo.png

.. link-button:: https://www.anyscale.com/blog/how-to-fine-tune-and-serve-llms-simply-quickly-and-cost-effectively-using
:type: url
:text: [Blog] How to fine tune and serve LLMs simply, quickly and cost effectively using Ray + DeepSpeed + HuggingFace
:classes: btn-link btn-block stretched-link webCrawler

---
:img-top: /images/ray_logo.png

.. link-button:: https://www.businessinsider.com/openai-chatgpt-trained-on-anyscale-ray-generative-lifelike-ai-models-2022-12
:type: url
:text: [Blog] How OpenAI Uses Ray to Train Tools like ChatGPT
:classes: btn-link btn-block stretched-link chatgpt

---
:img-top: /images/ray_logo.png

.. link-button:: /ray-air/examples/gptj_deepspeed_fine_tuning
:type: ref
:text: [Example] GPT-J-6B Fine-Tuning with Ray AIR and DeepSpeed
:classes: btn-link btn-block stretched-link antServing

---
:img-top: /images/ray_logo.png

.. link-button:: /ray-air/examples/dreambooth_finetuning
:type: ref
:text: [Example] Fine-tuning DreamBooth with Ray AIR
:classes: btn-link btn-block stretched-link rayForward

---
:img-top: /images/ray_logo.png

.. link-button:: /ray-air/examples/stablediffusion_batch_prediction
:type: ref
:text: [Example] Stable Diffusion Batch Prediction with Ray AIR
:classes: btn-link btn-block stretched-link rayForward

---
:img-top: /images/ray_logo.png

.. link-button:: /ray-air/examples/gptj_serving
:type: ref
:text: [Example] GPT-J-6B Serving with Ray AIR
:classes: btn-link btn-block stretched-link webCrawler

.. _ref-use-cases-batch-infer:

Batch Inference
Expand Down Expand Up @@ -530,13 +618,6 @@ The following highlights feature projects leveraging Ray Core's distributed APIs
---
:img-top: /images/ray_logo.png

.. link-button:: https://www.businessinsider.com/openai-chatgpt-trained-on-anyscale-ray-generative-lifelike-ai-models-2022-12
:type: url
:text: [Blog] How OpenAI Uses Ray to Train Tools like ChatGPT
:classes: btn-link btn-block stretched-link chatgpt
---
:img-top: /images/ray_logo.png

.. link-button:: https://www.anyscale.com/blog/building-highly-available-and-scalable-online-applications-on-ray-at-ant
:type: url
:text: [Blog] Highly Available and Scalable Online Applications on Ray at Ant Group
Expand Down
12 changes: 4 additions & 8 deletions doc/source/serve/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ First, let's take a look at our text-translation model. Here's its code:
:start-after: __start_translation_model__
:end-before: __end_translation_model__
:language: python
:linenos: true
```

The Python file, called `model.py`, uses the `Translator` class to translate English text to French.

- The `self.model` variable on line 8 inside `Translator`'s `__init__` method
- The `self.model` variable inside `Translator`'s `__init__` method
stores a function that uses the [t5-small](https://huggingface.co/t5-small)
model to translate text.
- When `self.model` is called on English text, it returns translated French text
inside a dictionary formatted as `[{"translation_text": "..."}]`.
- The `Translator`'s `translate` method extracts the translated text on
line 15 by indexing into the dictionary.
- The `Translator`'s `translate` method extracts the translated text by indexing into the dictionary.

You can copy-paste this script and run it locally. It translates `"Hello world!"`
into `"Bonjour Monde!"`.
Expand Down Expand Up @@ -133,7 +131,6 @@ Here's the full Ray Serve script that we built:
:start-after: __deployment_full_start__
:end-before: __deployment_full_end__
:language: python
:linenos: true
```

We can run our script with the `serve run` CLI command. This command takes in an import path
Expand Down Expand Up @@ -201,7 +198,7 @@ For example, let's deploy a machine learning pipeline with two steps:
You can copy-paste this script and run it locally. It summarizes the snippet from _A Tale of Two Cities_ to `it was the best of times, it was worst of times .`

```console
$ python model.py
$ python summary_model.py

it was the best of times, it was worst of times .
```
Expand All @@ -212,10 +209,9 @@ Here's a Ray Serve deployment graph that chains the two models together. The gra
:start-after: __start_graph__
:end-before: __end_graph__
:language: python
:linenos: true
```

This script contains our `Summarizer` class converted to a deployment and our `Translator` class with some modifications. In this script, the `Summarizer` class contains the `__call__` method since requests are sent to it first. It also takes in the `Translator` as one of its constructor arguments, so it can forward summarized texts to the `Translator` deployment. The `__call__` method also contains some new code on lines 44 and 45:
This script contains our `Summarizer` class converted to a deployment and our `Translator` class with some modifications. In this script, the `Summarizer` class contains the `__call__` method since requests are sent to it first. It also takes in the `Translator` as one of its constructor arguments, so it can forward summarized texts to the `Translator` deployment. The `__call__` method also contains some new code:

```python
translation_ref = await self.translator.translate.remote(summary)
Expand Down
3 changes: 2 additions & 1 deletion python/ray/tune/tests/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import torch.nn.functional as F

from ray import air, tune
from ray.air import session
from ray.tune.schedulers import ASHAScheduler
# __tutorial_imports_end__
# fmt: on
Expand Down Expand Up @@ -105,7 +106,7 @@ def train_mnist(config):
acc = test(model, test_loader)

# Send the current training result back to Tune
tune.report(mean_accuracy=acc)
session.report({"mean_accuracy": acc})

if i % 5 == 0:
# This saves the model to the trial directory
Expand Down

0 comments on commit 4479f66

Please sign in to comment.