mirror of
https://github.com/pytorch/pytorch.git
synced 2026-10-28 18:56:51 +08:00
On NVLink-C2C systems (Grace Hopper, Grace Blackwell), CPU↔GPU copies already use C2C automatically. The bottleneck is the CPU destination: `tensor.cpu()` allocates fresh pageable memory, so the first copy is limited by page allocation and faults rather than link bandwidth. Activation offloading that calls `.cpu()` every step can pay that cost every time. This PR documents the fix (allocate pinned CPU buffers once and reuse them), the synchronization rules, and the caveat that pinned memory can still fault under OS memory compaction. It also links the new section from `Tensor.cpu()`. [Slack Thread](https://pytorch.slack.com/archives/C3PDTEV8E/p1790188671754669?thread_ts=1788293519.083089&cid=C3PDTEV8E) Pull Request resolved: https://github.com/pytorch/pytorch/pull/199737 Approved by: https://github.com/MatthiasKohl, https://github.com/albanD Co-authored-by: Matthias Jouanneaux <matthias.kohl@hotmail.de>