-
Notifications
You must be signed in to change notification settings - Fork 689
Qualcomm AI Engine Direct - GA Static QWEN2.5 0.5B #12054
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
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
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
45 changes: 45 additions & 0 deletions
45
examples/qualcomm/oss_scripts/llama/hf_converter/convert_config.py
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,45 @@ | ||
# Copyright (c) Qualcomm Innovation Center, Inc. | ||
# All rights reserved | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
|
||
def convert_configs(config): | ||
# HF config keys are different from Llama configs. | ||
# Convert the config keys to align with Llama. | ||
if hasattr(config, "hidden_size"): | ||
config.dim = config.hidden_size | ||
delattr(config, "hidden_size") | ||
|
||
if hasattr(config, "num_attention_heads"): | ||
config.n_heads = config.num_attention_heads | ||
delattr(config, "num_attention_heads") | ||
|
||
if hasattr(config, "num_key_value_heads"): | ||
config.n_kv_heads = config.num_key_value_heads | ||
delattr(config, "num_key_value_heads") | ||
|
||
if hasattr(config, "rms_norm_eps"): | ||
config.norm_eps = config.rms_norm_eps | ||
delattr(config, "rms_norm_eps") | ||
|
||
if hasattr(config, "rope_theta"): | ||
config.rope_freq_base = config.rope_theta | ||
delattr(config, "rope_theta") | ||
|
||
if hasattr(config, "num_hidden_layers"): | ||
config.n_layers = config.num_hidden_layers | ||
delattr(config, "num_hidden_layers") | ||
|
||
if hasattr(config, "intermediate_size"): | ||
config.hidden_dim = config.intermediate_size | ||
delattr(config, "intermediate_size") | ||
|
||
if hasattr(config, "rope_scaling"): | ||
config.use_scaled_rope = config.rope_scaling | ||
# Use default value of precompute_freq_cis | ||
if not hasattr(config, "rope_scale_factor"): | ||
config.rope_scale_factor = 4 | ||
|
||
return config |
Oops, something went wrong.
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.
Can you share where this config come from and how we can scale to more models?
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 config can be found over here:
https://github.com/huggingface/transformers/blob/main/src/transformers/models/qwen2/configuration_qwen2.py.
For now, I checked qwen and gemma, and I think most configs are following the same naming, where they all use
PretrainedConfig
as the base class. Ideally, this function should be able to support most HF decoder models, but I will need to test them 1 by 1 to confirm they can all be supported using this function.