Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

306 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SageMaker HyperPod command-line interface

The Amazon SageMaker HyperPod command-line interface (HyperPod CLI) is a tool that helps manage clusters, training jobs, and inference endpoints on the SageMaker HyperPod clusters orchestrated by Amazon EKS.

This documentation serves as a reference for the available HyperPod CLI commands. For a comprehensive user guide, see Orchestrating SageMaker HyperPod clusters with Amazon EKS in the Amazon SageMaker Developer Guide.

Note: Old hyperpodCLI V2 has been moved to release_v2 branch. Please refer release_v2 branch for usage.

Table of Contents

Overview

The SageMaker HyperPod CLI is a tool that helps create training jobs and inference endpoint deployments to the Amazon SageMaker HyperPod clusters orchestrated by Amazon EKS. It provides a set of commands for managing the full lifecycle of jobs, including create, describe, list, and delete operations, as well as accessing pod and operator logs where applicable. The CLI is designed to abstract away the complexity of working directly with Kubernetes for these core actions of managing jobs on SageMaker HyperPod clusters orchestrated by Amazon EKS.

Prerequisites

Region Configuration

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Prerequisites for Training

  • HyperPod CLI currently supports starting PyTorchJobs. To start a job, you need to install Training Operator first.

Prerequisites for Inference

  • HyperPod CLI supports creating Inference Endpoints through jumpstart and through custom Endpoint config

Platform Support

SageMaker HyperPod CLI currently supports Linux and MacOS platforms. Windows platform is not supported now.

ML Framework Support

SageMaker HyperPod CLI currently supports start training job with:

  • PyTorch ML Framework. Version requirements: PyTorch >= 1.10

Installation

  1. Make sure that your local python version is 3.8, 3.9, 3.10 or 3.11.

  2. Install the sagemaker-hyperpod-cli package.

    pip install sagemaker-hyperpod
  3. Verify if the installation succeeded by running the following command.

    hyp --help

Usage

The HyperPod CLI provides the following commands:

Getting Started

Getting Cluster information

This command lists the available SageMaker HyperPod clusters and their capacity information.

hyp list-cluster
OptionTypeDescription
--region <region>OptionalThe region that the SageMaker HyperPod and EKS clusters are located. If not specified, it will be set to the region from the current AWS account credentials.
--namespace <namespace>OptionalThe namespace that users want to check the quota with. Only the SageMaker managed namespaces are supported.
--output <json|table>OptionalThe output format. Available values are table and json. The default value is json.
--debugOptionalEnable debug mode for detailed logging.

Connecting to a Cluster

This command configures the local Kubectl environment to interact with the specified SageMaker HyperPod cluster and namespace.

hyp set-cluster-context --cluster-name <cluster-name>
OptionTypeDescription
--cluster-name <cluster-name>RequiredThe SageMaker HyperPod cluster name to configure with.
--namespace <namespace>OptionalThe namespace that you want to connect to. If not specified, Hyperpod cli commands will auto discover the accessible namespace.
--region <region>OptionalThe AWS region where the HyperPod cluster resides.
--debugOptionalEnable debug mode for detailed logging.

Getting Cluster Context

Get all the context related to the current set Cluster

hyp get-cluster-context
OptionTypeDescription
--debugOptionalEnable debug mode for detailed logging.

CLI

Cluster Management

Important: For commands that accept the --region option, if no region is explicitly provided, the command will use the default region from your AWS credentials configuration.

Cluster stack names must be unique within each AWS region. If you attempt to create a cluster stack with a name that already exists in the same region, the deployment will fail.

Initialize Cluster Configuration

Initialize a new cluster configuration in the current directory:

hyp init cluster-stack

Important: The resource_name_prefix parameter in the generated config.yaml file serves as the primary identifier for all AWS resources created during deployment. Each deployment must use a unique resource name prefix to avoid conflicts. This prefix is automatically appended with a unique identifier during cluster creation to ensure resource uniqueness.

Configure Cluster Parameters

Configure cluster parameters interactively or via command line:

hyp configure --resource-name-prefix my-cluster --stage prod

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Cluster Stack

Create the cluster stack using the configured parameters:

hyp create --region <region>

Note: The region flag is optional. If not provided, the command will use the default region from your AWS credentials configuration.

List Cluster Stacks

hyp list cluster-stack
OptionTypeDescription
--region <region>OptionalThe AWS region to list stacks from.
--status "['CREATE_COMPLETE', 'UPDATE_COMPLETE']"OptionalFilter by stack status.
--debugOptionalEnable debug mode for detailed logging.

Describe Cluster Stack

hyp describe cluster-stack <stack-name>
OptionTypeDescription
--region <region>OptionalThe AWS region where the stack exists.
--debugOptionalEnable debug mode for detailed logging.

Delete Cluster Stack

Delete a HyperPod cluster stack. Removes the specified CloudFormation stack and all associated AWS resources. This operation cannot be undone.

 hyp delete cluster-stack <stack-name>
OptionTypeDescription
--region <region>RequiredThe AWS region where the stack exists.
--retain-resources S3Bucket-TrainingData,EFSFileSystem-ModelsOptionalComma-separated list of logical resource IDs to retain during deletion (only works on DELETE_FAILED stacks). Resource names are shown in failed deletion output, or use AWS CLI: aws cloudformation list-stack-resources STACK_NAME --region REGION.
--debugOptionalEnable debug mode for detailed logging.

Update Existing Cluster

hyp update cluster --cluster-name my-cluster \
--instance-groups '[{"InstanceCount":2,"InstanceGroupName":"worker-nodes","InstanceType":"ml.m5.large"}]' \
--node-recovery Automatic

Reset Configuration

Reset configuration to default values:

hyp reset

Training

Option 1: Create Pytorch job through init experience

Initialize Pytorch Job Configuration

Initialize a new pytorch job configuration in the current directory:

hyp init hyp-pytorch-job

Configure Pytorch Job Parameters

Configure pytorch job parameters interactively or via command line:

hyp configure --job-name my-pytorch-job

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Pytorch Job

Create the pytorch job using the configured parameters:

hyp create

Option 2: Create Pytorch job through create command

hyp create hyp-pytorch-job \
--version 1.0 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerators 8 \
--vcpu 96.0 \
--memory 1152.0 \
--accelerators-limit 8 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false

Example with accelerator parititons:

hyp create hyp-pytorch-job \
--version 1.1 \
--job-name test-pytorch-job \
--image pytorch/pytorch:latest \
--command '[python, train.py]' \
--args '[--epochs=10, --batch-size=32]' \
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
--pull-policy "IfNotPresent" \
--instance-type ml.p4d.24xlarge \
--tasks-per-node 8 \
--label-selector '{"accelerator": "nvidia", "network": "efa"}' \
--deep-health-check-passed-nodes-only true \
--scheduler-type "kueue" \
--queue-name "training-queue" \
--priority "high" \
--max-retry 3 \
--accelerator-partition-type "mig-1g.5gb" \
--accelerator-partition-count 2 \
--accelerator-partition-limit 4 \
--vcpu 96.0 \
--memory 1152.0 \
--vcpu-limit 96.0 \
--memory-limit 1152.0 \
--preferred-topology "topology.kubernetes.io/zone=us-west-2a" \
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
--volume name=training-output,type=pvc,mount_path=/data2,claim_name=my-pvc,read_only=false
ParameterTypeRequiredDescription
--job-nameTEXTYesUnique name for the training job (1-63 characters, alphanumeric with hyphens)
--imageTEXTYesDocker image URI containing your training code
--namespaceTEXTNoKubernetes namespace
--commandARRAYNoCommand to run in the container (array of strings)
--argsARRAYNoArguments for the entry script (array of strings)
--environmentOBJECTNoEnvironment variables as key-value pairs
--pull-policyTEXTNoImage pull policy (Always, Never, IfNotPresent)
--instance-typeTEXTNoInstance type for training
--node-countINTEGERNoNumber of nodes (minimum: 1)
--tasks-per-nodeINTEGERNoNumber of tasks per node (minimum: 1)
--label-selectorOBJECTNoNode label selector as key-value pairs
--deep-health-check-passed-nodes-onlyBOOLEANNoSchedule pods only on nodes that passed deep health check (default: false)
--scheduler-typeTEXTNoScheduler type
--queue-nameTEXTNoQueue name for job scheduling (1-63 characters, alphanumeric with hyphens)
--priorityTEXTNoPriority class for job scheduling
--max-retryINTEGERNoMaximum number of job retries (minimum: 0)
--volumeARRAYNoList of volume configurations (Refer Volume Configuration for detailed parameter info)
--service-account-nameTEXTNoService account name
--acceleratorsINTEGERNoNumber of accelerators a.k.a GPUs or Trainium Chips
--vcpuFLOATNoNumber of vCPUs
--memoryFLOATNoAmount of memory in GiB
--accelerators-limitINTEGERNoLimit for the number of accelerators a.k.a GPUs or Trainium Chips
--vcpu-limitFLOATNoLimit for the number of vCPUs
--memory-limitFLOATNoLimit for the amount of memory in GiB
--accelerator-partition-typeTEXTNoType of accelerator partition (e.g., mig-1g.5gb, mig-2g.10gb, mig-3g.20gb, mig-4g.20gb, mig-7g.40gb)
--accelerator-partition-countINTEGERNoNumber of accelerator partitions to request (minimum: 1)
--accelerator-partition-limitINTEGERNoLimit for the number of accelerator partitions (minimum: 1)
--preferred-topologyTEXTNoPreferred topology annotation for scheduling
--required-topologyTEXTNoRequired topology annotation for scheduling
--max-node-countINTEGERNoMaximum number of nodes
--elastic-replica-increment-stepINTEGERNoScaling step size for elastic training. Provide either this or elastic-replica-discrete-values
--elastic-graceful-shutdown-timeout-in-secondsINTEGERNoGraceful shutdown timeout in seconds for elastic scaling operations
--elastic-scaling-timeout-in-secondsINTEGERNoScaling timeout for elastic training
--elastic-scale-up-snooze-time-in-secondsINTEGERNoTimeout period after job restart during which no scale up/workload admission is allowed
--elastic-replica-discrete-valuesARRAYNoAlternative to elastic-replica-increment-step. Provides exact values for total replicas count (array of integers)
--debugFLAGNoEnable debug mode (default: false)

List Available Accelerator Partition Types

This command lists the available accelerator partition types on the cluster for a specific instance type.

hyp list-accelerator-partition-type --instance-type <instance-type>

List Training Jobs

hyp list hyp-pytorch-job

Describe a Training Job

hyp describe hyp-pytorch-job --job-name <job-name>

Listing Pods

This command lists all the pods associated with a specific training job.

hyp list-pods hyp-pytorch-job --job-name <job-name>
  • job-name (string) - Required. The name of the job to list pods for.

Accessing Logs

This command retrieves the logs for a specific pod within a training job.

hyp get-logs hyp-pytorch-job --pod-name <pod-name> --job-name <job-name>
ParameterRequiredDescription
--job-nameYesThe name of the job to get the log for.
--pod-nameYesThe name of the pod to get the log from.
--namespaceNoThe namespace of the job. Defaults to 'default'.
--containerNoThe container name to get logs from.

Get Operator Logs

hyp get-operator-logs hyp-pytorch-job --since-hours 0.5

Delete a Training Job

hyp delete hyp-pytorch-job --job-name <job-name>

Recipe Job

Use hyp-recipe-job to submit fine-tuning and evaluation jobs using pre-built recipes from SageMaker JumpStart Hub — no YAML authoring required.

Initialize Recipe Job Configuration

mkdir my-recipe-job &&cd my-recipe-job
# Option A: HuggingFace model ID
hyp init hyp-recipe-job . \
--huggingface-model-id Qwen/Qwen3-0.6B \
--technique SFT \
--instance-type ml.g5.48xlarge
# Option B: JumpStart model ID
hyp init hyp-recipe-job . \
--model-id huggingface-reasoning-qwen3-06b \
--technique SFT \
--instance-type ml.g5.48xlarge

Supported job types:

  • Fine-tuning: SFT, DPO, CPT, PPO, RLAIF, RLVR
  • Evaluation: deterministic, LLMAJ

Note: If you omit --instance-type, the CLI will automatically query your HyperPod clusters and find clusters with instance types supported by the selected recipe and technique. You will be presented with a list of compatible clusters to choose from.

Configure Recipe Job Parameters

hyp configure \
--name my-recipe-job \
--namespace default \
--data-path /data/recipes-data/sft/train.jsonl \
--global-batch-size 8 \
--learning-rate 0.0001 \
--max-epochs 1 \
--output-path /data/output/my-model \
--instance-type ml.g5.48xlarge

Validate Configuration

hyp validate

Reset Configuration

To reset config.yaml back to its default values:

hyp reset

Submit Recipe Job

hyp create

List Recipe Jobs

hyp list hyp-recipe-job --namespace default

Describe a Recipe Job

hyp describe hyp-recipe-job --job-name <job-name> --namespace default

List Pods for a Recipe Job

hyp list-pods hyp-recipe-job --job-name <job-name> --namespace default

Get Logs from a Recipe Job Pod

hyp get-logs hyp-recipe-job --job-name <job-name> --pod-name <pod-name> --namespace default

Get Operator Logs

hyp get-operator-logs hyp-recipe-job

Delete a Recipe Job

hyp delete hyp-recipe-job --job-name <job-name> --namespace default

Inference

Jumpstart Endpoint Creation

Option 1: Create jumpstart endpoint through init experience

Initialize Jumpstart Endpoint Configuration

Initialize a new jumpstart endpoint configuration in the current directory:

hyp init hyp-jumpstart-endpoint

Configure Jumpstart Endpoint Parameters

Configure jumpstart endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-jumpstart-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Jumpstart Endpoint

Create the jumpstart endpoint using the configured parameters:

hyp create

Option 2: Create jumpstart endpoint through create command

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

hyp create hyp-jumpstart-endpoint \
--version 1.2 \
--model-id jumpstart-model-id\
--instance-type ml.g5.8xlarge \
--endpoint-name endpoint-jumpstart
ParameterTypeRequiredDescription
--model-idTEXTYesJumpStart model identifier (1-63 characters, alphanumeric with hyphens)
--instance-typeTEXTYesEC2 instance type for inference (must start with "ml.")
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the jumpstart endpoint object
--accept-eulaBOOLEANNoWhether model terms of use have been accepted (default: false)
--model-versionTEXTNoSemantic version of the model (e.g., "1.0.0", 5-14 characters)
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--tls-certificate-output-s3-uriTEXTNoS3 URI to write the TLS certificate
--debugFLAGNoEnable debug mode (default: false)
--versionTEXTNoSchema version to use (default: "1.2")
--accelerator-partition-typeTEXTNoMIG profile for GPU partitioning (must start with "mig-")
--accelerator-partition-validationBOOLEANNoEnable MIG validation (default: true)
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--execution-roleTEXTNoIAM role ARN for deploying and managing the inference server
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--additional-configsJSONNoAdditional model configs as JSON key-value pairs
--gated-model-download-roleTEXTNoIAM role ARN for downloading gated models
--model-hub-nameTEXTNoName of the model hub
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--auto-scaling-specJSONNoFull autoScalingSpec JSON for autoscaling configuration
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers

Invoke a JumpstartModel Endpoint

hyp invoke hyp-jumpstart-endpoint \
--endpoint-name endpoint-jumpstart \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-jumpstart-endpoint
hyp describe hyp-jumpstart-endpoint --name endpoint-jumpstart

List Pods

hyp list-pods hyp-jumpstart-endpoint

Get Logs

hyp get-logs hyp-jumpstart-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-jumpstart-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart

Custom Endpoint Creation

Option 1: Create custom endpoint through init experience

Initialize Custom Endpoint Configuration

Initialize a new custom endpoint configuration in the current directory:

hyp init hyp-custom-endpoint

Configure Custom Endpoint Parameters

Configure custom endpoint parameters interactively or via command line:

hyp configure --endpoint-name my-custom-endpoint

Validate Configuration

Validate the configuration file syntax:

hyp validate

Create Custom Endpoint

Create the custom endpoint using the configured parameters:

hyp create

Option 2: Create custom endpoint through create command

hyp create hyp-custom-endpoint \
--version 1.2 \
--endpoint-name endpoint-custom \
--model-name my-pytorch-model \
--model-source-type s3 \
--model-location my-pytorch-training \
--model-volume-mount-name test-volume \
--s3-bucket-name your-bucket \
--s3-region us-east-1 \
--instance-type ml.g5.8xlarge \
--image-uri 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:latest \
--container-port 8080
ParameterTypeRequiredDescription
--model-nameTEXTYesName of model to create on SageMaker (1-63 characters, alphanumeric with hyphens)
--model-source-typeTEXTYesModel source type: "s3", "fsx", "huggingface", or "kubernetesVolume"
--image-uriTEXTYesDocker image URI for inference
--container-portINTEGERYesPort on which model server listens (1-65535)
--model-volume-mount-nameTEXTYesName of the model volume mount
--namespaceTEXTNoKubernetes namespace
--metadata-nameTEXTNoName of the custom endpoint object
--endpoint-nameTEXTNoName of SageMaker endpoint (1-63 characters, alphanumeric with hyphens)
--versionTEXTNoSchema version to use (default: "1.2")
--instance-typeTEXTNoEC2 instance type (mutually exclusive with --instance-types)
--instance-typesTEXTNoComma-separated list of instance types in order of preference
--envJSONNoEnvironment variables as JSON, e.g. '{"KEY":"value"}'
--metrics-enabledBOOLEANNoEnable metrics collection (default: false)
--metrics-scrape-interval-secondsINTEGERNoScrape interval for metrics collection
--model-metrics-pathTEXTNoPath where the model exposes metrics
--model-metrics-portINTEGERNoPort where the model exposes metrics
--model-versionTEXTNoVersion of the model (semantic version format)
--model-locationTEXTNoSpecific model data location
--prefetch-enabledBOOLEANNoWhether to pre-fetch model data (default: false)
--tls-certificate-output-s3-uriTEXTNoS3 URI for TLS certificate output
--fsx-dns-nameTEXTNoFSx File System DNS Name
--fsx-file-system-idTEXTNoFSx File System ID
--fsx-mount-nameTEXTNoFSx File System Mount Name
--s3-bucket-nameTEXTNoS3 bucket location
--s3-regionTEXTNoS3 bucket region
--huggingface-model-idTEXTNoHuggingFace Hub model identifier (e.g. "meta-llama/Llama-3.1-8B-Instruct")
--huggingface-commit-shaTEXTNoGit commit SHA for the model revision (40-char hex)
--huggingface-token-secret-nameTEXTNoName of the K8s Secret containing the HuggingFace API token
--huggingface-token-secret-keyTEXTNoKey in the K8s Secret for the HuggingFace API token
--model-volume-mount-pathTEXTNoPath inside container for model volume (default: "/opt/ml/model")
--resources-limitsJSONNoResource limits, e.g. '{"nvidia.com/gpu":"1"}'
--resources-requestsJSONNoResource requests, e.g. '{"cpu":"1","memory":"2Gi"}'
--replicasINTEGERNoNumber of inference server replicas (default: 1)
--initial-replica-countINTEGERNoNumber of desired pods (defaults to 1)
--max-deploy-time-in-secondsINTEGERNoMaximum deployment time in seconds (default: 3600)
--worker-argsTEXTNoComma-separated arguments to the entrypoint
--worker-commandTEXTNoComma-separated entrypoint command array
--working-dirTEXTNoWorking directory of the container
--invocation-endpointTEXTNoInvocation endpoint path (default: "invocations")
--intelligent-routing-enabledBOOLEANNoEnable intelligent routing
--routing-strategyTEXTNoRouting strategy: prefixaware, kvaware, session, or roundrobin
--enable-l1-cacheBOOLEANNoEnable L1 cache (CPU offloading)
--enable-l2-cacheBOOLEANNoEnable L2 cache
--l2-cache-backendTEXTNoL2 cache backend type
--l2-cache-local-urlTEXTNoL2 cache URL to local storage
--cache-config-fileTEXTNoKV cache configuration file path
--load-balancer-health-check-pathTEXTNoHealth check path for the ALB target group
--load-balancer-routing-algorithmTEXTNoRouting algorithm: least_outstanding_requests or round_robin
--max-concurrent-requestsINTEGERNoMaximum concurrent requests per pod
--max-queue-sizeINTEGERNoMaximum request queue size
--overflow-status-codeINTEGERNoHTTP status code when request limits exceeded (default: 429)
--custom-certificate-acm-arnTEXTNoACM certificate ARN for custom TLS
--custom-certificate-domain-nameTEXTNoDomain name for the custom TLS certificate
--kubernetesJSONNoKubernetes customizations (initContainers, volumes, schedulerName, serviceAccountName)
--node-affinityJSONNoNode affinity JSON for advanced scheduling
--tagsJSONNoTags as JSON key-value pairs
--probesJSONNoContainer probes JSON (livenessProbe, readinessProbe, startupProbe)
--auto-scaling-specJSONNoFull autoScalingSpec JSON (overrides individual CloudWatch fields)
--dns-hosted-zone-idTEXTNoRoute53 Hosted Zone ID for DNS automation
--data-captureJSONNoData capture configuration JSON for SageMaker, LoadBalancer, and Model Pod tiers
--dimensionsJSONNoCloudWatch Metric dimensions as key-value pairs
--metric-collection-periodINTEGERNoPeriod for CloudWatch query (default: 300)
--metric-collection-start-timeINTEGERNoStartTime for CloudWatch query (default: 300)
--metric-nameTEXTNoMetric name to query for CloudWatch trigger
--metric-statTEXTNoStatistics metric for CloudWatch (default: "Average")
--metric-typeTEXTNoType of metric for HPA ("Value" or "Average", default: "Average")
--min-valueNUMBERNoMinimum metric value for empty CloudWatch response (default: 0)
--cloud-watch-trigger-nameTEXTNoName for the CloudWatch trigger
--cloud-watch-trigger-namespaceTEXTNoAWS CloudWatch namespace for the metric
--target-valueNUMBERNoTarget value for the CloudWatch metric
--use-cached-metricsBOOLEANNoEnable caching of metric values (default: true)
--debugFLAGNoEnable debug mode (default: false)

Invoke a Custom Inference Endpoint

hyp invoke hyp-custom-endpoint \
--endpoint-name endpoint-custom-pytorch \
--body '{"inputs":"What is the capital of USA?"}'

Managing an Endpoint

hyp list hyp-custom-endpoint
hyp describe hyp-custom-endpoint --name endpoint-custom

List Pods

hyp list-pods hyp-custom-endpoint

Get Logs

hyp get-logs hyp-custom-endpoint --pod-name <pod-name>

Get Operator Logs

hyp get-operator-logs hyp-custom-endpoint --since-hours 0.5

Deleting an Endpoint

hyp delete hyp-custom-endpoint --name endpoint-custom

Space

Create a Space

hyp create hyp-space \
--name myspace \
--namespace default \
--display-name "My Space"
ParameterTypeRequiredDescription
--nameTEXTYesSpace name
--display-nameTEXTYesDisplay Name of the space
--namespaceTEXTNoKubernetes namespace
--imageTEXTNoImage specifies the container image to use
--desired-statusTEXTNoDesiredStatus specifies the desired operational status
--ownership-typeTEXTNoOwnershipType specifies who can modify the space. 'Public' means anyone with RBAC permissions can update/delete the space. 'OwnerOnly' means only the creator can update/delete the space.
--node-selectorTEXTNoNodeSelector specifies node selection constraints for the space pod (JSON string)
--affinityTEXTNoAffinity specifies node affinity and anti-affinity rules for the space pod (JSON string)
--tolerationsTEXTNoTolerations specifies tolerations for the space pod to schedule on nodes with matching taints (JSON string)
--lifecycleTEXTNoLifecycle specifies actions that the management system should take in response to container lifecycle events (JSON string)
--app-typeTEXTNoAppType specifies the application type for this workspace
--service-account-nameTEXTNoServiceAccountName specifies the name of the ServiceAccount to use for the workspace pod
--queue-nameTEXTNoQueue name for space scheduling (1-63 characters, alphanumeric with hyphens). Required when task governance is enabled on HyperPod EKS clusters.
--priorityTEXTNoPriority class for space scheduling. Sets the kueue.x-k8s.io/priority-class label.
--access-typeTEXTNoAccessType specifies who can connect to the workspace ('Public' or 'OwnerOnly')
--envTEXTNoEnvironment variables for the workspace container (JSON string, list of {name, value} objects)
--access-strategyTEXTNoReferences a WorkspaceAccessStrategy. Format: --access-strategy name=,namespace=
--pod-security-contextTEXTNoPod-level security context. Overrides template defaults when specified (JSON string)
--container-security-contextTEXTNoContainer-level security context for the main workspace container. Overrides template defaults (JSON string)
--init-containersTEXTNoInit containers to run before the workspace container starts (JSON string, max 10)
--idle-shutdownTEXTNoIdle shutdown configuration. Format: --idle-shutdown enabled=,idleTimeoutInMinutes=,detection=
--template-refTEXTNoTemplateRef references a WorkspaceTemplate to use as base configuration. Format: --template-ref name=,namespace=
--container-configTEXTNoContainer configuration. Format: --container-config command=,args=<arg1;arg2>
--storageTEXTNoStorage configuration. Format: --storage storageClassName=,size=,mountPath=
--volumeTEXTNoVolume configuration. Format: --volume name=,mountPath=,persistentVolumeClaimName=<pvc_name>. Use multiple --volume flags for multiple volumes.
--accelerator-partition-countTEXTNoFractional GPU partition count, e.g. '1'
--accelerator-partition-typeTEXTNoFractional GPU partition type, e.g. 'mig-3g.20gb'
--gpu-limitTEXTNoGPU resource limit, e.g. '1'
--gpuTEXTNoGPU resource request, e.g. '1'
--memory-limitTEXTNoMemory resource limit, e.g. '2Gi'
--memoryTEXTNoMemory resource request, e.g. '2Gi'
--cpu-limitTEXTNoCPU resource limit, e.g. '500m'
--cpuTEXTNoCPU resource request, e.g. '500m'

List Spaces

# List spaces in default namespace
hyp list hyp-space
# List spaces in specific namespace
hyp list hyp-space --namespace my-namespace
# List spaces across all namespaces
hyp list hyp-space --all-namespaces
# List spaces with JSON output
hyp list hyp-space --output json

Describe a Space

hyp describe hyp-space --name myspace

Update a Space

hyp update hyp-space \
--name myspace \
--display-name "Updated Space Name"

Start/Stop a Space

hyp start hyp-space --name myspace
hyp stop hyp-space --name myspace

Get Logs

hyp get-logs hyp-space --name myspace

Delete a Space

hyp delete hyp-space --name myspace

Port Forward to a Space

Port forward to access a space from your local machine:

# Port forward with default port (8888)
hyp portforward hyp-space --name myspace
# Port forward with custom local port
hyp portforward hyp-space --name myspace --local-port 8080

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

Create reusable space templates:

hyp create hyp-space-template --file template.yaml
hyp list hyp-space-template --all-namespaces
hyp describe hyp-space-template --name <template-name>
hyp update hyp-space-template --name <template-name> --file updated-template.yaml
hyp delete hyp-space-template --name <template-name>

Space Access

Create remote access to spaces. The --connection-type accepts web-ui or any {ide}-remote pattern (e.g. vscode-remote, kiro-remote, cursor-remote):

hyp create hyp-space-access --name myspace --connection-type vscode-remote
hyp create hyp-space-access --name myspace --connection-type kiro-remote
hyp create hyp-space-access --name myspace --connection-type cursor-remote
hyp create hyp-space-access --name myspace --connection-type web-ui

SDK

Along with the CLI, we also have SDKs available that can perform the cluster management, training and inference functionalities that the CLI performs

Cluster Management SDK

Creating a Cluster Stack

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStack# Initialize cluster stack configurationcluster_stack=HpClusterStack(
stage="prod",
resource_name_prefix="my-hyperpod",
hyperpod_cluster_name="my-hyperpod-cluster",
eks_cluster_name="my-hyperpod-eks",
# Infrastructure componentscreate_vpc_stack=True,
create_eks_cluster_stack=True,
create_hyperpod_cluster_stack=True,
# Network configurationvpc_cidr="10.192.0.0/16",
availability_zone_ids=["use2-az1", "use2-az2"],
# Instance group configurationinstance_group_settings=[
{
"InstanceCount": 1,
"InstanceGroupName": "controller-group",
"InstanceType": "ml.t3.medium",
"TargetAvailabilityZoneId": "use2-az2"
}
]
)
# Create the cluster stackresponse=cluster_stack.create(region="us-east-2")

Listing Cluster Stacks

# List all cluster stacksstacks=HpClusterStack.list(region="us-east-2")
print(f"Found {len(stacks['StackSummaries'])} stacks")

Describing a Cluster Stack

# Describe a specific cluster stackstack_info=HpClusterStack.describe("my-stack-name", region="us-east-2")
print(f"Stack status: {stack_info['Stacks'][0]['StackStatus']}")

Monitoring Cluster Status

fromsagemaker.hyperpod.cluster_management.hp_cluster_stackimportHpClusterStackstack=HpClusterStack()
response=stack.create(region="us-west-2")
status=stack.get_status(region="us-west-2")
print(status)

Deleting a Cluster Stack

# Delete with custom loggerimportlogginglogger=logging.getLogger(__name__)
HpClusterStack.delete("my-stack-name", region="us-west-2", logger=logger)
# Delete with retained resources (only works on DELETE_FAILED stacks)HpClusterStack.delete("my-stack-name", retain_resources=["S3Bucket", "EFSFileSystem"])

Training SDK

Creating a Training Job

fromsagemaker.hyperpod.training.hyperpod_pytorch_jobimportHyperPodPytorchJobfromsagemaker.hyperpod.training.config.hyperpod_pytorch_job_unified_configimport (
ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
)
fromsagemaker.hyperpod.common.config.metadataimportMetadata# Define job specificationsnproc_per_node="1"# Number of processes per nodereplica_specs= [
ReplicaSpec
(
name="pod", # Replica nametemplate=Template
(
spec=Spec
(
containers=
[
Containers
(
# Container namename="container-name", # Training imageimage="123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image:latest", # Always pull imageimage_pull_policy="Always", resources=Resources\
(
# No GPUs requestedrequests={"nvidia.com/gpu": "0"}, # No GPU limitlimits={"nvidia.com/gpu": "0"}, ),
# Command to runcommand=["python", "train.py"], # Script argumentsargs=["--epochs", "10", "--batch-size", "32"], )
]
)
),
)
]
# Keep pods after completionrun_policy=RunPolicy(clean_pod_policy="None") # Create and start the PyTorch jobpytorch_job=HyperPodPytorchJob
(
# Job namemetadata=Metadata(name="demo"), # Processes per nodenproc_per_node=nproc_per_node, # Replica specificationsreplica_specs=replica_specs, # Run policyrun_policy=run_policy, )
# Launch the jobpytorch_job.create() 

List Training Jobs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJobimportyaml# List all PyTorch jobsjobs=HyperPodPytorchJob.list()
print(yaml.dump(jobs))

Describe a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job)

List Pods for a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# List Pods for an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.list_pods())

Get Logs from a Pod

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get pod logs for a jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_logs_from_pod("pod-name"))

Get Training Operator Logs

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get training operator logsjob=HyperPodPytorchJob.get(name="my-pytorch-job")
print(job.get_operator_logs(since_hours=0.1))

Delete a Training Job

fromsagemaker.hyperpod.trainingimportHyperPodPytorchJob# Get an existing jobjob=HyperPodPytorchJob.get(name="my-pytorch-job")
# Delete the jobjob.delete()

Inference SDK

Creating a JumpstartModel Endpoint

Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io/en/v2.82.0/doc_utils/jumpstart.html and fed into the call for creating the endpoint

fromsagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_configimportModel, Server, SageMakerEndpoint, TlsConfigfromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointmodel=Model(
model_id='deepseek-llm-r1-distill-qwen-1-5b'
)
server=Server(
instance_type='ml.g5.8xlarge',
)
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
js_endpoint=HPJumpStartEndpoint(
model=model,
server=server,
sage_maker_endpoint=endpoint_name
)
js_endpoint.create()

Creating a Custom Inference Endpoint (with S3)

fromsagemaker.hyperpod.inference.config.hp_endpoint_configimportCloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Workerfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointmodel_source_config=ModelSourceConfig(
model_source_type='s3',
model_location="<my-model-folder-in-s3>",
s3_storage=S3Storage(
bucket_name='<my-model-artifacts-bucket>',
region='us-east-2',
),
)
environment_variables= [
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
]
worker=Worker(
image='763104351884.dkr.ecr.us-east-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.4.0-tgi2.3.1-gpu-py311-cu124-ubuntu22.04-v2.0',
model_volume_mount=ModelVolumeMount(
name='model-weights',
),
model_invocation_port=ModelInvocationPort(container_port=8080),
resources=Resources(
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
limits={"nvidia.com/gpu": 1}
),
environment_variables=environment_variables,
)
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
custom_endpoint=HPEndpoint(
endpoint_name='<my-endpoint-name>',
instance_type='ml.g5.8xlarge',
model_name='deepseek15b-test-model-name', tls_config=tls_config,
model_source_config=model_source_config,
worker=worker,
)
custom_endpoint.create()

List Endpoints

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List JumpStart endpointsjumpstart_endpoints=HPJumpStartEndpoint.list()
print(jumpstart_endpoints)
# List custom endpointscustom_endpoints=HPEndpoint.list()
print(custom_endpoints)

Describe an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get JumpStart endpoint detailsjumpstart_endpoint=HPJumpStartEndpoint.get(name="js-endpoint-name", namespace="test")
print(jumpstart_endpoint)
# Get custom endpoint detailscustom_endpoint=HPEndpoint.get(name="endpoint-custom")
print(custom_endpoint)

Invoke an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpointdata='{"inputs":"What is the capital of USA?"}'jumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
response=jumpstart_endpoint.invoke(body=data).body.read()
print(response)
custom_endpoint=HPEndpoint.get(name="endpoint-custom")
response=custom_endpoint.invoke(body=data).body.read()
print(response)

List Pods

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# List pods js_pods=HPJumpStartEndpoint.list_pods()
print(js_pods)
c_pods=HPEndpoint.list_pods()
print(c_pods)

Get Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Get logs from pod js_logs=HPJumpStartEndpoint.get_logs(pod=<pod-name>)
print(js_logs)
c_logs=HPEndpoint.get_logs(pod=<pod-name>)
print(c_logs)

Get Operator Logs

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Invoke JumpStart endpointprint(HPJumpStartEndpoint.get_operator_logs(since_hours=0.1))
# Invoke custom endpointprint(HPEndpoint.get_operator_logs(since_hours=0.1))

Delete an Endpoint

fromsagemaker.hyperpod.inference.hp_jumpstart_endpointimportHPJumpStartEndpointfromsagemaker.hyperpod.inference.hp_endpointimportHPEndpoint# Delete JumpStart endpointjumpstart_endpoint=HPJumpStartEndpoint.get(name="endpoint-jumpstart")
jumpstart_endpoint.delete()
# Delete custom endpointcustom_endpoint=HPEndpoint.get(name="endpoint-custom")
custom_endpoint.delete()

Observability - Getting Monitoring Information

fromsagemaker.hyperpod.observability.utilsimportget_monitoring_configmonitor_config=get_monitoring_config()

Space SDK

Creating a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpacefromhyperpod_space_template.v1_1.modelimportSpaceConfig# Create space configurationspace_config=SpaceConfig(
name="myspace",
namespace="default",
display_name="My Space",
)
# Create and start the spacespace=HPSpace(config=space_config)
space.create()

List Spaces

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# List all spaces in default namespacespaces=HPSpace.list()
forspaceinspaces:
print(f"Space: {space.config.name}, Status: {space.status}")
# List spaces in specific namespacespaces=HPSpace.list(namespace="your-namespace")

Get a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get specific spacespace=HPSpace.get(name="myspace", namespace="default")
print(f"Space name: {space.config.name}")
print(f"Display name: {space.config.display_name}")

Update a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Update space configurationspace.update(
display_name="Updated Space Name",
)

Start/Stop a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Start the spacespace.start()
# Stop the spacespace.stop()

Get Space Logs

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and retrieve logsspace=HPSpace.get(name="myspace")
# Get logs from default pod and containerlogs=space.get_logs()
print(logs)

List Space Pods

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get space and list associated podsspace=HPSpace.get(name="myspace")
pods=space.list_pods()
forpodinpods:
print(f"Pod: {pod}")

Create Space Access

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Create VS Code remote accessvscode_access=space.create_space_access(connection_type="vscode-remote")
print(f"VS Code URL: {vscode_access['SpaceConnectionUrl']}")
# Create Kiro remote accesskiro_access=space.create_space_access(connection_type="kiro-remote")
print(f"Kiro URL: {kiro_access['SpaceConnectionUrl']}")
# Create web UI accessweb_access=space.create_space_access(connection_type="web-ui")
print(f"Web UI URL: {web_access['SpaceConnectionUrl']}")

Delete a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Delete the spacespace.delete()

Port Forward to a Space

fromsagemaker.hyperpod.space.hyperpod_spaceimportHPSpace# Get existing spacespace=HPSpace.get(name="myspace")
# Port forward with default remote port (8888)space.portforward_space(local_port="8080")
# Port forward with custom remote portspace.portforward_space(local_port="8080", remote_port="8888")

Access the space via http://localhost:<local-port> after port forwarding is established. Press Ctrl+C to stop port forwarding.

Space Template Management

fromsagemaker.hyperpod.space.hyperpod_space_templateimportHPSpaceTemplate# Create space template from YAML filetemplate=HPSpaceTemplate(file_path="template.yaml")
template.create()
# List all space templatestemplates=HPSpaceTemplate.list()
fortemplateintemplates:
print(f"Template: {template.name}")
# Get specific space templatetemplate=HPSpaceTemplate.get(name="my-template")
print(template.to_yaml())
# Update space templatetemplate.update(file_path="updated-template.yaml")
# Delete space templatetemplate.delete()

Examples

This repository provides both a full end-to-end example walkthrough of using the CLI for real-world training and inference workloads as well as standalone example notebooks for individual features.

End-to-End Walkthrough

End-to-End Walkthrough Example

Standalone Examples

Cluster Management Example Notebooks

CLI Cluster Management Example

SDK Cluster Management Example

Training Example Notebooks

CLI Training Init Experience Example

CLI Training Example

SDK Training Example

Inference Example Notebooks

CLI

CLI Inference Jumpstart Model Init Experience Example

CLI Inference JumpStart Model Example

CLI Inference FSX Model Example

CLI Inference S3 Model Init Experience Example

CLI Inference S3 Model Example

SDK

SDK Inference JumpStart Model Example

SDK Inference FSX Model Example

SDK Inference S3 Model Example

Disclaimer

  • This CLI and SDK requires access to the user's file system to set and get context and function properly. It needs to read configuration files such as kubeconfig to establish the necessary environment settings.

Working behind a proxy server ?

  • Follow these steps from here to set up HTTP proxy connections

About

A CLI tool that helps manage training jobs on the SageMaker HyperPod clusters orchestrated by Amazon EKS

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages