Skip to content

[Prototype] Reduce M-FSDP v2 CPU overhead: foreach grad copy, cached DBuffer views, nvtx tags - #6487

Draft
shjwudp wants to merge 1 commit into
NVIDIA:mainfrom
shjwudp:split/pr-e-cpu-overhead
Draft

shjwudp wants to merge 1 commit into
NVIDIA:mainfrom
shjwudp:split/pr-e-cpu-overhead

Conversation

@shjwudp

@shjwudp shjwudp commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reduce M-FSDP v2 CPU overhead in the backward gradient path and make M-FSDP v2 communication visible in nsys traces.

Changes

  • copy_gradients_to_partial_buffer: replace the per-parameter .copy_() loop with torch._foreach_copy_() over batched destination/source lists — one kernel launch instead of O(params) launches.
  • DBuffer.get_local_tensor: cache narrow/view results keyed by tensor index; invalidate on storage resize (release/reallocate). Views are stable within a buffer lifetime since storage is preserved on resize.
  • FsdpModule: add nvtx ranges for the all-gather (unshard) and reduce-grad phases so M-FSDP v2 comm is visible in nsys traces.

Notes

Split out of PR #6197; standalone (based on main, no dependency on the overlap PR).

Test plan

  • py_compile + isort pass
  • M-FSDP v2 unit tests on the GB200 CI container (lyris)

@copy-pr-bot

copy-pr-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

…s, nvtx tags

- copy_gradients_to_partial_buffer: replace the per-parameter .copy_() loop
  with torch._foreach_copy_() over batched destination/source lists.
- DBuffer.get_local_tensor: cache narrow/view results keyed by tensor index;
  invalidate on storage resize (release/reallocate). Views are stable within
  a buffer lifetime since storage is preserved on resize.
- FsdpModule: add nvtx ranges for the all-gather (unshard) and reduce-grad
  phases so M-FSDP v2 comm is visible in nsys traces.

Signed-off-by: Jianbin Chang <jianbinc@nvidia.com>
@shjwudp
shjwudp force-pushed the split/pr-e-cpu-overhead branch from f6a3dd4 to 6afab9d Compare August 12, 2026 18:11
@shjwudp shjwudp changed the title Reduce M-FSDP v2 CPU overhead: foreach grad copy, cached DBuffer views, nvtx tags [Prototype] Reduce M-FSDP v2 CPU overhead: foreach grad copy, cached DBuffer views, nvtx tags Aug 12, 2026

This branch has not been deployed

No deployments
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.

1 participant