Skip to content

[torch-neuronx 2.14.3] Eager matmul+elementwise loop slows 30–50× as device memory fills, then fails with "Failed to load model" where an OOM error was expected #1447

Open

Description

@scttfrdmn

Environment, common to both:

  • trn2.3xlarge, Ubuntu 24.04.5 LTS, kernel 7.0.0-1014-aws, Neuron DLAMI for SDK 2.33.
  • torch 2.14.0, torch-neuronx 2.14.3.0.1+b1b6c66, neuronx-cc 2.28.7631.0+8f7b0cf5, nki 0.7.0+37713544100.gfede04bb.
  • aws-neuronx-runtime-lib 2.35.30.0, aws-neuronx-dkms 2.31.7.0, aws-neuronx-collectives 2.35.43.0, aws-neuronx-tools 2.33.38.0.
  • Logical NeuronCore config 2 (default); NEURON_RT_VISIBLE_CORES=1; eager mode, fp32.
import time, torch, torch_neuronx

HOLD_GB = 14            # 8 -> 1.2 s, 10 -> 35 s, 14 -> 64 s, 18 -> "Failed to load model"
nocc, nvir, naux, ic = 96, 672, 2304, 8
dev = "neuron"
hold = torch.zeros(int(HOLD_GB * 2**30 / 4), device=dev)   # stands in for other live tensors
B = (0.01 * torch.randn(nocc * nvir, naux)).to(dev)         # 595 MB
eo = (-0.5 - torch.rand(nocc)).to(dev)
ev = (0.2 + torch.rand(nvir)).to(dev)
eo2 = eo.view(nocc, 1, 1, 1) + eo.view(1, nocc, 1, 1)
ev2 = ev.view(1, 1, nvir, 1) + ev.view(1, 1, 1, nvir)
for rep in range(2):
    t0 = time.perf_counter()
    e = torch.zeros((), device=dev)
    for i0 in range(0, nocc, ic):                            # 12 chunks; T is 1.39 GB
        T = (B[i0 * nvir:(i0 + ic) * nvir] @ B.T).reshape(ic, nvir, nocc, nvir).permute(0, 2, 1, 3)
        e = e + (T * (2 * T - T.transpose(-2, -1)) / (eo2[i0:i0 + ic] - ev2)).sum()
    float(e); torch_neuronx.synchronize()
    print(rep, round(time.perf_counter() - t0, 2), "s")

Observed, warm rep, per logical core (24 GB HBM):

HOLD_GB time
0 1.22 s
8 1.22 s
10 35 s
14 64 s
18 about 5 min of retries, then RuntimeError: NRT Execution error occurred on Neuron for operation=aten::zeros ... Failed to load model, Invalid NEFF, instruction, or input

During the 18 GB run the runtime wrote a memory-table dump every ~6 s (/tmp/nrt_mem_log_device_0_*.csv, /tmp/neuron_mem_table_device_0_nc_6.log).

Expected: about the same time until the working set no longer fits, then a prompt out-of-memory error. Instead, a silent 30–50× slowdown at 40–60% HBM occupancy, then a model-load failure.

The likely cause is NEFF unload/reload or allocator thrash under pressure; that is a guess from the repeated memory dumps. A real DF-MP2 run (trnblas 768/96/2304) hits it with its natural working set: 24.7 s against 1.3 s with smaller chunks.

Found while benchmarking DF-MP2 in trnblas (trnsci/trnblas#57, #50).

Activity

  1. github-actions commented on Oct 30, 2026

    @github-actions

    Hi @scttfrdmn, Thank you for filing the issue! We will take a look and get back to you.

  2. added
    bug
    on Oct 30, 2026
  3. aws-charansg commented on Nov 10, 2026

    @aws-charansg

    From the torch-neuronx side, the team is looking at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Trn2buginference

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions