Cognibiz

AWS Trainium2 and Inferentia2: from compiled model to distributed systemaws.amazon.com

AI technologies, organized by technology area.

Trainium2 prototype shown by AWS at re:Invent 2023. Official Amazon product imagery.Inset: Interconnected accelerators distribute training and inference.Credit and source

The sketch explained

Two AWS families with distinct use cases

Model and data feed one accelerator family or the other. Trainium2 supports training and inference. Inferentia2 is designed for inference. The columns do not represent a single shared circuit.

On a small screen, scroll the diagram horizontally to read its labels.

Two AWS families with distinct use casesTrainium2 · Inferentia2 · Training and inference · Inference · Model and dataModel and dataTrainium2Inferentia2Training and inferenceInference
Trainium2
Accelerator family used in Trn2 instances, among other configurations.
Inferentia2
Accelerator family used in Inf2 instances, among other configurations.
Training and inference
Training adjusts weights; inference uses the model to produce output.
Inference
Inference runs an already-trained model to answer a request.
Model and data
Required inputs are sent to the selected environment.
Two simplified usage paths, without a speed or size comparison. Small squares do not represent an instance’s chip count. The product image shows a Trainium2 prototype.Technical documentation
Updated

UNDERSTANDING THE SYSTEM

AWS Trainium2 and Inferentia2: from compiled model to distributed system

These purpose-built accelerators make sense together with the compiler, memory and communications that feed them. The right choice depends on actual model support, input shapes and service requirements as much as advertised compute capability.

02 / CHAPTER

Two chips, several system boundaries

Trainium2 is the AWS chip used in EC2 Trn2 instances for training and inference. Inferentia2 powers inference-oriented Inf2 instances: inference means running an already trained model. These names identify neither a library nor an AI model. This article retains those specific generations without presenting them as the latest.

A chip provides local resources; an instance adds host CPUs, host memory and connectivity. A Trn2 UltraServer joins four trn2u.48xlarge instances and 64 chips through NeuronLink. It is neither a 64-core chip nor an arbitrary group of four servers. Name the system boundary whenever comparing memory, networking or cost.

Two chips, several system boundaries
ResourceChipsAggregate HBM, technical documentation
Inferentia2132 GiB
inf2.24xlarge6192 GiB
inf2.48xlarge12384 GiB
Trainium2196 GiB
trn2.48xlarge161 536 GiB
Trn2 UltraServer646 144 GiB

References for this chapter[1][2][3][4]

03 / CHAPTER

What actually runs inside a NeuronCore

Matrix engines perform operations such as matrix multiplication; vector and scalar resources handle other operations, while GPSIMD provides additional programmability. On-chip SRAM keeps data near compute. Reusing a block already loaded avoids repeatedly reading HBM: tensor movement matters as much as arithmetic operations.

Inferentia2 uses NeuronCore-v2 and Trainium2 uses NeuronCore-v3. On Trn2, the LNC configuration groups physical cores into logical cores exposed to software. Compiler and runtime configurations must agree. Record LNC and component versions rather than deriving process counts from chip counts. A peak FP8 or BF16 rate says nothing by itself about utilization or the final model’s numerical quality.

References for this chapter[5][6][2]

04 / CHAPTER

Fit the model without confusing capacity and bandwidth

Capacity measures how much HBM can hold; bandwidth measures bytes transferred per second. Technical documentation lists 96 GiB and 2.9 TB/s per Trainium2, versus 32 GiB and 820 GiB/s per Inferentia2. These units are not interchangeable: 1 GiB = 2³⁰ bytes, while 1 GB = 10⁹ bytes. Product pages sometimes use different abbreviations; the calculations below follow technical capacities in GiB.

Hypothetical example: 70 billion parameters at two bytes each require 140 × 10⁹ bytes, approximately 130.4 GiB of weights. The capacity-only lower bound is five 32 GiB chips or two 96 GiB chips. This does not prescribe an instance size: placement, replication, buffers and operators add constraints. Inference also needs KV cache; training needs gradients, optimizer states and activations. Summing HBM capacities does not create uniform local access, and summing bandwidths does not predict tokens/s.

KV cache
Attention keys and values retained for active sequences. Size grows with context and concurrent requests, and also depends on architecture and precision.
Operational headroom
Measure actual peak memory for every partition, including temporary workspaces and fragmentation. An adequate theoretical sum can hide an overloaded partition.

References for this chapter[1][2][3][4]

05 / CHAPTER

Neuron: compile a program, then execute it

Neuron is the software stack connecting frameworks to the accelerators. In a compiled flow, a graph and its constraints are optimized for a target; neuronx-cc produces a NEFF artifact that the runtime loads and executes. Compilation and execution are separate activities. A long compilation does not imply poor performance once the program is ready; the converse is equally possible.

The persistent cache in the PyTorch/XLA path avoids some recompilation across runs. It is neither a response cache nor the model’s KV cache. Changing the graph, shapes, target or options may require a different artifact. Keeping code, weights, tokenizer, versions, options, LNC and artifact identities makes deployment reproducible. Native paths and libraries evolve: use the compatibility matrix for the integration actually selected.

From graph to reproducible execution

Three functional stages with no time scale. The path back to the compiler means a new artifact is required, not that every request must compile.

  1. Graph and contract

    Model, shapes, precision and target define what the compiler must prepare. A quality test set accompanies this contract.

  2. Compilation and artifact

    neuronx-cc turns the program into NEFF. Compatible artifacts can be reused; their provenance must remain traceable.

  3. Loading and execution

    The runtime places the program and its data on selected resources. Measure startup, warm-up and steady state separately.

References for this chapter[7][8][9][13][14]

06 / CHAPTER

Input shapes become an operational decision

A shape specifies tensor dimensions, such as batch size and sequence length. Hardware support for dynamic shapes does not guarantee that every library accepts arbitrary dimensions without preparation. Some paths compile several variants and select a bucket: a prepared size large enough for the input. Padding fills the remaining dimensions; masks must preserve the meaning of the computation.

Educational example: sequences of 300, 700 and 1,500 tokens, processed separately, use buckets of 512, 1,024 and 2,048 positions. They reserve 3,584 positions, compared with 6,144 if each uses a single 2,048-position bucket: 2,560 fewer positions, or 41.7%. This is not a 41.7% time saving: attention, KV cache, batches and kernels do not all scale linearly. More variants may reduce padding while increasing compilation, storage and qualification work.

Reserve a shape close to actual demand

Hypothetical lengths and reserved positions, with no performance measurement. The lighter region represents padding: 212, 324 and 548 positions.

  1. 300 → 512

    300 useful positions, 212 added. The first bucket fits; a program prepared for a smaller length would not.

  2. 700 → 1 024

    700 useful positions, 324 added. The router selects the smallest prepared shape that can accept the input.

  3. 1 500 → 2 048

    1,500 useful positions, 548 added. Inputs beyond the largest bucket need an explicit rejection, splitting or alternative-processing policy.

buckets = (512, 1024, 2048)
lengths = (300, 700, 1500)

def choose_bucket(length):
    if length < 1:
        raise ValueError(length)
    return next((b for b in buckets if length <= b), None)

selected = [choose_bucket(n) for n in lengths]
assert selected == [512, 1024, 2048]
assert choose_bucket(2049) is None
reserved = sum(selected)
single_bucket = len(lengths) * buckets[-1]
print(reserved, single_bucket, single_bucket - reserved)
Standalone Python accounting for reserved positions: 3,584, 6,144, 2,560. This educational router neither compiles nor runs a Neuron model; None requires an explicit policy for inputs outside the contract.

References for this chapter[10][15]

07 / CHAPTER

Distributed training: place the communications too

Data parallelism processes different examples on replicas and synchronizes gradients. Tensor parallelism divides computation within a layer and exchanges partial results; pipeline parallelism places groups of layers on different resources and passes microbatches between them. These strategies can be combined. Choose their degrees from memory and communication requirements rather than automatically equating one chip with one replica.

AllReduce combines contributions and returns the result to participants; AllGather assembles fragments. Excessive exchanges or waiting for the slowest participant can leave engines idle. NeuronLink connects chips; in a Trn2 UltraServer it also spans the four purpose-configured instances. EFA supports cluster expansion beyond that domain. A fast network removes neither synchronization nor imbalance. Profile whether communication and computation actually overlap.

References for this chapter[11][12][3][4]

08 / CHAPTER

Inference: qualify the service, not just the kernel

Prefill processes the prompt; decode then generates tokens while reusing KV cache. Measure time to first token and inter-token latency separately. Add queueing, tokenization and transfers to establish user-visible latency. High aggregate throughput can coexist with poor response time at peak demand.

Inf2 can shard a model over multiple Inferentia2 chips; Trn2 can serve inference too. Product positioning therefore does not make the decision for you. Test actual lengths, concurrent requests and arrival rates, then output quality after every precision change. Model support does not guarantee support for every feature: quantization, speculative decoding, architecture and engine version must be checked together. A successful Trn2 example does not establish Inf2 compatibility.

References for this chapter[4][13][14][15]

09 / CHAPTER

A comparison protocol that survives production

First fix weights, tokenizer, data, minimum quality and service requirements. Record instance, SDK, driver, runtime, compiler, precision, LNC, parallelism and buckets. Separate cold compilation, loading, warm-up and the measurement window; wait for operations to finish before stopping the timer. Test several length distributions and restart both with and without available artifacts.

Compare the cost of completed work at equivalent quality. For training: time to the quality target, checkpoints and recovery after interruption. For serving: successful requests meeting the latency target, errors and the cost of idle capacity. Include compilation, CPU, storage, networking and porting effort. Obtain prices and regional capacity when the project is evaluated; this article establishes no fixed price or universal cost advantage.

A comparison protocol that survives production
TestWhat to observeDecision criterion
CompatibilityOperators, shapes and features actually usedNo essential feature without a validated path
QualitySame evaluation, documented precisionDifference within the project’s tolerance
LoadQueueing latency, first token, subsequent tokens, errorsTarget met under representative traffic
RecoveryArtifacts, weights and checkpoint restoredRestart within the accepted window
EconomicsTotal cost per compliant resultBenefit exceeds migration and operating cost

References for this chapter[7][9][8][16]

10 / CHAPTER

Select a first workload and define success

A good pilot uses a stable model, a supported feature and measurable traffic, with a team able to manage compilation and operations. An established AWS environment may reduce operational friction; it does not prove economic benefit. For daily model changes, highly customized operators or strong CUDA-kernel dependencies, estimate porting effort and recompilation delays first. Compare a GPU path and, for smaller needs, CPU execution or a managed service.

A useful deliverable includes a reproducible manifest, identified artifacts, memory budget per partition, quality and load results, a recovery test and full cost. Define the scaling threshold and abandonment criteria before the experiment. The examples here remain documentary: no instance was reserved, no runtime installed and no performance measured on AWS hardware.

References for this chapter[13][14][10]

ORIGINAL DOCUMENT

Catalog record

1. Foundations: hardware, silicon and accelerators

AWS aws.amazon.com Trainium2 & Inferentia2 — Innovation: 7, Adoption: 8

7/10Innovation
8/10Adoption

Editorial source: Taxonomie des Technologies d'Intelligence Artificielle · § 5522. Addresses restored with dots; innovation and adoption scores remain those of the document.

VERIFY AND EXPLORE

References

Historical scope: Trainium2/Trn2 and Inferentia2/Inf2. Specifications come from primary sources accessed on November 4, 2026; numerical examples are educational, with no benchmark or cloud spending.

  1. 01
    Trainium2 architecture

    Chip specifications: HBM capacity and bandwidth; vendor specifications rather than application measurements.

    awsdocs-neuron.readthedocs-hosted.com ·
  2. 02
    Inferentia2 architecture

    Inferentia2 chip and technical GiB/GiB/s units. The product page uses different labels.

    awsdocs-neuron.readthedocs-hosted.com ·
  3. 03
    Trn2 instance architecture

    Chip, instance and UltraServer boundaries; technical table and interconnects. Regional availability must be checked separately.

    awsdocs-neuron.readthedocs-hosted.com ·
  4. 04
    Inf2 instance architecture

    Four Inf2 sizes, separate host memory and inter-chip collectives. Totals do not constitute uniform memory.

    awsdocs-neuron.readthedocs-hosted.com ·
  5. 05
    NeuronCore-v3 architecture

    Compute engines and software-managed SRAM; functional description without extrapolated throughput.

    awsdocs-neuron.readthedocs-hosted.com ·
  6. 06
    Logical NeuronCore configuration

    Logical configuration and compiler/runtime consistency requirement. Terminology in the accessed documentation, without asserting a hardware change.

    awsdocs-neuron.readthedocs-hosted.com ·
  7. 07
    Neuron Graph Compiler

    From graph to NEFF file; compilation targets and options. No particular API is assumed universal.

    awsdocs-neuron.readthedocs-hosted.com ·
  8. 08
    NeuronX Runtime

    Loading, allocation and execution. Details must match the selected runtime version.

    awsdocs-neuron.readthedocs-hosted.com ·
  9. 09
    Neuron Persistent Cache

    Compilation cache in the historical PyTorch/XLA flow; do not generalize its path or calls to every integration.

    awsdocs-neuron.readthedocs-hosted.com ·
  10. 10
    Optimum Neuron: model export

    Export and input shapes in Optimum Neuron; evidence that the software contract matters alongside silicon capabilities.

    huggingface.co ·
  11. 11
    Tensor parallelism overview (archived library)

    Tensor splitting and result gathering; archived library used for the mechanism rather than as current installation guidance.

    awsdocs-neuron.readthedocs-hosted.com ·
  12. 12
    Pipeline parallelism overview (archived library)

    Pipelines and microbatches; archived conceptual reference without promising support for every architecture.

    awsdocs-neuron.readthedocs-hosted.com ·
  13. 13
    What is AWS Neuron?

    SDK components and current software paths. A library recommendation for Trn2 does not automatically validate Inf2.

    awsdocs-neuron.readthedocs-hosted.com ·
  14. 14
    vLLM Neuron: feature and model compatibility

    Compatibility matrix: check model, feature and target together; no portability promise without examination.

    awsdocs-neuron.readthedocs-hosted.com ·
  15. 15
    vLLM Neuron: feature guide

    Bucketing, compilation and serving options; details of this Trn2 integration are not automatically transferred to Inf2.

    awsdocs-neuron.readthedocs-hosted.com ·
  16. 16
    Amazon EC2 Trn2: product page

    Product positioning, 16 chips and 64-chip UltraServer. Marketing percentages, prices and inconsistent availability statements are not used as results.

    aws.amazon.com ·

Catalog provenance

Taxonomie des Technologies d'Intelligence Artificielle · Google Docs

Source document consulted on . § 5522.

Websites cited in the record

A website’s inclusion in the catalog does not verify the versions, projections or results mentioned in the document.

FROM KNOWLEDGE TO PROJECT

Apply this knowledge to your context.

Scope, architecture, roadmap and notes: keep your decisions in the dedicated space.

Open dedicated space