Skip to content

feat: add launch_server and teardown_server in inference engine api#550

Merged
nuzant merged 5 commits intomainfrom
fw/local-inf-server
Nov 10, 2025
Merged

feat: add launch_server and teardown_server in inference engine api#550
nuzant merged 5 commits intomainfrom
fw/local-inf-server

Conversation

@garrett4wade
Copy link
Copy Markdown
Collaborator

Description

Fixes #530

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not
    work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with
    jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @garrett4wade, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a more robust and integrated approach to managing local inference server processes within the system. By adding explicit launch_server and teardown_server methods to the core InferenceEngine API and implementing them across the SGLang and vLLM backends, the change streamlines the control over server lifecycles. This enhancement improves the consistency and maintainability of how local inference servers are started and stopped, ensuring better resource management and a clearer abstraction for server operations.

Highlights

  • API Extension for Inference Server Management: Introduced launch_server and teardown_server abstract methods to the InferenceEngine API, providing a standardized way to manage the lifecycle of local inference servers.
  • New Data Structure for Server Information: Added a LocalInfServerInfo dataclass to areal/api/io_struct.py to encapsulate the address and process object of a locally launched inference server.
  • Backend Implementations for Server Control: Provided concrete implementations for launch_server and teardown_server in RemoteInfEngine and its SGLang and vLLM backends, enabling the actual spawning and termination of server processes.
  • Refactored Server Launchers: Updated the SGLang and vLLM server launchers (sglang_server.py and vllm_server.py) to leverage the new launch_server methods from their respective backends, centralizing server process creation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@garrett4wade garrett4wade changed the title feat: add launch_server and teardown_server in inference server api feat: add launch_server and teardown_server in inference engine api Nov 7, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 introduces a valuable feature for programmatically launching and tearing down inference servers, which enhances the flexibility of the system. The overall implementation is well-structured, centralizing server launch logic into backend-specific classes. However, I've identified a critical race condition in the vLLM server launcher that needs to be addressed. Additionally, there are several opportunities for improvement regarding code quality, such as removing redundant imports, and enhancing robustness in server teardown and logging. My detailed comments are below.

Comment thread areal/launcher/vllm_server.py Outdated
Comment thread areal/core/remote_inf_engine.py Outdated
Comment thread areal/engine/sglang_remote.py
Comment thread areal/engine/sglang_remote.py
Comment thread areal/engine/vllm_remote.py
Comment thread areal/engine/vllm_remote.py
@garrett4wade
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 introduces launch_server and teardown_server APIs to programmatically manage local inference servers, which is a great addition for testing and dynamic environments. The implementation is solid, covering server launch, health checks, and graceful shutdown. My main feedback is to improve the logging for these locally launched servers. Currently, their output is directed to the main process's stdout, which can become messy when multiple servers are launched. I've suggested a refactoring to redirect output to unique log files and manage their lifecycle properly. This involves small, coordinated changes across a few files to pass around and manage the log file handle.

Comment thread areal/api/io_struct.py
Comment thread areal/core/remote_inf_engine.py
Comment thread areal/core/remote_inf_engine.py
Comment thread areal/core/remote_inf_engine.py
Comment thread areal/engine/sglang_remote.py
Comment thread areal/engine/vllm_remote.py
@garrett4wade garrett4wade added the safe-to-test Ready to run unit-tests in a PR. label Nov 7, 2025
return self.workflow_executor.resume()

def launch_server(self, server_args: dict[str, Any]) -> LocalInfServerInfo:
"""Launch a local inference server."""
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.

Maybe we should add doc strings to remind users this function should be carefully used (or just should not be used) in SPMD mode since inference servers and training processes will share GPUs.

Copy link
Copy Markdown
Collaborator

@nuzant nuzant left a comment

Choose a reason for hiding this comment

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

We should also add a test for launch_serverand teardown_server.

@nuzant nuzant added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Nov 10, 2025
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Nov 10, 2025
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Nov 10, 2025
@nuzant nuzant merged commit 9af34d2 into main Nov 10, 2025
4 checks passed
@nuzant nuzant deleted the fw/local-inf-server branch November 10, 2025 08:21
Bruce-rl-hw pushed a commit to Bruce-rl-hw/AReaL-vllm that referenced this pull request Dec 4, 2025
…nclusionAI#550)

* add launch_server and teardown_server in inference server api

* revert vllm sglang launcher

* update doc

* update tests

* fix tests
leandermaben pushed a commit to leandermaben/AReaL that referenced this pull request Mar 24, 2026
…nclusionAI#550)

* add launch_server and teardown_server in inference server api

* revert vllm sglang launcher

* update doc

* update tests

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Ready to run unit-tests in a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor InferenceEngine API to support server process launching

2 participants