vllm - ✅(Solved) Fix [Bug]: MLA attention casts activations to int32 when using Marlin FP8 on GPUs without native FP8 support (sm < 89) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#38658Fetched 2026-04-08 01:58:42
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Error Message

RuntimeError: unsupported 'a' scalar_type

Root Cause

In vllm/model_executor/layers/quantization/fp8.py (line 284-286), GPUs with compute capability < 8.9 set use_marlin = True:

self.use_marlin = (
    not current_platform.has_device_capability(89)
    or envs.VLLM_TEST_FORCE_FP8_MARLIN
)

Then in prepare_fp8_layer_for_marlin(), the FP8 weights are repacked into Marlin's int32 format. After this, kv_b_proj.weight.dtype == torch.int32.

In mla_attention.py, the code assumes weight.dtype reflects the expected activation dtype, but after Marlin repacking this assumption is broken.

Fix Action

Fix / Workaround

============================== CPU Info

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 43 bits physical, 48 bits virtual CPU(s): 48 On-line CPU(s) list: 0-47 Thread(s) per core: 1 Core(s) per socket: 24 Socket(s): 2 NUMA node(s): 2 Vendor ID: AuthenticAMD CPU family: 23 Model: 49 Model name: AMD EPYC 7402 24-Core Processor Stepping: 0 Frequency boost: enabled CPU MHz: 2846.125 CPU max MHz: 3349.6089 CPU min MHz: 1500.0000 BogoMIPS: 5599.93 Virtualization: AMD-V L1d cache: 1.5 MiB L1i cache: 1.5 MiB L2 cache: 24 MiB L3 cache: 256 MiB NUMA node0 CPU(s): 0-23 NUMA node1 CPU(s): 24-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 Reg file data sampling: Not affected Vulnerability Retbleed: Mitigation; untrained return thunk; SMT disabled Vulnerability Spec rstack overflow: Mitigation; SMT disabled 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; Retpolines, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected 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 pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip rdpid overflow_recov succor smca sme sev sev_es

PR fix notes

PR #38771: [Bugfix] Fix MLA kv_b_proj activation dtype with Marlin FP8

Description (problem / solution / changelog)

Purpose

Fixes #38658.

This PR fixes an MLA prefill dtype bug when FP8 weights are served through the Marlin path on GPUs without native FP8 support (sm < 89).

On affected GPUs, Marlin repacks FP8 weights into torch.int32. In vllm/model_executor/layers/attention/mla_attention.py, _compute_prefill_context() was using self.kv_b_proj.weight.dtype to determine how to cast kv_c_normed before passing it to kv_b_proj.

After Marlin repacking, that dtype becomes torch.int32, which reflects the packed storage format rather than the expected activation compute dtype. This can cause MLA to cast activations to int32, and the Marlin kernel then fails with: RuntimeError: unsupported 'a' scalar_type

This change switches MLA to use self.kv_b_proj.params_dtype, which correctly tracks the layer's compute/input dtype even when the stored weight tensor has been repacked.

This PR also adds a focused regression test covering the dtype selection logic in _compute_prefill_context().

Test Plan

Targeted regression and unit coverage

python -m pytest tests/model_executor/layers/attention/test_mla_attention.py -v

Local reproduction

Reproduced the root cause locally on an affected GPU (sm_86) and confirmed that using the repacked torch.int32 storage dtype for activation casting triggers RuntimeError: unsupported 'a' scalar_type

Test Result

Hardware used for local reproduction

  • AWS EC2 g5.xlarge
  • GPU: NVIDIA A10G
  • CUDA capability: sm_86

Targeted regression test

tests/model_executor/layers/attention/test_mla_attention.py::test_compute_prefill_context_uses_kv_b_proj_params_dtype PASSED

Local validation before fix

Verified the failure mechanism described in the issue:

  • Marlin repacks FP8 weights to torch.int32
  • the old MLA logic selected weight.dtype
  • activations were cast to int32
  • Marlin failed with: RuntimeError: unsupported 'a' scalar_type

Changed files

  • tests/model_executor/layers/attention/test_mla_attention.py (added, +72/-0)
  • vllm/model_executor/layers/attention/mla_attention.py (modified, +6/-15)

Code Example

For security purposes, please feel free to check the contents of collect_env.py before running it.
python collect_env.py
--2026-03-31 17:05:06--  https://raw.githubusercontent.com/vllm-project/vllm/main/vllm/collect_env.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8001::154, 2606:50c0:8000::154, 2606:50c0:8003::154, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8001::154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27835 (27K) [text/plain]
Saving to: ‘collect_env.py’

collect_env.py                                   100%[=========================================================================================================>]  27.18K  --.-KB/s    in 0.001s  

2026-03-31 17:05:06 (18.5 MB/s) - ‘collect_env.py’ saved [27835/27835]

Collecting environment information...
==============================
        System Info
==============================
OS                           : Debian GNU/Linux 11 (bullseye) (x86_64)
GCC version                  : (Debian 10.2.1-6) 10.2.1 20210110
Clang version                : 11.0.1-2
CMake version                : version 3.18.4
Libc version                 : glibc-2.31

==============================
       PyTorch Info
==============================
PyTorch version              : 2.10.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.11.13 (main, Jun  5 2025, 13:12:00) [GCC 11.2.0] (64-bit runtime)
Python platform              : Linux-5.10.0-34-amd64-x86_64-with-glibc2.31

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : Could not collect
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : 
GPU 0: NVIDIA RTX A6000
GPU 1: NVIDIA RTX A6000
GPU 2: NVIDIA RTX A6000
GPU 3: NVIDIA RTX A6000
GPU 4: NVIDIA RTX A6000
GPU 5: NVIDIA RTX A6000
GPU 6: NVIDIA RTX A6000
GPU 7: NVIDIA RTX A6000

Nvidia driver version        : 550.54.15
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
Address sizes:                        43 bits physical, 48 bits virtual
CPU(s):                               48
On-line CPU(s) list:                  0-47
Thread(s) per core:                   1
Core(s) per socket:                   24
Socket(s):                            2
NUMA node(s):                         2
Vendor ID:                            AuthenticAMD
CPU family:                           23
Model:                                49
Model name:                           AMD EPYC 7402 24-Core Processor
Stepping:                             0
Frequency boost:                      enabled
CPU MHz:                              2846.125
CPU max MHz:                          3349.6089
CPU min MHz:                          1500.0000
BogoMIPS:                             5599.93
Virtualization:                       AMD-V
L1d cache:                            1.5 MiB
L1i cache:                            1.5 MiB
L2 cache:                             24 MiB
L3 cache:                             256 MiB
NUMA node0 CPU(s):                    0-23
NUMA node1 CPU(s):                    24-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 Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; untrained return thunk; SMT disabled
Vulnerability Spec rstack overflow:   Mitigation; SMT disabled
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; Retpolines, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
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 pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip rdpid overflow_recov succor smca sme sev sev_es

==============================
Versions of relevant libraries
==============================
[pip3] flake8==7.3.0
[pip3] flashinfer-python==0.6.6
[pip3] mypy==1.17.1
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.2
[pip3] nvidia-cutlass-dsl-libs-base==4.4.2
[pip3] nvidia-ml-py==13.595.45
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torch_memory_saver==0.0.9
[pip3] torchao==0.9.0
[pip3] torchaudio==2.10.0
[pip3] torchcodec==0.8.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.1
[pip3] triton==3.6.0
[conda] flashinfer-python         0.6.6                    pypi_0    pypi
[conda] numpy                     2.2.6                    pypi_0    pypi
[conda] nvidia-cublas-cu12        12.8.4.1                 pypi_0    pypi
[conda] nvidia-cuda-cupti-cu12    12.8.90                  pypi_0    pypi
[conda] nvidia-cuda-nvrtc-cu12    12.8.93                  pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.8.90                  pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.10.2.21                pypi_0    pypi
[conda] nvidia-cudnn-frontend     1.18.0                   pypi_0    pypi
[conda] nvidia-cufft-cu12         11.3.3.83                pypi_0    pypi
[conda] nvidia-cufile-cu12        1.13.1.3                 pypi_0    pypi
[conda] nvidia-curand-cu12        10.3.9.90                pypi_0    pypi
[conda] nvidia-cusolver-cu12      11.7.3.90                pypi_0    pypi
[conda] nvidia-cusparse-cu12      12.5.8.93                pypi_0    pypi
[conda] nvidia-cusparselt-cu12    0.7.1                    pypi_0    pypi
[conda] nvidia-cutlass-dsl        4.4.2                    pypi_0    pypi
[conda] nvidia-cutlass-dsl-libs-base 4.4.2                    pypi_0    pypi
[conda] nvidia-ml-py              13.595.45                pypi_0    pypi
[conda] nvidia-nccl-cu12          2.27.5                   pypi_0    pypi
[conda] nvidia-nvjitlink-cu12     12.8.93                  pypi_0    pypi
[conda] nvidia-nvshmem-cu12       3.4.5                    pypi_0    pypi
[conda] nvidia-nvtx-cu12          12.8.90                  pypi_0    pypi
[conda] pyzmq                     27.1.0          py311h2315fbb_0    conda-forge
[conda] torch                     2.10.0                   pypi_0    pypi
[conda] torch-c-dlpack-ext        0.1.5                    pypi_0    pypi
[conda] torch-memory-saver        0.0.9                    pypi_0    pypi
[conda] torchao                   0.9.0                    pypi_0    pypi
[conda] torchaudio                2.10.0                   pypi_0    pypi
[conda] torchcodec                0.8.0                    pypi_0    pypi
[conda] torchvision               0.25.0                   pypi_0    pypi
[conda] transformers              4.57.1                   pypi_0    pypi
[conda] triton                    3.6.0                    pypi_0    pypi

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.18.1
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
        GPU0    GPU1    GPU2    GPU3    GPU4    GPU5    GPU6    GPU7    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      SYS     SYS     SYS     SYS     SYS     SYS     NV4     0-23    0               N/A
GPU1    SYS      X      PHB     SYS     NV4     SYS     SYS     SYS     0-23    0               N/A
GPU2    SYS     PHB      X      NV4     SYS     SYS     SYS     SYS     0-23    0               N/A
GPU3    SYS     SYS     NV4      X      SYS     SYS     SYS     SYS     0-23    0               N/A
GPU4    SYS     NV4     SYS     SYS      X      SYS     SYS     SYS     24-47   1               N/A
GPU5    SYS     SYS     SYS     SYS     SYS      X      NV4     SYS     24-47   1               N/A
GPU6    SYS     SYS     SYS     SYS     SYS     NV4      X      PHB     24-47   1               N/A
GPU7    NV4     SYS     SYS     SYS     SYS     SYS     PHB      X      24-47   1               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

==============================
     Environment Variables
==============================
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1

---

_kv_b_proj_w_dtype = (
    self.kv_b_proj.weight.dtype          # ← returns int32 after Marlin repacking!
    if hasattr(self.kv_b_proj, "weight")
    else self.kv_b_proj.params_dtype
)
...
kv_c_normed = kv_c_normed.to(_kv_b_proj_w_dtype)  # ← casts activation to int32!

---

RuntimeError: unsupported 'a' scalar_type

---

# Serve the model on any GPU with compute capability < 8.9 (e.g., A6000, A100)
vllm serve mistralai/Leanstral-2603 \
  --tokenizer-mode mistral \
  --config-format mistral \
  --load-format mistral \
  --tensor-parallel-size 8 \
  --gpu-memory-utilization 0.95 \
  --max-model-len 8192 \
  --dtype bfloat16 \
  --enforce-eager \
  --host 0.0.0.0 \
  --port 8000

---

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistralai/Leanstral-2603",
    "messages": [{"role": "user", "content": "Hello"}],
    "max_tokens": 64
  }'

---

RuntimeError: unsupported 'a' scalar_type

  File "vllm/model_executor/models/pixtral.py", line 381, in forward
  File "vllm/model_executor/models/deepseek_v2.py", line 1197, in forward
  File "vllm/model_executor/layers/attention/mla_attention.py", line 2509, in forward
    → kv_nope = self.kv_b_proj(kv_c_normed)[0].view(...)
  File "vllm/model_executor/layers/linear.py", line 582, in forward
  File "vllm/model_executor/layers/quantization/fp8.py", line 499, in apply
  File "vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py", line 69, in apply_fp8_marlin_linear
return ops.gptq_marlin_gemm(...)

---

self.use_marlin = (
    not current_platform.has_device_capability(89)
    or envs.VLLM_TEST_FORCE_FP8_MARLIN
)

---

- _kv_b_proj_w_dtype = (
-     self.kv_b_proj.weight.dtype
-     if hasattr(self.kv_b_proj, "weight")
-     else self.kv_b_proj.params_dtype
- )
+ _kv_b_proj_w_dtype = self.kv_b_proj.params_dtype
RAW_BUFFERClick to expand / collapse

Your current environment

For security purposes, please feel free to check the contents of collect_env.py before running it.
python collect_env.py
--2026-03-31 17:05:06--  https://raw.githubusercontent.com/vllm-project/vllm/main/vllm/collect_env.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8001::154, 2606:50c0:8000::154, 2606:50c0:8003::154, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8001::154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27835 (27K) [text/plain]
Saving to: ‘collect_env.py’

collect_env.py                                   100%[=========================================================================================================>]  27.18K  --.-KB/s    in 0.001s  

2026-03-31 17:05:06 (18.5 MB/s) - ‘collect_env.py’ saved [27835/27835]

Collecting environment information...
==============================
        System Info
==============================
OS                           : Debian GNU/Linux 11 (bullseye) (x86_64)
GCC version                  : (Debian 10.2.1-6) 10.2.1 20210110
Clang version                : 11.0.1-2
CMake version                : version 3.18.4
Libc version                 : glibc-2.31

==============================
       PyTorch Info
==============================
PyTorch version              : 2.10.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.11.13 (main, Jun  5 2025, 13:12:00) [GCC 11.2.0] (64-bit runtime)
Python platform              : Linux-5.10.0-34-amd64-x86_64-with-glibc2.31

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : Could not collect
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : 
GPU 0: NVIDIA RTX A6000
GPU 1: NVIDIA RTX A6000
GPU 2: NVIDIA RTX A6000
GPU 3: NVIDIA RTX A6000
GPU 4: NVIDIA RTX A6000
GPU 5: NVIDIA RTX A6000
GPU 6: NVIDIA RTX A6000
GPU 7: NVIDIA RTX A6000

Nvidia driver version        : 550.54.15
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
Address sizes:                        43 bits physical, 48 bits virtual
CPU(s):                               48
On-line CPU(s) list:                  0-47
Thread(s) per core:                   1
Core(s) per socket:                   24
Socket(s):                            2
NUMA node(s):                         2
Vendor ID:                            AuthenticAMD
CPU family:                           23
Model:                                49
Model name:                           AMD EPYC 7402 24-Core Processor
Stepping:                             0
Frequency boost:                      enabled
CPU MHz:                              2846.125
CPU max MHz:                          3349.6089
CPU min MHz:                          1500.0000
BogoMIPS:                             5599.93
Virtualization:                       AMD-V
L1d cache:                            1.5 MiB
L1i cache:                            1.5 MiB
L2 cache:                             24 MiB
L3 cache:                             256 MiB
NUMA node0 CPU(s):                    0-23
NUMA node1 CPU(s):                    24-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 Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; untrained return thunk; SMT disabled
Vulnerability Spec rstack overflow:   Mitigation; SMT disabled
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; Retpolines, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
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 pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip rdpid overflow_recov succor smca sme sev sev_es

==============================
Versions of relevant libraries
==============================
[pip3] flake8==7.3.0
[pip3] flashinfer-python==0.6.6
[pip3] mypy==1.17.1
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.2
[pip3] nvidia-cutlass-dsl-libs-base==4.4.2
[pip3] nvidia-ml-py==13.595.45
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torch_memory_saver==0.0.9
[pip3] torchao==0.9.0
[pip3] torchaudio==2.10.0
[pip3] torchcodec==0.8.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.1
[pip3] triton==3.6.0
[conda] flashinfer-python         0.6.6                    pypi_0    pypi
[conda] numpy                     2.2.6                    pypi_0    pypi
[conda] nvidia-cublas-cu12        12.8.4.1                 pypi_0    pypi
[conda] nvidia-cuda-cupti-cu12    12.8.90                  pypi_0    pypi
[conda] nvidia-cuda-nvrtc-cu12    12.8.93                  pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.8.90                  pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.10.2.21                pypi_0    pypi
[conda] nvidia-cudnn-frontend     1.18.0                   pypi_0    pypi
[conda] nvidia-cufft-cu12         11.3.3.83                pypi_0    pypi
[conda] nvidia-cufile-cu12        1.13.1.3                 pypi_0    pypi
[conda] nvidia-curand-cu12        10.3.9.90                pypi_0    pypi
[conda] nvidia-cusolver-cu12      11.7.3.90                pypi_0    pypi
[conda] nvidia-cusparse-cu12      12.5.8.93                pypi_0    pypi
[conda] nvidia-cusparselt-cu12    0.7.1                    pypi_0    pypi
[conda] nvidia-cutlass-dsl        4.4.2                    pypi_0    pypi
[conda] nvidia-cutlass-dsl-libs-base 4.4.2                    pypi_0    pypi
[conda] nvidia-ml-py              13.595.45                pypi_0    pypi
[conda] nvidia-nccl-cu12          2.27.5                   pypi_0    pypi
[conda] nvidia-nvjitlink-cu12     12.8.93                  pypi_0    pypi
[conda] nvidia-nvshmem-cu12       3.4.5                    pypi_0    pypi
[conda] nvidia-nvtx-cu12          12.8.90                  pypi_0    pypi
[conda] pyzmq                     27.1.0          py311h2315fbb_0    conda-forge
[conda] torch                     2.10.0                   pypi_0    pypi
[conda] torch-c-dlpack-ext        0.1.5                    pypi_0    pypi
[conda] torch-memory-saver        0.0.9                    pypi_0    pypi
[conda] torchao                   0.9.0                    pypi_0    pypi
[conda] torchaudio                2.10.0                   pypi_0    pypi
[conda] torchcodec                0.8.0                    pypi_0    pypi
[conda] torchvision               0.25.0                   pypi_0    pypi
[conda] transformers              4.57.1                   pypi_0    pypi
[conda] triton                    3.6.0                    pypi_0    pypi

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.18.1
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
        GPU0    GPU1    GPU2    GPU3    GPU4    GPU5    GPU6    GPU7    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      SYS     SYS     SYS     SYS     SYS     SYS     NV4     0-23    0               N/A
GPU1    SYS      X      PHB     SYS     NV4     SYS     SYS     SYS     0-23    0               N/A
GPU2    SYS     PHB      X      NV4     SYS     SYS     SYS     SYS     0-23    0               N/A
GPU3    SYS     SYS     NV4      X      SYS     SYS     SYS     SYS     0-23    0               N/A
GPU4    SYS     NV4     SYS     SYS      X      SYS     SYS     SYS     24-47   1               N/A
GPU5    SYS     SYS     SYS     SYS     SYS      X      NV4     SYS     24-47   1               N/A
GPU6    SYS     SYS     SYS     SYS     SYS     NV4      X      PHB     24-47   1               N/A
GPU7    NV4     SYS     SYS     SYS     SYS     SYS     PHB      X      24-47   1               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

==============================
     Environment Variables
==============================
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1

🐛 Describe the bug

Bug description

When serving an FP8-quantized model with MLA attention on GPUs that lack native FP8 hardware support (compute capability < 8.9, e.g. A6000/A100), vllm routes FP8 linear operations through the Marlin W8A16 kernel. As part of Marlin's weight preparation, FP8 weights are repacked into torch.int32 format via pack_fp8_to_int32() + gptq_marlin_repack().

The bug is in _compute_prefill_context() in vllm/model_executor/layers/attention/mla_attention.py. The code reads self.kv_b_proj.weight.dtype to determine the dtype to cast activations to before passing them to the linear layer:

_kv_b_proj_w_dtype = (
    self.kv_b_proj.weight.dtype          # ← returns int32 after Marlin repacking!
    if hasattr(self.kv_b_proj, "weight")
    else self.kv_b_proj.params_dtype
)
...
kv_c_normed = kv_c_normed.to(_kv_b_proj_w_dtype)  # ← casts activation to int32!

After Marlin FP8 repacking, self.kv_b_proj.weight.dtype is torch.int32 (the packed Marlin format), not the original compute dtype. This causes kv_c_normed to be cast to int32, which the Marlin CUDA kernel rejects with:

RuntimeError: unsupported 'a' scalar_type

The Marlin kernel only accepts float16, bfloat16, float8_e4m3fn, or int8 for the activation (a) tensor.

How to reproduce

# Serve the model on any GPU with compute capability < 8.9 (e.g., A6000, A100)
vllm serve mistralai/Leanstral-2603 \
  --tokenizer-mode mistral \
  --config-format mistral \
  --load-format mistral \
  --tensor-parallel-size 8 \
  --gpu-memory-utilization 0.95 \
  --max-model-len 8192 \
  --dtype bfloat16 \
  --enforce-eager \
  --host 0.0.0.0 \
  --port 8000

The server starts and loads the model successfully. The crash occurs on the first inference request:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistralai/Leanstral-2603",
    "messages": [{"role": "user", "content": "Hello"}],
    "max_tokens": 64
  }'

Error traceback

RuntimeError: unsupported 'a' scalar_type

  File "vllm/model_executor/models/pixtral.py", line 381, in forward
  File "vllm/model_executor/models/deepseek_v2.py", line 1197, in forward
  File "vllm/model_executor/layers/attention/mla_attention.py", line 2509, in forward
    → kv_nope = self.kv_b_proj(kv_c_normed)[0].view(...)
  File "vllm/model_executor/layers/linear.py", line 582, in forward
  File "vllm/model_executor/layers/quantization/fp8.py", line 499, in apply
  File "vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py", line 69, in apply_fp8_marlin_linear
    → return ops.gptq_marlin_gemm(...)

All 8 worker processes crash with the same error.

Root cause

In vllm/model_executor/layers/quantization/fp8.py (line 284-286), GPUs with compute capability < 8.9 set use_marlin = True:

self.use_marlin = (
    not current_platform.has_device_capability(89)
    or envs.VLLM_TEST_FORCE_FP8_MARLIN
)

Then in prepare_fp8_layer_for_marlin(), the FP8 weights are repacked into Marlin's int32 format. After this, kv_b_proj.weight.dtype == torch.int32.

In mla_attention.py, the code assumes weight.dtype reflects the expected activation dtype, but after Marlin repacking this assumption is broken.

Suggested fix

Replace self.kv_b_proj.weight.dtype with self.kv_b_proj.params_dtype. The params_dtype attribute is always available on LinearBase subclasses and correctly reflects the model's compute dtype (e.g. float16 or bfloat16), regardless of how weights are stored internally.

- _kv_b_proj_w_dtype = (
-     self.kv_b_proj.weight.dtype
-     if hasattr(self.kv_b_proj, "weight")
-     else self.kv_b_proj.params_dtype
- )
+ _kv_b_proj_w_dtype = self.kv_b_proj.params_dtype

After applying the fix, the model serves successfully and produces correct inference results on 8x A6000 GPUs with --dtype bfloat16 --enforce-eager.

Affected configurations

Any FP8-quantized model using MLA attention served on GPUs with compute capability < 8.9, including:

  • GPUs: A6000, A100, and other Ampere GPUs (sm_86, sm_80)
  • Models: mistralai/Leanstral-2603, and potentially any other FP8-quantized DeepSeek V2 / MLA-based model

GPUs with compute capability >= 8.9 (e.g., H100, L40S) are not affected because they use native FP8 compute and do not go through the Marlin repacking path.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

TL;DR

Replace self.kv_b_proj.weight.dtype with self.kv_b_proj.params_dtype in mla_attention.py to correctly determine the activation dtype.

Guidance

  • Identify the affected models and GPUs: FP8-quantized models using MLA attention served on GPUs with compute capability < 8.9 (e.g., A6000, A100).
  • Update the mla_attention.py file with the suggested fix to ensure correct activation dtype.
  • Verify the fix by serving the model and checking for correct inference results.
  • Be aware that GPUs with compute capability >= 8.9 (e.g., H100, L40S) are not affected.

Example

The corrected code in mla_attention.py should look like this:

- _kv_b_proj_w_dtype = (
-     self.kv_b_proj.weight.dtype
-     if hasattr(self.kv_b_proj, "weight")
-     else self.kv_b_proj.params_dtype
- )
+ _kv_b_proj_w_dtype = self.kv_b_proj.params_dtype

Notes

This fix assumes that self.kv_b_proj.params_dtype correctly reflects the model's compute dtype. If this is not the case, further investigation may be needed.

Recommendation

Apply the suggested fix to mla_attention.py to resolve the issue, as it correctly determines the activation dtype and allows the model to serve successfully on affected GPUs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING