Skip to content

Seperate api_server and pytorch engine into different processors - #3627

Merged
lvhan028 merged 16 commits into
InternLM:mainfrom
grimoire:mp-engine
Jun 26, 2025
Merged

lvhan028 merged 16 commits into
InternLM:mainfrom
grimoire:mp-engine

Conversation

@grimoire

@grimoire grimoire commented Jun 9, 2025

Copy link
Copy Markdown
Collaborator

The PR adds a new layer between API server and pytorch engine, so both of them can be run in their own process.

@grimoire
grimoire marked this pull request as ready for review June 16, 2025 12:53
@CUHKSZzxy CUHKSZzxy mentioned this pull request Jun 25, 2025
9 tasks done

@RunningLeon RunningLeon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@CUHKSZzxy CUHKSZzxy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lvhan028 lvhan028 added the enhancement New feature or request label Jun 26, 2025
@lvhan028 lvhan028 changed the title Mp engine Seperate api_server and pytorch engine into different processors Jun 26, 2025
Comment thread requirements/serve.txt Resolved
logger.info(f'create server with url={url}')
logger.info(f'backend_config_dp={backend_config_dp} gpus={gpu_ids_per_dp}')
proc = mp.Process(target=_run_server, args=(gpu_ids_per_dp, model_path), kwargs=cur_server_kwargs, daemon=True)
proc = mp.Process(target=_run_server, args=(gpu_ids_per_dp, model_path), kwargs=cur_server_kwargs)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the motivation to remove the "daemon" indicator?
If we start the api_server during rollout, do we need to remove it also if MP is enabled?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

spawn process in daemon process is not allowed.

Comment thread benchmark/profile_throughput.py Resolved

handle_torchrun()
_, pipeline_class = get_task(model_path)
if isinstance(backend_config, PytorchEngineConfig):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It is noticed that enable_mp_engine defaults to False, but api_server changes it to True by force. So, we don't recommend it when pipeline is used or pipeline hasn't support this feature yet

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Host performance is acceptable on pipeline. I don't want the system to be too complex.

@lvhan028
lvhan028 merged commit e4b1d04 into InternLM:main Jun 26, 2025
oliveagle pushed a commit to oliveagle/lmdeploy that referenced this pull request May 22, 2026
…ernLM#3627)

* mp router

* optimize

* better streaming

* optimize streaming

* close engine

* safe exit

* support pd

* fix loader

* optimize

* safe exit

* safe exit

* fix comment

* remove empty line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants