Repository navigation
Closed
Labels
triagedIssue has been triaged by maintainers
Description
version:
python3 -c "import tensorrt_llm; print(tensorrt_llm.__version__)"
0.7.1
nvidia-ammo~=0.5.0
I'm currently trying to use AMMO to quantize my model with awq_int4. My customed model is based on llama2-13B, but the attention and mlp layers of the model have bias, and the model is GQA structure.
I have set attn_bias=True, mlp_bias=True here and the model runs correctly with fp16 precision.
I encountered an issue when using AMMO for quantization.
Cannot export model to the model_config. The AMMO optimized model state_dict (including the quantization factors) is saved to /target/model/quantized_int4-awq/ammo_model.0.pth using torch.save for further inspection.
Detailed export error:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/ammo/torch/export/model_config_export.py", line 181, in export_model_config
for model_config in torch_to_model_config(
File "/usr/local/lib/python3.10/dist-packages/ammo/torch/export/model_config_export.py", line 114, in torch_to_model_config
build_decoder_config(layer, model_metadata_config, decoder_type, dtype)
File "/usr/local/lib/python3.10/dist-packages/ammo/torch/export/layer_utils.py", line 782, in build_decoder_config
config.attention = build_attention_config(layer, model_metadata_config, dtype, config)
File "/usr/local/lib/python3.10/dist-packages/ammo/torch/export/layer_utils.py", line 598, in build_attention_config
config.qkv = build_qkv(qkv_modules, model_metadata_config, dtype, ext_config)
File "/usr/local/lib/python3.10/dist-packages/ammo/torch/export/layer_utils.py", line 436, in build_qkv
assert not (hasattr(m, "bias") and m.bias is not None)
AssertionErrorI suspected it was related to bias, so I commented out the assert checks related to bias
#/usr/local/lib/python3.10/dist-packages/ammo/torch/export/layer_utils.py
for m in qkv_modules:
assert type(m) == nn.Linear
# assert not (hasattr(m, "bias") and m.bias is not None)
...
# assert (
# not qkv_modules[0].bias and not qkv_modules[1].bias and not qkv_modules[2].bias
# ), "bias is not supported yet."and added some code.
q_bias = qkv_modules[0].bias
k_bias = qkv_modules[1].bias
v_bias = qkv_modules[2].biasSince in my model "intermediate_size": 13632, so I can only use quantization with group_size=64. My configuration is as follows:
{'*weight_quantizer': {'num_bits': 4, 'block_sizes': {-1: 64}, 'enable': True}, '*input_quantizer': {'enable': False}, 'default': {'enable': False}}
The quantization process went relatively smoothly.
Activity
[-]AWQ-int[/-][+]AWQ-int4-quantization errors on Llama-2 13B with AMMO[/+][-]AWQ-int4-quantization errors on Llama-2 13B with AMMO[/-][+]AWQ-int4-quantization errors on Llama-2 13B based model with AMMO[/+]Hongbosherlock commentedon Jan 15, 2024
After quantization, I built the model.
then
but the inference results I obtained were completely meaningless.
I have successfully quantized my model based on AutoAWQ before, and the results looked promising.
Time-Limit commentedon Feb 1, 2024
Hello, have you solved this issue? I also encountered the same issue.
Hongbosherlock commentedon Feb 20, 2024
I have solved this
You should modify func
load_from_awq_llamain theweight.pynv-guomingz commentedon Nov 15, 2024
hi @Hongbosherlock Feel free to reopen it if needed