Skip to content

Conversation

lio1226
Copy link

@lio1226 lio1226 commented Oct 14, 2025

…od in test_rejection_sampler

What this PR does / why we need it?

This 'test_rejection_sampler' unit test is something wrong.

def test_sample_recovered_tokens_pytorch_autoregressive(self):
output_token_ids = torch.empty(2, dtype=torch.int32)
cu_num_draft_tokens = torch.tensor([1, 1])
draft_token_ids = torch.tensor([0, 1])

len(draft_token_ids ) = 2, cu_num_draft_tokens should be torch.tensor([1, 2]) or torch.tensor([2, 2])

I fix it and set cu_num_draft_tokens = torch.tensor([1, 2]). The methods before and after optimization can pass.

Does this PR introduce any user-facing change?

No

How was this patch tested?

NA

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 correctly fixes a bug in the test_sample_recovered_tokens_pytorch_autoregressive unit test. The value of cu_num_draft_tokens was incorrect, causing the test to not properly check behavior for the second request in the batch. The provided fix corrects this value, making the test logic sound. I have one suggestion to improve the completeness of this test.

"""Test recovered token sampling for autoregressive models"""
output_token_ids = torch.empty(2, dtype=torch.int32)
cu_num_draft_tokens = torch.tensor([1, 1])
cu_num_draft_tokens = torch.tensor([1, 2])
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This fix is correct and enables the test to properly process both requests in the batch. However, the test currently only asserts the output for the first request. To ensure the function behaves correctly for all cases covered by this test, an assertion for the second request's output should be added. Based on my analysis of the test data, output_token_ids[1] should be 0. Please consider adding assert output_token_ids[1].item() == 0 to make the test more robust.

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