Skip to content

Conversation

@yangqinghao-cmss
Copy link
Contributor

@yangqinghao-cmss yangqinghao-cmss commented Jul 21, 2025

What this PR does / why we need it?

Add ut for test_communicator.py

Does this PR introduce any user-facing change?

How was this patch tested?

pytest test_communicator.py

Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
@yangqinghao-cmss
Copy link
Contributor Author

test_communicator.py is assigned to me by @FieeFlip.

Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
@yangqinghao-cmss
Copy link
Contributor Author

@MengqingCao @Yikun help me to review my UT code

Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
rank=rank,
timeout=timedelta(seconds=30))

torch.npu.set_device(rank)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ut rans on CPU machine. I think this doesn't work. You can use mock for npu action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The NPU actions have been mocked.

Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.91%. Comparing base (8cfd257) to head (d19445c).
⚠️ Report is 121 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1897       +/-   ##
===========================================
+ Coverage   60.17%   76.91%   +16.74%     
===========================================
  Files          71      115       +44     
  Lines        7989    13079     +5090     
===========================================
+ Hits         4807    10060     +5253     
+ Misses       3182     3019      -163     
Flag Coverage Δ
unittests 76.91% <100.00%> (+16.74%) ⬆️

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.

return decorator


def test_all_to_all_with_sizes():
Copy link
Collaborator

Choose a reason for hiding this comment

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

move all test func to Test class. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests have been modified to be wrapped in a Test class

Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
@patch("torch.distributed.is_initialized", return_value=True)
@patch("torch.distributed.get_rank", return_value=1)
@patch("torch.distributed.is_initialized", return_value=True)
@patch("torch.distributed.get_backend", return_value="nccl")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@patch("torch.distributed.get_backend", return_value="nccl")
@patch("torch.distributed.get_backend", return_value="hccl")

@patch("torch.distributed.is_initialized", return_value=True)
@patch("torch.distributed.get_rank", return_value=1)
@patch("torch.distributed.is_initialized", return_value=True)
@patch("torch.distributed.get_backend", return_value="nccl")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@patch("torch.distributed.get_backend", return_value="nccl")
@patch("torch.distributed.get_backend", return_value="hccl")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, that's changed

Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
Signed-off-by: yangqinghao-cmss <yangqinghao_yewu@cmss.chinamobile.com>
@yangqinghao-cmss
Copy link
Contributor Author

I have added unit tests for the dispatch and combine functions. @MengqingCao @wangxiyuan

@yangqinghao-cmss yangqinghao-cmss closed this by deleting the head repository Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants