Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

</div>

[AutoGluon](https://auto.gluon.ai/stable/index.html) is an open-source AutoML library that trains state-of-the-art ML models on tabular, time-series, and multimodal data with just a few lines of code. AutoGluon-Cloud takes that same API and runs it on AWS — train models and serve predictions on [Amazon SageMaker](https://aws.amazon.com/sagemaker/) without managing infrastructure or setting up a heavyweight ML environment on your local machine.

It supports two workflows:
AutoGluon-Cloud lets you train and deploy state-of-the-art ML models in the cloud in a few lines of code. Run [AutoGluon](https://auto.gluon.ai/stable/index.html) on [Amazon SageMaker](https://aws.amazon.com/sagemaker/) without worrying about infrastructure, dependencies, or a heavy local ML environment. It supports two workflows:

- **[Train your own predictor](https://auto.gluon.ai/cloud/stable/tutorials/predictor-tabular.html)** — the same `fit → deploy → predict` workflow as local AutoGluon, with all the heavy lifting offloaded to SageMaker.
- **[Run pretrained foundation models](https://auto.gluon.ai/cloud/stable/tutorials/foundation-model-timeseries.html)** — deploy state-of-the-art pretrained models like [Chronos-2](https://huggingface.co/amazon/chronos-2) for zero-shot inference, with no training required.
Expand All @@ -27,7 +25,7 @@ It supports two workflows:
pip install autogluon.cloud
```

Then provision the IAM role and S3 bucket AutoGluon-Cloud needs on AWS:
Then provision the IAM role and S3 bucket AutoGluon-Cloud needs to run on AWS:

```python
from autogluon.cloud import bootstrap
Expand All @@ -39,6 +37,8 @@ See the [Setup tutorial](https://auto.gluon.ai/cloud/stable/tutorials/setup.html

## ⚙️ Train your own model

Train an AutoGluon predictor on your data and serve it from a SageMaker endpoint — same API as local AutoGluon, all heavy lifting on AWS. Full walkthrough: [tabular](https://auto.gluon.ai/cloud/stable/tutorials/predictor-tabular.html), [time series](https://auto.gluon.ai/cloud/stable/tutorials/predictor-timeseries.html).

```python
from autogluon.cloud import TabularCloudPredictor

Expand All @@ -65,6 +65,8 @@ result = cloud_predictor.predict(test_data)

## 🚀 Run a pretrained foundation model

Skip training entirely — deploy a pretrained model like Chronos-2 to SageMaker and get zero-shot predictions out of the box. Full walkthrough: [time series](https://auto.gluon.ai/cloud/stable/tutorials/foundation-model-timeseries.html).

```python
from autogluon.cloud import TimeSeriesFoundationModel

Expand Down
23 changes: 9 additions & 14 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ Train and Deploy AutoGluon in the Cloud

::::::

[AutoGluon](https://auto.gluon.ai/stable/index.html) is an open-source AutoML library that trains state-of-the-art ML models on tabular, time-series, and multimodal data with just a few lines of code. AutoGluon-Cloud takes that same API and runs it on AWS — train models and serve predictions on [Amazon SageMaker](https://aws.amazon.com/sagemaker/) without managing infrastructure or setting up a heavyweight ML environment on your local machine.

It supports two workflows:
AutoGluon-Cloud lets you train and deploy state-of-the-art ML models in the cloud in a few lines of code. Run [AutoGluon](https://auto.gluon.ai/stable/index.html) on [Amazon SageMaker](https://aws.amazon.com/sagemaker/) without worrying about infrastructure, dependencies, or a heavy local ML environment. It supports two workflows:

- **[Train your own predictor](tutorials/predictor-tabular.md)** — the same `fit → deploy → predict` workflow as local AutoGluon, with all the heavy lifting offloaded to SageMaker.
- **[Run pretrained foundation models](tutorials/foundation-model-timeseries.md)** — deploy state-of-the-art pretrained models like [Chronos-2](https://huggingface.co/amazon/chronos-2) for zero-shot inference, with no training required.

## {octicon}`package` Installation

```bash
pip install autogluon.cloud
```

Before running any of the snippets below, follow the [Setup tutorial](tutorials/setup.md) to register the IAM role and S3 bucket that SageMaker will use.

## {octicon}`gear` Train AutoGluon predictors in the cloud

Full walkthrough: [Tabular](tutorials/predictor-tabular.md), [Time Series](tutorials/predictor-timeseries.md).
Expand Down Expand Up @@ -146,17 +152,6 @@ endpoint.delete_endpoint()
:::


## {octicon}`package` Installation

[![PyPI](https://img.shields.io/pypi/v/autogluon.cloud.svg)](https://pypi.org/project/autogluon.cloud/)
[![Python Versions](https://img.shields.io/pypi/pyversions/autogluon.cloud)](https://pypi.org/project/autogluon.cloud/)

```bash
pip install autogluon.cloud
```

Before running the examples above, set up your AWS resources (IAM role + S3 bucket) by following the [Setup](tutorials/setup.md) tutorial.

```{toctree}
---
caption: Tutorials
Expand Down
120 changes: 98 additions & 22 deletions docs/tutorials/foundation-model-timeseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,19 @@ That makes the workflow much simpler than [training your own time series predict

AutoGluon-Cloud exposes this workflow through {py:class}`~autogluon.cloud.TimeSeriesFoundationModel`. For now it covers time series forecasting only, with models like Chronos-2 available out of the box.

```{attention}
SageMaker compute and S3 storage are billed to your AWS account. AutoGluon-Cloud is a free wrapper, but it's your responsibility to monitor usage and delete endpoints when no longer needed.
```

## Create the model

A {py:class}`~autogluon.cloud.TimeSeriesFoundationModel` needs an IAM execution role (so SageMaker can run jobs on your behalf) and an S3 bucket (to stage data and store outputs). There are two ways to supply them:

- Use a saved config (recommended). Save the role and bucket once to `~/.autogluon/cloud.yaml` — see [Setup](./setup.md) — and subsequent constructor calls will pick them up automatically:

```python
from autogluon.cloud import TimeSeriesFoundationModel

model = TimeSeriesFoundationModel(model_id="chronos-2")
```
```{important}
Before running any code below, follow the [Setup tutorial](./setup.md) to register the IAM role and S3 bucket that SageMaker will use. The examples assume those resources are saved in `~/.autogluon/cloud.yaml`.
```

- Pass them at construction. Useful when you need different roles or buckets per call:
```python
from autogluon.cloud import TimeSeriesFoundationModel

```python
model = TimeSeriesFoundationModel(
model_id="chronos-2",
role="arn:aws:iam::222222222222:role/MyAutoGluonRole",
cloud_output_path="s3://my-autogluon-bucket/ag-foundation-model",
)
```
model = TimeSeriesFoundationModel(model_id="chronos-2")
```

The examples in the rest of this tutorial reuse a single `model` object created this way.
The rest of the tutorial reuses this `model` object.

### Available models

Expand Down Expand Up @@ -160,6 +146,96 @@ The endpoint stays active — and billed — until you delete it:
endpoint.delete_endpoint()
```

### Invoke the endpoint without AutoGluon-Cloud

The deployed endpoint is a normal SageMaker endpoint, so you can invoke it from any AWS SDK. Unlike the trained-predictor case, foundation model endpoints always need per-request inference settings (`prediction_length`, `freq`, `target`, etc.) bundled into the payload — so plain CSV is not supported. Pick one of the two structured payload formats below.

:::{dropdown} Payload formats — boto3 examples
:animate: fade-in-slide-down
:color: secondary

**Option 1: AutoGluon-Cloud's native `application/x-autogluon` envelope.** Each DataFrame is serialized as base64-encoded parquet, with inference settings carried in `inference_kwargs`. This is what {py:meth}`autogluon.cloud.TimeSeriesEndpoint.predict` sends under the hood:

```python
import base64
import io
import json
import boto3
import pandas as pd

def df_to_b64(df: pd.DataFrame) -> str:
return base64.b64encode(df.to_parquet()).decode("ascii")

data = pd.read_parquet("https://autogluon.s3.amazonaws.com/datasets/timeseries/retail_sales/train.parquet")
known_covariates = (
pd.read_parquet("https://autogluon.s3.amazonaws.com/datasets/timeseries/retail_sales/test.parquet")
.drop(columns=["Sales"])
)

payload = {
"version": 1,
"data": df_to_b64(data),
"known_covariates": df_to_b64(known_covariates),
"inference_kwargs": {
"prediction_length": 13,
"target": "Sales",
"id_column": "id",
"timestamp_column": "timestamp",
},
}

client = boto3.client("sagemaker-runtime")
response = client.invoke_endpoint(
EndpointName=ENDPOINT_NAME,
ContentType="application/x-autogluon",
Accept="application/x-parquet",
Body=json.dumps(payload).encode("utf-8"),
)
forecasts = pd.read_parquet(io.BytesIO(response["Body"].read()))
```

**Option 2: Per-item JSON.** Each item is a JSON object with its target history and, optionally, past and future values of covariates inline. This is the same payload schema used by [Chronos-2 on SageMaker JumpStart](https://github.com/amazon-science/chronos-forecasting/blob/v2.2.2/notebooks/deploy-chronos-to-amazon-sagemaker.ipynb), so it's a drop-in if you already have code talking to a JumpStart endpoint:

```python
import io
import json
import boto3
import pandas as pd

payload = {
"inputs": [
{
"item_id": "store_1",
"start": "2014-01-05", # ISO timestamp of the first target value
"target": [123.0, 145.0, 167.0, ...], # historical target values
"past_covariates": { # past covariate values (same length as target)
"Promo": [0, 1, 0, ...],
"SchoolHoliday": [0, 0, 1, ...],
},
"future_covariates": { # future values over the forecast horizon (length = prediction_length)
"Promo": [1, 0, ..., 1],
"SchoolHoliday": [0, 1, ..., 0],
},
},
# ... one entry per item
],
"parameters": {
"prediction_length": 13,
"freq": "W", # required when "start" is set
},
}

client = boto3.client("sagemaker-runtime")
response = client.invoke_endpoint(
EndpointName=ENDPOINT_NAME,
ContentType="application/json",
Accept="application/x-parquet",
Body=json.dumps(payload).encode("utf-8"),
)
forecasts = pd.read_parquet(io.BytesIO(response["Body"].read()))
```
:::

### Reattaching to an existing endpoint

To send requests to an endpoint that's already running (e.g. from a previous session, or one a
Expand Down
35 changes: 12 additions & 23 deletions docs/tutorials/predictor-tabular.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
# Train and Deploy a Tabular Predictor on Amazon SageMaker

```{tip}
```{note}
This tutorial covers tabular classification and regression. For time series forecasting, see [Train a Time Series Predictor](./predictor-timeseries.md).
```

AutoGluon-Cloud lets you train, deploy, and run inference with AutoGluon tabular predictors on AWS using the same APIs you'd use locally. Under the hood, it runs your jobs on [Amazon SageMaker](https://aws.amazon.com/sagemaker/) using AWS's official [AutoGluon deep learning containers](https://aws.github.io/deep-learning-containers/reference/available_images/#autogluon-training) — so you don't manage any infrastructure yourself.

```{attention}
SageMaker compute and S3 storage are billed to your AWS account. AutoGluon-Cloud is a free wrapper, but it's your responsibility to monitor usage to avoid unexpected charges.
```

## Training

**Create the predictor.** A {py:class}`~autogluon.cloud.TabularCloudPredictor` needs an IAM execution role (so SageMaker can run jobs on your behalf) and an S3 bucket (to stage data and store trained artifacts). There are two ways to supply them:

- Use a saved config (recommended). Save the role and bucket once to `~/.autogluon/cloud.yaml` — see [Setup](setup.md) — and subsequent constructor calls will pick them up automatically:

```python
from autogluon.cloud import TabularCloudPredictor

cloud_predictor = TabularCloudPredictor()
```
```{important}
Before running any code below, follow the [Setup tutorial](setup.md) to register the IAM role and S3 bucket that SageMaker will use. The examples assume those resources are saved in `~/.autogluon/cloud.yaml`.
```

- Pass them at construction. Useful when you need different roles or buckets per call:
Create the predictor:

```python
cloud_predictor = TabularCloudPredictor(
role="arn:aws:iam::222222222222:role/MyAutoGluonRole",
cloud_output_path="s3://my-autogluon-bucket/tabular-demo",
)
```
```python
from autogluon.cloud import TabularCloudPredictor

**Train.** {py:meth}`autogluon.cloud.TabularCloudPredictor.fit` runs [`TabularPredictor.fit()`](https://auto.gluon.ai/stable/api/autogluon.tabular.TabularPredictor.fit.html) inside a remote SageMaker job — along with `train_data`, the `predictor_init_args` and `predictor_fit_args` are forwarded straight through. Training, model artifacts, and AutoGluon itself all live on the remote instance, so you don't need AutoGluon installed locally.
cloud_predictor = TabularCloudPredictor()
```

`train_data` can be a pandas DataFrame, or a path to a local or S3 file (CSV or Parquet). In every case AutoGluon-Cloud loads the data locally and uploads it to your `cloud_output_path` bucket before kicking off the SageMaker job.
{py:meth}`TabularCloudPredictor.fit() <autogluon.cloud.TabularCloudPredictor.fit>` runs [`TabularPredictor.fit()`](https://auto.gluon.ai/stable/api/autogluon.tabular.TabularPredictor.fit.html) inside a remote SageMaker job — along with `train_data`, the `predictor_init_args` and `predictor_fit_args` are forwarded straight through. Training, model artifacts, and AutoGluon itself all live on the remote instance, so you don't need AutoGluon installed locally.

```python
cloud_predictor.fit(
Expand All @@ -44,6 +31,8 @@ cloud_predictor.fit(
)
```

`train_data` can be a pandas DataFrame, or a path to a local or S3 file (CSV or Parquet). In every case AutoGluon-Cloud loads the data locally and uploads it to your `cloud_output_path` bucket before kicking off the SageMaker job.

### Reattach to a training job
If your local connection drops, the training job keeps running on SageMaker. You can reattach with another `CloudPredictor` via {py:meth}`~autogluon.cloud.TabularCloudPredictor.attach_job` as long as you have the job name — it's logged when training starts (`INFO:sagemaker:Creating training-job with name: ag-cloudpredictor-...`) and also visible in the SageMaker console.

Expand Down
Loading
Loading