Skip to content

Skip accelerator sync for unprofiled comm ops - #8795

Merged
hwchen2017 merged 1 commit into
deepspeedai:masterfrom
guptaishaan:fix-8756
Oct 27, 2026
Merged

hwchen2017 merged 1 commit into
deepspeedai:masterfrom
guptaishaan:fix-8756

Conversation

@guptaishaan

Copy link
Copy Markdown
Contributor

Fixes #8756

timed_op called get_accelerator().synchronize() for every wrapped comm op whenever comms logging was enabled. Ops not selected by prof_ops, prof_all or prof get no timer and no record, so the sync was pure overhead.

The sync is now guarded by should_profile. The MPI cdb.barrier() is unchanged.

Test: test_collective_profiling now counts synchronize() calls. It must be 0 for the unselected case and 1 for prof_all, prof, and both prof_ops cases. Without the fix the 8 unselected cases fail; with it all 52 tests in test_comms_logger.py pass. yapf is clean.

Verified on a node with A40 GPUs, but the tests use a mocked backend and accelerator, so no GPU was exercised. Not verified: real NCCL/MPI runs, training step timing, or the rest of the unit test suite.

Thanks to @marcusacosta for the report.

This change was prepared by an automated AI agent (Claude) and verified as described above.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-10T03:29:49.033806Z f4e19bb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI 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.

🟢 Approval recommended

The focused implementation matches the issue requirements and is covered across all supported profiling-selection modes.

0 open findings

What changed in this PR

Limits accelerator synchronization to communication operations selected for profiling, reducing unnecessary logging overhead.

Changes:

  • Guard accelerator synchronization with should_profile.
  • Test synchronization behavior across profiling modes.
File Description
deepspeed/​comm/​comm.py Skips synchronization for unprofiled operations.
tests/​unit/​comm/​test_comms_logger.py Verifies synchronization call counts.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@hwchen2017

Copy link
Copy Markdown
Contributor

Can you fix the DCO error?

timed_op synchronized the accelerator after every wrapped comm op
whenever comms logging was enabled, even for ops that were not
selected by prof_ops, prof_all or prof. Those ops never get a timer
or a record, so the sync only added overhead.

Only synchronize when should_profile is set. The MPI barrier is
unchanged. Count synchronize() calls in test_collective_profiling for
both profiled and unselected ops.

Signed-off-by: guptaishaan <[email protected]>
@guptaishaan

Copy link
Copy Markdown
Contributor Author

Thanks for catching that. The commit was missing its Signed-off-by line. I rebuilt the branch as a single commit on current master with the sign-off added, and will force-push it. The code change is identical to before, and master had no conflicting changes in deepspeed/comm/comm.py or the test.

@hwchen2017
hwchen2017 added this pull request to the merge queue Oct 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 27, 2026
@hwchen2017
hwchen2017 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into deepspeedai:master with commit b582959 Oct 27, 2026
16 checks passed
@tohtana tohtana added needs-gpu-test GPU testing is recommended to validate the changes in this PR. and removed needs-gpu-test GPU testing is recommended to validate the changes in this PR. labels Nov 10, 2026
@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid unnecessary synchronization for unprofiled communication logging

4 participants