vllm-project / vllm

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

[Bug]: The MixtralForCausalLM architecture and the mistralai/Mixtral-8x7B-Instruct-v0.1 model are stated to be supported by vLLM, but an error occurs during model loading. #7713

Open Anwesh2 opened 3 weeks ago

Anwesh2 commented 3 weeks ago

Your current environment

The output of `python collect_env.py` ```text Collecting environment information... PyTorch version: 2.4.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.30.1 Libc version: glibc-2.35 Python version: 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0] (64-bit runtime) Python platform: Linux-6.2.0-1018-aws-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: 12.1.66 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA A10G GPU 1: NVIDIA A10G GPU 2: NVIDIA A10G GPU 3: NVIDIA A10G Nvidia driver version: 535.154.05 cuDNN version: Could not collect 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: 48 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 48 On-line CPU(s) list: 0-47 Vendor ID: AuthenticAMD Model name: AMD EPYC 7R32 CPU family: 23 Model: 49 Thread(s) per core: 2 Core(s) per socket: 24 Socket(s): 1 Stepping: 0 BogoMIPS: 5599.99 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch topoext ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr rdpru wbnoinvd arat npt nrip_save rdpid Hypervisor vendor: KVM Virtualization type: full L1d cache: 768 KiB (24 instances) L1i cache: 768 KiB (24 instances) L2 cache: 12 MiB (24 instances) L3 cache: 96 MiB (6 instances) NUMA node(s): 1 NUMA node0 CPU(s): 0-47 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Retbleed: Mitigation; untrained return thunk; SMT enabled with STIBP protection Vulnerability Spec rstack overflow: Mitigation; safe RET Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Versions of relevant libraries: [pip3] adapter-transformers==4.0.0 [pip3] numpy==1.26.4 [pip3] nvidia-cublas-cu12==12.1.3.1 [pip3] nvidia-cuda-cupti-cu12==12.1.105 [pip3] nvidia-cuda-nvrtc-cu12==12.1.105 [pip3] nvidia-cuda-runtime-cu12==12.1.105 [pip3] nvidia-cudnn-cu12==9.1.0.70 [pip3] nvidia-cufft-cu12==11.0.2.54 [pip3] nvidia-curand-cu12==10.3.2.106 [pip3] nvidia-cusolver-cu12==11.4.5.107 [pip3] nvidia-cusparse-cu12==12.1.0.106 [pip3] nvidia-ml-py==12.555.43 [pip3] nvidia-nccl-cu12==2.20.5 [pip3] nvidia-nvjitlink-cu12==12.3.101 [pip3] nvidia-nvtx-cu12==12.1.105 [pip3] pynvml==11.5.0 [pip3] pytorch-triton==3.0.0+901819d2b6 [pip3] pyzmq==25.1.2 [pip3] torch==2.4.0 [pip3] torchaudio==2.4.0 [pip3] torchvision==0.19.0 [pip3] transformers==4.43.4 [pip3] triton==3.0.0 [conda] adapter-transformers 4.0.0 pypi_0 pypi [conda] numpy 1.26.4 pypi_0 pypi [conda] nvidia-cublas-cu12 12.1.3.1 pypi_0 pypi [conda] nvidia-cuda-cupti-cu12 12.1.105 pypi_0 pypi [conda] nvidia-cuda-nvrtc-cu12 12.1.105 pypi_0 pypi [conda] nvidia-cuda-runtime-cu12 12.1.105 pypi_0 pypi [conda] nvidia-cudnn-cu12 9.1.0.70 pypi_0 pypi [conda] nvidia-cufft-cu12 11.0.2.54 pypi_0 pypi [conda] nvidia-curand-cu12 10.3.2.106 pypi_0 pypi [conda] nvidia-cusolver-cu12 11.4.5.107 pypi_0 pypi [conda] nvidia-cusparse-cu12 12.1.0.106 pypi_0 pypi [conda] nvidia-ml-py 12.555.43 pypi_0 pypi [conda] nvidia-nccl-cu12 2.20.5 pypi_0 pypi [conda] nvidia-nvjitlink-cu12 12.3.101 pypi_0 pypi [conda] nvidia-nvtx-cu12 12.1.105 pypi_0 pypi [conda] pynvml 11.5.0 pypi_0 pypi [conda] pytorch-triton 3.0.0+901819d2b6 pypi_0 pypi [conda] pyzmq 25.1.2 pypi_0 pypi [conda] torch 2.4.0 pypi_0 pypi [conda] torchaudio 2.4.0 pypi_0 pypi [conda] torchvision 0.19.0 pypi_0 pypi [conda] transformers 4.43.4 pypi_0 pypi [conda] triton 3.0.0 pypi_0 pypi ROCM Version: Could not collect Neuron SDK Version: N/A vLLM Version: 0.5.4@4db5176d9758b720b05460c50ace3c01026eb158 vLLM Build Flags: CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled GPU Topology: GPU0 GPU1 GPU2 GPU3 CPU Affinity NUMA Affinity GPU NUMA ID GPU0 X PHB PHB PHB 0-47 0 N/A GPU1 PHB X PHB PHB 0-47 0 N/A GPU2 PHB PHB X PHB 0-47 0 N/A GPU3 PHB PHB PHB X 0-47 0 N/A 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 ```

🐛 Describe the bug

The MixtralForCausalLM architecture and the mistralai/Mixtral-8x7B-Instruct-v0.1 model with LoRA are stated to be supported by vLLM (reference), but an error occurs during model loading. I tested it for vllm versions [v0.5.4] [v0.5.3.post1], and [v0.5.3].

image

#Sample code
from vllm import LLM
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
llm = LLM(model = model_id, enable_lora = True, max_lora_rank = 16, quantization = "bitsandbytes", load_format = "bitsandbytes", enforce_eager = True)
#ErrorMessage
vllm version: 0.5.4
WARNING 08-21 00:27:46 config.py:254] bitsandbytes quantization is not fully optimized yet. The speed can be slower than non-quantized models.
WARNING 08-21 00:27:46 config.py:1342] bitsandbytes quantization is not tested with LoRA yet.
INFO 08-21 00:27:46 llm_engine.py:174] Initializing an LLM engine (v0.5.4) with config: model='mistralai/Mixtral-8x7B-Instruct-v0.1', speculative_config=None, tokenizer='mistralai/Mixtral-8x7B-Instruct-v0.1', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, rope_scaling=None, rope_theta=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.bfloat16, max_seq_len=32768, download_dir=None, load_format=LoadFormat.BITSANDBYTES, tensor_parallel_size=1, pipeline_parallel_size=1, disable_custom_all_reduce=False, quantization=bitsandbytes, enforce_eager=True, kv_cache_dtype=auto, quantization_param_path=None, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='outlines'), observability_config=ObservabilityConfig(otlp_traces_endpoint=None), seed=0, served_model_name=mistralai/Mixtral-8x7B-Instruct-v0.1, use_v2_block_manager=False, enable_prefix_caching=False)
INFO 08-21 00:27:46 model_runner.py:720] Starting to load model mistralai/Mixtral-8x7B-Instruct-v0.1...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 6
      1 ##################################################################################################################################
      2 ########################## MODEL LOADING #########################################################################################
      3 ##################################################################################################################################
      5 model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
----> 6 llm = LLM(model = model_id, enable_lora = True, max_lora_rank = 16, quantization = "bitsandbytes", load_format = "bitsandbytes", enforce_eager = True)
      8 # sampling_params_xlam = SamplingParams(temperature = 0.0, max_tokens = 10000)
      9 # originalmixtral_lora_id = "Anwesh0127/legacycp_ORIGINALMIXTRAL_withadaptor"
     10 # originalmixtral_lora_path = snapshot_download(repo_id = xlam_lora_id)
   (...)
     18 # caspermixtral_lora_path = snapshot_download(repo_id = xlam_lora_id)
     19 # caspermixtralLR = LoRARequest("caspermixtral", 1, xlam_lora_path)

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/entrypoints/llm.py:158, in LLM.__init__(self, model, tokenizer, tokenizer_mode, skip_tokenizer_init, trust_remote_code, tensor_parallel_size, dtype, quantization, revision, tokenizer_revision, seed, gpu_memory_utilization, swap_space, cpu_offload_gb, enforce_eager, max_context_len_to_capture, max_seq_len_to_capture, disable_custom_all_reduce, **kwargs)
    135     raise TypeError(
    136         "There is no need to pass vision-related arguments anymore.")
    137 engine_args = EngineArgs(
    138     model=model,
    139     tokenizer=tokenizer,
   (...)
    156     **kwargs,
    157 )
--> 158 self.llm_engine = LLMEngine.from_engine_args(
    159     engine_args, usage_context=UsageContext.LLM_CLASS)
    160 self.request_counter = Counter()

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/engine/llm_engine.py:445, in LLMEngine.from_engine_args(cls, engine_args, usage_context, stat_loggers)
    443 executor_class = cls._get_executor_cls(engine_config)
    444 # Create the LLM engine.
--> 445 engine = cls(
    446     **engine_config.to_dict(),
    447     executor_class=executor_class,
    448     log_stats=not engine_args.disable_log_stats,
    449     usage_context=usage_context,
    450     stat_loggers=stat_loggers,
    451 )
    453 return engine

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/engine/llm_engine.py:249, in LLMEngine.__init__(self, model_config, cache_config, parallel_config, scheduler_config, device_config, load_config, lora_config, multimodal_config, speculative_config, decoding_config, observability_config, prompt_adapter_config, executor_class, log_stats, usage_context, stat_loggers)
    243 self.generation_config_fields = _load_generation_config_dict(
    244     model_config)
    246 self.input_processor = INPUT_REGISTRY.create_input_processor(
    247     self.model_config)
--> 249 self.model_executor = executor_class(
    250     model_config=model_config,
    251     cache_config=cache_config,
    252     parallel_config=parallel_config,
    253     scheduler_config=scheduler_config,
    254     device_config=device_config,
    255     lora_config=lora_config,
    256     multimodal_config=multimodal_config,
    257     speculative_config=speculative_config,
    258     load_config=load_config,
    259     prompt_adapter_config=prompt_adapter_config,
    260 )
    262 if not self.model_config.embedding_mode:
    263     self._initialize_kv_caches()

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/executor/executor_base.py:47, in ExecutorBase.__init__(self, model_config, cache_config, parallel_config, scheduler_config, device_config, load_config, lora_config, multimodal_config, speculative_config, prompt_adapter_config)
     44 self.speculative_config = speculative_config
     45 self.prompt_adapter_config = prompt_adapter_config
---> 47 self._init_executor()

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/executor/gpu_executor.py:36, in GPUExecutor._init_executor(self)
     34 self.driver_worker = self._create_worker()
     35 self.driver_worker.init_device()
---> 36 self.driver_worker.load_model()

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/worker/worker.py:139, in Worker.load_model(self)
    138 def load_model(self):
--> 139     self.model_runner.load_model()

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/worker/model_runner.py:722, in GPUModelRunnerBase.load_model(self)
    720 logger.info("Starting to load model %s...", self.model_config.model)
    721 with CudaMemoryProfiler() as m:
--> 722     self.model = get_model(model_config=self.model_config,
    723                            device_config=self.device_config,
    724                            load_config=self.load_config,
    725                            lora_config=self.lora_config,
    726                            multimodal_config=self.multimodal_config,
    727                            parallel_config=self.parallel_config,
    728                            scheduler_config=self.scheduler_config,
    729                            cache_config=self.cache_config)
    731 self.model_memory_usage = m.consumed_memory
    732 logger.info("Loading model weights took %.4f GB",
    733             self.model_memory_usage / float(2**30))

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/model_executor/model_loader/__init__.py:21, in get_model(model_config, load_config, device_config, parallel_config, scheduler_config, lora_config, multimodal_config, cache_config)
     14 def get_model(*, model_config: ModelConfig, load_config: LoadConfig,
     15               device_config: DeviceConfig, parallel_config: ParallelConfig,
     16               scheduler_config: SchedulerConfig,
     17               lora_config: Optional[LoRAConfig],
     18               multimodal_config: Optional[MultiModalConfig],
     19               cache_config: CacheConfig) -> nn.Module:
     20     loader = get_model_loader(load_config)
---> 21     return loader.load_model(model_config=model_config,
     22                              device_config=device_config,
     23                              lora_config=lora_config,
     24                              multimodal_config=multimodal_config,
     25                              parallel_config=parallel_config,
     26                              scheduler_config=scheduler_config,
     27                              cache_config=cache_config)

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/model_executor/model_loader/loader.py:942, in BitsAndBytesModelLoader.load_model(self, model_config, device_config, lora_config, multimodal_config, parallel_config, scheduler_config, cache_config)
    940 with set_default_torch_dtype(model_config.dtype):
    941     with torch.device(device_config.device):
--> 942         model = _initialize_model(model_config, self.load_config,
    943                                   lora_config, multimodal_config,
    944                                   cache_config)
    946         self._load_weights(model_config, model)
    948 return model.eval()

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/model_executor/model_loader/loader.py:157, in _initialize_model(model_config, load_config, lora_config, multimodal_config, cache_config, scheduler_config)
    151 model_class = get_model_architecture(model_config)[0]
    152 quant_config = _get_quantization_config(model_config, load_config)
    154 return model_class(config=model_config.hf_config,
    155                    cache_config=cache_config,
    156                    quant_config=quant_config,
--> 157                    **_get_model_initialization_kwargs(
    158                        model_class, lora_config, multimodal_config,
    159                        scheduler_config))

File ~/miniconda3/envs/demo/lib/python3.11/site-packages/vllm/model_executor/model_loader/loader.py:124, in _get_model_initialization_kwargs(model_class, lora_config, multimodal_config, scheduler_config)
    122     extra_kwargs["lora_config"] = lora_config
    123 elif lora_config:
--> 124     raise ValueError(
    125         f"Model {model_class.__name__} does not support LoRA, "
    126         "but LoRA is enabled. Support for this model may "
    127         "be added in the future. If this is important to you, "
    128         "please open an issue on github.")
    130 if supports_vision(model_class):
    131     if multimodal_config is None:

ValueError: Model MixtralForCausalLM does not support LoRA, but LoRA is enabled. Support for this model may be added in the future. If this is important to you, please open an issue on github.
jeejeelee commented 3 weeks ago

Because you set quantization = 'bitsandbytes', the corresponding model_class is MixtralForCausalLM, and this model indeed does not support LoRA.

Moreover, even if this model supported LoRA, it would still throw an error due to lack of support for BNB.

Anwesh2 commented 3 weeks ago

Hi @jeejeelee, that makes sense.

But I noticed that this page indicates that LoRA is supported for MixtralForCausalLM models. Could this be an oversight? For example, will MixtralForCausalLM with LoRA and AWQ quantization not work for vLLM inferencing?

Additionally, I came across information that BnB support has recently been added in vLLM. Is there a document or list available that details which models are currently supported for bitsandbytes?

jeejeelee commented 3 weeks ago

But I noticed that this page indicates that LoRA is supported for MixtralForCausalLM models. Could this be an oversight?

Supported Models indeed contains ambiguity

For example, will MixtralForCausalLM with LoRA and AWQ quantization not work for vLLM inferencing?

The model support for LoRA depends on whether it inherits from the SupportsLoRA

Additionally, I came across information that BnB support has recently been added in vLLM. Is there a document or list available that details which models are currently supported for bitsandbytes?

cc @chenqianfzh

chenqianfzh commented 2 weeks ago

Hi @jeejeelee, that makes sense.

But I noticed that this page indicates that LoRA is supported for MixtralForCausalLM models. Could this be an oversight? For example, will MixtralForCausalLM with LoRA and AWQ quantization not work for vLLM inferencing?

Additionally, I came across information that BnB support has recently been added in vLLM. Is there a document or list available that details which models are currently supported for bitsandbytes?

As JJ Lee explained, the models supported by Bnb quantization is limited. Only Llama is supported. We will be working to extend it to more models.