Skip to content

Fix CUDA low-memory external weights export - #21798

Open
Gasoonjia wants to merge 1 commit into
mainfrom
low-host-mem-cuda-export-fix
Open

Fix CUDA low-memory external weights export#21798
Gasoonjia wants to merge 1 commit into
mainfrom
low-host-mem-cuda-export-fix

Conversation

@Gasoonjia

Copy link
Copy Markdown
Contributor

Summary

  • Stream AOTInductor external weights to disk instead of materializing a model-sized bytes object in host memory.
  • Keep the resulting weights blob file-backed during PTE serialization.
  • Avoid deep-copying immutable tensor storage for each delegated method.
  • Move compile-time clones of mutated buffers to CPU and temporarily release zero-initialized KV-cache storage.
  • Preserve the existing export path unless low_memory_mode is enabled.

On MG 30B, peak host RSS decreased from 75.2 GiB to 48.8 GiB, a 26.3 GiB (35.1%) reduction. A separate 131K-context export completed with approximately 17 GiB peak GPU.

Testing

  • Added CUDA low-memory export and serialization unit tests.
  • Verified full MG 30B export and runtime successfully.

@pytorch-bot

pytorch-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21798

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 1 Unrelated Failure, 4 Unclassified Failures

As of commit 72243ad with merge base e60faa2 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 13, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant