sagemaker-hyperpod 3.0.1__tar.gz → 3.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sagemaker_hyperpod-3.0.1/src/sagemaker_hyperpod.egg-info → sagemaker_hyperpod-3.0.2}/PKG-INFO +58 -67
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/README.md +57 -66
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/pyproject.toml +1 -1
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/setup.py +1 -1
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/commands/cluster.py +29 -18
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/commands/inference.py +29 -10
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/commands/training.py +16 -6
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/hyp_cli.py +8 -8
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/training_utils.py +87 -78
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/config/metadata.py +3 -3
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/telemetry/constants.py +1 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/telemetry/telemetry_logging.py +1 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/config/hp_endpoint_config.py +12 -3
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/config/hp_jumpstart_endpoint_config.py +13 -4
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2/src/sagemaker_hyperpod.egg-info}/PKG-INFO +58 -67
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/LICENSE +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/NOTICE +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/setup.cfg +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/clients/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/clients/kubernetes_client.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/commands/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/constants/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/constants/command_constants.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/constants/exception_constants.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/constants/hyperpod_instance_types.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/constants/kueue_constants.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/constants/pytorch_constants.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/inference_utils.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/cancel_training_job.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/discover_namespaces.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/exec_command.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/get_logs.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/get_namespaces.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/get_training_job.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/list_pods.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/list_training_jobs.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/service/self_subject_access_review.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/templates/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/templates/k8s_pytorch_job_template.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/utils.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/validators/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/validators/cluster_validator.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/validators/job_validator.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/validators/validator.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/config/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/telemetry/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/telemetry/user_agent.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/common/utils.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/config/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/config/constants.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/hp_endpoint.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/hp_endpoint_base.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/inference/hp_jumpstart_endpoint.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/observability/MonitoringConfig.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/observability/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/observability/constants.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/observability/utils.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/training/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/training/config/__init__.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/training/config/hyperpod_pytorch_job_unified_config.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/training/hyperpod_pytorch_job.py +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker_hyperpod.egg-info/SOURCES.txt +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker_hyperpod.egg-info/dependency_links.txt +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker_hyperpod.egg-info/entry_points.txt +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker_hyperpod.egg-info/requires.txt +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker_hyperpod.egg-info/top_level.txt +0 -0
- {sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker_hyperpod.egg-info/zip-safe +0 -0
{sagemaker_hyperpod-3.0.1/src/sagemaker_hyperpod.egg-info → sagemaker_hyperpod-3.0.2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sagemaker-hyperpod
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.2
|
|
4
4
|
Summary: Amazon SageMaker HyperPod SDK and CLI
|
|
5
5
|
Home-page: https://github.com/aws/sagemaker-hyperpod-cli
|
|
6
6
|
Author: Amazon Web Services
|
|
@@ -212,8 +212,8 @@ hyp create hyp-pytorch-job \
|
|
|
212
212
|
--version 1.0 \
|
|
213
213
|
--job-name test-pytorch-job \
|
|
214
214
|
--image pytorch/pytorch:latest \
|
|
215
|
-
--command '[
|
|
216
|
-
--args '[
|
|
215
|
+
--command '[python, train.py]' \
|
|
216
|
+
--args '[--epochs=10, --batch-size=32]' \
|
|
217
217
|
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
|
|
218
218
|
--pull-policy "IfNotPresent" \
|
|
219
219
|
--instance-type ml.p4d.24xlarge \
|
|
@@ -224,9 +224,8 @@ hyp create hyp-pytorch-job \
|
|
|
224
224
|
--queue-name "training-queue" \
|
|
225
225
|
--priority "high" \
|
|
226
226
|
--max-retry 3 \
|
|
227
|
-
--
|
|
228
|
-
--
|
|
229
|
-
--output-s3-uri s3://my-bucket/model-artifacts
|
|
227
|
+
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
|
|
228
|
+
--volume name=training-output,type=pvc,mount_path=/data,claim_name=my-pvc,read_only=false
|
|
230
229
|
```
|
|
231
230
|
|
|
232
231
|
Key required parameters explained:
|
|
@@ -235,8 +234,6 @@ Key required parameters explained:
|
|
|
235
234
|
|
|
236
235
|
--image: Docker image containing your training environment
|
|
237
236
|
|
|
238
|
-
This command starts a training job named test-pytorch-job. The --output-s3-uri specifies where the trained model artifacts will be stored, for example, s3://my-bucket/model-artifacts. Note this location, as you’ll need it for deploying the custom model.
|
|
239
|
-
|
|
240
237
|
### Inference
|
|
241
238
|
|
|
242
239
|
#### Creating a JumpstartModel Endpoint
|
|
@@ -311,9 +308,10 @@ Along with the CLI, we also have SDKs available that can perform the training an
|
|
|
311
308
|
|
|
312
309
|
```
|
|
313
310
|
|
|
314
|
-
from sagemaker.hyperpod import HyperPodPytorchJob
|
|
315
|
-
from sagemaker.hyperpod.
|
|
316
|
-
import ReplicaSpec, Template, Spec,
|
|
311
|
+
from sagemaker.hyperpod.training import HyperPodPytorchJob
|
|
312
|
+
from sagemaker.hyperpod.training
|
|
313
|
+
import ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
|
|
314
|
+
from sagemaker.hyperpod.common.config import Metadata
|
|
317
315
|
|
|
318
316
|
# Define job specifications
|
|
319
317
|
nproc_per_node = "1" # Number of processes per node
|
|
@@ -328,7 +326,7 @@ replica_specs =
|
|
|
328
326
|
(
|
|
329
327
|
containers =
|
|
330
328
|
[
|
|
331
|
-
|
|
329
|
+
Containers
|
|
332
330
|
(
|
|
333
331
|
# Container name
|
|
334
332
|
name="container-name",
|
|
@@ -369,8 +367,6 @@ pytorch_job = HyperPodPytorchJob
|
|
|
369
367
|
replica_specs = replica_specs,
|
|
370
368
|
# Run policy
|
|
371
369
|
run_policy = run_policy,
|
|
372
|
-
# S3 location for artifacts
|
|
373
|
-
output_s3_uri="s3://my-bucket/model-artifacts"
|
|
374
370
|
)
|
|
375
371
|
# Launch the job
|
|
376
372
|
pytorch_job.create()
|
|
@@ -390,24 +386,21 @@ Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io
|
|
|
390
386
|
from sagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_config import Model, Server, SageMakerEndpoint, TlsConfig
|
|
391
387
|
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
|
|
392
388
|
|
|
393
|
-
model
|
|
394
|
-
model_id=
|
|
395
|
-
model_version=
|
|
389
|
+
model=Model(
|
|
390
|
+
model_id='deepseek-llm-r1-distill-qwen-1-5b',
|
|
391
|
+
model_version='2.0.4',
|
|
396
392
|
)
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
instance_type="ml.g5.8xlarge"
|
|
393
|
+
server=Server(
|
|
394
|
+
instance_type='ml.g5.8xlarge',
|
|
400
395
|
)
|
|
396
|
+
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
|
|
397
|
+
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket>')
|
|
401
398
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
tls_config = TlsConfig(tls_certificate_output_s3_uri="s3://sample-bucket")
|
|
405
|
-
|
|
406
|
-
js_endpoint = HPJumpStartEndpoint(
|
|
399
|
+
js_endpoint=HPJumpStartEndpoint(
|
|
407
400
|
model=model,
|
|
408
401
|
server=server,
|
|
409
402
|
sage_maker_endpoint=endpoint_name,
|
|
410
|
-
tls_config=tls_config
|
|
403
|
+
tls_config=tls_config,
|
|
411
404
|
)
|
|
412
405
|
|
|
413
406
|
js_endpoint.create()
|
|
@@ -423,51 +416,51 @@ print(response)
|
|
|
423
416
|
```
|
|
424
417
|
|
|
425
418
|
|
|
426
|
-
#### Creating a Custom Inference Endpoint
|
|
419
|
+
#### Creating a Custom Inference Endpoint (with S3)
|
|
427
420
|
|
|
428
421
|
```
|
|
429
|
-
from sagemaker.hyperpod.inference.config.
|
|
430
|
-
from sagemaker.hyperpod.inference.
|
|
422
|
+
from sagemaker.hyperpod.inference.config.hp_endpoint_config import CloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Worker
|
|
423
|
+
from sagemaker.hyperpod.inference.hp_endpoint import HPEndpoint
|
|
431
424
|
|
|
432
|
-
|
|
433
|
-
model_source_type=
|
|
434
|
-
model_location="
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
425
|
+
model_source_config = ModelSourceConfig(
|
|
426
|
+
model_source_type='s3',
|
|
427
|
+
model_location="<my-model-folder-in-s3>",
|
|
428
|
+
s3_storage=S3Storage(
|
|
429
|
+
bucket_name='<my-model-artifacts-bucket>',
|
|
430
|
+
region='us-east-2',
|
|
431
|
+
),
|
|
438
432
|
)
|
|
439
433
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
)
|
|
434
|
+
environment_variables = [
|
|
435
|
+
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
|
|
436
|
+
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
|
|
437
|
+
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
|
|
438
|
+
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
|
|
439
|
+
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
|
|
440
|
+
]
|
|
446
441
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
442
|
+
worker = Worker(
|
|
443
|
+
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',
|
|
444
|
+
model_volume_mount=ModelVolumeMount(
|
|
445
|
+
name='model-weights',
|
|
446
|
+
),
|
|
447
|
+
model_invocation_port=ModelInvocationPort(container_port=8080),
|
|
448
|
+
resources=Resources(
|
|
449
|
+
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
|
|
450
|
+
limits={"nvidia.com/gpu": 1}
|
|
451
|
+
),
|
|
452
|
+
environment_variables=environment_variables,
|
|
458
453
|
)
|
|
459
454
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
tls_config = TlsConfig(tls_certificate_output_s3_uri="s3://sample-bucket")
|
|
455
|
+
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
|
|
463
456
|
|
|
464
|
-
custom_endpoint =
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
environment=env,
|
|
469
|
-
sage_maker_endpoint=endpoint_name,
|
|
457
|
+
custom_endpoint = HPEndpoint(
|
|
458
|
+
endpoint_name='<my-endpoint-name>',
|
|
459
|
+
instance_type='ml.g5.8xlarge',
|
|
460
|
+
model_name='deepseek15b-test-model-name',
|
|
470
461
|
tls_config=tls_config,
|
|
462
|
+
model_source_config=model_source_config,
|
|
463
|
+
worker=worker,
|
|
471
464
|
)
|
|
472
465
|
|
|
473
466
|
custom_endpoint.create()
|
|
@@ -484,19 +477,17 @@ print(response)
|
|
|
484
477
|
#### Managing an Endpoint
|
|
485
478
|
|
|
486
479
|
```
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
print(endpoint.name, endpoint.status)
|
|
480
|
+
endpoint_list = HPEndpoint.list()
|
|
481
|
+
print(endpoint_list[0])
|
|
490
482
|
|
|
491
|
-
|
|
492
|
-
print(logs)
|
|
483
|
+
print(custom_endpoint.get_operator_logs(since_hours=0.5))
|
|
493
484
|
|
|
494
485
|
```
|
|
495
486
|
|
|
496
487
|
#### Deleting an Endpoint
|
|
497
488
|
|
|
498
489
|
```
|
|
499
|
-
|
|
490
|
+
custom_endpoint.delete()
|
|
500
491
|
|
|
501
492
|
```
|
|
502
493
|
|
|
@@ -158,8 +158,8 @@ hyp create hyp-pytorch-job \
|
|
|
158
158
|
--version 1.0 \
|
|
159
159
|
--job-name test-pytorch-job \
|
|
160
160
|
--image pytorch/pytorch:latest \
|
|
161
|
-
--command '[
|
|
162
|
-
--args '[
|
|
161
|
+
--command '[python, train.py]' \
|
|
162
|
+
--args '[--epochs=10, --batch-size=32]' \
|
|
163
163
|
--environment '{"PYTORCH_CUDA_ALLOC_CONF": "max_split_size_mb:32"}' \
|
|
164
164
|
--pull-policy "IfNotPresent" \
|
|
165
165
|
--instance-type ml.p4d.24xlarge \
|
|
@@ -170,9 +170,8 @@ hyp create hyp-pytorch-job \
|
|
|
170
170
|
--queue-name "training-queue" \
|
|
171
171
|
--priority "high" \
|
|
172
172
|
--max-retry 3 \
|
|
173
|
-
--
|
|
174
|
-
--
|
|
175
|
-
--output-s3-uri s3://my-bucket/model-artifacts
|
|
173
|
+
--volume name=model-data,type=hostPath,mount_path=/data,path=/data \
|
|
174
|
+
--volume name=training-output,type=pvc,mount_path=/data,claim_name=my-pvc,read_only=false
|
|
176
175
|
```
|
|
177
176
|
|
|
178
177
|
Key required parameters explained:
|
|
@@ -181,8 +180,6 @@ Key required parameters explained:
|
|
|
181
180
|
|
|
182
181
|
--image: Docker image containing your training environment
|
|
183
182
|
|
|
184
|
-
This command starts a training job named test-pytorch-job. The --output-s3-uri specifies where the trained model artifacts will be stored, for example, s3://my-bucket/model-artifacts. Note this location, as you’ll need it for deploying the custom model.
|
|
185
|
-
|
|
186
183
|
### Inference
|
|
187
184
|
|
|
188
185
|
#### Creating a JumpstartModel Endpoint
|
|
@@ -257,9 +254,10 @@ Along with the CLI, we also have SDKs available that can perform the training an
|
|
|
257
254
|
|
|
258
255
|
```
|
|
259
256
|
|
|
260
|
-
from sagemaker.hyperpod import HyperPodPytorchJob
|
|
261
|
-
from sagemaker.hyperpod.
|
|
262
|
-
import ReplicaSpec, Template, Spec,
|
|
257
|
+
from sagemaker.hyperpod.training import HyperPodPytorchJob
|
|
258
|
+
from sagemaker.hyperpod.training
|
|
259
|
+
import ReplicaSpec, Template, Spec, Containers, Resources, RunPolicy
|
|
260
|
+
from sagemaker.hyperpod.common.config import Metadata
|
|
263
261
|
|
|
264
262
|
# Define job specifications
|
|
265
263
|
nproc_per_node = "1" # Number of processes per node
|
|
@@ -274,7 +272,7 @@ replica_specs =
|
|
|
274
272
|
(
|
|
275
273
|
containers =
|
|
276
274
|
[
|
|
277
|
-
|
|
275
|
+
Containers
|
|
278
276
|
(
|
|
279
277
|
# Container name
|
|
280
278
|
name="container-name",
|
|
@@ -315,8 +313,6 @@ pytorch_job = HyperPodPytorchJob
|
|
|
315
313
|
replica_specs = replica_specs,
|
|
316
314
|
# Run policy
|
|
317
315
|
run_policy = run_policy,
|
|
318
|
-
# S3 location for artifacts
|
|
319
|
-
output_s3_uri="s3://my-bucket/model-artifacts"
|
|
320
316
|
)
|
|
321
317
|
# Launch the job
|
|
322
318
|
pytorch_job.create()
|
|
@@ -336,24 +332,21 @@ Pre-trained Jumpstart models can be gotten from https://sagemaker.readthedocs.io
|
|
|
336
332
|
from sagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_config import Model, Server, SageMakerEndpoint, TlsConfig
|
|
337
333
|
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
|
|
338
334
|
|
|
339
|
-
model
|
|
340
|
-
model_id=
|
|
341
|
-
model_version=
|
|
335
|
+
model=Model(
|
|
336
|
+
model_id='deepseek-llm-r1-distill-qwen-1-5b',
|
|
337
|
+
model_version='2.0.4',
|
|
342
338
|
)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
instance_type="ml.g5.8xlarge"
|
|
339
|
+
server=Server(
|
|
340
|
+
instance_type='ml.g5.8xlarge',
|
|
346
341
|
)
|
|
342
|
+
endpoint_name=SageMakerEndpoint(name='<my-endpoint-name>')
|
|
343
|
+
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket>')
|
|
347
344
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
tls_config = TlsConfig(tls_certificate_output_s3_uri="s3://sample-bucket")
|
|
351
|
-
|
|
352
|
-
js_endpoint = HPJumpStartEndpoint(
|
|
345
|
+
js_endpoint=HPJumpStartEndpoint(
|
|
353
346
|
model=model,
|
|
354
347
|
server=server,
|
|
355
348
|
sage_maker_endpoint=endpoint_name,
|
|
356
|
-
tls_config=tls_config
|
|
349
|
+
tls_config=tls_config,
|
|
357
350
|
)
|
|
358
351
|
|
|
359
352
|
js_endpoint.create()
|
|
@@ -369,51 +362,51 @@ print(response)
|
|
|
369
362
|
```
|
|
370
363
|
|
|
371
364
|
|
|
372
|
-
#### Creating a Custom Inference Endpoint
|
|
365
|
+
#### Creating a Custom Inference Endpoint (with S3)
|
|
373
366
|
|
|
374
367
|
```
|
|
375
|
-
from sagemaker.hyperpod.inference.config.
|
|
376
|
-
from sagemaker.hyperpod.inference.
|
|
368
|
+
from sagemaker.hyperpod.inference.config.hp_endpoint_config import CloudWatchTrigger, Dimensions, AutoScalingSpec, Metrics, S3Storage, ModelSourceConfig, TlsConfig, EnvironmentVariables, ModelInvocationPort, ModelVolumeMount, Resources, Worker
|
|
369
|
+
from sagemaker.hyperpod.inference.hp_endpoint import HPEndpoint
|
|
377
370
|
|
|
378
|
-
|
|
379
|
-
model_source_type=
|
|
380
|
-
model_location="
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
371
|
+
model_source_config = ModelSourceConfig(
|
|
372
|
+
model_source_type='s3',
|
|
373
|
+
model_location="<my-model-folder-in-s3>",
|
|
374
|
+
s3_storage=S3Storage(
|
|
375
|
+
bucket_name='<my-model-artifacts-bucket>',
|
|
376
|
+
region='us-east-2',
|
|
377
|
+
),
|
|
384
378
|
)
|
|
385
379
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
)
|
|
380
|
+
environment_variables = [
|
|
381
|
+
EnvironmentVariables(name="HF_MODEL_ID", value="/opt/ml/model"),
|
|
382
|
+
EnvironmentVariables(name="SAGEMAKER_PROGRAM", value="inference.py"),
|
|
383
|
+
EnvironmentVariables(name="SAGEMAKER_SUBMIT_DIRECTORY", value="/opt/ml/model/code"),
|
|
384
|
+
EnvironmentVariables(name="MODEL_CACHE_ROOT", value="/opt/ml/model"),
|
|
385
|
+
EnvironmentVariables(name="SAGEMAKER_ENV", value="1"),
|
|
386
|
+
]
|
|
392
387
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
388
|
+
worker = Worker(
|
|
389
|
+
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',
|
|
390
|
+
model_volume_mount=ModelVolumeMount(
|
|
391
|
+
name='model-weights',
|
|
392
|
+
),
|
|
393
|
+
model_invocation_port=ModelInvocationPort(container_port=8080),
|
|
394
|
+
resources=Resources(
|
|
395
|
+
requests={"cpu": "30000m", "nvidia.com/gpu": 1, "memory": "100Gi"},
|
|
396
|
+
limits={"nvidia.com/gpu": 1}
|
|
397
|
+
),
|
|
398
|
+
environment_variables=environment_variables,
|
|
404
399
|
)
|
|
405
400
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
tls_config = TlsConfig(tls_certificate_output_s3_uri="s3://sample-bucket")
|
|
401
|
+
tls_config=TlsConfig(tls_certificate_output_s3_uri='s3://<my-tls-bucket-name>')
|
|
409
402
|
|
|
410
|
-
custom_endpoint =
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
environment=env,
|
|
415
|
-
sage_maker_endpoint=endpoint_name,
|
|
403
|
+
custom_endpoint = HPEndpoint(
|
|
404
|
+
endpoint_name='<my-endpoint-name>',
|
|
405
|
+
instance_type='ml.g5.8xlarge',
|
|
406
|
+
model_name='deepseek15b-test-model-name',
|
|
416
407
|
tls_config=tls_config,
|
|
408
|
+
model_source_config=model_source_config,
|
|
409
|
+
worker=worker,
|
|
417
410
|
)
|
|
418
411
|
|
|
419
412
|
custom_endpoint.create()
|
|
@@ -430,19 +423,17 @@ print(response)
|
|
|
430
423
|
#### Managing an Endpoint
|
|
431
424
|
|
|
432
425
|
```
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
print(endpoint.name, endpoint.status)
|
|
426
|
+
endpoint_list = HPEndpoint.list()
|
|
427
|
+
print(endpoint_list[0])
|
|
436
428
|
|
|
437
|
-
|
|
438
|
-
print(logs)
|
|
429
|
+
print(custom_endpoint.get_operator_logs(since_hours=0.5))
|
|
439
430
|
|
|
440
431
|
```
|
|
441
432
|
|
|
442
433
|
#### Deleting an Endpoint
|
|
443
434
|
|
|
444
435
|
```
|
|
445
|
-
|
|
436
|
+
custom_endpoint.delete()
|
|
446
437
|
|
|
447
438
|
```
|
|
448
439
|
|
|
@@ -47,7 +47,7 @@ for root, dirs, files in os.walk(
|
|
|
47
47
|
setup(
|
|
48
48
|
data_files=sagemaker_hyperpod_recipes,
|
|
49
49
|
name="sagemaker-hyperpod",
|
|
50
|
-
version="3.0.
|
|
50
|
+
version="3.0.2",
|
|
51
51
|
description="Amazon SageMaker HyperPod SDK and CLI",
|
|
52
52
|
long_description=open("README.md").read(),
|
|
53
53
|
long_description_content_type="text/markdown",
|
{sagemaker_hyperpod-3.0.1 → sagemaker_hyperpod-3.0.2}/src/sagemaker/hyperpod/cli/commands/cluster.py
RENAMED
|
@@ -120,7 +120,7 @@ def list_cluster(
|
|
|
120
120
|
debug: bool,
|
|
121
121
|
namespace: Optional[List],
|
|
122
122
|
):
|
|
123
|
-
"""List SageMaker Hyperpod Clusters with
|
|
123
|
+
"""List SageMaker Hyperpod Clusters with metadata.
|
|
124
124
|
|
|
125
125
|
Example Usage:
|
|
126
126
|
1. List clusters with JSON output: hyperpod get-clusters -n hyperpod-ns-test-team
|
|
@@ -233,7 +233,7 @@ def list_cluster(
|
|
|
233
233
|
print(tabulate(cluster_capacities, headers=headers, tablefmt="presto"))
|
|
234
234
|
elif output == OutputFormat.JSON.value:
|
|
235
235
|
json_list = [dict(zip(headers, value)) for value in cluster_capacities]
|
|
236
|
-
_restructure_output(json_list, namespace)
|
|
236
|
+
json_list = _restructure_output(json_list, namespace)
|
|
237
237
|
print(json.dumps(json_list, indent=4))
|
|
238
238
|
|
|
239
239
|
|
|
@@ -379,23 +379,34 @@ def _get_hyperpod_clusters(sm_client: boto3.client) -> List[str]:
|
|
|
379
379
|
|
|
380
380
|
|
|
381
381
|
def _restructure_output(summary_list, namespaces):
|
|
382
|
-
|
|
383
|
-
return
|
|
382
|
+
cluster_dict = dict()
|
|
384
383
|
|
|
385
384
|
for node_summary in summary_list:
|
|
386
|
-
node_summary["
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
total_accelerators = node_summary[ns + TOTAL_ACCELERATOR_DEVICES_KEY]
|
|
392
|
-
quota_accelerator_info = {
|
|
393
|
-
AVAILABLE_ACCELERATOR_DEVICES_KEY: available_accelerators,
|
|
394
|
-
TOTAL_ACCELERATOR_DEVICES_KEY: total_accelerators,
|
|
385
|
+
cluster_name = node_summary["Cluster"]
|
|
386
|
+
if cluster_name not in cluster_dict:
|
|
387
|
+
cluster_dict[cluster_name] = {
|
|
388
|
+
"Cluster": cluster_name,
|
|
389
|
+
"Instances": []
|
|
395
390
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
node_summary
|
|
391
|
+
node_summary.pop("Cluster")
|
|
392
|
+
if namespaces:
|
|
393
|
+
node_summary["Namespaces"] = {}
|
|
394
|
+
for ns in namespaces:
|
|
395
|
+
available_accelerators = node_summary[
|
|
396
|
+
ns + AVAILABLE_ACCELERATOR_DEVICES_KEY
|
|
397
|
+
]
|
|
398
|
+
total_accelerators = node_summary[ns + TOTAL_ACCELERATOR_DEVICES_KEY]
|
|
399
|
+
quota_accelerator_info = {
|
|
400
|
+
AVAILABLE_ACCELERATOR_DEVICES_KEY: available_accelerators,
|
|
401
|
+
TOTAL_ACCELERATOR_DEVICES_KEY: total_accelerators,
|
|
402
|
+
}
|
|
403
|
+
node_summary["Namespaces"][ns] = quota_accelerator_info
|
|
404
|
+
node_summary.pop(ns + AVAILABLE_ACCELERATOR_DEVICES_KEY, None)
|
|
405
|
+
node_summary.pop(ns + TOTAL_ACCELERATOR_DEVICES_KEY, None)
|
|
406
|
+
cluster_dict[cluster_name]["Instances"].append(node_summary)
|
|
407
|
+
|
|
408
|
+
return list(cluster_dict.values())
|
|
409
|
+
|
|
399
410
|
|
|
400
411
|
|
|
401
412
|
def _aggregate_nodes_info(
|
|
@@ -553,7 +564,7 @@ def get_cluster_context(
|
|
|
553
564
|
debug: bool,
|
|
554
565
|
) -> Tuple[Any, str]:
|
|
555
566
|
"""
|
|
556
|
-
Get
|
|
567
|
+
Get context related to the current set cluster.
|
|
557
568
|
|
|
558
569
|
Args:
|
|
559
570
|
debug (bool): Enable debug mode.
|
|
@@ -584,7 +595,7 @@ def get_cluster_context(
|
|
|
584
595
|
@click.option("--prometheus", is_flag=True, help="Returns Prometheus Workspace URL")
|
|
585
596
|
@click.option("--list", is_flag=True, help="Returns list of available metrics")
|
|
586
597
|
def get_monitoring(grafana: bool, prometheus: bool, list: bool) -> None:
|
|
587
|
-
"""Get monitoring configurations for Hyperpod cluster"""
|
|
598
|
+
"""Get monitoring configurations for Hyperpod cluster."""
|
|
588
599
|
try:
|
|
589
600
|
if not any([grafana, prometheus, list]):
|
|
590
601
|
print("Error: Please select at least one option")
|