Repository navigation
Fix CUDA low-memory external weights export - #21798
Conversation
🔗 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. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
36140a4 to
bfeac06
Compare
|
@claude review this PR plz |
|
Claude finished @Gasoonjia's task in 8m 19s —— View job PR Review: Fix CUDA low-memory external weights export
Overall this is a well-structured change. Every new behavior is gated behind A few things worth confirming or tightening before merge. 1. Blob alignment: the production (all-CUDA) path is packed, but only the padded path is unit-testedIn if not all_cuda and (padding := (-nbytes) % 64):
output.write(bytes(padding))So the real MG 30B export (all constants on CUDA) writes tensors back-to-back with no alignment padding, while the CPU/mixed path pads each tensor to a 64-byte boundary. The blob's constant offsets are baked into the AOTI-generated wrapper at compile time ( The docstring claims "same layout as AOTInductor's
2.
|
Authored with Codex.
| raw_array = (ctypes.c_ubyte * nbytes).from_address(storage.data_ptr()) | ||
| raw_view = memoryview(raw_array).cast("B") | ||
| for offset in range(0, nbytes, chunk_size): | ||
| output.write(raw_view[offset : offset + chunk_size]) |
There was a problem hiding this comment.
any noticeable increase in export time because of all these writes?
There was a problem hiding this comment.
no the export time remains the same
Summary
low_memory_modeis 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