Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

AWS Logo
Menu
Advanced Strategies for GenAI Infrastructure in Production

Advanced Strategies for GenAI Infrastructure in Production

Deep Technical Insights into Distributed Training and Inference Foundation Models

T. K. Daisy Leung
Amazon Employee
Published Mar 3, 2025
The past year has seen a remarkable explosion in the capabilities and adoption of generative AI models. From large language models that can engage in human-like dialogue to advanced computer vision and multimodal systems, these AI agents are redefining what's possible across a wide range of industries. Equally important is the continued emphasis on both fine-tuning existing models and training foundation models with tens to hundreds of billions of parameters -- advancements that have made advanced infrastructure choices increasingly critical.
In this deep dive, we examine AWS’s GenAI services from a performance engineering perspective. We detail the inner workings of distributed training libraries, including in-depth comparisons between SMDDP and NCCL, as well as advanced configuration strategies for SageMaker, HyperPod, and container orchestration platforms.

1. Advanced Training Infrastructure

Amazon SageMaker: Optimizing Distributed Training at Scale

Architectural Details

Integrated Deep Learning Containers: Amazon SageMaker integrates cutting-edge deep learning containers that encapsulate both data parallelism and model parallelism techniques. At the heart of these solutions lie libraries such as PyTorch FSDP and DeepSpeed ZeRO‑3, enhanced by AWS’s proprietary optimizations.
Low-Level Collective Communication: SageMaker’s containers leverage NCCL as the baseline for GPU-to-GPU communication to implement collective operations (e.g., AllReduce, AllGather). NCCL’s standard implementation can occupy up to 24 streaming multiprocessors (SMs) on high-end GPUs such as NVIDIA A100 GPUs. AWS’s SMDDP layer — integrated into SageMaker’s Deep Learning Containers — reconfigures these collective operations. By reducing SM usage (to fewer than 9 SMs per operation) and overlapping AllReduce and AllGather collectives with backward passes via async transfers and low-latency GPU memory copy via GPUDirect RDMA, SMDPP liberates additional GPU cycles for core computation. In one benchmark, training 100B-parameter GPT-NeoX model on 32 p4d nodes yielded a throughput improvement of ~30.58% compared to using NCCL alone.

Fine-Grained Resource Scheduling

Dynamic Cluster Configuration: SageMaker automatically configures instance clusters based on model requirements. For example, when training models with 30B parameters, the system dynamically selects instance types (e.g., ml.p4d.24xlarge) and configures the communication group size. Users can further refine the configuration via advanced hyperparameters — such as adjusting the gradient accumulation steps, activation checkpointing intervals, or specifying custom NCCL environment variables (e.g., NCCL_SOCKET_IFNAME and NCCL_IB_HCA) — to minimize latency across nodes.
• Cost Efficiency and Resiliency: Managed Spot Training leverages automated checkpointing to maintain progress during interruptions, often achieving cost reductions of 70–90%. Integration with Amazon FSx for Lustre further accelerates I/O-bound workloads by providing a high-throughput, low-latency file system natively connected to Amazon S3.
• Hugging Face and Custom Container Integration: SageMaker’s native support for Hugging Face is augmented by pre-built containers that include optimized versions of SMDDP. Developers can also extend these containers, adding custom libraries and tuning parameters (such as specifying a custom smp_config.json with parameters like offload_activations and activation_loading_horizon ) to meet stringent performance goals.

SageMaker HyperPod: Engineering for Extreme-Scale Training

SageMaker HyperPod is engineered for training foundation models over extended durations (weeks or months) on clusters comprising thousands of GPUs. It uses a combination of resilient orchestration (via Slurm or EKS integration) and aggressive performance optimizations.
Persistent, Self-Healing Clusters: HyperPod’s infrastructure continuously monitors GPU health using built-in diagnostics. When a fault is detected, the system automatically isolates and replaces the affected node, resuming training from the latest checkpoint without manual intervention. Advanced users can analyze logs from the primary node (often tagged “algo-1”) via CloudWatch for fine-grained performance tuning.
• Optimized Communication Over EFA: By leveraging the Elastic Fabric Adapter (EFA), HyperPod achieves high-bandwidth, low-latency interconnects that minimize communication overhead. Advanced configurations can adjust EFA mesh parameters to further optimize inter-node synchronization.
• Flexible Orchestration and Scheduling: Whether using Slurm or integrating with Amazon EKS, HyperPod enables fine-tuned control over task scheduling. Users can configure parameters such as GPU group size, the degree of model parallelism, and the balance between data and pipeline parallelism. For instance, in sharded data parallel scenarios, one can set a parameter like sharded_data_parallel_degree to 128 to balance memory requirements and communication load — ensuring that the data parallel degree is optimally set (e.g., 256 total GPUs yielding a replication factor of 2).

Container Orchestration via EKS/ECS and HPC Clusters

For organizations requiring granular control beyond what SageMaker and HyperPod offer natively:
• EKS/ECS: Deploying distributed training on Amazon EKS or ECS allows for custom orchestration using frameworks such as KServe, TorchServe, or Triton. This approach offers direct access to tuning NCCL parameters, customizing Horizontal Pod Autoscaling (HPA) policies based on GPU utilization, and integrating with proprietary logging frameworks (e.g., Nvidia Nsight Systems) for real-time monitoring.
ParallelCluster for HPC Workloads: AWS ParallelCluster is ideal for research teams needing to port existing HPC code. With native support for Slurm, it allows for detailed configuration of job scheduling, node-level performance, and efficient use of EFA-backed interconnects.

2. Advanced Inference Infrastructure

AWS Bedrock: Serverless Inference with AWS-Optimized Safety and Throughput

AWS Bedrock abstracts away infrastructure management by using a token-based pricing model and dynamic resource allocation. Its design is optimized for use cases where minimal operational overhead is paramount.
Throughput and Guardrails: Bedrock uses state-of-the-art load balancing and distributed inference strategies to handle both streaming and batched requests. Although the model configurations are fixed, its content filtering and guardrail mechanisms ensure that the outputs adhere to safety standards — making it an excellent choice for applications that require rapid scaling with minimal custom logic.

SageMaker Inference: Advanced Deployment Options

Real-Time Endpoints: Auto-scaling endpoints leverage multi-model serving and advanced prediction pipelines. Advanced users can configure custom inference pipelines that include pre- and post-processing steps written in optimized C++ or CUDA for ultra-low latency.
• Serverless and Asynchronous Options: For workloads with bursty demand or batch processing, SageMaker offers serverless and asynchronous inference options that automatically scale based on request volume. Users can fine-tune these deployments using custom metrics to balance cold-start latency against cost efficiency.
• Custom Container Integration: For maximum control, users can deploy custom containers with inference frameworks like Triton or vLLM, enabling direct tuning of memory management, batch scheduling, and quantization strategies.

EKS/ECS for Inference:

Deploying inference on container orchestration platforms such as EKS or ECS allows for complete control over the serving stack. Advanced users can integrate microservice architectures with custom load balancers, implement fine-grained scaling policies, and custom GPU monitoring solutions to optimize performance under variable loads.

3. SMDDP vs. NCCL

NVIDIA’s NCCL is widely adopted for its collective operations (e.g., AllReduce, AllGather) that underpin most distributed training setups. It is highly optimized for standard GPU clusters but typically utilizes up to 24 SMs on high-end GPUs such as the A100, which can sometimes limit available compute resources for model operations.
SMDDP is not a replacement for NCCL; rather, it is an AWS-specific enhancement that builds on NCCL’s capabilities. It reduces SM usage during collective operations (often to fewer than 9 SMs) by overlapping communication with computation, using asynchronous transfers and low-latency GPU memory copies (via technologies like GPUDirect RDMA). This means more GPU cycles are dedicated to the actual forward and backward passes, resulting in higher overall throughput. SMDDP is integrated into the latest SageMaker deep learning containers, meaning it works in tandem with NCCL rather than being mutually exclusive.
The most recent AWS deep learning containers come pre-packaged with SMDDP optimizations and are supported in all regions where SageMaker is available. This integration is standard in containers for PyTorch 2.x and is not offered as a separate runtime option—thus, users automatically benefit from these optimizations when they deploy distributed training jobs on SageMaker or HyperPod.

4. Strategic Recommendations for Advanced Deployments

For Training:
Choose SageMaker (Hyperpod) with SMDDP for most large-scale training tasks. Leverage its ability to configure both the data parallel and model parallel strategies with parameters such as gradient_accumulation_steps, offload_activations, and delayed_parameter_initialization. Use HyperPod when training models that require persistent, self-healing clusters and where advanced orchestration (via Slurm or EKS) is necessary. Consider EKS/ECS or ParallelCluster for environments requiring granular tuning of low-level communication parameters.
For Inference:
• When Minimal Customization is Required: AWS Bedrock is ideal, offering simplicity and dynamic resource scaling.
• For Custom Pipelines and Ultra-Low Latency: SageMaker Inference—with custom container support—provides the most flexibility, enabling advanced optimizations and integration with pre/post-processing pipelines.
• For Fully Customized Serving: Use container orchestration via EKS/ECS to build and deploy a completely tailored inference stack.

Conclusion

Advanced AWS GenAI infrastructure — from SageMaker’s SMDDP-enhanced training environment to HyperPod’s resilient, large-scale orchestration — is designed for today’s extreme-scale AI workloads. By combining low-level communication optimizations (NCCL, SMDDP) with advanced parallelism strategies (FSDP, tensor and pipeline parallelism, context parallelism, FP8 mixed precision), AWS enables near–linear scaling and significant throughput gains. Whether you adopt managed solutions like AWS Bedrock for serverless inference or build fully customized serving stacks on EKS/ECS, these advanced strategies provide LLMops teams with the sophisticated tools needed for production-grade generative AI.
This blog post is intended to help technical teams navigate AWS’s diverse GenAI offerings. I hope it provides clarity and sparks innovative ideas for your next project. Feel free to share your thoughts and experiences — let’s drive the conversation on building scalable, enterprise‑grade GenAI solutions on AWS.
For further technical details, explore:

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments

Log in to comment