Skip to content

[Feature] Optimize forward metadata collection across dp ranks #1857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jianzs
Copy link
Collaborator

@jianzs jianzs commented Jul 17, 2025

Resubmit #1593

What this PR does / why we need it?

This PR introduces two optimizations for cases where data parallel size > 1:

  1. Eliminates DP communication in set_forward_context
  2. Implements HCCL for DP metadata communication, resulting in significant performance improvements for large DP configurations
    • Achieves ~20ms latency reduction with DP size of 64

Does this PR introduce any user-facing change?

no

How was this patch tested?

CI passed.

@jianzs jianzs force-pushed the feat/dp-comm-opt branch from d35cbf3 to f8eba17 Compare July 17, 2025 11:46
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.80%. Comparing base (33ef5dc) to head (2b0c3c1).
Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1857   +/-   ##
=======================================
  Coverage   54.80%   54.80%           
=======================================
  Files          75       75           
  Lines        9327     9327           
=======================================
  Hits         5112     5112           
  Misses       4215     4215           
Flag Coverage Δ
unittests 54.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Yikun
Copy link
Collaborator

Yikun commented Jul 17, 2025

Rebase here: f9dfde0

@jianzs jianzs force-pushed the feat/dp-comm-opt branch 2 times, most recently from 7b605f8 to 2b0c3c1 Compare July 18, 2025 03:15
if runner.dp_size > 1:
max_num_tokens, with_prefill = runner._get_forward_metadata_across_dp(
max_num_tokens, with_prefill)
if runner.dp_size <= 1:
Copy link
Collaborator

@wangxiyuan wangxiyuan Jul 19, 2025

Choose a reason for hiding this comment

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

Let's do the torchair refactor fist. Then add related code there #1885

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What are your plans for the model_runner refactoring?

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: Jade Zheng <zheng.shoujian@outlook.com>
@jianzs jianzs force-pushed the feat/dp-comm-opt branch from d913fa5 to ca448e1 Compare July 21, 2025 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants