Page MenuHomePhabricator
Paste P88981

multiprocessing error thrown when vLLM is loading model using roost's sever.py
ActivePublic

Authored by kevinbazira on Feb 23 2026, 1:08 PM.
$ python3 server.py
/opt/amdgpu/share/libdrm/amdgpu.ids: No such file or directory
/opt/amdgpu/share/libdrm/amdgpu.ids: No such file or directory
INFO 02-23 13:05:09 [utils.py:282] non-default args: {'trust_remote_code': True, 'disable_log_stats': True, 'model': 'openai/gpt-oss-safeguard-20b'}
The argument `trust_remote_code` is to be used with Auto classes. It has no effect here and is ignored.
config.json: 1.81kB [00:00, 8.20MB/s]
The argument `trust_remote_code` is to be used with Auto classes. It has no effect here and is ignored.
[aiter] import [module_aiter_enum] under /srv/venv/lib/python3.11/site-packages/aiter/jit/module_aiter_enum.so
[2026-02-23 13:05:18] INFO core.py:477: import [module_aiter_enum] under /srv/venv/lib/python3.11/site-packages/aiter/jit/module_aiter_enum.so
INFO 02-23 13:05:18 [model.py:541] Resolved architecture: GptOssForCausalLM
model.safetensors.index.json: 36.4kB [00:00, 78.2MB/s]
Parse safetensors files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 6.22it/s]
INFO 02-23 13:05:19 [model.py:1561] Using max model len 131072
INFO 02-23 13:05:19 [scheduler.py:226] Chunked prefill is enabled with max_num_batched_tokens=8192.
INFO 02-23 13:05:19 [config.py:314] Overriding max cuda graph capture size to 1024 for performance.
INFO 02-23 13:05:19 [vllm.py:624] Asynchronous scheduling is enabled.
generation_config.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 165/165 [00:00<00:00, 1.74MB/s]
tokenizer_config.json: 4.20kB [00:00, 13.4MB/s]
tokenizer.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████| 27.9M/27.9M [00:00<00:00, 54.2MB/s]
special_tokens_map.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 98.0/98.0 [00:00<00:00, 753kB/s]
chat_template.jinja: 16.7kB [00:00, 42.4MB/s]
WARNING 02-23 13:05:20 [system_utils.py:140] We must use the `spawn` multiprocessing start method. Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. See https://docs.vllm.ai/en/latest/usage/troubleshooting.html#python-multiprocessing for more information. Reasons: CUDA is initialized
/opt/amdgpu/share/libdrm/amdgpu.ids: No such file or directory
/opt/amdgpu/share/libdrm/amdgpu.ids: No such file or directory
INFO 02-23 13:05:25 [utils.py:282] non-default args: {'trust_remote_code': True, 'disable_log_stats': True, 'model': 'openai/gpt-oss-safeguard-20b'}
The argument `trust_remote_code` is to be used with Auto classes. It has no effect here and is ignored.
The argument `trust_remote_code` is to be used with Auto classes. It has no effect here and is ignored.
INFO 02-23 13:05:25 [model.py:541] Resolved architecture: GptOssForCausalLM
Parse safetensors files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 13.83it/s]
INFO 02-23 13:05:25 [model.py:1561] Using max model len 131072
[aiter] import [module_aiter_enum] under /srv/venv/lib/python3.11/site-packages/aiter/jit/module_aiter_enum.so
[2026-02-23 13:05:27] INFO core.py:477: import [module_aiter_enum] under /srv/venv/lib/python3.11/site-packages/aiter/jit/module_aiter_enum.so
INFO 02-23 13:05:28 [scheduler.py:226] Chunked prefill is enabled with max_num_batched_tokens=8192.
INFO 02-23 13:05:28 [config.py:314] Overriding max cuda graph capture size to 1024 for performance.
INFO 02-23 13:05:28 [vllm.py:624] Asynchronous scheduling is enabled.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.11/multiprocessing/spawn.py", line 120, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/multiprocessing/spawn.py", line 129, in _main
prepare(preparation_data)
File "/usr/lib/python3.11/multiprocessing/spawn.py", line 240, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "/usr/lib/python3.11/multiprocessing/spawn.py", line 291, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen runpy>", line 291, in run_path
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/srv/model-community/gpt/server.py", line 16, in <module>
llm = LLM(model=MODEL, trust_remote_code=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/entrypoints/llm.py", line 334, in __init__
self.llm_engine = LLMEngine.from_engine_args(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/llm_engine.py", line 172, in from_engine_args
return cls(
^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/llm_engine.py", line 106, in __init__
self.engine_core = EngineCoreClient.make_client(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 94, in make_client
return SyncMPClient(vllm_config, executor_class, log_stats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 647, in __init__
super().__init__(
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 479, in __init__
with launch_core_engines(vllm_config, executor_class, log_stats) as (
File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/utils.py", line 908, in launch_core_engines
local_engine_manager = CoreEngineProcManager(
^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/utils.py", line 150, in __init__
proc.start()
File "/usr/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/multiprocessing/context.py", line 288, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/usr/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/usr/lib/python3.11/multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/multiprocessing/spawn.py", line 158, in get_preparation_data
_check_not_importing_main()
File "/usr/lib/python3.11/multiprocessing/spawn.py", line 138, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Traceback (most recent call last):
File "/srv/model-community/gpt/server.py", line 16, in <module>
llm = LLM(model=MODEL, trust_remote_code=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/entrypoints/llm.py", line 334, in __init__
self.llm_engine = LLMEngine.from_engine_args(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/llm_engine.py", line 172, in from_engine_args
return cls(
^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/llm_engine.py", line 106, in __init__
self.engine_core = EngineCoreClient.make_client(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 94, in make_client
return SyncMPClient(vllm_config, executor_class, log_stats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 647, in __init__
super().__init__(
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 479, in __init__
with launch_core_engines(vllm_config, executor_class, log_stats) as (
File "/usr/lib/python3.11/contextlib.py", line 144, in __exit__
next(self.gen)
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/utils.py", line 926, in launch_core_engines
wait_for_engine_startup(
File "/srv/venv/lib/python3.11/site-packages/vllm/v1/engine/utils.py", line 985, in wait_for_engine_startup
raise RuntimeError(
RuntimeError: Engine core initialization failed. See root cause above. Failed core proc(s): {}

Event Timeline

kevinbazira changed the title of this paste from multiprocessing error thrown when vLLM is loading model using root's sever.py to multiprocessing error thrown when vLLM is loading model using roost's sever.py.

The error above was fixed by updating roost's server.py to use FastAPI's lifespan context manager. This tells the app to wait until the server is fully booted and Python is done bootstrapping, and only then load the model:

"""Minimal vLLM server for gpt-oss-safeguard:20b with Harmony format."""

from contextlib import asynccontextmanager
from fastapi import FastAPI
from pydantic import BaseModel
from openai_harmony import (
    Conversation, Message, Role, SystemContent, DeveloperContent,
    HarmonyEncodingName, load_harmony_encoding,
)
from vllm import LLM, SamplingParams
from vllm.inputs import TokensPrompt

# MODEL = "openai/gpt-oss-safeguard-20b"
MODEL = "/model-cache/snapshots/8a11e17b25c973a24099d4016bf2e17dd7ec1574"

# Define placeholders for our model and encoder globally
llm = None
encoding = None

# Use a lifespan manager to load vLLM safely AFTER Python bootstraps
@asynccontextmanager
async def lifespan(app: FastAPI):
    global llm, encoding
    print("Loading Harmony encodings and vLLM engine...")
    encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
    llm = LLM(model=MODEL, trust_remote_code=True)
    print("Model loaded successfully!")
    yield
    # We can add cleanup code here if needed upon shutdown

# Attach the lifespan to the FastAPI app
app = FastAPI(lifespan=lifespan)


class ChatRequest(BaseModel):
    messages: list[dict]
    max_tokens: int = 4096
    temperature: float = 0.7
    top_p: float = 0.95
    system_prompt: str | None = None
    developer_prompt: str | None = None


@app.post("/v1/chat/completions")
def chat(req: ChatRequest):
    # Build harmony conversation
    msgs = [Message.from_role_and_content(Role.SYSTEM, SystemContent.new())]

    if req.developer_prompt:
        msgs.append(Message.from_role_and_content(
            Role.DEVELOPER,
            DeveloperContent.new().with_instructions(req.developer_prompt)
        ))

    for m in req.messages:
        role = {"user": Role.USER, "assistant": Role.ASSISTANT}.get(m["role"], Role.USER)
        msgs.append(Message.from_role_and_content(role, m["content"]))

    conversation = Conversation.from_messages(msgs)

    # Render conversation to token IDs
    prefill_ids = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)

    # Get stop tokens and configure sampling
    stop_token_ids = encoding.stop_tokens_for_assistant_actions()
    sampling_params = SamplingParams(
        max_tokens=req.max_tokens,
        temperature=req.temperature,
        top_p=req.top_p,
        stop_token_ids=stop_token_ids,
    )

    # Generate response
    prompt = TokensPrompt(prompt_token_ids=prefill_ids)
    completion_token_ids = llm.generate(prompts=[prompt], sampling_params=sampling_params)[0].outputs[0].token_ids

    # Parse Harmony output channels
    response_messages = encoding.parse_messages_from_completion_tokens(completion_token_ids, Role.ASSISTANT)

    # Extract reasoning and verdict from channels
    reasoning = ""
    verdict = ""
    for msg in response_messages:
        content = msg.content if isinstance(msg.content, str) else str(msg.content)
        if msg.channel == "final":
            verdict = content.strip()
        else:
            reasoning += content

    # Fallback if no final channel
    if not verdict and response_messages:
        content = response_messages[-1].content
        verdict = content if isinstance(content, str) else str(content)

    return {
        "reasoning": reasoning.strip(),
        "verdict": verdict,
    }


if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)