Skip to content

Add async AR_COL for 2d sync (#4530) - #4530

Open
axeisghost wants to merge 1 commit into
meta-pytorch:mainfrom
axeisghost:export-D114156292
Open

Add async AR_COL for 2d sync (#4530)#4530
axeisghost wants to merge 1 commit into
meta-pytorch:mainfrom
axeisghost:export-D114156292

Conversation

@axeisghost

@axeisghost axeisghost commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary:

  • Extends DMPCollection.set_all_reduce_hook so custom hooks receive the active replication process group, while preserving the existing constructor-provided hook behavior.
  • Adds the default-off async_two_dim_sparse_parallelism_sync pipeline option. The option is accepted only when both two_dim_sparse_parallelism_sync and pipeline_embedding_lookup_fwd are enabled and the model is a DMPCollection.
  • Registers an async hook from TrainPipelineCustomizedOrderSparseDist that runs all_reduce_coalesced with ReduceOp.AVG and async_op=True, retaining every returned future across parameter dtypes, optimizer state, and DMP contexts.
  • Waits for all pending 2D synchronization futures immediately after model forward and before post-forward hooks or backward, then clears the completed handles. The existing blocking synchronization path remains unchanged when the new option is disabled.
  • Adds focused coverage for process-group forwarding, legacy-hook override behavior, option validation, async collective arguments, future ownership and cleanup, and forward -> wait -> post-forward ordering.

Differential Revision: D114156292

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 11, 2026
@meta-codesync

meta-codesync Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@axeisghost has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114156292.

@meta-codesync meta-codesync Bot changed the title Add async AR_COL for 2d sync Add async AR_COL for 2d sync (#4530) Aug 18, 2026
axeisghost added a commit to axeisghost/torchrec that referenced this pull request Aug 18, 2026
Summary:

- Extends `DMPCollection.set_all_reduce_hook` so custom hooks receive the active replication process group, while preserving the existing constructor-provided hook behavior.
- Adds the default-off `async_two_dim_sparse_parallelism_sync` pipeline option. The option is accepted only when both `two_dim_sparse_parallelism_sync` and `pipeline_embedding_lookup_fwd` are enabled and the model is a `DMPCollection`.
- Registers an async hook from `TrainPipelineCustomizedOrderSparseDist` that runs `all_reduce_coalesced` with `ReduceOp.AVG` and `async_op=True`, retaining every returned future across parameter dtypes, optimizer state, and DMP contexts.
- Waits for all pending 2D synchronization futures immediately after model forward and before post-forward hooks or backward, then clears the completed handles. The existing blocking synchronization path remains unchanged when the new option is disabled.
- Adds focused coverage for process-group forwarding, legacy-hook override behavior, option validation, async collective arguments, future ownership and cleanup, and `forward -> wait -> post-forward` ordering.

Differential Revision: D114156292
axeisghost added a commit to axeisghost/torchrec that referenced this pull request Aug 18, 2026
Summary:

- Extends `DMPCollection.set_all_reduce_hook` so custom hooks receive the active replication process group, while preserving the existing constructor-provided hook behavior.
- Adds the default-off `async_two_dim_sparse_parallelism_sync` pipeline option. The option is accepted only when both `two_dim_sparse_parallelism_sync` and `pipeline_embedding_lookup_fwd` are enabled and the model is a `DMPCollection`.
- Registers an async hook from `TrainPipelineCustomizedOrderSparseDist` that runs `all_reduce_coalesced` with `ReduceOp.AVG` and `async_op=True`, retaining every returned future across parameter dtypes, optimizer state, and DMP contexts.
- Waits for all pending 2D synchronization futures immediately after model forward and before post-forward hooks or backward, then clears the completed handles. The existing blocking synchronization path remains unchanged when the new option is disabled.
- Adds focused coverage for process-group forwarding, legacy-hook override behavior, option validation, async collective arguments, future ownership and cleanup, and `forward -> wait -> post-forward` ordering.

Differential Revision: D114156292
Summary:

- Extends `DMPCollection.set_all_reduce_hook` so custom hooks receive the active replication process group, while preserving the existing constructor-provided hook behavior.
- Adds the default-off `async_two_dim_sparse_parallelism_sync` pipeline option. The option is accepted only when both `two_dim_sparse_parallelism_sync` and `pipeline_embedding_lookup_fwd` are enabled and the model is a `DMPCollection`.
- Registers an async hook from `TrainPipelineCustomizedOrderSparseDist` that runs `all_reduce_coalesced` with `ReduceOp.AVG` and `async_op=True`, retaining every returned future across parameter dtypes, optimizer state, and DMP contexts.
- Waits for all pending 2D synchronization futures immediately after model forward and before post-forward hooks or backward, then clears the completed handles. The existing blocking synchronization path remains unchanged when the new option is disabled.
- Adds focused coverage for process-group forwarding, legacy-hook override behavior, option validation, async collective arguments, future ownership and cleanup, and `forward -> wait -> post-forward` ordering.

Differential Revision: D114156292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant