Skip to content

Conversation

@mickaelseznec
Copy link
Contributor

@mickaelseznec mickaelseznec commented Sep 4, 2025

Purpose

The tests pass, only because they run sequentially and the first do the necessary init. Now we can run them in any order (and parallel).

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

otherwise they implicitly require to run sequentially

Signed-off-by: Mickael Seznec <[email protected]>
@mergify mergify bot added the v1 label Sep 4, 2025
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 addresses an issue with test isolation by introducing a with_init_none_hash pytest fixture to ensure the KV cache hash is initialized before tests that require it. This is a good improvement for test stability and allows for parallel execution. The fixture is applied to many tests across the suite. My review identifies a couple of minor cases of redundancy where init_none_hash is called explicitly within tests that also use the new fixture. Removing these redundant calls will clean up the code.

Signed-off-by: Mickael Seznec <[email protected]>
@mickaelseznec
Copy link
Contributor Author

cc @vMaroon



@pytest.fixture
def with_init_none_hash():
Copy link
Contributor

Choose a reason for hiding this comment

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

This definitely is a step towards cleaner testing, though it may look out of place when passed as test argument without much context.

Perhaps this can be taken a step further by using the @pytest.fixture(autouse=True) decorator and either:

  1. Implicitly calling init_none_hash where needed:
pytest.fixture(autouse=True)
def _auto_init_hash_fn(request):
    if "hash_fn" in request.fixturenames:
        init_none_hash(request.getfixturevalue("hash_fn"))
  1. Explicit dependency
@pytest.fixture
def initialized_hash_fn(hash_fn):
    """Fixture that automatically initializes the hash function."""
    init_none_hash(hash_fn)
    return hash_fn

# Update relevant tests to use the above fixture, e.g.:
@pytest.mark.parametrize("hash_fn", [sha256, sha256_cbor_64bit, hash])
def test_hash_block_tokens(initialized_hash_fn):
    # Replace the manual init_none_hash call
    hash_fn = initialized_hash_fn
    # ...

@mickaelseznec What do you think?

Both can optionally be enhanced by capturing and restoring global state by utilizing yield.
I think either is good, personal preference is to the first. I assume you tagged me because I introduced the manual inits, but maintainer input is required here (cc @heheda12345).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot for the feedback! The first proposition looks good, let me update my PR :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can keep the thing simple. For example, auto-apply with_init_none_hash in test_prefix_caching.py and call init_none_hash manually in other tests if needed. This won't be too confusing as most tests require it is related to hash.

I don't what it to be a autouse by default because then CI can't detect problems due to un-initialized non-hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the nice ideas, I think I've come up with nice in-between:

  • autouse fixture for the two relevant files only
    It has some code dup, but it's less intrusive (and probably easier to understand to read) than putting the fixture in conftest.py.

Let me know if that sounds good to you :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah make sense to me.

@mergify
Copy link

mergify bot commented Sep 10, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @mickaelseznec.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Sep 10, 2025
@mergify mergify bot removed the needs-rebase label Sep 15, 2025
Signed-off-by: Mickael Seznec <[email protected]>
@mickaelseznec mickaelseznec force-pushed the mseznec/fix-kv-test-init branch from d56a6b3 to 3097d6d Compare September 15, 2025 17:07
Signed-off-by: Mickael Seznec <[email protected]>
Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

LGTM!

Signed-off-by: Mickael Seznec <[email protected]>
Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

LGTM!

@heheda12345 heheda12345 enabled auto-merge (squash) September 15, 2025 21:00
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 15, 2025
@heheda12345 heheda12345 merged commit 45bfa49 into vllm-project:main Sep 15, 2025
28 of 30 checks passed
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
QierLi pushed a commit to QierLi/vllm that referenced this pull request Oct 5, 2025
Signed-off-by: bbartels <[email protected]>

[gpt-oss] Add IncompleteDetails to ResponsesRepsonse (vllm-project#24561)

Signed-off-by: Andrew Xia <[email protected]>

[gpt-oss][1a] create_responses stream outputs BaseModel type, api server is SSE still (vllm-project#24759)

Signed-off-by: Andrew Xia <[email protected]>

[Performance] Remove redundant clone() calls in cutlass_mla (vllm-project#24891)

[Bug] Fix Cutlass Scaled MM Compilation Error (vllm-project#24887)

Signed-off-by: yewentao256 <[email protected]>

[ci] fix wheel names for arm wheels (vllm-project#24898)

Signed-off-by: simon-mo <[email protected]>

[Tests] fix initialization of kv hash in tests (vllm-project#24273)

Signed-off-by: Mickael Seznec <[email protected]>

[Compile] Fix noop_elimination pass and add tests for noop_elimination (vllm-project#24880)

Signed-off-by: zjy0516 <[email protected]>

Propagate entire tokens to connector for resumed preemptions

Signed-off-by: Qier Li <[email protected]>

Fix pre-commit

Signed-off-by: Qier Li <[email protected]>

Rename field and nullify empty lists

Signed-off-by: Qier Li <[email protected]>

Update vllm/v1/core/sched/scheduler.py

Co-authored-by: Nick Hill <[email protected]>
Signed-off-by: Qier Li <[email protected]>

Add unit test for preemption resumption

Signed-off-by: Qier Li <[email protected]>
xuebwang-amd pushed a commit to xuebwang-amd/vllm that referenced this pull request Oct 10, 2025
choprahetarth pushed a commit to Tandemn-Labs/vllm that referenced this pull request Oct 11, 2025
xuebwang-amd pushed a commit to xuebwang-amd/vllm that referenced this pull request Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants