This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: n1ck-guo <[email protected]>
- Loading branch information
Showing
4 changed files
with
220 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 2 additions & 0 deletions
2
...l_extension_for_transformers/transformers/modeling/kv_cache_compression/prune/__init__.py
This file contains 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,2 @@ | ||
from .base import PruneConfig, KVPruner | ||
from .h2o import H2OConfig, H2OKVPruner |
30 changes: 30 additions & 0 deletions
30
intel_extension_for_transformers/transformers/modeling/kv_cache_compression/prune/base.py
This file contains 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,30 @@ | ||
class PruneConfig(dict): | ||
def __init__(self, real_drop=True): | ||
self.real_drop = real_drop | ||
|
||
class KVPruner: | ||
def __init__(self, prune_config) -> None: | ||
self._past_length = 0 | ||
|
||
def self_attn_init(self, module): | ||
pass | ||
|
||
def prune(self, module, query_states, key_states, value_states, **kwargs): | ||
pass | ||
|
||
def before_generate(self, model, **kwargs): | ||
self.past_length = 0 | ||
|
||
def after_generate(self, model, **kwargs): | ||
pass | ||
|
||
def get_mask(self, model, **kwargs): | ||
pass | ||
|
||
@property | ||
def past_length(self): | ||
return self._past_length | ||
|
||
@past_length.setter | ||
def past_length(self, value): | ||
self._past_length = value |
Oops, something went wrong.