Skip to content

Commit

Permalink
[AIR][Docs] Remove BatchPredictor from examples (ray-project#37178)
Browse files Browse the repository at this point in the history
ray-project#36947 deprecated `BatchPredictor`. This PR removes or updates references to `BatchPredictor` in the AIR examples.

The following examples already use updated APIs:
* Stable Diffusion Batch Prediction with Ray AIR
* GPT-J-6B Batch Prediction with Ray AIR (LLM)

The following examples have been updated to use updated APIs:
* Training a model with distributed XGBoost
* Training a model with distributed LightGBM

I've removed batch prediction sections from the other examples, and, where appropriate, linked to the batch inference user guide.

Signed-off-by: harborn <[email protected]>
  • Loading branch information
bveeramani authored and harborn committed Aug 17, 2023
1 parent 9651059 commit cca8034
Show file tree
Hide file tree
Showing 32 changed files with 592 additions and 3,343 deletions.
1 change: 0 additions & 1 deletion doc/source/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ parts:
- file: ray-air/deployment
- file: ray-air/examples/index
sections:
- file: ray-air/examples/opt_deepspeed_batch_inference
- file: ray-air/examples/torch_image_example
- file: ray-air/examples/torch_detection
- file: ray-air/examples/convert_existing_pytorch_code_to_ray_air
Expand Down
14 changes: 0 additions & 14 deletions doc/source/ray-air/doc_code/pytorch_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,3 @@ def train_func(config):
result = trainer.fit()
print(f"Last result: {result.metrics}")
# __air_pytorch_train_end__


# # __air_pytorch_batchpred_start__
# import random
# from ray.train.batch_predictor import BatchPredictor
# from ray.train.torch import TorchPredictor

# batch_predictor = BatchPredictor.from_checkpoint(result.checkpoint, TorchPredictor)

# items = [{"x": random.uniform(0, 1) for _ in range(10)}]
# prediction_dataset = ray.data.from_items(items)

# predictions = batch_predictor.predict(prediction_dataset, dtype=torch.float)
# # __air_pytorch_batchpred_end__
21 changes: 0 additions & 21 deletions doc/source/ray-air/doc_code/tf_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,3 @@ def train_func(config: dict):
result = trainer.fit()
print(result.metrics)
# __air_tf_train_end__

# __air_tf_batchpred_start__
import numpy as np

from ray.train.batch_predictor import BatchPredictor
from ray.train.tensorflow import TensorflowPredictor


batch_predictor = BatchPredictor.from_checkpoint(
result.checkpoint, TensorflowPredictor, model_definition=build_model
)

items = [{"x": np.random.uniform(0, 1)} for _ in range(10)]
prediction_dataset = ray.data.from_items(items)

predictions = batch_predictor.predict(prediction_dataset, dtype=tf.float32)

print("PREDICTIONS")
predictions.show()

# __air_tf_batchpred_end__
13 changes: 1 addition & 12 deletions doc/source/ray-air/examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,12 @@ filegroup(
py_test_run_all_subdirectory(
size = "medium",
include = ["*.py"],
exclude = ["torch_image_batch_pretrained.py"],
extra_srcs = [],
data = ["//doc/source/ray-air/examples:air_examples"],
tags = ["exclusive", "team:ml", "ray_air"],
)

py_test_run_all_subdirectory(
size = "medium",
include = ["torch_image_batch_pretrained.py"],
exclude = [],
extra_srcs = [],
data = ["//doc/source/ray-air/examples:air_examples"],
tags = ["exclusive", "team:ml", "ray_air", "gpu"],
tags = ["exclusive", "team:ml", "ray_air"],
)


# --------------------------------------------------------------------
# Test all doc/source/ray-air/examples notebooks.
# --------------------------------------------------------------------
Expand All @@ -50,7 +40,6 @@ py_test_run_all_notebooks(
"gptj_serving.ipynb", # Requires GPUs
"stablediffusion_batch_prediction.ipynb", # Requires GPUs
"gptj_deepspeed_fine_tuning.ipynb", # Requires release test
"opt_deepspeed_batch_inference.ipynb", # Requires release test
"dolly_lightning_fsdp_finetuning.ipynb", # Requires release test
],
data = ["//doc/source/ray-air/examples:air_examples"],
Expand Down
Loading

0 comments on commit cca8034

Please sign in to comment.