Skip to content

Add support for SGLang generate API to compare and match GPT-OSS reference implementation in v6.0 (part of #4)#80

Merged
nv-alicheng merged 5 commits intomainfrom
feature/alicheng-sglang-generate
Jan 2, 2026
Merged

Add support for SGLang generate API to compare and match GPT-OSS reference implementation in v6.0 (part of #4)#80
nv-alicheng merged 5 commits intomainfrom
feature/alicheng-sglang-generate

Conversation

@nv-alicheng
Copy link
Copy Markdown
Collaborator

@nv-alicheng nv-alicheng commented Jan 1, 2026

What does this PR do?

Modularizes worker.py to more easily add support for multiple APIs, adds support for SGLang's /generate API endpoint.

#4

Tested locally running GPT-OSS on H200x8.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor/cleanup

Related issues

Testing

  • Tests added/updated
  • All tests pass locally
  • Manual testing completed

Checklist

  • Code follows project style
  • Pre-commit hooks pass
  • Documentation updated (if needed)

@nv-alicheng nv-alicheng requested a review from a team as a code owner January 1, 2026 03:27
@nv-alicheng nv-alicheng requested a review from viraatc January 1, 2026 03:28
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 1, 2026

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @nv-alicheng, 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 significantly enhances the system's flexibility by integrating support for the SGLang /generate API, alongside the existing OpenAI API. The core change involves modularizing the API interaction layer, allowing for dynamic selection of API types and streamlining the process of adding new API endpoints in the future. This refactoring ensures that different inference endpoints can be benchmarked and probed using their native API specifications, improving compatibility and maintainability.

Highlights

  • SGLang API Support: Added comprehensive support for SGLang's /generate API endpoint, allowing the system to interact with SGLang-compatible inference servers.
  • API Type Selection: Introduced a new --api-type command-line argument for probe and benchmark commands, enabling users to specify whether to use openai (default) or sglang API types.
  • Modular API Adapters: Refactored the worker.py module and HTTP client configuration to dynamically select API adapters (e.g., OpenAIMsgspecAdapter, SGLangGenerateAdapter) based on the configured api_type, improving modularity and extensibility for future API integrations.
  • Streaming Response Accumulators: Implemented OpenAISSEAccumulator and SGLangSSEAccumulator classes to handle streaming responses from different API types, correctly processing and accumulating Server-Sent Events (SSE) chunks.
  • Dedicated Type Definitions: Extracted OpenAI-specific msgspec structs into a new openai/types.py file and created new sglang/types.py and sglang/adapter.py files to define SGLang API request/response structures and the corresponding adapter logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

Copy link
Copy Markdown

@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 support for the SGLang /generate API and refactors worker.py to better accommodate multiple API types. The changes are well-structured, with the introduction of an APIType enum and dedicated SSE accumulator classes being a significant improvement for modularity. However, I've identified a critical bug in the SGLangSSEAccumulator that prevents streaming from working as intended. Additionally, I have a couple of medium-severity suggestions to enhance documentation clarity and code maintainability. Once the critical bug is addressed, this will be a solid contribution.

@nv-alicheng nv-alicheng force-pushed the feature/alicheng-sglang-generate branch 3 times, most recently from 9b0cf6b to 4484187 Compare January 1, 2026 04:01
… since CICD will not change the .yml until merge
@nv-alicheng nv-alicheng force-pushed the feature/alicheng-sglang-generate branch from 4484187 to 5bddcda Compare January 1, 2026 04:12
Copy link
Copy Markdown
Collaborator

@arekay-nv arekay-nv left a comment

Choose a reason for hiding this comment

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

Amazing. Thanks!

@nv-alicheng nv-alicheng merged commit f73730d into main Jan 2, 2026
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 2, 2026
@nvzhihanj nvzhihanj changed the title Add support for SGLang generate API to compare and match GPT-OSS reference implementation in v6.0 Add support for SGLang generate API to compare and match GPT-OSS reference implementation in v6.0 (part of #4) Jan 8, 2026
@arekay-nv arekay-nv deleted the feature/alicheng-sglang-generate branch April 2, 2026 03:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants