Overview
Ray 2.0, released on August 15, 2022, introduces Ray AIR (AI Runtime) for a unified ML API covering training, tuning, and serving.
Main Features
Ray AIR
Ray AIR unifies Ray libraries (Train, Tune, Serve, Data) under a consistent API to simplify end-to-end ML workflows.
python
import ray
from ray import train
from ray.train.xgboost import XGBoostTrainer
ray.init()
trainer = XGBoostTrainer(
label_column='target',
params={'max_depth': 6, 'eta': 0.3},
datasets={'train': train_dataset},
)
result = trainer.fit()
print(result.metrics)
Unified ML API
Predictors and Checkpoints provide a common interface for model deployment, regardless of the training framework used.
python
import ray
from ray import serve
@serve.deployment
class ModelServing:
def __init__(self):
self.model = None # load model
async def __call__(self, request):
data = await request.json()
return {'prediction': 42}
# serve.run(ModelServing.bind())
