Skip to content

[CI] Fix race condition in test_kv_cache_events test #18169

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

Merged
merged 1 commit into from
May 14, 2025

Conversation

russellb
Copy link
Member

We observed an occasional failure on this test case:

tests/v1/engine/test_engine_core_client.py::test_kv_cache_events[True-tcp]

I believe this change should resolve it. The KV event publisher was
initializing its zmq socket in a new thread, which gives a window of
opportunity for the subscriber created in the test to try to connect too
soon, putting things in a bad state and missing the event expected.

The time.sleep(0.1) in the test is a pretty good hint that this is a
problem. I assume whoever put that there observed this race and found
that this yield seemed to be enough to fix it. Unfortunately this sort
of thing is usually still bound to fail on occassion.

The fix here is to move zmq socket initialization back into the main
flow of control prior to creating the background thread. That way we
know it's created before the test creates the subscriber. The change
also removes the sleep, as it should no longer be necessary if this race
condition was the reason it was added originally.

Signed-off-by: Russell Bryant rbryant@redhat.com

We observed an occasional failure on this test case:

tests/v1/engine/test_engine_core_client.py::test_kv_cache_events[True-tcp]

I believe this change should resolve it. The KV event publisher was
initializing its zmq socket in a new thread, which gives a window of
opportunity for the subscriber created in the test to try to connect too
soon, putting things in a bad state and missing the event expected.

The `time.sleep(0.1)` in the test is a pretty good hint that this is a
problem. I assume whoever put that there observed this race and found
that this yield seemed to be enough to fix it. Unfortunately this sort
of thing is usually still bound to fail on occassion.

The fix here is to move zmq socket initialization back into the main
flow of control prior to creating the background thread. That way we
know it's created before the test creates the subscriber. The change
also removes the sleep, as it should no longer be necessary if this race
condition was the reason it was added originally.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@robertgshaw2-redhat
Copy link
Collaborator

@russellb - can you unskip the test in the CI?

@simon-mo simon-mo merged commit 78aa341 into vllm-project:main May 14, 2025
13 of 15 checks passed
davidxia added a commit to davidxia/vllm that referenced this pull request May 15, 2025
vllm-project#18169 fixed vllm-project#18167

Signed-off-by: David Xia <david@davidxia.com>
@davidxia
Copy link
Contributor

@robertgshaw2-redhat, #18183 will reinstate the test

trevor-m added a commit to trevor-m/sglang that referenced this pull request May 16, 2025
zzzyq pushed a commit to zzzyq/vllm that referenced this pull request May 24, 2025
)

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Yuqi Zhang <yuqizhang@google.com>
minpeter pushed a commit to minpeter/vllm that referenced this pull request Jun 24, 2025
)

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: minpeter <kali2005611@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants