Repository navigation
Fix AsyncTP enabling - #3869
Fix AsyncTP enabling#3869jenniew wants to merge 1 commit into
Conversation
|
|
|
@jenniew pytorch/pytorch#172163, calling |
@fegin Yes, I test on cuda and xpu, after calling |
| ) | ||
|
|
||
| group_name = tp_mesh.get_group().group_name | ||
| from torch.distributed._symmetric_memory import enable_symm_mem_for_group |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
| 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.
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.
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.