Skip to content

GPTJForCausalLM Support - #7839

Merged
Kangyan-Zhou merged 3 commits into
sgl-project:mainfrom
wenchen76:gptj
Jan 30, 2026
Merged

Kangyan-Zhou merged 3 commits into
sgl-project:mainfrom
wenchen76:gptj

Conversation

@wenchen76

@wenchen76 wenchen76 commented Jul 8, 2025 •

Copy link
Copy Markdown
Contributor

Motivation

Model Support Issue: #7429

This PR adds support for GPT-J

Modifications

Evaluation (MMLU)

Subject # Questions Accuracy (SGLang) Accuracy (vLLM)
abstract_algebra 100 0.270 0.280
anatomy 135 0.252 0.244
astronomy 152 0.263 0.250
business_ethics 100 0.280 0.290
clinical_knowledge 265 0.257 0.234
college_biology 144 0.257 0.257
college_chemistry 100 0.170 0.130
college_computer_science 100 0.240 0.260
college_mathematics 100 0.310 0.270
college_medicine 173 0.277 0.243
Average — 0.259 0.245

Checklist

@gemini-code-assist gemini-code-assist Bot 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.

Summary of Changes

Hello @wenchen76, 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 adds comprehensive support for the GPT-J causal language model to the sglang framework. It provides the full model architecture definition and includes the necessary logic to load pre-trained GPT-J weights, making the model ready for inference within the system.

Highlights

  • New Model Support: This pull request introduces a complete implementation of the GPT-J model architecture, including its attention, MLP, and block structures, specifically adapted for the sglang inference runtime. This enables the framework to support GPT-J models for causal language modeling tasks.
  • HuggingFace Compatibility: A load_weights method has been added to the GPTJForCausalLM class. This method is designed to facilitate seamless loading of pre-trained GPT-J model weights from HuggingFace, handling specific parameter mappings (e.g., QKV projections) and quantization scales.
  • Modular Architecture Implementation: The GPT-J model is implemented using a modular design, breaking down the architecture into GPTJAttention, GPTJMLP, GPTJBlock, and GPTJModel classes. These components leverage existing sglang.srt.layers for parallel linear layers, attention mechanisms (RadixAttention), and rotary embeddings, ensuring integration with the framework's optimized operations.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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. ↩

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for the GPT-J model architecture. The implementation correctly follows the parallel attention and MLP structure from the Hugging Face Transformers library and reuses existing components for tensor parallelism and quantization. The code is well-structured. I've identified one minor issue in the weight loading logic where there's some leftover code from another model, which should be removed for clarity.

Comment thread python/sglang/srt/models/gpt_j.py Resolved
@wenchen76 wenchen76 mentioned this pull request Jul 8, 2025
5 of 81 tasks
@wenchen76

Copy link
Copy Markdown
Contributor Author

Hi @b8zhong @lifuhuang, would you mind taking a look at this PR? Any comments or suggestions would be greatly appreciated. Thank you!

@wenchen76
wenchen76 force-pushed the gptj branch 2 times, most recently from 6ceb002 to 989f9e7 Compare July 20, 2025 22:47

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

@wenchen76 Hi, sorry for the delay. It looks good.

Can you add it to the supported model documentation? I'll try to get someone to review ASAP.

@wenchen76

Copy link
Copy Markdown
Contributor Author

@wenchen76 Hi, sorry for the delay. It looks good.

Can you add it to the supported model documentation? I'll try to get someone to review ASAP.

Hi @b8zhong, thank you! I'll add it shortly

@wenchen76

Copy link
Copy Markdown
Contributor Author

Hi @b8zhong, just updated the supported model documentation, thanks!

@wenchen76

Copy link
Copy Markdown
Contributor Author

Hi @b8zhong, just checking in — any updates on reviewing this PR? Thank you!

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jan 30, 2026
@Kangyan-Zhou
Kangyan-Zhou merged commit 046b29b into sgl-project:main Jan 30, 2026
sfiisf pushed a commit to sfiisf/sglang that referenced this pull request Feb 5, 2026
0826joyce pushed a commit to 0826joyce/sglang-perf-opt that referenced this pull request May 19, 2026
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants