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
2 changes: 1 addition & 1 deletion doc/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ h3 {
}

p {
font-size: 0.875rem;
font-size: 1.0rem;
color: #4b5563;
}
78 changes: 9 additions & 69 deletions doc/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

This guide will help you get started with the SageMaker HyperPod CLI and SDK to perform basic operations.

## Cluster Management

### List Available Clusters
## List Available Clusters

List all available SageMaker HyperPod clusters in your account:

Expand All @@ -19,20 +17,14 @@ hyp list-cluster [--region <region>] [--namespace <namespace>] [--output <json|t

````{tab-item} SDK
```python
from sagemaker.hyperpod.hyperpod_manager import HyperPodManager
from sagemaker.hyperpod import list_clusters

clusters = HyperPodManager.list_clusters(region='us-east-2')
print(clusters)
list_clusters(region='us-east-2')
```
````
`````

**Parameters:**
- `region` (string) - Optional. The AWS region where the SageMaker HyperPod and EKS clusters are located. If not specified, uses the region from your current AWS account credentials.
- `namespace` (string) - Optional. The namespace to check quota with. Only SageMaker managed namespaces are supported.
- `output` (enum) - Optional. The output format: `table` or `json` (default).

### Connect to a Cluster
## Connect to a Cluster

Configure your local kubectl environment to interact with a specific SageMaker HyperPod cluster and namespace:

Expand All @@ -45,18 +37,14 @@ hyp set-cluster-context --cluster-name <cluster-name> [--namespace <namespace>]

````{tab-item} SDK
```python
from sagemaker.hyperpod.hyperpod_manager import HyperPodManager
from sagemaker.hyperpod import set_cluster_context

HyperPodManager.set_context('<hyperpod-cluster-name>', region='us-east-2')
set_cluster_context('<my-cluster>', region='us-east-2')
```
````
`````

**Parameters:**
- `cluster-name` (string) - Required. The SageMaker HyperPod cluster name to configure with.
- `namespace` (string) - Optional. The namespace to connect to. If not specified, the CLI will automatically discover accessible namespaces.

### Get Current Cluster Context
## Get Current Cluster Context

View information about the currently configured cluster context:

Expand All @@ -69,61 +57,13 @@ hyp get-cluster-context

````{tab-item} SDK
```python
from sagemaker.hyperpod.hyperpod_manager import HyperPodManager

# Get current context information
context = HyperPodManager.get_context()
print(context)
```
````
`````

## Job Management

### List Pods for a Training Job
from sagemaker.hyperpod import get_cluster_context

View all pods associated with a specific training job:

`````{tab-set}
````{tab-item} CLI
```bash
hyp list-pods hyp-pytorch-job --job-name <job-name>
```
````

````{tab-item} SDK
```python
# List all pods created for this job
pytorch_job.list_pods()
```
````
`````

**Parameters:**
- `job-name` (string) - Required. The name of the job to list pods for.

### Access Pod Logs

View logs for a specific pod within a training job:

`````{tab-set}
````{tab-item} CLI
```bash
hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
```
````

````{tab-item} SDK
```python
# Check the logs from pod0
pytorch_job.get_logs_from_pod("demo-pod-0")
get_cluster_context()
```
````
`````

**Parameters:**
- `job-name` (string) - Required. The name of the job to get logs for.
- `pod-name` (string) - Required. The name of the pod to get logs from.

## Next Steps

Expand Down
4 changes: 3 additions & 1 deletion doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Example Notebooks <examples>
API reference <_apidoc/modules>
```

SageMaker HyperPod CLI and SDK provide a seamless way to manage distributed training and inference workloads on EKS-hosted SageMaker HyperPod clusters—without needing Kubernetes expertise. Use the powerful CLI to launch and monitor training jobs and endpoints, or leverage the Python SDK to do the same programmatically with minimal code, including support for JumpStart models, custom endpoints, and built-in monitoring.
SageMaker HyperPod Command Line Interface (CLI) and Software Development Kit (SDK) provide a seamless way to manage distributed training and inference workloads on EKS-hosted SageMaker HyperPod clusters—without needing Kubernetes expertise. Use the powerful CLI to launch and monitor training jobs and endpoints, or leverage the Python SDK to do the same programmatically with minimal code, including support for JumpStart models, custom endpoints, and built-in monitoring.

## Start Here

## Start Here

Expand Down
123 changes: 89 additions & 34 deletions doc/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ You can create inference endpoints using either JumpStart models or custom model
````{tab-item} CLI
```bash
hyp create hyp-jumpstart-endpoint \
--version 1.0 \
--model-id jumpstart-model-id \
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart \
--tls-output-s3-uri s3://sample-bucket
--model-id jumpstart-model-id \
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
```
````

Expand Down Expand Up @@ -69,19 +67,21 @@ js_endpoint.create()
````{tab-item} CLI
```bash
hyp create hyp-custom-endpoint \
--version 1.0 \
--endpoint-name endpoint-custom \
--model-uri s3://my-bucket/model-artifacts \
--image 123456789012.dkr.ecr.us-west-2.amazonaws.com/my-inference-image:latest \
--instance-type ml.g5.8xlarge \
--tls-output-s3-uri s3://sample-bucket
--version 1.0 \
--endpoint-name endpoint-s3 \
--model-name <model-name> \
--model-source-type s3 \
--instance-type <instance-type> \
--image-uri <image-uri> \
--container-port 8080 \
--model-volume-mount-name model-weights
```
````

````{tab-item} SDK
```python
from sagemaker.hyperpod.inference.config.hp_custom_endpoint_config import Model, Server, SageMakerEndpoint, TlsConfig, EnvironmentVariables
from sagemaker.hyperpod.inference.hp_custom_endpoint import HPCustomEndpoint
from sagemaker.hyperpod.inference.hp_custom_endpoint import HPEndpoint

model = Model(
model_source_type="s3",
Expand Down Expand Up @@ -115,7 +115,7 @@ endpoint_name = SageMakerEndpoint(name="endpoint-custom-pytorch")

tls_config = TlsConfig(tls_certificate_output_s3_uri="s3://sample-bucket")

custom_endpoint = HPCustomEndpoint(
custom_endpoint = HPEndpoint(
model=model,
server=server,
resources=resources,
Expand All @@ -129,16 +129,18 @@ custom_endpoint.create()
````
`````

## Key Parameters
### Key Parameters

When creating an inference endpoint, you'll need to specify:

- **endpoint-name**: Unique identifier for your endpoint
- **model-id** (JumpStart): ID of the pre-trained JumpStart model
- **model-uri** (Custom): S3 location of your model artifacts
- **image** (Custom): Docker image containing your inference code
- **instance-type**: The EC2 instance type to use
- **tls-output-s3-uri**: S3 location to store TLS certificates
- **model-id** (JumpStart): ID of the pre-trained JumpStart model
- **image-uri** (Custom): Docker image containing your inference code
- **model-name** (Custom): Name of model to create on SageMaker
- **model-source-type** (Custom): Source type: fsx or s3
- **model-volume-mount-name** (Custom): Name of the model volume mount
- **container-port** (Custom): Port on which the model server listens

## Managing Inference Endpoints

Expand All @@ -158,14 +160,14 @@ hyp list hyp-custom-endpoint
````{tab-item} SDK
```python
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
from sagemaker.hyperpod.inference.hp_custom_endpoint import HPCustomEndpoint
from sagemaker.hyperpod.inference.hp_custom_endpoint import HPEndpoint

# List JumpStart endpoints
jumpstart_endpoints = HPJumpStartEndpoint.list()
print(jumpstart_endpoints)

# List custom endpoints
custom_endpoints = HPCustomEndpoint.list()
custom_endpoints = HPEndpoint.list()
print(custom_endpoints)
```
````
Expand All @@ -177,24 +179,24 @@ print(custom_endpoints)
````{tab-item} CLI
```bash
# Describe JumpStart endpoint
hyp describe hyp-jumpstart-endpoint --endpoint-name <endpoint-name>
hyp describe hyp-jumpstart-endpoint --name <endpoint-name>

# Describe custom endpoint
hyp describe hyp-custom-endpoint --endpoint-name <endpoint-name>
hyp describe hyp-custom-endpoint --name <endpoint-name>
```
````

````{tab-item} SDK
```python
from sagemaker.hyperpod.inference import HyperPodJumpstartEndpoint, HyperPodCustomEndpoint
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
from sagemaker.hyperpod.inference.hp_custom_endpoint import HPEndpoint

# Get JumpStart endpoint details
jumpstart_endpoint = HyperPodJumpstartEndpoint.load(endpoint_name="endpoint-jumpstart")
jumpstart_details = jumpstart_endpoint.describe()
print(jumpstart_details)
jumpstart_endpoint = HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)

# Get custom endpoint details
custom_endpoint = HyperPodCustomEndpoint.load(endpoint_name="endpoint-custom")
custom_endpoint = HPEndpoint.get(endpoint_name="endpoint-custom")
custom_details = custom_endpoint.describe()
print(custom_details)
```
Expand All @@ -206,11 +208,15 @@ print(custom_details)
`````{tab-set}
````{tab-item} CLI
```bash
# Invoke Jumpstart endpoint
hyp invoke hyp-jumpstart-endpoint \
--endpoint-name <endpoint-name> \
--body '{"inputs":"What is the capital of USA?"}'

# Invoke custom endpoint
hyp invoke hyp-custom-endpoint \
--endpoint-name <endpoint-name> \
--content-type "application/json" \
--payload '{"inputs": "What is machine learning?"}'
--body '{"inputs": "What is machine learning?"}'
```
````

Expand All @@ -223,29 +229,78 @@ print(response)
````
`````

### List Pods

`````{tab-set}
````{tab-item} CLI
```bash
# JumpStart endpoint
hyp list-pods hyp-jumpstart-endpoint

# Custom endpoint
hyp list-pods hyp-custom-endpoint
```
````
`````

### Get Logs

`````{tab-set}
````{tab-item} CLI
```bash
# JumpStart endpoint
hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

# Custom endpoint
hyp get-logs hyp-custom-endpoint --pod-name <pod-name>
```
````
`````

### Get Operator Logs

`````{tab-set}
````{tab-item} CLI
```bash
# JumpStart endpoint
hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

# Custom endpoint
hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5
```
````

````{tab-item} SDK
```python
print(endpoint.get_operator_logs(since_hours=0.1))
```
````
`````

### Delete an Endpoint

`````{tab-set}
````{tab-item} CLI
```bash
# Delete JumpStart endpoint
hyp delete hyp-jumpstart-endpoint --endpoint-name <endpoint-name>
hyp delete hyp-jumpstart-endpoint --name <endpoint-name>

# Delete custom endpoint
hyp delete hyp-custom-endpoint --endpoint-name <endpoint-name>
hyp delete hyp-custom-endpoint --name <endpoint-name>
```
````

````{tab-item} SDK
```python
from sagemaker.hyperpod.inference import HyperPodJumpstartEndpoint, HyperPodCustomEndpoint
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
from sagemaker.hyperpod.inference.hp_custom_endpoint import HPEndpoint

# Delete JumpStart endpoint
jumpstart_endpoint = HyperPodJumpstartEndpoint.load(endpoint_name="endpoint-jumpstart")
jumpstart_endpoint = HPJumpStartEndpoint.get(endpoint_name="endpoint-jumpstart")
jumpstart_endpoint.delete()

# Delete custom endpoint
custom_endpoint = HyperPodCustomEndpoint.load(endpoint_name="endpoint-custom")
custom_endpoint = HPEndpoint.get(endpoint_name="endpoint-custom")
custom_endpoint.delete()
```
````
Expand Down
Loading