Revolutionizing ML Training: How Amazon Search M5 Achieved 30% Cost Savings with AWS Trainium
Tags: aws, modeltraining, trainium, machinelearning
Published: 2024-02-14 06:15:11

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Overview of Amazon's ML Innovations</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For the past decade, the leader of innovation in Machine learning (ML) is the amazon. Machine learning has been used constantly for better customer experience. Machine learning has been used by Amazon in various scenarios which include algorithm improvement and fraud detection.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Evolution from Traditional ML to Neural Networks and Deep Learning</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Over time, improvement in machine learning has also been done. With all the shifts, hardware acceleration for the exploration of latest architectural models has been embraced. Because of this advancement, the team of Amazon was empowered to jump into the Multi-entity, multi-locale, multitask along with encompassing video, text and images.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Introduction to the M5 Program within Amazon Search</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The <a href="https://aws.amazon.com/solutions/case-studies/amazon-search-ml-case-study/">M5 program </a>is very important within Amazon Search, leading the learning strategy of discovery for the company. Large scale models with diverse aspect coverage are built using these programs. These include multitasking capabilities, multiple entities along with the Multimodalities like video, text and images. These models serve as the universal plant and foundations, serving more than hindered teams on Amazon. The m% program mainly focuses on serving ML Models with high quality at a low cost.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Utilizing AWS Accelerators</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Introduction to AWS Inferentia and Trainium</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Purpose built acceleration is served by Amazon Web Service (AWS), which includes Trainium along with Inferentia. Trainium and Inferentia helps with the better Machine learning.<a href="https://aws.amazon.com/machine-learning/inferentia/"> Inferentia</a> was produced in the year 2020, acceleration in workload efficient deployment is provided by Inferentia. This then assists in both, latency upgrade and cost.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Overview of Trainium Trn1 and Trn1n Instances</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The two instances of Trainium which are <a href="https://aws.amazon.com/ec2/instance-types/trn1/">Trn1</a> &amp; <a href="https://aws.amazon.com/about-aws/whats-new/2023/04/amazon-ec2-trn1n-instances-network-ai-models/">Trn1n</a> are solely designed to serve the needs of training of large scale which have billions of parameters. The <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/arch/neuron-hardware/neuron-core-v2.html">NeuronCore-V2 </a>is the instance powered by Trn1 which helps with memory and acceleration. Trn1n, it helps with the network bandwidth.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Importance of Accelerators in ML Organizations</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A very important role is played by the accelerators in ML organization. It helps with improvement of speed along with efficiency for both processes of training and inference. High performance and cost optimization by ML teams can be achieved using Trainium.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Integration of Neuron SDK and PyTorch XLA for Accelerator Support</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A robust layer of software is very important in order to harness the acceleration power. PyTorch XLA mixed with the Neuron SDK, helps with the integration of accelerators into ML workflows. An example of the PyTorch XLA and Neuron SDK employment is given below:</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>import torch_xla.core.xla_model as xm

# Set up XLA device

xla_device = xm.xla_device()

# Define your PyTorch model

model = MyModel(*args, **kwargs)

# Load model state from a checkpoint

model.load_state_dict(torch.load(PATH))

# Move the model to the XLA device

model.to(xla_device)</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>This integration is pivotal for the M5 team's exploration of Trainium to achieve cost-effective model training.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Integration of Neuron SDK and PyTorch XLA for Accelerator Support (Continued)</strong></h3>
<!-- /wp:heading -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading"><strong>Example Code for Using Neuron SDK and PyTorch XLA</strong></h4>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>import torch

import torch_xla.core.xla_model as xm

import torch_xla.distributed.xla_multiprocessing as xmp

import torch_xla.distributed.parallel_loader as pl

import torch_xla.utils.serialization as xser

# Set up XLA devices

devices = xm.get_xla_supported_devices()

device = xm.xla_device()

# Define your PyTorch model

model = MyModel(*args, **kwargs)

# Move the model to the XLA device

model.to(device)

# Define loss function and optimizer

loss_fn = torch.nn.CrossEntropyLoss()

optimizer = torch.optim.SGD(model.parameters(), lr=0.01, momentum=0.9)

# Wrap the model and optimizer with PyTorch XLA ParallelLoader

model, optimizer = pl.ParallelLoader(model, &#91;optimizer], device_ids=&#91;device]).load()

# Training loop

for epoch in range(num_epochs):

&nbsp;&nbsp;&nbsp;&nbsp;for batch in train_loader:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs, labels = batch

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs, labels = inputs.to(device), labels.to(device)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Forward pass

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outputs = model(inputs)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loss = loss_fn(outputs, labels)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Backward pass and optimization

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;optimizer.zero_grad()

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loss.backward()

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;optimizer.step()

# Save the model

xser.save(model.state_dict(), MODEL_PATH)</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>The integration of PyTorch XLA and Neuron SDK for the training of Trainium as an example is given. The use of ParallelLoader of PyTorch XLA makes sure about the data distortion and its efficiency.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Model and Workload Overview</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Description of the M5 Team's Training and Deployment Process</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The implementation of discovery learning strategy is the responsibility of the M5 Amazon search team. The process of team deployment process and training includes the making and distribution of universal embedding models across Amazon. The service of different needs along with provision of excellent experience to amazon.com customers is what this is designed for.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Specifics of the Foundational Model - Text Encoder with MLP</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The foundation model consisting of the encoder text including Multi-layer perception (MLP) is one of the core model developments of the M5 team. The explicit and implicit features are incorporated by this architecture. The model is trained of billions of tokens and millions of embeddings are generated in the setting of offline batch. Input to customer-facing tier-1 is what these embedding serves as.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Production Pipeline Infrastructure Using AWS Batch and Trn1.32xlarge Cluster</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>M5 team’s production pipeline replies of AWS Batch, fair share queuing strategies are used. An <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/frameworks/torch/torch-neuronx/setup-trn1-multi-node-execution.html">EFA enabled Multi-node Trn1.32xlarge cluster</a> is used for model training. Incremental model training is what’s passed by the pipeline of production functionally. In the Service level agreement, the infrastructure is instrumental which also ensures the efficient deployment process without the regression.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Goals and Criteria for Transition to Trainium</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Focus on Customer Satisfaction and SLAs</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Primary focus remained on customer satisfaction while transitioning to Trainium. Service level agreements are very essential is the giving nature of the pipeline. The main goal is to make the experience of the customer of Amazon.com better.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Critical Acceptance Criteria for Transitioning to Trainium</strong></h3>
<!-- /wp:heading -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Model Quality: customer experience is greatly influenced by the Model of ML. The establishment of critical criteria is done by the M5 team, the difference should be less than 0.1%  model quality when related to previous GPU based pipelines. To check if the model exceeds or meets the benchmarks, rigorous testing and validation processes are used.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Training Throughput: another criterion of acceptance is set by the M5 team when recognizing the importance of timely model convergence. A predefined period is during which the model convergence must be achieved, searched as two weeks, to align with production SLA’s.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Ensuring Model Quality and Training Throughput</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Backward work is done by the M5 team to systematically outline goals and to achieve the acceptance criteria that was defined. Adaption of Training scripts, compilation optimization for Trainium, checkpoint visibility insurance are involved in this.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Adapting Training Script for Trainium</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Importance of Making the Training Script XLA Compliant</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Domain specific compiler for operations of linear algebra is the XLA. This adaptation helps with the enhancement of performance and the contribution towards the achievement of the goals defined by model quality.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Use of Distributed Data Parallel (DDP) for Increased Throughput</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The Distributed Data Parallel (DDP) is the technique used by the M5 team for the purpose of increasing training throughput. Scaling of Machine numbers without significant code change is enabled by DDP. The efficient and saleable training processes on Trainium are aligned with the approach of DDP.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Technical Details and Code Changes in the Training Script</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>Placement of xm.mark_step()</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The xm.mark_step() function plays a crucial role in the training script. It gathers and executes the collected graphs of computation. Strategic placement of xm.mark_step () after a forward and backward pass is used to optimize training. Optimal balance is ensured by the attentive placement between the size and the graphs of computation.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Data Loader Wrapping with XLA Multiprocessing Device Loader</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A very important step in adapting the script training involves data loader with XLA multiprocessing device loader. The torch_xla.distributed.parallel_loader.MpDeviceLoader is employed to load training data on each XLA device. Options of preload and data overlapping are provided by the wrapper. Moreover, the loader of the device invokes xm.mark_step (), allowing for the construction of graphs for data loading from the host to the device.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Compilation for Trainium</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Introduction to AOT and JIT Compilation</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In the preparation of a model for acceleration, Compilation is an important step. Two main approaches include: Ahead of time (AOT) approach and Justin in time (JIT) approach. As the graphs are encountered, JIT traces, compiles and runs them, whereas the AOT traces, compiles and runs the graphs before running.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Using Neuron SDK for AOT Compilation</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The facility of neuron_parallel_compile is provided by Neuron SDK for AOT compilation. During the training, it is mandatory to make sure that no new graphs are made. In the process of integration, AOT Compilation is a critical step.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Enforcing Constraints for Static Shapes and Fixed-Size Batches</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The creation of new graphs of computation during model training can be done while dynamic shapes of training batches. Enforcement of constraints on training is what the M5 team does to mitigate this. The need for improved training and time compilation of training is eliminated by this approach.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Compiler-Level Optimization Options and Flags</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The Neuron compiler provides three optimization options:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>O1 (Optimization Level 1): Enables core optimizations on the compute graph and minimizes compilation time.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>O2 (Optimization Level 2): Balances between compilation time and model run throughput.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>O3 (Optimization Level 3): Provides improved model run throughput at the cost of higher compilation time.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>For the M5 team's use case, the choice is made to use the O1 optimization, which demonstrated an 86% reduction in compilation time with no adverse effects on model accuracy metrics. Below is an example code snippet showcasing the use of compilation flags?</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code><em>export NEURON_CC_FLAGS="--target trn1 --auto-cast all --auto-cast-type bf16 --model-type transformer --optlevel O1"</em></code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>This example sets the compilation flags, specifying the target accelerator, enabling automatic casting, defining the model type, and choosing the optimization level. The flexibility in choosing optimization levels allows teams to tailor the compilation process based on their specific use cases.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Checkpoint Compatibility</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Seamless Transitioning Between GPU and Trainium</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Seamless transitioning between the Trainium and GPU is very important to ensure for the M5 team workflow. This enables the team to hold compatibility for the best of both worlds. Flexibility is also maintained while selecting the model training hardware.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Use of PyTorch Checkpoint Loading Utility</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The strengths of PyTorch checkpoint loading utility is to facilitate transition. The direct way of loading and saving models is provided by this utility. This also makes it possible to transition models between Trainium and GPU without any significant changes of code.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Example Code for Saving and Loading Models on GPU and Trainium</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Saving the Model on GPU:</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>import torch

# Save the model on GPU

torch.save(model.state_dict(), PATH)

Loading the Model on Trainium:

import torch_xla.core.xla_model as xm

# Set up XLA device

xla_device = xm.xla_device()

# Define the model on Trainium

model = MyModel(*args, **kwargs)

# Load the model back from the saved checkpoint

model.load_state_dict(torch.load(PATH))

# Move the model to the XLA device

model.to(xla_device)

Saving the Model on Trainium:

import torch_xla.core.xla_model as xm

# Save the model on Trainium

xm.save(model.state_dict(), PATH)

Loading the Model on GPU:

# Define the model on GPU

model = MyModel(*args, **kwargs)

# Load the model back from the saved checkpoint on Trainium

model.load_state_dict(torch.load(PATH))

# Move the model to the desired GPU device

model.to(device)&nbsp; # Can be any GPU device</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>This example code illustrates the process of saving a model on one hardware configuration (GPU) and seamlessly loading it onto a different hardware configuration (Trainium) using PyTorch utilities. The compatibility between GPU and Trainium ensures operational stability and flexibility for the M5 team during the transition.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Operational Stability</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Importance of Operational Stability in Production Pipelines</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>A very important part of running ML workloads in operational stability. The ensure of a stable pipeline during the training of model, evaluation and inference is the duty of the M5 team. The stable operation reduces the downtime and problems and increases the reliability of ML workflow.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Running Sanity Tests before Model Training</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before the start of the training of the model, sanity tests are done by the M5 team to look at the health of the overall system and specifically machines. A simple tensor operation is involved in the test to ensure the functional accelerator devices. The NCCOM test suite from the Neuron SDK is utilized, running operations such as all-gather, all-reduce, and reduce-scatter to ensure proper communication and functionality.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Resilience Mechanisms for Handling Transient Issues</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Knowing that the issue in any pipeline is inevitable, without any underlying accelerator, mechanism of resilience is implemented by M5 team. To address the main issues, a retry mechanism is implemented by the M5 team in the pipelines. This proactive approach minimizes the impact of transient issues and enhances the robustness of the overall pipeline.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Achieving High Success Rates with Retry Mechanisms</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Example Code for AWS Batch Automated Retries</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>import boto3

import time

# Define AWS Batch job parameters

job_name = "your-job-name"

job_queue = "your-job-queue"

job_definition = "your-job-definition"

retry_attempts = 3&nbsp; # Number of retry attempts

# Create an AWS Batch client

batch_client = boto3.client('batch')

# Define job submission parameters

job_submission_params = {

&nbsp;&nbsp;&nbsp;&nbsp;'jobName': job_name,

&nbsp;&nbsp;&nbsp;&nbsp;'jobQueue': job_queue,

&nbsp;&nbsp;&nbsp;&nbsp;'jobDefinition': job_definition,

&nbsp;&nbsp;&nbsp;&nbsp;# Additional job parameters...

}

# Submit the job to AWS Batch

response = batch_client.submit_job(**job_submission_params)

# Monitor job status and implement retry logic

for attempt in range(retry_attempts):

&nbsp;&nbsp;&nbsp;&nbsp;# Check job status

&nbsp;&nbsp;&nbsp;&nbsp;job_status = batch_client.describe_jobs(jobs=&#91;response&#91;'jobId']])&#91;'jobs']&#91;0]&#91;'status']

&nbsp;&nbsp;&nbsp;&nbsp;if job_status == 'SUCCEEDED':

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("Job succeeded!")

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break

&nbsp;&nbsp;&nbsp;&nbsp;elif job_status == 'FAILED':

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("Job failed after retry attempts.")

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break

&nbsp;&nbsp;&nbsp;&nbsp;else:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Wait before retrying

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(60 * (2 ** attempt))&nbsp; # Exponential backoff

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Retry job submission

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response = batch_client.submit_job(**job_submission_params)

else:

&nbsp;&nbsp;&nbsp;&nbsp;print("Maximum retry attempts reached. Consider manual intervention.")</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>This example code demonstrates a simple implementation of retry mechanisms for AWS Batch jobs. The script monitors the status of the submitted job and retries the job submission in case of transient failures. The use of exponential back off in the waiting period between retries helps mitigate issues caused by transient failures. Adjust the parameters and error handling based on specific requirements and characteristics of the production pipeline.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Results and Validation</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Validation of Model Accuracy on a Holdout Dataset</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To make sure the transition to Trainium works successfully, the m% team validates the accuracy of models on the holdout datasheet. Representative sample is what this datasheet serves as. The process of validation involves the comparison between the accuracy metrics, consistency and benchmarks of quality.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><strong>Conclusion</strong></h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Factors to Consider When Evaluating Accelerators</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Key considerations include:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Model Quality: The quality should not be compromised by the accelerator. Production of accurate and believable results is also necessary.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Throughput: The ability to handle large training is an important factor of the accelerator.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Cost-effectiveness: For the accession of implications of cost, a specific accelerator is used. Best performance achievement along with maximum efficiency of ML workflow is the end goal.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Achievements and Cost Savings with Trainium</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The M5 team successfully reduced the cost of training models by 30%, showcasing the efficiency and effectiveness of Trainium accelerators. The achievements include:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Model Quality Parity: Trainium trained models act better as compared to the ones which are GPU trained.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Training Throughput: Trainium is the powerful solution within a specific period for achieving model convergence. Also for meeting production SLA’s and betterment of customer experience.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Cost Savings: The cost-effectiveness analysis revealed up to 30% cheaper cost to model GPU.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><strong>Encouragement to Explore Trainium and Neuron Devices for ML Workloads</strong></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>At the end, <a href="https://aws.amazon.com/blogs/hpc/how-amazons-search-m5-team-optimizes-compute-resources-and-cost-with-fair-share-scheduling-on-aws-batch/">M5 team</a> succession rate with Trainium serves at the ML encouragement and organisations for the purpose of exploring Trainium capabilities. By considering factors which are operational stability and cost, optimal results can easily be achieved in ML workloads. The commitment to innovation and continuous improvement is highlighted by the ongoing partnership and collaboration with the Annapurna Neuron team.</p>
<!-- /wp:paragraph -->