Repository navigation
fix: use spawn start method for vLLM evaluation to avoid CUDA re-initialization error - #2421
Merged
xin3he merged 2 commits intoOct 19, 2026
Conversation
… error When running evaluation with the vLLM backend, vLLM's engine core uses multiprocessing workers. If CUDA has already been initialized in the main process (e.g. during device capability checks or preceding quantization), using the default 'fork' start method on Linux triggers: RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method. Explicitly configure the multiprocessing start method to 'spawn' in eval_with_vllm before vLLM initialization, avoiding CUDA re-init crashes. Fixes intel#2414 Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical test-collection and CPU compatibility issues, plus unresolved multiprocessing configuration concerns, block approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
This PR configures vLLM evaluation to use multiprocessing spawn, preventing CUDA re-initialization failures, and adds unit coverage.
Changes:
- Sets the multiprocessing start method before vLLM initialization.
- Adds a test for spawn configuration.
| File | Review findings |
|---|---|
auto_round/eval/eval_cli.py |
Three moderate issues: swallowed start-method errors (3 votes), vLLM may still select fork (1 vote), and process-wide context is not restored (1 vote). |
test/unit/common/eval/test_eval_cli.py |
Two critical issues: duplicate test-class definition prevents collection of existing tests (2 votes), and the new test fails on CPU runners without mocking device detection (3 votes). |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment has been minimized.
This comment has been minimized.
- Raise RuntimeError if multiprocessing start method fails to set to spawn - Consolidate vLLM evaluation regression tests into the existing TestEvalWithVllm class - Mock major device as CUDA and patch device environment mapping to ensure CPU-safe testing Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
Collaborator
|
/azp run Unit-Test-CUDA-AutoRound |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
@wenhuach21 Please check whether it address the issue you met. I didn't reproduce your issue in my env. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
When running evaluation with the vLLM backend, vLLM's engine core uses multiprocessing workers (\EngineCoreProc). If CUDA has already been initialized in the main process (e.g. during device capability checks, model loading, or preceding quantization steps), using the default \ork\ start method on Linux triggers:
\
RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
\\
This PR explicitly sets the multiprocessing start method to \"spawn"\ in \eval_with_vllm\ prior to vLLM initialization, avoiding CUDA re-init failures in forked subprocesses.
Testing
Added unit test in \ est/unit/common/eval/test_eval_cli.py:
Fixes #2414