-
Notifications
You must be signed in to change notification settings - Fork 43
Adding SwiftKV Infra changes in QEFF for execution of swiftKV models #285
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
229b75d
added initial version of SwiftKV for AI 100
ochougul e91d8e2
BUGFIX
ochougul 58b8909
BUGFIX
ochougul 12ec8bb
BUGFIX
ochougul 597dc18
BUGFIX
ochougul b8b6dbc
BUGFIX
ochougul f5fd0bf
BUGFIX
ochougul f0a80b9
BUGFIX
ochougul 7281ccb
BUGFIX
ochougul 10cc781
BUGFIX
ochougul 9b87d8f
BUGFIX
ochougul 4c60712
BUGFIX
ochougul 1fa0a3c
all bugfixes in
ochougul 4534ba6
added init file
ochougul 3c95661
all changes except BQA are in with this
ochougul dd5633d
more updates
ochougul a73da94
Enabling the SwiftKV model in the QEFF Infra
quic-hemagnih ed4e1a9
rebased
ochougul 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,6 @@ | ||
# ----------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# ----------------------------------------------------------------------------- |
41 changes: 41 additions & 0 deletions
41
QEfficient/transformers/models/llama_swiftkv/config_llama_swiftkv.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,41 @@ | ||
# ----------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# The Modules are updated as required by Cloud AI 100 HW requirements. | ||
|
||
|
||
"""Inference-only LLaMA model compatible with HuggingFace weights.""" | ||
|
||
from typing import Optional | ||
from transformers import LlamaConfig | ||
|
||
|
||
class LlamaSwiftKVConfig(LlamaConfig): | ||
""" | ||
Args: | ||
num_key_value_layers (int, optional): | ||
The number of layers, from the first layer, that have keys and | ||
values. If None, all layers have keys and values. | ||
last_key_value_heads (int, optional): | ||
The number of heads in the last layer that have keys and values. | ||
If None, the number of heads in the last key-value layer is equal | ||
to the number of heads in all the other key-value layers. | ||
""" | ||
|
||
model_type = "llama_swiftkv" | ||
|
||
def __init__( | ||
self, | ||
swiftkv: bool = False, | ||
num_key_value_layers: Optional[int] = None, | ||
key_value_group_size: Optional[int] = None, | ||
**kwargs, | ||
): | ||
super().__init__(**kwargs) | ||
self.swiftkv = swiftkv | ||
self.num_key_value_layers = num_key_value_layers or self.num_hidden_layers | ||
self.key_value_group_size = key_value_group_size or 1 | ||
assert (self.num_hidden_layers - self.num_key_value_layers) % self.key_value_group_size == 0 |
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.
Move this peice of code in the modelling file