Skip to content

fix: use spawn start method for vLLM evaluation to avoid CUDA re-initialization error - #2421

Merged
xin3he merged 2 commits into
intel:mainfrom
reginaldalfret:fix/2414-vllm-eval-spawn-multiprocessing
Oct 19, 2026
Merged

xin3he merged 2 commits into
intel:mainfrom
reginaldalfret:fix/2414-vllm-eval-spawn-multiprocessing

Conversation

@reginaldalfret

Copy link
Copy Markdown
Contributor

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:

  • \TestEvalWithVllm::test_eval_with_vllm_configures_spawn_start_method\

Fixes #2414

… 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>
Copilot AI lite review requested due to automatic review settings September 24, 2026 11:45

Copilot AI 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.

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 High severity · 1 Medium severity

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.

Comment thread test/unit/common/eval/test_eval_cli.py Resolved
Comment thread test/unit/common/eval/test_eval_cli.py Resolved
Comment thread auto_round/eval/eval_cli.py Resolved
@AutoRoundBot

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>
@AutoRoundBot

Copy link
Copy Markdown
Collaborator

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@wenhuach21
wenhuach21 requested a review from xin3he September 30, 2026 05:43

@xin3he xin3he 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.

LGTM

@xin3he

xin3he commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@wenhuach21 Please check whether it address the issue you met. I didn't reproduce your issue in my env.

@xin3he
xin3he merged commit 234ac7a into intel:main Oct 19, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: vllm eval failed

4 participants