-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
[Model] Add Ernie4.5 and Ernie4.5MoE Model Support #20220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3cbd865
[Model] Add Ernie4.5 and Ernie4.5MoE
CSWYF3634076 8e7b263
[Model] Add Ernie4.5 and Ernie4.5MoE v2 delete unused code
CSWYF3634076 11407be
[Model] Add Ernie4.5 and Ernie4.5MoE v2 update docs
CSWYF3634076 485d3bd
[Model] Add Ernie4.5 and Ernie4.5MoE v2 alphabetical order
CSWYF3634076 3158dfd
[Model] Add Ernie4.5 and Ernie4.5MoE v2 fix annotation
CSWYF3634076 7f221fb
[Model] Add Ernie4.5 and Ernie4.5MoE v2 shared_experts tp reduce
CSWYF3634076 b8d44f4
[Model] Add Ernie4.5 and Ernie4.5MoE v2 dense inherit LlamaForCausalLM
CSWYF3634076 8ccea66
[Model] Add Ernie4.5 and Ernie4.5MoE v2 code style
CSWYF3634076 4dfe76a
Merge remote-tracking branch 'upstream/main' into dev
CSWYF3634076 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
CSWYF3634076 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
||
# Copyright 2025 The Baidu team. | ||
# Copyright 2023 The vLLM team. | ||
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. | ||
# | ||
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX | ||
# and OPT implementations in this library. It has been modified from its | ||
# original forms to accommodate minor architectural differences compared | ||
# to GPT-NeoX and OPT used by the Meta AI team that trained the model. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Inference-only Erine model compatible with HuggingFace weights.""" | ||
from vllm.config import VllmConfig | ||
from vllm.model_executor.models.llama import LlamaForCausalLM | ||
|
||
from .utils import PPMissingLayer | ||
|
||
|
||
class Ernie4_5_ForCausalLM(LlamaForCausalLM): | ||
|
||
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""): | ||
super().__init__(vllm_config=vllm_config, prefix=prefix) | ||
# Hack Llama model to fit HF format Ernie4.5 dense implementation | ||
# Attention difference between Ernie and Llama: | ||
# 1. rotary_dim and no Neox style. | ||
# 2. There is no bias for o_proj in attention | ||
for layer in self.model.layers: | ||
if not isinstance(layer, PPMissingLayer): | ||
layer.self_attn.rotary_emb.is_neox_style = False | ||
layer.self_attn.o_proj.bias = None | ||
layer.self_attn.o_proj.skip_bias_add = True |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.