Skip to content

[Bugfix] Fix XPU/ROCm compatibility in spawn_new_process_for_each_test - #41895

Merged
ProExpertProg merged 4 commits into
vllm-project:mainfrom
dzhengAP:bugfix/fix-spawn-decorator-exitcode
May 8, 2026
Merged

ProExpertProg merged 4 commits into
vllm-project:mainfrom
dzhengAP:bugfix/fix-spawn-decorator-exitcode

Conversation

@dzhengAP

@dzhengAP dzhengAP commented May 7, 2026

Copy link
Copy Markdown
Contributor

Purpose

Follow-up to #41423.

mp.set_start_method("spawn") was inadvertently removed when the decorator was rewritten to use subprocess.run. While the decorator itself doesn't need it (since subprocess.run launches a fresh interpreter regardless), other parts of the test session — specifically XPU/ROCm engine workers that use mp.Process directly — depend on this global mp start method being set to spawn.

Without it, those workers default back to fork on Linux, causing:
RuntimeError: Cannot re-initialize XPU in forked subprocess

This restore has no effect on the failure-propagation fix from #41423.

cc @jikunshang @ProExpertProg @AndreasKaratzas

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added nvidia rocm Related to AMD ROCm intel-gpu Related to Intel GPU v1 bug Something isn't working labels May 7, 2026
@mergify

mergify Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

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

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

@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 refactors the spawn_new_process_for_each_test decorator to use subprocess.run combined with cloudpickle for serializing test functions and arguments. This change ensures that exceptions occurring in the child process are captured and propagated back to the parent, preventing silent test failures. The PR also adds comprehensive unit tests for the decorator and updates existing tests in test_cudagraph_dispatch.py and test_custom_online.py to align with the new implementation. Feedback suggests that the child_script should explicitly set the multiprocessing start method to 'spawn' to avoid potential RuntimeError issues in environments where 'fork' is the default.

Comment thread tests/utils.py Resolved
@luobosibing2

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1eba41a30a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/utils.py Resolved
Comment thread tests/utils.py Resolved
Comment thread tests/utils.py Resolved
@chaojun-zhang

Copy link
Copy Markdown
Contributor

Please check @create_new_process_for_each_test() uses spawn on XPU, which cannot pickle the server fixture (it contains a multiprocessing.Process with an unpicklable AuthenticationString).

FAILED tests/v1/logits_processors/test_custom_online.py::test_custom_logitsprocs[server1-facebook/opt-125m] - TypeError: Pickling an AuthenticationString object is disallowed for security reasons

Comment thread tests/utils.py Resolved
@dzhengAP

dzhengAP commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Please check @create_new_process_for_each_test() uses spawn on XPU, which cannot pickle the server fixture (it contains a multiprocessing.Process with an unpicklable AuthenticationString).

FAILED tests/v1/logits_processors/test_custom_online.py::test_custom_logitsprocs[server1-facebook/opt-125m] - TypeError: Pickling an AuthenticationString object is disallowed for security reasons

Yes, exactly. The RemoteOpenAIServerCustom fixture uses multiprocessing.Process internally which holds an AuthenticationString that can't be pickled across a spawn boundary. I would think of the fix to not wrap that specific test with spawn_new_process_for_each_test. Will implement this tmr. @chaojun-zhang

@AndreasKaratzas

Copy link
Copy Markdown
Member

@dzhengAP Please fix pre-commit so we can begin evaluations of this PR.

@dzhengAP
dzhengAP force-pushed the bugfix/fix-spawn-decorator-exitcode branch from 5ad28d8 to c2623ff Compare May 7, 2026 17:46
@mergify

mergify Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

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

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 May 7, 2026
@dzhengAP
dzhengAP force-pushed the bugfix/fix-spawn-decorator-exitcode branch from 07c609c to 4eb8f08 Compare May 7, 2026 17:53
@mergify mergify Bot removed the needs-rebase label May 7, 2026
@dzhengAP

dzhengAP commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@dzhengAP Please fix pre-commit so we can begin evaluations of this PR.

@AndreasKaratzas Hi Andreas are you able to add a ready label?

@AndreasKaratzas

Copy link
Copy Markdown
Member

@dzhengAP pre-commit is still failing.

@AndreasKaratzas

Copy link
Copy Markdown
Member

@jikunshang can you help add the ready label to check CI, since focus now mainly on Intel CI tests. cc: @ProExpertProg @AndreasKaratzas

So this does not fix rocm? So we should probably move on with reverting the other PR then.

@dzhengAP

dzhengAP commented May 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@jikunshang can you help add the ready label to check CI, since focus now mainly on Intel CI tests. cc: @ProExpertProg @AndreasKaratzas

So this does not fix rocm? So we should probably move on with reverting the other PR then.

@AndreasKaratzas what new ROCM failure did you see? can you help paste here? AMD CI tests were passed after the fix in this PR. — the mp.set_start_method("spawn") guard applies to both current_platform.is_rocm() or current_platform.is_xpu(). The VLLM_WORKER_MULTIPROC_METHOD=spawn is also set in the child env for both platforms. Please make sure share the specific ROCm failure you're seeing. I want to make sure we address it before any revert decision.

@ProExpertProg ProExpertProg added the ready ONLY add when PR is ready to merge/full CI is needed label May 7, 2026
@dzhengAP

dzhengAP commented May 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @ProExpertProg @jikunshang I went through the CI log and put a summary below, which seems unrelated to #41895

1. test_custom_logitsprocs — v1/logits_processors

Error: RuntimeError: Cannot re-initialize XPU in forked subprocess
Root cause: The test intentionally sets VLLM_WORKER_MULTIPROC_METHOD=fork so the entry_points monkey-patch is visible to workers. This is fundamentally incompatible with XPU which requires spawn.
Status: Pre-existing issue

2. test_qwen35_text_lora — lora/

Error: RuntimeError: Engine core initialization failed (XPU fork error in EngineCoreProc)
Root cause: The vLLM engine core is forking despite VLLM_WORKER_MULTIPROC_METHOD=spawn being set. XPU executor path is not respecting the spawn context.
Status: Pre-existing issue


Fix Plan

test_custom_logitsprocs may need to replace fork-based entrypoint injection with spawn-compatible approach (config file or env var instead of monkey-patching across fork boundary)
test_qwen35_text_lora need to Investigate why EngineCoreProc forks on XPU despite spawn env var; explicitly use mp.get_context("spawn") in XPU executor path


I can submit followup PRs for them or fix the bugs here, but it may make current PR too heavy, what do you guys think? cc @jikunshang @ProExpertProg

@jikunshang

jikunshang commented May 8, 2026 •

Copy link
Copy Markdown
Member

for intel/ci,

  1. test_custom_logitsprocs — v1/logits_processors. I didn't notice it force use fork before. I will investigate more how to proper handle this case on XPU. maybe I should just skip it due to such limitation.
  2. I agree test_qwen35_text_lora — lora/ is not related. we can ignore it. test_qwen35_text_lora is case with create_new_process_for_each_test decorator. it still use fork instead of spawn.

What confuse me is:
#41423 changed spawn_new_process_for_each_test method behavior, no longer use spawn, see comments #41423 (comment), this may affect some other ROCm/XPU test case with create_new_process_for_each_test decorator.

@dzhengAP

dzhengAP commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

What confuse me is:
#41423 changed spawn_new_process_for_each_test method behavior, no longer use spawn, see comments #41423 (comment), this may affect some other ROCm/XPU test case with create_new_process_for_each_test decorator.

Hi @jikunshang. The new spawn_new_process_for_each_test uses subprocess.run([sys.executable, ...]) which launches a completely fresh interpreter — this is actually more isolated than mp.spawn since there's no shared state at all. The child process sets VLLM_WORKER_MULTIPROC_METHOD=spawn and calls mp.set_start_method('spawn') before running the test, so any mp.Process calls inside the test still use spawn semantics. The behavior change is in how the subprocess is launched, not in what the subprocess does.

@dzhengAP

dzhengAP commented May 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@ProExpertProg @jikunshang @chaojun-zhang @AndreasKaratzas
After checking the Intel CI log for test_qwen35_text_lora — the actual error is AssertionError: lora isn't supported on XPU, not a fork/spawn issue. The test is running via subprocess.run correctly (you can see python3 -c "import sys, cloudpickle, traceback..." in the output). That means, the new decorator is working correctly and properly surfacing this pre-existing failure. This test should be skipped on XPU with pytest.mark.skip or a platform check. The fork/spawn concern doesn't apply here.
image
Aligned with @jikunshang

@dzhengAP

dzhengAP commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

As for the first one: Same as before — 1 failed, 33 passed — only test_custom_logitsprocs failing with the XPU fork error (Cannot re-initialize XPU in forked subprocess). This is because the test explicitly sets VLLM_WORKER_MULTIPROC_METHOD=fork internally.

In summay, both are pre-existing XPU limitations, not caused by this PR. The decorator is working correctly in both cases — it's properly surfacing failures that were previously hidden.

@ProExpertProg @jikunshang @chaojun-zhang @AndreasKaratzas

@jikunshang

Copy link
Copy Markdown
Member

Intel CI doens't gate PR merge currently. thanks @dzhengAP for great work.
Intel folk will temperary disable these failed case in anohter PR to make ci happy and provide solid fix for these.

@github-project-automation github-project-automation Bot moved this from In review to Ready in NVIDIA May 8, 2026
@ProExpertProg
ProExpertProg merged commit 1acd67a into vllm-project:main May 8, 2026
16 of 18 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD May 8, 2026
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA May 8, 2026
@dzhengAP

dzhengAP commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jikunshang and @AndreasKaratzas, I am trying to propose a fix for in #42040
This PR fixes the LOGITPROC_SOURCE_ENTRYPOINT fork compatibility issue on XPU/ROCm that was previously failing Intel and AMD CI, as we discussed here (failure 1). The monkey-patch approach required VLLM_WORKER_MULTIPROC_METHOD=fork which is incompatible with XPU/ROCm. The fix registers a real dist-info package on disk via PYTHONPATH so any spawned subprocess can discover the entrypoint without needing fork. Please give this a look when you get a chance!
cc: @ProExpertProg

Soyaazz pushed a commit to Soyaazz/vllm that referenced this pull request May 10, 2026
vllm-project#41895)

Signed-off-by: dqzhengAP <dqzheng1996@gmail.com>
Signed-off-by: JisoLya <523420504@qq.com>
weifang231 pushed a commit to weifang231/eb-vllm that referenced this pull request May 13, 2026
mfylcek pushed a commit to mfylcek/vllm that referenced this pull request May 19, 2026
MingqiWang-coder added a commit to intellistream/vllm-hust-legacy-20260831 that referenced this pull request Jul 2, 2026
Cherry-pick 62 bugfix/security PRs from upstream vllm-project/vllm main
(2026-05-03 to 2026-06-17), covering scheduler, engine core, model runner,
worker, attention, KV cache, compilation, and structured output fixes.

Security (4): vllm-project#43286 vllm-project#44744 vllm-project#45118 vllm-project#45252
Bugfix (56): vllm-project#35536 vllm-project#36616 vllm-project#38895 vllm-project#39155 vllm-project#39324 vllm-project#39562 vllm-project#39805 vllm-project#40398 vllm-project#40726
Runner fix (2): vllm-project#44568 vllm-project#44603

Skipped: vllm-project#43781 (ROCm-specific, not applicable to Ascend NPU)

Conflict resolutions:
- Manual merge: vllm-project#43286 vllm-project#45118 vllm-project#42112 vllm-project#43160 vllm-project#43719 vllm-project#44560
- Upstream-preferred (-X theirs): vllm-project#43808 vllm-project#43988 vllm-project#42967 vllm-project#35536 vllm-project#45195
- Test files (--theirs): vllm-project#44744 vllm-project#41895 vllm-project#42040 vllm-project#41233 vllm-project#45345 vllm-project#43982

Co-authored-by: GitHub Copilot
Signed-off-by: MingqiWang-coder <mingqiwang@hust.edu.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working intel-gpu Related to Intel GPU nvidia ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm v1

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants