Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 0.6.3.post1 regression: RuntimeError during mem profiling on Mistral Large AWQ with -q awq_marlin #809

Open
khanonnie opened this issue Nov 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@khanonnie
Copy link

khanonnie commented Nov 5, 2024

Your current environment

The output of `python env.py`
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.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-124-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA RTX A6000
GPU 1: NVIDIA RTX A6000
GPU 2: NVIDIA GeForce RTX 3090

Nvidia driver version: 555.42.06
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:                        39 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               16
On-line CPU(s) list:                  0-15
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
CPU family:                           6
Model:                                158
Thread(s) per core:                   2
Core(s) per socket:                   8
Socket(s):                            1
Stepping:                             12
CPU max MHz:                          5000.0000
CPU min MHz:                          800.0000
BogoMIPS:                             7200.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 cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            256 KiB (8 instances)
L1i cache:                            256 KiB (8 instances)
L2 cache:                             2 MiB (8 instances)
L3 cache:                             16 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-15
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; IBRS
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Mitigation; Microcode
Vulnerability Tsx async abort:        Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] pyzmq==26.2.0
[pip3] torch==2.4.0
[pip3] torchvision==0.19.0
[pip3] transformers==4.45.2
[pip3] triton==3.0.0
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] pyzmq                     26.2.0                   pypi_0    pypi
[conda] torch                     2.4.0                    pypi_0    pypi
[conda] torchvision               0.19.0                   pypi_0    pypi
[conda] transformers              4.45.2                   pypi_0    pypi
[conda] triton                    3.0.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
Aphrodite Version: 0.6.3.post1
Aphrodite Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
�[4mGPU0	GPU1	GPU2	CPU Affinity	NUMA Affinity	GPU NUMA ID�[0m
GPU0	 X 	NV4	PHB	0-15	0		N/A
GPU1	NV4	 X 	PHB	0-15	0		N/A
GPU2	PHB	PHB	 X 	0-15	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

After upgrading from 0.6.2.post1 to 0.6.3.post1, I can no longer successfully load Mistral Large GEMM AWQ quants (such as TechxGenus_Mistral-Large-Instruct-2407-AWQ or casperhansen_mistral-large-instruct-2407-awq) with the awq_marlin flag. Regular awq works.

Not yet clear if it affects AWQ quants for other models/architectures, I have not been able to test this yet, will follow-up when I can.

Expected behavior

  • Obtain/quantize mistralai_Mistral-Large-Instruct-2407
  • Launch aphrodite serve:
aphrodite run /mnt/nvme/llm/models/TechxGenus_Mistral-Large-Instruct-2407-AWQ \
  --quantization=awq_marlin \
  --gpu-memory-utilization 0.99 \
  --host 0.0.0.0 \
  --port 2222 \
  --max-model-len 8192\
  --enforce-eager \
  --tensor-parallel-size 2 \
  --max-num-seqs 1 \
  --kv-cache-dtype auto \
  --context-shift \
  --tokenizer-mode mistral
  • Weights load successfully
  • Memory profiling completes successfully
  • Server is started and model processes prompts and generates tokens.

Actual behavior

  • Weights load successfully
  • Memory profiling throws RuntimeError: b_zeros dim 1 = 896 is not size_n = 7168
Full log output
$ aphrodite run /mnt/nvme/llm/models/TechxGenus_Mistral-Large-Instruct-2407-AWQ \
  --quantization=awq_marlin \
  --gpu-memory-utilization 0.99 \
  --host 0.0.0.0 \
  --port 2222 \
  --max-model-len 43850 \
  --enforce-eager \
  --tensor-parallel-size 2 \
  --max-num-seqs 1 \
  --kv-cache-dtype auto \
  --context-shift \
  --tokenizer-mode mistral
INFO:     The model is convertible to awq_marlin during runtime. Using awq_marlin kernel.
INFO:     Multiprocessing frontend to use ipc:///tmp/e8f6fb84-fce4-4aa0-84e1-86fbd986aa27 for RPC Path.
INFO:     Started engine process with PID 11192
INFO:     The model is convertible to awq_marlin during runtime. Using awq_marlin kernel.
INFO:     Defaulting to use mp for distributed inference.
WARNING:  The model has a long context length (43850). This may cause OOM errors during the initial memory profiling phase,
or result in low performance due to small KV cache space. Consider setting --max-model-len to a smaller value.
INFO:     -------------------------------------------------------------------------------------
INFO:     Initializing Aphrodite Engine (v0.6.3.post1 commit f0e00f1b) with the following config:
INFO:     Model = '/mnt/nvme/llm/models/TechxGenus_Mistral-Large-Instruct-2407-AWQ'
INFO:     DataType = torch.float16
INFO:     Tensor Parallel Size = 2
INFO:     Pipeline Parallel Size = 1
INFO:     Disable Custom All-Reduce = False
INFO:     Quantization Format = 'awq_marlin'
INFO:     Context Length = 43850
INFO:     Enforce Eager Mode = True
INFO:     Prefix Caching = True
INFO:     Device = device(type='cuda')
INFO:     Guided Decoding Backend = DecodingConfig(guided_decoding_backend='lm-format-enforcer')
INFO:     -------------------------------------------------------------------------------------
WARNING:  Reducing Torch parallelism from 8 threads to 1 to avoid unnecessary CPU contention. Set OMP_NUM_THREADS in the
external environment to tune this value as needed.
DEBUG:    Setting Triton cache manager to: aphrodite.triton_utils.custom_cache_manager:CustomCacheManager
(AphroditeWorkerProcess pid=11226) INFO:     Worker ready; awaiting tasks
DEBUG:    world_size=2 rank=0 local_rank=0 distributed_init_method=tcp://127.0.0.1:33955 backend=nccl
(AphroditeWorkerProcess pid=11226) DEBUG:    world_size=2 rank=1 local_rank=1 distributed_init_method=tcp://127.0.0.1:33955 backend=nccl
DEBUG:    Found nccl from library libnccl.so.2
(AphroditeWorkerProcess pid=11226) DEBUG:    Found nccl from library libnccl.so.2
DEBUG:    Aphrodite is using nccl==2.20.5
(AphroditeWorkerProcess pid=11226) DEBUG:    Aphrodite is using nccl==2.20.5
(AphroditeWorkerProcess pid=11226) DEBUG:    reading GPU P2P access cache from /home/khanonnie/.config/aphrodite/gpu_p2p_access_cache_for_0,1.json
DEBUG:    reading GPU P2P access cache from /home/khanonnie/.config/aphrodite/gpu_p2p_access_cache_for_0,1.json
DEBUG:    Aphrodite message queue communication handle: Handle(connect_ip='127.0.0.1', local_reader_ranks=[1],
buffer=\<aphrodite.distributed.device_communicators.shm_broadcast.ShmRingBuffer object at 0x7fe49d54d1d0>,
local_subscribe_port=44477, remote_subscribe_port=None)
INFO:     Loading model /mnt/nvme/llm/models/TechxGenus_Mistral-Large-Instruct-2407-AWQ...
⠏ Loading model weights... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 100% 60.44/60.44 GiB 0:00:49
INFO:     Model loaded in 53.60 seconds.
INFO:     Total model weights memory usage: 60.58 GiB
INFO:     Profiling peak memory usage...
INFO:     Killing local Aphrodite worker processes
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/endpoints/openai/rpc/server.py", line 214, in run_rpc_server
    server = AsyncEngineRPCServer(async_engine_args, rpc_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/endpoints/openai/rpc/server.py", line 29, in __init__
    self.engine = AsyncAphrodite.from_engine_args(async_engine_args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/engine/async_aphrodite.py", line 601, in from_engine_args
    engine = cls(
             ^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/engine/async_aphrodite.py", line 510, in __init__
    self.engine = self._init_engine(*args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/engine/async_aphrodite.py", line 694, in _init_engine
    return engine_class(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/engine/aphrodite_engine.py", line 274, in __init__
    self._initialize_kv_caches()
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/engine/aphrodite_engine.py", line 336, in _initialize_kv_caches
    self.model_executor.determine_num_available_blocks())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/executor/distributed_gpu_executor.py", line 35, in determine_num_available_blocks
    num_blocks = self._run_workers("determine_num_available_blocks", )
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/executor/multiproc_gpu_executor.py", line 189, in _run_workers
    driver_worker_output = driver_worker_method(*args, **kwargs)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/task_handler/worker.py", line 196, in determine_num_available_blocks
    self.model_runner.profile_run()
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/task_handler/model_runner.py", line 1125, in profile_run
    self.execute_model(model_input, kv_caches, intermediate_tensors)
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/task_handler/model_runner.py", line 1553, in execute_model
    hidden_or_intermediate_states = model_executable(
                                    ^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/modeling/models/llama.py", line 445, in forward
    model_output = self.model(input_ids, positions, kv_caches,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/modeling/models/llama.py", line 327, in forward
    hidden_states, residual = layer(
                              ^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/modeling/models/llama.py", line 249, in forward
    hidden_states = self.self_attn(
                    ^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/modeling/models/llama.py", line 176, in forward
    qkv, _ = self.qkv_proj(hidden_states)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/modeling/layers/linear.py", line 369, in forward
    output_parallel = self.quant_method.apply(self, input_, bias)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/quantization/awq_marlin.py", line 258, in apply
    return apply_awq_marlin_linear(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/quantization/utils/marlin_utils.py", line 289, in apply_awq_marlin_linear
    output = ops.gptq_marlin_gemm(reshaped_x,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/_custom_ops.py", line 28, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/llm/aphrodite-engine/aphrodite/_custom_ops.py", line 326, in gptq_marlin_gemm
    return torch.ops._C.gptq_marlin_gemm(a, b_q_weight, b_scales, b_zeros,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khanonnie/miniconda3/envs/aphrodite/lib/python3.11/site-packages/torch/_ops.py", line 1061, in __call__
    return self_._op(*args, **(kwargs or {}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: b_zeros dim 1 = 896 is not size_n = 7168
[rank0]:[W1102 19:38:20.694451703 CudaIPCTypes.cpp:16] Producer process has been terminated before all shared CUDA tensors released. See Note [Sharing CUDA tensors]

Other notes

  • I produced an HQQ quant, but ran into a few issues getting aphrodite to load that, which could be due to user error since I had to load the model across three cards to quantize it properly and I'm not sure that I did that properly. I will follow up in a separate ticket.
  • Using -q awq does pass the memory profiling step, but throws TypeError: SentencePieceTokenizer.encode() missing 2 required positional arguments: 'bos' and 'eos' when actually submitting a prompt. This also could just be user error or something wrong with the pre-quantized models I'm using, I've not been able to prepare my own AWQ quant of this model yet.
  • I'm not yet sure if this affects non-Mistral Large based models. Will try to test later this week.
@khanonnie khanonnie added the bug Something isn't working label Nov 5, 2024
@advpropsys
Copy link

Same here! Affects newer models with AutoAWQ quants.

@AlpinDale
Copy link
Member

For the sentencepiece error, removing the mistral tokenizer mode flag seems to resolve this. As discussed earlier, I will be separating the windows and Linux codepaths for the marlin kernels a bit more aggressively for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants