Skip to content

Skip caching_allocator_warmup on Neuron (no reuse pool to warm; currently OOMs)#47029

Draft
dacorvo wants to merge 2 commits into
mainfrom
skip_neuron_device_warmup
Draft

Skip caching_allocator_warmup on Neuron (no reuse pool to warm; currently OOMs)#47029
dacorvo wants to merge 2 commits into
mainfrom
skip_neuron_device_warmup

Conversation

@dacorvo

@dacorvo dacorvo commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

CI

What does this PR do?

caching_allocator_warmup pre-allocates get_total_byte_count bytes per device in a single
torch.empty(...). The cuda/xpu branch bounds that allocation against device capacity via
mem_get_info; mps is skipped (#46239). Every other accelerator device — including neuron
(AWS Trainium/Inferentia, a PrivateUse1 backend) — falls through to the unclamped allocation, which
OOMs the NeuronCore during from_pretrained, before any weight is loaded:

RuntimeError: NRT allocation failed for size 233658313344 (OOM)

This happens because since torch.neuron exposes no mem_get_info, the allocation can't be bounded.

Incidentally, the warmup provides no benefit. on Neuron, since the backend keeps no CUDA-style reuse pool for a warm-up to fill: torch_neuronx.memory_stats() reports reserved_bytes = 0 even while 2 GB is allocated.

Skipping therefore costs nothing and fixes the OOM — the same trade-off as the MPS skip (#46239).

Before submitting

  • Read the contributor guideline.
  • Verified on AWS Trainium2: the OOM repro + allocator/timing measurements above, and a full support
    sweep with the skip applied — the warmup allocations are gone, models load up to their real footprint,
    and TP>1 models that previously passed still pass (no regression). transformers CI has no Neuron runner,
    as with the MPS skip.

Who can review?

@Cyrilvallez @SunMarc (reviewed the related warmup PRs #36380 / #46145; cf. the MPS skip #46239)

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@dacorvo dacorvo marked this pull request as draft July 2, 2026 18:38
@dacorvo

dacorvo commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Pushed without my consent by an overzealous agent, sorry about that.

caching_allocator_warmup pre-allocates get_total_byte_count bytes per device in
a single torch.empty(). The cuda/xpu branch clamps that with mem_get_info and
mps is skipped (#46239); every other accelerator, including neuron (a
PrivateUse1 backend), falls through to the unclamped allocation.

On Neuron this OOMs the NeuronCore during from_pretrained, before any weight is
placed, and provides no benefit: Neuron keeps no CUDA-style reuse pool for the
warmup to fill (torch_neuronx.memory_stats() reports reserved_bytes == 0 even
while memory is allocated, and pre-warming shows no measured speedup), and
torch.neuron exposes no mem_get_info so the allocation cannot be bounded.
Skip warmup on neuron, mirroring the mps skip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dacorvo dacorvo force-pushed the skip_neuron_device_warmup branch from 1b8b78b to 5987414 Compare July 3, 2026 13:08
Remove outdated comments regarding Neuron device warmup.
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 28662697911:1
Result: failure | Jobs: 14 | Tests: 46,239 | Failures: 1 | Duration: 16h 24m

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants