Skip to content

Fix AsyncTP enabling - #3869

Closed
jenniew wants to merge 1 commit into
pytorch:mainfrom
jenniew:fix_asynctp
Closed

jenniew wants to merge 1 commit into
pytorch:mainfrom
jenniew:fix_asynctp

Conversation

@jenniew

@jenniew jenniew commented Jul 6, 2026 •

Copy link
Copy Markdown

After we set enable_async_tensor_parallel in torchtitan, it would run micro_pipeline_tp_pass to fuse_all_gather_matmul and fuse_matmul_reduce_scatter. fuse_all_gather_matmul and fuse_matmul_reduce_scatter would check is_symm_mem_enabled_for_group is True or False. If is_symm_mem_enabled_for_group is False, fuse_all_gather_matmul and fuse_matmul_reduce_scatter would not replace matched patterns with torch.ops.symm_mem.fused_all_gather_matmul and torch.ops.symm_mem.fused_scaled_matmul_reduce_scatter.
In torchtitan, we haven't enabled symm_mem_enabled_for_group during initialization, so the check would be fail, and symmetric fused APIs would not be used.
This PR is to enable symm_mem_enabled_for_group during the torchtitan trainner initialization.

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

pytorch-bot Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

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

@fegin

fegin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@jenniew pytorch/pytorch#172163, calling symm_mem_enabled_for_group should no longer be required. Have you verified that with this call, you can get all patterns matched?

@jenniew

jenniew commented Jul 17, 2026

Copy link
Copy Markdown
Author

@jenniew pytorch/pytorch#172163, calling symm_mem_enabled_for_group should no longer be required. Have you verified that with this call, you can get all patterns matched?

@fegin Yes, I test on cuda and xpu, after calling symm_mem_enabled_for_group , the patterns get replaced.
I know this API will be deprecated, but I cannot find the better way to enable symm_mem for group. I have tried to use _SymmetricMemory.rendezvous, but during fusing, is_symm_mem_enabled_for_group still return false, so the pattern cannot be replaced. Can you suggest a better way to fix it?

)

group_name = tp_mesh.get_group().group_name
from torch.distributed._symmetric_memory import enable_symm_mem_for_group

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.

Move this to the top of the file to align with other imports.

"Async TP requires 'model' in --compile.components and --compile.enable"
)

group_name = tp_mesh.get_group().group_name

@acisseJZhong acisseJZhong Jul 29, 2026 •

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.

Suggested change
group_name = tp_mesh.get_group().group_name
if parallel_dims.spmd_backend == "spmd_types":
tp_mesh = parallel_dims.spmd_dense_mesh()["tp"]
elif parallel_dims.spmd_backend == "full_dtensor":
tp_mesh = parallel_dims.spmd_meshes()[0]["tp"]
else:
tp_mesh = parallel_dims.get_mesh("tp")
group_name = tp_mesh.get_group().group_name

I think we need sth like this to ensure that spmd_types and full_dtensor also works.

acisseJZhong added a commit that referenced this pull request Aug 12, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* __->__ #4045

## Summary
inheriting from #3869 
  Fix async TP setup across SPMD backends by:

  - enabling symmetric memory on the exact dense TP process group
  - adding `ParallelDims.get_dense_tp_mesh()` for backend-aware mesh
  selection
  - Move async TP enablement from parallelism config to compile config.
  - Configure async TP inside `apply_compile` using the dense TP mesh.
@tianyu-l tianyu-l closed this Oct 7, 2026
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

None yet

Development

Successfully merging this pull request may close these issues.

4 participants