Skip to content

Conversation

@dragondream-chen
Copy link
Contributor

@dragondream-chen dragondream-chen commented Nov 24, 2025

What this PR does / why we need it?

Add mtp_proposer ut

Does this PR introduce any user-facing change?

How was this patch tested?

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 adds unit tests for the MtpProposer. The tests cover initialization, model loading, and various helper methods for token generation. I've found several critical issues in the new tests that cause them to be broken or incorrect. One test has an incorrect assertion on an exception message. Another test has a syntax error that prevents it from running, as well as a logical flaw in its assertions. These issues need to be addressed to ensure the tests are reliable and correctly validate the code's behavior.

Comment on lines +131 to +137
with pytest.raises(AssertionError) as excinfo:
proposer.load_model(mock_model)

assert str(excinfo.value) == ""
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The assertion assert str(excinfo.value) == "" is incorrect. When pytest catches an AssertionError, its string representation is the assertion expression that failed (e.g., 'assert 0 == 1'), not an empty string. This causes the test to fail incorrectly. To fix this, you should remove the assertion on the exception value if you only care that an AssertionError is raised.

Suggested change
with pytest.raises(AssertionError) as excinfo:
proposer.load_model(mock_model)
assert str(excinfo.value) == ""
with pytest.raises(AssertionError):
proposer.load_model(mock_model)


mock_backup_output = proposer.backup_next_token_ids

expected_backup_cpu = np.array([1000, 2000, 3000, 4000, 0, 0, ...])[:10]
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This line has a syntax error. The ellipsis ... is not a valid element within a list used to initialize a numpy.array. This will raise a SyntaxError and prevent the test from running.

Suggested change
expected_backup_cpu = np.array([1000, 2000, 3000, 4000, 0, 0, ...])[:10]
expected_backup_cpu = np.array([1000, 2000, 3000, 4000, 0, 0, 0, 0, 0, 0])

Comment on lines 319 to 320
expected_next_tokens = torch.tensor([103, 2, 3, 4], dtype=torch.int32, device="cpu")
assert torch.equal(next_token_ids, expected_next_tokens)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The expected value for next_token_ids is incorrect. The backup tokens are calculated from the mocked requests to be [1000, 2000, 3000, 4000]. The method under test correctly calculates the backup tokens and copies them to the GPU buffer. For discarded requests, it should fall back to these values. However, the test asserts against [2, 3, 4], which seems to be based on a stale mock value. The assertion should check against the correctly calculated backup tokens.

Suggested change
expected_next_tokens = torch.tensor([103, 2, 3, 4], dtype=torch.int32, device="cpu")
assert torch.equal(next_token_ids, expected_next_tokens)
expected_next_tokens = torch.tensor([103, 2000, 3000, 4000], dtype=torch.int32, device="cpu")
assert torch.equal(next_token_ids, expected_next_tokens)

Signed-off-by: chenmenglong <[email protected]>
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.

1 participant