-
Notifications
You must be signed in to change notification settings - Fork 459
[EPLB] ut for EPLB #3035
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
[EPLB] ut for EPLB #3035
Conversation
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a suite of unit tests for the Expert Placement Load Balancing (EPLB) functionality. The tests cover various components, including adaptors, policies, and utility functions. While the coverage is a good step forward, my review identified several critical issues in the new tests. These include incorrect assertions that do not match the code's behavior, and flawed test setups that would cause tests to fail for reasons different from what they intend to verify. Addressing these issues is crucial to ensure the reliability and correctness of the test suite.
|
||
|
||
def test_generate_task_and_state_flow(mock_adaptor): | ||
loader_obj = loader.D2DExpertWeightLoader(mock_adaptor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The D2DExpertWeightLoader
class is instantiated with mock_adaptor
as an argument, but its __init__
method does not accept any arguments. This will cause a TypeError
. The adaptor should be set using the set_adator
method after instantiation. This needs to be fixed in all test functions in this file (lines 60, 96, 102, 118).
loader_obj = loader.D2DExpertWeightLoader(mock_adaptor) | |
loader_obj = loader.D2DExpertWeightLoader() | |
loader_obj.set_adator(mock_adaptor) |
with pytest.raises(ZeroDivisionError): | ||
policy.safe_divide(1, 0) | ||
|
||
# safe_exact_divide | ||
assert policy.safe_exact_divide(10, 3) == 3 | ||
with pytest.raises(ZeroDivisionError): | ||
policy.safe_exact_divide(1, 0) | ||
|
||
# safe_mod | ||
assert policy.safe_mod(10, 3) == 1 | ||
with pytest.raises(ZeroDivisionError): | ||
policy.safe_mod(1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests for safe_divide
, safe_exact_divide
, and safe_mod
incorrectly expect a ZeroDivisionError
to be raised on division by zero. The implementation of these safe operations is designed to handle this case by returning 0 and printing a message, not by raising an exception. The tests should be updated to assert that the return value is 0 in these scenarios.
with pytest.raises(ZeroDivisionError): | |
policy.safe_divide(1, 0) | |
# safe_exact_divide | |
assert policy.safe_exact_divide(10, 3) == 3 | |
with pytest.raises(ZeroDivisionError): | |
policy.safe_exact_divide(1, 0) | |
# safe_mod | |
assert policy.safe_mod(10, 3) == 1 | |
with pytest.raises(ZeroDivisionError): | |
policy.safe_mod(1, 0) | |
assert policy.safe_divide(1, 0) == 0 | |
# safe_exact_divide | |
assert policy.safe_exact_divide(10, 3) == 3 | |
assert policy.safe_exact_divide(1, 0) == 0 | |
# safe_mod | |
assert policy.safe_mod(10, 3) == 1 | |
assert policy.safe_mod(1, 0) == 0 |
expert_table_zero = np.array([[]]) # 1 layer, 0 NPU, 0 experts | ||
workload_zero = np.array([[]]) | ||
with pytest.raises(ValueError): | ||
policy.rebalance_experts(expert_table_zero, workload_zero) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test case for num_npus <= 0
is not correctly set up. The input arrays expert_table_zero
and workload_zero
are initialized as np.array([[]])
, which creates 2D arrays with shape (1, 0)
. However, the rebalance_experts
method expects 3D arrays. This will cause a ValueError: not enough values to unpack (expected 3, got 2)
when trying to unpack the shape, which is not the error this test case is intended to catch. To correctly test the num_npus <= 0
check, you should provide 3D arrays with the second dimension being 0, for example, np.zeros((1, 0, 0))
.
expert_table_zero = np.array([[]]) # 1 layer, 0 NPU, 0 experts | |
workload_zero = np.array([[]]) | |
with pytest.raises(ValueError): | |
policy.rebalance_experts(expert_table_zero, workload_zero) | |
expert_table_zero = np.zeros((1, 0, 0)) | |
workload_zero = np.zeros((1, 0, 0)) | |
with pytest.raises(ValueError): | |
policy.rebalance_experts(expert_table_zero, workload_zero) |
7b3134c
to
dc75e4d
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
919f01d
to
d5ba017
Compare
d5ba017
to
adf74ec
Compare
cc125e1
to
e0faf1d
Compare
Signed-off-by: tanqingshan (A) <t50050625@china.huawei.com> Signed-off-by: <> Signed-off-by: tanqingshan (A) <50050625@china.huawei.com>
Signed-off-by: <> Signed-off-by: tanqingshan <50050625@china.huawei.com>
Signed-off-by: <> Signed-off-by: tanqingshan <50050625@china.huawei.com>
e0faf1d
to
ac11e65
Compare
Signed-off-by: daishixun <dsxsteven@sina.com>
UT for EPLB
Co-authored-by Skywalker-EP 173723846@qq.com
Co-authored-by offline 0806@qq.com
Co-authored-by dsxsteven@sina.com
UT Description
1. Module Description
2. Covered Source Files
3. Testing Method
4. Coverage
Statement Coverage: 90%
vLLM version: v0.10.2
vLLM main: vllm-project/vllm@f225ea7