This document is relevant for: Inf2, Trn1, Trn2, Trn3
NCC_EOOM001#
Error message: The combined memory needed for the model tensors exceeds the high-bandwidth memory limit.
The memory usage consists of:
I/O tensors: Input and output activation tensors
Internal allocations: Scratchpad memory for intermediate computations
SBUF spills: Data that cannot fit in on-chip SBUF memory and must spill to HBM
To fix this issue, do one or more of these steps:
Decrease the batch size or the sequence length, if possible.
Shard the model across more NeuronCores. With TorchNeuron, use the standard
torch.distributedAPIs on theneuronbackend: tensor parallelism with DTensor, or FSDP2 to shard parameters, gradients, and optimizer state.For training at scale, use TorchTitan Neuron, which combines these parallelism strategies. For inference, use the tensor parallelism of vLLM Neuron.
This example shards two linear layers with tensor parallelism on the neuron backend:
from torch.distributed.device_mesh import init_device_mesh
from torch.distributed.tensor.parallel import (
ColwiseParallel, RowwiseParallel, parallelize_module,
)
tp_mesh = init_device_mesh("neuron", (world_size,), mesh_dim_names=("tp",))
model = torch.nn.Sequential(
torch.nn.Linear(16, 32), torch.nn.ReLU(), torch.nn.Linear(32, 16),
).to("neuron")
model = parallelize_module(
model, tp_mesh, {"0": ColwiseParallel(), "2": RowwiseParallel()},
)
For more information:
This document is relevant for: Inf2, Trn1, Trn2, Trn3