Skip to content

Commit c7bbc74

Browse files
committed
update content
Signed-off-by: Max Pumperla <max.pumperla@googlemail.com>
1 parent 67c2a0f commit c7bbc74

File tree

77 files changed

+1244
-370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1244
-370
lines changed

_toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ parts:
6868
- file: courses/00_Developer_Intro_to_Ray/output/05_Intro_Ray_Serve_PyTorch_03.ipynb
6969
- file: courses/00_Developer_Intro_to_Ray/output/05_Intro_Ray_Serve_PyTorch_04.ipynb
7070
- file: courses/00_Developer_Intro_to_Ray/output/05_Intro_Ray_Serve_PyTorch_05.ipynb
71+
- file: courses/00_Developer_Intro_to_Ray/output/README_01.ipynb
7172
- caption: Anyscale 101
7273
chapters:
7374
- file: courses/anyscale_101/output/101_anyscale_intro_jobs_01.ipynb

courses/00_Developer_Intro_to_Ray/00_Intro_Ray_Core_Basics.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"metadata": {},
168168
"source": [
169169
"<div class=\"alert alert-info\">\n",
170-
" <strong><a href=\"https://docs.ray.io/en/latest/ray-core/key-concepts.html#tasks\" target=\"_blank\">Tasks</a></strong> is a remote, stateless Python function invokation.\n",
170+
" <strong><a href=\"https://docs.ray.io/en/latest/ray-core/key-concepts.html#tasks\" target=\"_blank\">Tasks</a></strong> is a remote, stateless Python function invocation.\n",
171171
"</div>\n"
172172
]
173173
},
@@ -466,9 +466,9 @@
466466
],
467467
"metadata": {
468468
"kernelspec": {
469-
"display_name": "Xing-ray-jupyter-3.11",
469+
"display_name": "ray-jupyter",
470470
"language": "python",
471-
"name": "xing-ray-jupyter"
471+
"name": "python3"
472472
},
473473
"language_info": {
474474
"codemirror_mode": {

courses/00_Developer_Intro_to_Ray/00a_Intro_Ray_Core_Advancement.ipynb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"id": "fcd84432-84b0-426e-8546-42f33804f2fa",
3232
"metadata": {},
3333
"source": [
34-
"This notebook provides a step-by-step introduction to Object store, Tasks, and Actors, which all are the fundamental building blocks of Ray that enables distributed computing.\n",
34+
"This notebook provides a step-by-step introduction to Object store, Tasks, and Actors, which are all the fundamental building blocks of Ray that enables distributed computing.\n",
3535
"\n",
3636
"<div class=\"alert alert-block alert-info\">\n",
3737
"\n",
@@ -79,7 +79,7 @@
7979
},
8080
{
8181
"cell_type": "code",
82-
"execution_count": 4,
82+
"execution_count": null,
8383
"id": "98399ea9-933a-452f-be3f-bc1535006443",
8484
"metadata": {
8585
"tags": []
@@ -227,7 +227,7 @@
227227
"metadata": {},
228228
"source": [
229229
"<div class=\"alert alert-info\">\n",
230-
"This patterns assumes that two conditions are satisftied:\n",
230+
"This pattern assumes that two conditions are satisfied:\n",
231231
"<ol>\n",
232232
"<li> the object is large</li>\n",
233233
"<li> user wants to reuse the object multiple times</li>\n",
@@ -308,6 +308,15 @@
308308
"metadata": {},
309309
"outputs": [],
310310
"source": [
311+
"@ray.remote\n",
312+
"def remote_add(a, b):\n",
313+
" return a + b\n",
314+
"\n",
315+
"@ray.remote\n",
316+
"def expensive_square(x):\n",
317+
" time.sleep(5)\n",
318+
" return x**2\n",
319+
"\n",
311320
"# 1st task\n",
312321
"square_ref = expensive_square.remote(2)\n",
313322
"square_value = ray.get(square_ref)\n",
@@ -474,7 +483,7 @@
474483
"id": "09269628",
475484
"metadata": {},
476485
"source": [
477-
"Note we did not have to re-define the remote function, instead we can an update version using `.options`"
486+
"Note we did not have to re-define the remote function, instead we could have used `.options`"
478487
]
479488
},
480489
{
@@ -547,9 +556,9 @@
547556
"metadata": {},
548557
"outputs": [],
549558
"source": [
550-
"@ray.remote(runtime_env={\"env_vars\": {\"my_custom_env\": \"prod\"}})\n",
559+
"@ray.remote(runtime_env={\"env_vars\": {\"MY_CUSTOM_ENV\": \"prod\"}})\n",
551560
"def f():\n",
552-
" env = os.environ[\"my_custom_env\"]\n",
561+
" env = os.environ[\"MY_CUSTOM_ENV\"]\n",
553562
" return f\"My custom env is {env}\""
554563
]
555564
},
@@ -624,7 +633,7 @@
624633
"source": [
625634
"However, these resource specifications are not enforced - i.e. they are entirely [logical and not physical](https://docs.ray.io/en/latest/ray-core/scheduling/resources.html#physical-resources-vs-logical-resources).\n",
626635
"\n",
627-
"This means that you can for instance perform multiprocessing ormultithreading within a task and oversubscribe to resources."
636+
"This means that you can for instance perform multiprocessing or multithreading within a task and oversubscribe to resources."
628637
]
629638
},
630639
{
@@ -684,7 +693,7 @@
684693
" <li><strong>Memory</strong></li>\n",
685694
"</ul>\n",
686695
"\n",
687-
"<p>Ray's scheduler checks the <strong>resource specification</strong> (sometimes referred to as <strong>resource shape</strong>) to match tasks and actors with available resources in the cluster. If the exact resource combination is unavailable, Ray may autoscaler the cluster.</p>\n",
696+
"<p>Ray's scheduler checks the <strong>resource specification</strong> (sometimes referred to as <strong>resource shape</strong>) to match tasks and actors with available resources in the cluster. If the exact resource combination is unavailable, Ray may autoscale the cluster.</p>\n",
688697
"\n",
689698
"<p>You can inspect the current resource availability using:</p>\n",
690699
"<pre><code>\n",
@@ -1142,7 +1151,7 @@
11421151
"id": "9ad7a2da-0411-4e77-a371-3583a21c949e",
11431152
"metadata": {},
11441153
"source": [
1145-
"Define an actor with the `@ray.remote` decorator and then use `<class_name>.remote()` ask Ray to construct and instance of this actor somewhere in the cluster.\n",
1154+
"Define an actor with the `@ray.remote` decorator and then use `<class_name>.remote()` to ask Ray to construct an instance of this actor somewhere in the cluster.\n",
11461155
"\n",
11471156
"We get an actor handle which we can use to communicate with that actor, pass to other code, tasks, or actors, etc."
11481157
]
@@ -1324,9 +1333,9 @@
13241333
],
13251334
"metadata": {
13261335
"kernelspec": {
1327-
"display_name": "Xing-ray-jupyter-3.11",
1336+
"display_name": "ray-jupyter",
13281337
"language": "python",
1329-
"name": "xing-ray-jupyter"
1338+
"name": "python3"
13301339
},
13311340
"language_info": {
13321341
"codemirror_mode": {

courses/00_Developer_Intro_to_Ray/01_Intro_Ray_AI_Libs_Overview.ipynb

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"source": [
1818
"💻 **Launch Locally**: You can run this notebook locally, but performance will be reduced.\n",
1919
"\n",
20-
"🚀 **Launch on Cloud**: A Ray Cluster with 4 GPUs (Click [here](http://console.anyscale.com/register) to easily start a Ray cluster on Anyscale) is recommanded to run this notebook."
20+
"🚀 **Launch on Cloud**: A Ray Cluster with 4 GPUs (Click [here](http://console.anyscale.com/register) to easily start a Ray cluster on Anyscale) is recommended to run this notebook."
2121
]
2222
},
2323
{
@@ -51,15 +51,24 @@
5151
{
5252
"cell_type": "code",
5353
"execution_count": null,
54-
"metadata": {
55-
"tags": []
56-
},
54+
"metadata": {},
55+
"outputs": [],
56+
"source": [
57+
"# (Optional): If you get an XGBoostError at import, you might have to `brew install libomp` before importing xgboost again\n",
58+
"!brew install libomp"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {},
5765
"outputs": [],
5866
"source": [
5967
"import asyncio\n",
6068
"import fastapi\n",
6169
"import pandas as pd\n",
6270
"import requests\n",
71+
"# macos: If you get an XGBoostError at import, you might have to `brew install libomp` before importing xgboost again\n",
6372
"import xgboost\n",
6473
"from pydantic import BaseModel\n",
6574
"from sklearn.model_selection import train_test_split\n",
@@ -68,6 +77,7 @@
6877
"import ray.tune\n",
6978
"import ray.train\n",
7079
"from ray.train.xgboost import XGBoostTrainer as RayTrainXGBoostTrainer\n",
80+
"from ray.train import RunConfig\n",
7181
"import ray.data\n",
7282
"import ray.serve"
7383
]
@@ -86,7 +96,7 @@
8696
"\n",
8797
"|<img src=\"https://technical-training-assets.s3.us-west-2.amazonaws.com/Introduction_to_Ray_AIR/e2e_air.png\" width=\"100%\" loading=\"lazy\">|\n",
8898
"|:-:|\n",
89-
"|Ray AI Libraries enable end-to-end ML development and provides multiple options for integrating with other tools and libraries form the MLOps ecosystem.|\n",
99+
"|Ray AI Libraries enable end-to-end ML development and provides multiple options for integrating with other tools and libraries from the MLOps ecosystem.|\n",
90100
"\n"
91101
]
92102
},
@@ -108,7 +118,7 @@
108118
"* **`fare_amount`**\n",
109119
" * Float representing total price including tax, tip, fees, etc.\n",
110120
"* **`tolls_amount`**\n",
111-
" * Float represnting the total paid on tolls if any.\n",
121+
" * Float representing the total paid on tolls if any.\n",
112122
"\n",
113123
"**Target**\n",
114124
"* **`trip_amount`**\n",
@@ -177,7 +187,7 @@
177187
"metadata": {},
178188
"outputs": [],
179189
"source": [
180-
"model_path = \"/mnt/cluster_storage/model.ubj\" # Modify this path to your local folder if it runs on your local environment"
190+
"storage_folder = \"/mnt/cluster_storage/\" # Modify this path to your local folder if it runs on your local environment"
181191
]
182192
},
183193
{
@@ -186,6 +196,9 @@
186196
"metadata": {},
187197
"outputs": [],
188198
"source": [
199+
"from pathlib import Path\n",
200+
"model_path = Path(storage_folder) / \"model.ubj\"\n",
201+
"\n",
189202
"def my_xgboost_func(params): \n",
190203
" evals_result = {}\n",
191204
" dtrain, dtest = load_data()\n",
@@ -196,6 +209,7 @@
196209
" evals=[(dtest, \"eval\")], \n",
197210
" evals_result=evals_result,\n",
198211
" )\n",
212+
" # Use Path\n",
199213
" bst.save_model(model_path)\n",
200214
" print(f\"{evals_result['eval']}\")\n",
201215
" return {\"eval-rmse\": evals_result[\"eval\"][\"rmse\"][-1]}\n",
@@ -234,6 +248,7 @@
234248
" \"max_depth\": 6,\n",
235249
" \"eta\": ray.tune.uniform(0.01, 0.3),\n",
236250
" },\n",
251+
" run_config=RunConfig(storage_path=storage_folder),\n",
237252
" tune_config=ray.tune.TuneConfig( # Tell it which metric to tune\n",
238253
" metric=\"eval-rmse\",\n",
239254
" mode=\"min\",\n",
@@ -264,7 +279,7 @@
264279
"\n",
265280
"In case your training data is too large, your training might take a long time to complete.\n",
266281
"\n",
267-
"To speed it up, shard the dataset across training workers and perform distributed XBoost training.\n",
282+
"To speed it up, shard the dataset across training workers and perform distributed XGBoost training.\n",
268283
"\n",
269284
"Let's redefine `load_data` to now load a different slice of the data given the worker index/rank."
270285
]
@@ -484,7 +499,7 @@
484499
"metadata": {},
485500
"outputs": [],
486501
"source": [
487-
"prediction_pipeline.write_parquet(\"/mnt/cluster_storage/xgboost_predictions\") #update this to your local path if runs on your local"
502+
"prediction_pipeline.write_parquet(\"./xgboost_predictions\") #update this to your local path if runs on your local"
488503
]
489504
},
490505
{
@@ -500,22 +515,33 @@
500515
"metadata": {},
501516
"outputs": [],
502517
"source": [
503-
"!ls /mnt/cluster_storage/xgboost_predictions/ #update this to your local path if runs on your local"
518+
"!ls {storage_folder}/xgboost_predictions/"
519+
]
520+
},
521+
{
522+
"cell_type": "markdown",
523+
"metadata": {},
524+
"source": [
525+
"### 2.6 Clean up"
504526
]
505527
},
506528
{
507529
"cell_type": "code",
508530
"execution_count": null,
509531
"metadata": {},
510532
"outputs": [],
511-
"source": []
533+
"source": [
534+
"# Run this cell for file cleanup \n",
535+
"!rm -rf {storage_folder}/xgboost_predictions/\n",
536+
"!rm {model_path}"
537+
]
512538
}
513539
],
514540
"metadata": {
515541
"kernelspec": {
516-
"display_name": "Xing-ray-jupyter-3.11",
542+
"display_name": "ray-jupyter",
517543
"language": "python",
518-
"name": "xing-ray-jupyter"
544+
"name": "python3"
519545
},
520546
"language_info": {
521547
"codemirror_mode": {

0 commit comments

Comments
 (0)