-
Notifications
You must be signed in to change notification settings - Fork 162
feat: add per-head fp8 kv attention calibration #2044
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
base: main
Are you sure you want to change the base?
Changes from all commits
4b672fc
ec6cb05
ec402e6
c99f852
1fffef6
e9766a5
3a3aa43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,8 @@ def __init__( | |
| output_dir: str = "./compressed_models", | ||
| static_kv_dtype: Optional[torch.dtype] = None, # TODO later this should be scheme wenhuach | ||
| static_attention_dtype: Optional[torch.dtype] = None, | ||
| static_kv_granularity: str = "tensor", | ||
| static_attention_granularity: str = "tensor", | ||
| **kwargs, | ||
| ) -> None: | ||
| super().__init__() | ||
|
|
@@ -58,6 +60,8 @@ def __init__( | |
| self.is_immediate_saving = is_immediate_saving | ||
| self.static_kv_dtype = static_kv_dtype | ||
| self.static_attention_dtype = static_attention_dtype | ||
| self.static_kv_granularity = static_kv_granularity | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I think KV-related options belong in the scheme context rather than the compression context. @n1ck-guo, could you refine the definition of each context and clearly explain its purpose? That would make it much easier for developers to understand which context a new option should belong to. |
||
| self.static_attention_granularity = static_attention_granularity | ||
|
|
||
| def clear_memory(self, tensor=None): | ||
| """Clear GPU/CPU memory only when ``low_gpu_mem_usage`` is enabled.""" | ||
|
|
||
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.
We already have too many CLI arguments. Is there a way to group all the KV-related options into a kv_scheme and provide some predefined presets to cover the common use cases?
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.
Yes, I’m also thinking about refining the KV-cache and attention quantization configs into dedicated schemes, something like:
I’ll prepare an RFC for this later. For this PR, though, I think the current functionality looks good.