Skip to content
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

[SW-212057] Enable QDQ (#101) #1704

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"method": "HOOKS",
"mode": "QUANTIZE",
"observer": "maxabs",
"scale_method": "maxabs_hw",
"scale_format": "SCALAR",
"dump_stats_path": "./hqt_output/measure",
"use_qdq": "True"
}
4 changes: 4 additions & 0 deletions optimum/habana/transformers/models/llama/modeling_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ def get_k_proj_weight_dtype(self):
Scales tensor gets the weight dtype."""
if hasattr(self.k_proj, "qweight"):
return self.k_proj.scales.dtype
elif hasattr(self.k_proj, "use_qdq") and self.k_proj.use_qdq:
return self.k_proj.dequant_weights.hp_dtype
elif isinstance(self.k_cache, KVCache) and "float8" in str(self.k_proj.weight.dtype):
return self.k_proj.scale_weight.dtype
return self.k_proj.weight.dtype

def allocate_kv_cache(self, batch_size, max_seq_len, inp_seq_len):
Expand Down