Skip to content

[Test][310P] Cover unsupported sampler parameters - #15328

Open
UniversePeak wants to merge 1 commit into
vllm-project:mainfrom
UniversePeak:test/310p-sampler-unsupported-params
Open

UniversePeak wants to merge 1 commit into
vllm-project:mainfrom
UniversePeak:test/310p-sampler-unsupported-params

Conversation

@UniversePeak

@UniversePeak UniversePeak commented Aug 29, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it?

The Ascend310PSampler for 310P model runner v2 intentionally rejects unsupported sampling parameters, including repetition, presence, and frequency penalties. This PR adds focused unit coverage for each rejection path so future changes cannot silently broaden the supported parameter set.

The existing greedy and random-sampling checks remain covered, and the new cases exercise the three penalty fields independently plus the combined presence/frequency path.

Related: #15235

Does this PR introduce any user-facing change?

No. This change only adds unit tests for existing rejection behavior.

How was this patch tested?

  • python -m py_compile tests/ut/_310p/test_model_runner_v2_310p.py vllm_ascend/_310p/worker/v2/sampler.py
  • ruff check tests/ut/_310p/test_model_runner_v2_310p.py
  • ruff format --check tests/ut/_310p/test_model_runner_v2_310p.py
  • git diff --check

The focused pytest invocation was attempted, but this host's installed vLLM/NPU environment did not complete test collection within 300 seconds. The test file and sampler module compile successfully; full pytest and 310P hardware validation should run in CI or on maintainer hardware.

Signed-off-by: UniversePeak UniversePeak@users.noreply.github.com

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the test suite for the Ascend310PSampler within the 310P model runner. The primary goal is to formalize the rejection behavior for unsupported sampling parameters, ensuring that future development does not inadvertently alter these constraints. The changes are strictly limited to testing infrastructure and do not affect the runtime behavior of the model.

Highlights

  • Unit Test Coverage: Added comprehensive unit tests to verify that the Ascend310PSampler correctly rejects unsupported sampling parameters.
  • Penalty Parameter Validation: Implemented parameterized tests for repetition, presence, and frequency penalties to ensure they trigger the expected NotImplementedError.
  • Greedy Sampling Verification: Added a dedicated test case to confirm that supported greedy sampling parameters are accepted by the sampler.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

Copy link
Copy Markdown
Contributor

👋 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 test coverage for the rejection of unsupported sampling parameters in Ascend310PSampler by introducing a parametrized test for penalty parameters and updating greedy/random sampling tests. The feedback recommends consolidating and expanding these tests into a single, comprehensive parametrized test to cover all unsupported parameters (such as top_p, top_k, min_p, logprobs, and logit_bias) that are currently missing from the test suite.

Suggested PR Title:

[Test][Misc] Add unit tests for unsupported sampling parameters in Ascend310PSampler

Suggested PR Summary:

### What this PR does / why we need it?
This PR adds focused unit test coverage for the rejection paths of unsupported sampling parameters in `Ascend310PSampler`. It introduces parametrized tests for repetition, presence, and frequency penalties, and refactors existing tests for greedy and random sampling.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Tested using the newly added unit tests in `tests/ut/_310p/test_model_runner_v2_310p.py`.

Comment on lines +155 to +176
@pytest.mark.parametrize(
("sampling_kwargs", "message"),
[
({"repetition_penalty": 1.1}, "repetition_penalty"),
({"presence_penalty": 0.1}, "presence/frequency penalty"),
({"frequency_penalty": 0.1}, "presence/frequency penalty"),
(
{"presence_penalty": 0.1, "frequency_penalty": 0.1},
"presence/frequency penalty",
),
],
)
def test_sampler_rejects_unsupported_penalty_parameters(sampling_kwargs, message) -> None:
sampler = Ascend310PSampler()
with pytest.raises(NotImplementedError, match=message):
sampler.add_request(0, 4, SamplingParams(temperature=0, **sampling_kwargs))


def test_sampler_rejects_random_sampling_parameters() -> None:
sampler = Ascend310PSampler()
with pytest.raises(NotImplementedError, match="Unsupported sampling parameters"):
sampler.add_request(1, 4, SamplingParams(temperature=1))
sampler.add_request(0, 4, SamplingParams(temperature=1))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The PR description states that this PR adds focused unit coverage for each rejection path of unsupported sampling parameters. However, several unsupported parameters checked in Ascend310PSampler.add_request (such as top_p, top_k, min_p, logprobs, prompt_logprobs, and logit_bias) are not covered by the new tests.

We can consolidate and expand the test coverage by replacing both test_sampler_rejects_unsupported_penalty_parameters and test_sampler_rejects_random_sampling_parameters with a single, comprehensive parametrized test that covers all unsupported parameters.

@pytest.mark.parametrize(
    ("sampling_kwargs", "message"),
    [
        ({"temperature": 1.0}, "temperature"),
        ({"top_p": 0.9}, "top_p"),
        ({"top_k": 5}, "top_k"),
        ({"min_p": 0.1}, "min_p"),
        ({"repetition_penalty": 1.1}, "repetition_penalty"),
        ({"presence_penalty": 0.1}, "presence/frequency penalty"),
        ({"frequency_penalty": 0.1}, "presence/frequency penalty"),
        (
            {"presence_penalty": 0.1, "frequency_penalty": 0.1},
            "presence/frequency penalty",
        ),
        ({"logprobs": 1}, "logprobs"),
        ({"prompt_logprobs": 1}, "logprobs"),
        ({"logit_bias": {1: 1.0}}, "logits processors"),
    ],
)
def test_sampler_rejects_unsupported_parameters(sampling_kwargs, message) -> None:
    sampler = Ascend310PSampler()
    temp = sampling_kwargs.pop("temperature", 0)
    with pytest.raises(NotImplementedError, match=message):
        sampler.add_request(0, 4, SamplingParams(temperature=temp, **sampling_kwargs))

@UniversePeak

Copy link
Copy Markdown
Author

CI gate is currently failing because select-tests found tests (has_tests=true, has_tests_a5=true) but neither ready-precise nor ready-all is set. This account cannot add the required label (AddLabelsToLabelable permission denied), so a maintainer needs to add ready-precise to run the selected tests: https://github.com/vllm-project/vllm-ascend/actions/runs/33259079459

The Gemini review also requests coverage for the remaining unsupported sampler parameters (top_p, top_k, min_p, logprobs, prompt_logprobs, and logit_bias).

@UniversePeak
UniversePeak force-pushed the test/310p-sampler-unsupported-params branch from fdab2e4 to 6e3c828 Compare August 29, 2026 17:07
@UniversePeak

Copy link
Copy Markdown
Author

Added focused coverage for the remaining unsupported 310P sampling parameters requested in review: top_p, top_k, min_p, logprobs, prompt_logprobs, and logit_bias, alongside the existing penalty cases.

Verification:

  • py_compile: passed
  • Ruff check: passed
  • Ruff format check: passed
  • git diff --check: passed
  • The focused pytest collection is blocked on this Windows host by the installed vLLM environment (vllm._C is unavailable and uvloop is missing); no test assertion failure was observed.

The update is in commit 6e3c82898a7d3e846df6d7ae8fc7edb3201af36b, and DCO is signed. The remaining ci-gate requirement still needs a maintainer to add ready-precise or ready-all and rerun the selected tests.

@github-actions

Copy link
Copy Markdown
Contributor

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

@UniversePeak

Copy link
Copy Markdown
Author

Merged the latest main into this branch and resolved the conflict in tests/ut/_310p/test_model_runner_v2_310p.py: the combined accepts-greedy / rejects-random test from #16043 is kept, and the parametrized coverage for unsupported sampling parameters (top_p, top_k, min_p, penalties, logprobs, logit_bias) is preserved on top of it. py_compile, ruff check, and ruff format --check all pass. Ready for review.

@UniversePeak
UniversePeak force-pushed the test/310p-sampler-unsupported-params branch from 9f796fc to 3c157cf Compare September 12, 2026 11:58
@UniversePeak

Copy link
Copy Markdown
Author

The CI failure on 3c157cf was a test bug, not a sampler gap: the pinned vLLM main commit normalizes top_p/top_k/min_p to greedy defaults (1.0/0/0.0) in SamplingParams.__post_init__ when temperature=0, so those cases never reached the 310P MRv2 guard and pytest reported DID NOT RAISE.

Pushed ba37d4f to build the top_p/top_k/min_p cases with temperature=1.0 so the NotImplementedError guard is actually exercised; the penalty/logprobs/logit_bias cases keep temperature=0 since they are not affected by greedy normalization. py_compile, ruff check, and ruff format --check pass locally. CI is rerunning on the new head.

@UniversePeak

Copy link
Copy Markdown
Author

Update: on the new head ba37d4f, pre-commit and cpu-ut both pass (the three DID NOT RAISE failures are gone). The only remaining check is ci-gate, which reports that precision tests are required before merge and asks a maintainer to add one label — ready-precise (recommended), ready-all, or main2main. The PR itself only touches tests/ut/_310p/test_model_runner_v2_310p.py, and we can't add labels ourselves, so a maintainer's label would be the last step before review/merge.

@github-actions

Copy link
Copy Markdown
Contributor

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

@UniversePeak
UniversePeak force-pushed the test/310p-sampler-unsupported-params branch from 86b62f5 to af29bf8 Compare September 17, 2026 12:26
Add CPU UT coverage for unsupported sampler penalties on 310P
(test_model_runner_v2_310p.py), rebased cleanly on current main as a
single commit to avoid rebase conflicts in CI.

Signed-off-by: UniversePeak <UniversePeak@users.noreply.github.com>
@UniversePeak
UniversePeak force-pushed the test/310p-sampler-unsupported-params branch from af29bf8 to bc52f8c Compare September 17, 2026 12:28
@UniversePeak

Copy link
Copy Markdown
Author

Conflicts are resolved: the branch is now rebased on the latest main as a single clean commit (bc52f8c), so the CI "Rebase on main snapshot" step no longer hits the conflict in tests/ut/_310p/test_model_runner_v2_310p.py.

Current status on the latest commit: pre-commit ✅, DCO ✅, cpu-ut ✅. The ci-gate check reports this PR touches source code, so precision/full tests are required before merge — could a maintainer add the ready-precise label (or ready-all/main2main) to trigger the test suite? Thanks!

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