Feature Description
Extend FP8 KV/Attention calibration from per-tensor scaling to per-head scaling.
Context
We previously added support for collecting per-tensor scales for FP8 KV/Attention calibration, including usage examples and unit tests:
|
def test_mxfp8_llmcompressor_kv_config(self, tiny_opt_model_path, tmp_path): |
|
ar = AutoRound( |
|
model=tiny_opt_model_path, |
|
iters=0, |
|
disable_opt_rtn=True, |
|
scheme="mxfp8", |
|
static_kv_dtype="fp8", |
|
) |
|
_, quantized_model_path = ar.quantize_and_save(output_dir=tmp_path, format="llm_compressor") |
|
|
|
with open(os.path.join(quantized_model_path, "config.json")) as f: |
|
config = json.load(f) |
|
|
|
kv_cache_scheme = config["quantization_config"]["kv_cache_scheme"] |
|
assert kv_cache_scheme is not None |
|
assert kv_cache_scheme["num_bits"] == 8 |
|
assert kv_cache_scheme["type"] == "float" |
|
assert kv_cache_scheme["strategy"] == "tensor" |
|
assert kv_cache_scheme["dynamic"] is False |
|
assert kv_cache_scheme["symmetric"] is True |
|
|
|
def test_mxfp8_llmcompressor_attention_config(self, tiny_opt_model_path, tmp_path): |
This feature extends the calibration granularity to per-head scaling, meaning each attention head has its own scale. Compared with per-tensor scaling, per-head scaling can better capture head-wise activation ranges and may improve accuracy while keeping inference overhead minimal, assuming the target backend supports per-head scales efficiently.
Definition of Done
-
Support per-head FP8 KV/Attention calibration for:
-
Support export formats:
-
For the LLMC format, validate accuracy on the vLLM side using the Triton backend.
Additional Context
N/A
Feature Description
Extend FP8 KV/Attention calibration from per-tensor scaling to per-head scaling.
Context
We previously added support for collecting per-tensor scales for FP8 KV/Attention calibration, including usage examples and unit tests:
auto-round/test/test_cpu/export/test_llmc_format.py
Lines 131 to 152 in 5e586bc
This feature extends the calibration granularity to per-head scaling, meaning each attention head has its own scale. Compared with per-tensor scaling, per-head scaling can better capture head-wise activation ranges and may improve accuracy while keeping inference overhead minimal, assuming the target backend supports per-head scales efficiently.
Definition of Done
Support per-head FP8 KV/Attention calibration for:
Support export formats:
For the LLMC format, validate accuracy on the vLLM side using the Triton backend.
Additional Context
N/A