[BugFix] Fix bugs when using ascend quantization (#275)
### What this PR does / why we need it? It fixes following bugs: 1. When searching a specific linear quantization implementation from a tool (such as MindIE-Turbo), the mapping of packed linear is required to identify correponding quant type. 2. The exception is narrowed down to ImportError when importing MindIETurboQuantizer to better throw other errors. 3. The api of AscendKVCacheMethod.apply is aligned with that in AscendAttentionBackendImpl. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? By performing offline inference:  --------- Signed-off-by: angazenn <zengyanjia@huawei.com> Co-authored-by: angazenn <zengyanjia@huawei.com>
This commit is contained in:
@@ -744,10 +744,19 @@ class AscendAttentionBackendImpl(AttentionImpl):
|
||||
block_tables = attn_metadata.decode_metadata.block_tables if attn_metadata.decode_metadata else None
|
||||
# Details of kv_cache arrangement in attention quantization
|
||||
# are implemented by quant_method.
|
||||
layer.quant_method.apply(layer, query, key, value, self.key_cache,
|
||||
self.value_cache, self.scale,
|
||||
self.seq_lens_tensor_cpu, block_tables,
|
||||
isPrefill, attn_metadata, output)
|
||||
layer.quant_method.apply(
|
||||
layer,
|
||||
query,
|
||||
key,
|
||||
value,
|
||||
self.key_cache,
|
||||
self.value_cache,
|
||||
self.scale,
|
||||
block_tables,
|
||||
isPrefill,
|
||||
attn_metadata,
|
||||
output,
|
||||
seq_lens_tensor_cpu=self.seq_lens_tensor_cpu)
|
||||
else:
|
||||
if self.key_cache is not None:
|
||||
torch_npu._npu_reshape_and_cache(key=key,
|
||||
|
||||
Reference in New Issue
Block a user