Skip to content

Add FSDP symmetric memory configuration and related tests - #3105

Merged
tianyu-l merged 17 commits into
pytorch:mainfrom
crcrpar:symm_mem_for_fsdp2_comm
May 26, 2026
Merged

tianyu-l merged 17 commits into
pytorch:mainfrom
crcrpar:symm_mem_for_fsdp2_comm

Conversation

@crcrpar

@crcrpar crcrpar commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Enable FSDP symmetric-memory communication in TorchTitan’s default trainer path.

This PR wires parallelism.enable_fsdp_symm_mem through the regular FSDP2 parallelization paths and calls FSDPModule.set_symm_mem_for_comm() on FSDP modules. This covers the default trainer path, not graph trainer or Inductor compiled async-TP symmetric-memory kernels.

Benchmarks

100-step runs on 4x GB200, default trainer path. Throughput excludes the first 20 warmup steps.

Model torch.compile symm_mem off symm_mem on Speedup
Llama 3 8B on 17,158 tok/s 17,551 tok/s 1.023x
Llama 3 8B off 16,050 tok/s 16,234 tok/s 1.011x
Qwen3 32B on 4,312 tok/s 4,414 tok/s 1.024x
Qwen3 32B off 3,544 tok/s 3,638 tok/s 1.027x
GPT-OSS 20B on 12,839 tok/s 13,644 tok/s 1.063x
GPT-OSS 20B off 9,882 tok/s 10,220 tok/s 1.034x

Used GPT-5.5

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 26, 2026
@pytorch-bot

pytorch-bot Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@crcrpar
crcrpar marked this pull request as ready for review April 27, 2026 13:35

@fegin fegin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weifengpy can you review?

Comment thread tests/integration_tests/features.py Resolved
Comment thread torchtitan/distributed/fsdp.py Resolved
Comment thread torchtitan/distributed/fsdp.py Resolved

@weifengpy weifengpy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good on fsdp changes

some nits before landing:

  • maybe avoid un-related linter change to make the PR focused?
  • I dont see force sum yet. titan use fp32 reduce dtype by default. but would be good to have force sum in case people override default to use bf16/fp16 reduce

@crcrpar
crcrpar force-pushed the symm_mem_for_fsdp2_comm branch 2 times, most recently from 1ef927c to 0377c49 Compare May 18, 2026 07:17
@crcrpar
crcrpar force-pushed the symm_mem_for_fsdp2_comm branch from 0377c49 to 18be5aa Compare May 18, 2026 07:18
@crcrpar

crcrpar commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

As I can't merge this myself, could any of you land this? maybe @weifengpy?

@weifengpy

Copy link
Copy Markdown
Contributor

fsdp change looks good to me. seems this can only be landed with code-owner review from @fegin @tianyu-l

Comment thread torchtitan/distributed/fsdp.py Outdated
Comment on lines +34 to +36
# Potential hiccup: TorchTitan also supports float8 FSDP all-gather
# via torchao. That path customizes FSDP communication behavior, so
# this combination may need extra validation when both are enabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float8 FSDP all-gather has been deprecated in torchtitan. Please remove this comment.

Comment on lines +123 to +126
"""
Whether to enable FSDP2 symmetric-memory communication optimizations for
all FSDP modules after `fully_shard` has been applied.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it only work on NVIDIA GPUs? We probably should error out in ParallelismConfig'spost_init

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI burden is heavy. Maybe just add one more test, or piggyback on an existing test that also skip_rocm, e.g. https://github.com/pytorch/torchtitan/blob/main/tests/integration_tests/features.py#L607

@tianyu-l

Copy link
Copy Markdown
Contributor

@crcrpar

crcrpar commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

@tianyu-l
tianyu-l merged commit 58b0344 into pytorch:main May 26, 2026
18 of 20 checks passed
@crcrpar
crcrpar deleted the symm_mem_for_fsdp2_comm branch May 27, 2026 00:47
saforem2 added a commit to saforem2/torchtitan that referenced this pull request May 27, 2026
… routing

Merged 7 upstream commits (19c567f..af33f76). Documents which
ones needed ezpz replays:

- PR pytorch#3398 (Module subclass refactor): 3 import paths replayed in
  b052f29 — pure import-path swap, class API unchanged.
- PR pytorch#3146 (deterministic MoE routing): inherits transitively; this
  is the upstream fix for the _histc_xpu non-determinism blocker
  we hit on 2026-05-21. --debug.deterministic on MoE+XPU should now
  work.
- PR pytorch#3423 (MoE [7/n] 3D tensors): inherits transitively; doesn't
  touch deepseek_v3 callsites.
- PR pytorch#3105 (FSDP symm_mem): skipped — ezpz has its own apply_fsdp
  and symm_mem is an optional optimization XPU CCL likely doesn't
  support.
- PRs pytorch#3331/pytorch#3369/pytorch#3361: graph_trainer-only no-ops.

Captures two action items: smoke-test before next production push,
and re-try --debug.deterministic on MoE+XPU.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants