-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[model] add support for ERNIE 4.5 VL MoE #19475
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
Open
isLinXu
wants to merge
8
commits into
ggml-org:master
Choose a base branch
from
isLinXu:ernie-vl-4.5
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
727cce0
[model] support ernie4-5-vl-moe model
isLinXu 59774d2
[model] support ernie4-5-vl-moe model
isLinXu b35f2db
[model] support ernie4-5-vl-moe model
isLinXu 790be8a
[model] support ernie4-5-vl-moe model
isLinXu 75705b5
[model] support ernie4-5-vl-moe model
isLinXu 57133ba
[model] support ernie4-5-vl-moe model
isLinXu 23a38d5
[model] support ernie4-5-vl-moe model
isLinXu c932d7e
update&fix
isLinXu 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ROPE_TYPE system is quite fragile now and I think we should always reflect twice before adding a new mode.
It seems like interleaved h/w freq is already supported by Pixtral model, please verify one more time if you can reuse the code from Pixtral instead of adding a new rope kernel here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads-up. I completely agree that we should be cautious with the ROPE_TYPE system. I’ll re-examine the Pixtral implementation to see if we can reuse its interleaved frequency logic instead of adding a new kernel.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I’ve conducted a detailed mathematical comparison between Pixtral’s
build_rope_2dand the ERNIE implementation. It turns out they are mathematically incompatible, and direct reuse would result in incorrect positional embeddings.Below is the technical breakdown:
freq_scale_odd)rope_ext+concatggml_rope_multiwith mrope 4-slotKey Technical Differences:
freq_scaleto one-half of the dimensions. ERNIE usessections [20, 20, 0, 0]to strictly block frequencies, where each section starts its theta accumulation independently fromRegarding the complexity of the
ROPE_TYPEsystem:GGML_ROPE_TYPE_VISION. No new mode is introduced here.GGML_ROPE_TYPE_ERNIE3Dis a strict requirement to support the Temporal (t) dimension. Current 2D implementations (like Pixtral) cannot handle this 3D mapping.Conclusion:
To maintain mathematical correctness and support 3D RoPE, we cannot reuse the Pixtral logic. The new
ERNIE3Dtype is the minimum necessary change to support these specific requirements. I will ensure the implementation is as modular as possible to keep the system maintainable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the difference is just the normal and neox style, you can also permute the Q and K tensor upon converting to GGUF.
Kimi 2.5 also do exactly this, you can copy the conversion code from #19170
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also just a friendly reminder: We don't allow replying to human maintainer with AI-generated response. Please write the response with your own writing,to prove that you fully understand your code