vllm-project / vllm

A high-throughput and memory-efficient inference and serving engine for LLMs
https://docs.vllm.ai
Apache License 2.0
30.06k stars 4.54k forks source link

[Bug]: export failed when kv cache fp8 quantizing Qwen1.5-72B-Chat-GPTQ-Int4 #4714

Open frankxyy opened 6 months ago

frankxyy commented 6 months ago

Your current environment

pip3 install vllm==0.4.2 nvidia-ammo==0.7.1

Collecting environment information... PyTorch version: 2.3.0+cu121 Is debug build: False CUDA used to build PyTorch: 12.1 ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: Could not collect CMake version: version 3.27.6 Libc version: glibc-2.35

Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-3.10.0-1160.108.1.el7.x86_64-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: 12.2.140 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA A10 GPU 1: NVIDIA A10 GPU 2: NVIDIA A10 GPU 3: NVIDIA A10 GPU 4: NVIDIA A10 GPU 5: NVIDIA A10 GPU 6: NVIDIA A10 GPU 7: NVIDIA A10

Nvidia driver version: 535.129.03 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.5 /usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.5 /usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.5 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.5 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.5 /usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.5 /usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.5 HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 96 On-line CPU(s) list: 0-95 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) Gold 5318Y CPU @ 2.10GHz CPU family: 6 Model: 106 Thread(s) per core: 2 Core(s) per socket: 24 Socket(s): 2 Stepping: 6 Frequency boost: enabled CPU max MHz: 2101.0000 CPU min MHz: 800.0000 BogoMIPS: 4200.00 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 invpcid_single ssbd mba rsb_ctxsw ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq md_clear pconfig spec_ctrl intel_stibp flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 2.3 MiB (48 instances) L1i cache: 1.5 MiB (48 instances) L2 cache: 60 MiB (48 instances) L3 cache: 72 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-23,48-71 NUMA node1 CPU(s): 24-47,72-95 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; Load fences, usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] numpy==1.22.2 [pip3] nvidia-nccl-cu12==2.20.5 [pip3] onnx==1.14.0 [pip3] onnx-graphsurgeon==0.5.2 [pip3] onnxruntime==1.16.3 [pip3] onnxsim==0.4.36 [pip3] pytorch-quantization==2.1.2 [pip3] torch==2.3.0 [pip3] torch-tensorrt==0.0.0 [pip3] torchdata==0.7.0a0 [pip3] torchprofile==0.0.4 [pip3] torchtext==0.16.0a0 [pip3] torchvision==0.18.0 [pip3] triton==2.3.0 [pip3] vllm-nccl-cu12==2.18.1.0.4.0 [conda] Could not collectROCM Version: Could not collect Neuron SDK Version: N/A vLLM Version: 0.4.2 vLLM Build Flags: CUDA Archs: 5.2 6.0 6.1 7.0 7.2 7.5 8.0 8.6 8.7 9.0+PTX; ROCm: Disabled; Neuron: Disabled GPU Topology: GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 NIC0 NIC1 CPU Affinity NUMA Affinity GPU NUMA ID GPU0 X PIX PXB PXB SYS SYS SYS SYS SYS SYS 0-23,48-71 0 N/A GPU1 PIX X PXB PXB SYS SYS SYS SYS SYS SYS 0-23,48-71 0 N/A GPU2 PXB PXB X PXB SYS SYS SYS SYS SYS SYS 0-23,48-71 0 N/A GPU3 PXB PXB PXB X SYS SYS SYS SYS SYS SYS 0-23,48-71 0 N/A GPU4 SYS SYS SYS SYS X PIX PXB PXB SYS SYS 24-47,72-95 1 N/A GPU5 SYS SYS SYS SYS PIX X PXB PXB SYS SYS 24-47,72-95 1 N/A GPU6 SYS SYS SYS SYS PXB PXB X PXB SYS SYS 24-47,72-95 1 N/A GPU7 SYS SYS SYS SYS PXB PXB PXB X SYS SYS 24-47,72-95 1 N/A NIC0 SYS SYS SYS SYS SYS SYS SYS SYS X PIX NIC1 SYS SYS SYS SYS SYS SYS SYS SYS PIX X

Legend:

X = Self SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI) NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU) PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge) PIX = Connection traversing at most a single PCIe bridge NV# = Connection traversing a bonded set of # NVLinks

NIC Legend:

NIC0: mlx5_0 NIC1: mlx5_1

🐛 Describe the bug

Run the command: python quantize.py --model_dir /workspace/models2/Qwen1.5-72B-Chat-GPTQ-Int4 --dtype float16 \ --qformat fp8 --kv_cache_dtype fp8 --output_dir /workspace/output_models/qwen-72b_int4_fp8 \ --calib_size 512 --tp_size 4

and got:

01fcb094ed8e3b8e158400c1094fb6cf
DearPlanet commented 6 months ago

I got a similar error when converting Qwen-14B-GPTQ-int4, and I used the latest released modelopt library.

Cannot export model to the model_config. The modelopt-optimized model state_dict (including the quantization factors) is saved to ../Qwen1.5-14B-Chat-GPTQ-Int4-g128-fpcache/modelopt_model.0.pth using torch.save for further inspection.
Detailed export error: 'QuantLinear' object has no attribute 'weight'
Traceback (most recent call last):
  File "/opt/miniconda3/envs/vllm_pr/lib/python3.11/site-packages/modelopt/torch/export/model_config_export.py", line 364, in export_tensorrt_llm_checkpoint
    for tensorrt_llm_config, weights in torch_to_tensorrt_llm_checkpoint(
  File "/opt/miniconda3/envs/vllm_pr/lib/python3.11/site-packages/modelopt/torch/export/model_config_export.py", line 220, in torch_to_tensorrt_llm_checkpoint
    build_decoder_config(layer, model_metadata_config, decoder_type, dtype)
  File "/opt/miniconda3/envs/vllm_pr/lib/python3.11/site-packages/modelopt/torch/export/layer_utils.py", line 1179, in build_decoder_config
    config.attention = build_attention_config(layer, model_metadata_config, dtype, config)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/vllm_pr/lib/python3.11/site-packages/modelopt/torch/export/layer_utils.py", line 649, in build_attention_config
    config.dense = build_linear_config(layer, LINEAR_ROW, dtype)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/vllm_pr/lib/python3.11/site-packages/modelopt/torch/export/layer_utils.py", line 592, in build_linear_config
    torch_weight = module.weight.detach()
                   ^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/vllm_pr/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1709, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'QuantLinear' object has no attribute 'weight'

Seems like either ammo or modelopt can not deal with quantized models, and they have no gptq quantization supports. Maybe modelopt.torch.export.export_tensorrt_llm_checkpoint (and related func in ammo) should do adaptations to QuantLinear layer.

github-actions[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this issue should remain open. Thank you!