vllm - ✅(Solved) Fix [Bug]: CPUFusedMOE raises IndexError when running EP across CPU-only nodes [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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#38033Fetched 2026-04-08 01:26:58
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

Error Message

(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932] File "/root/venv/lib/python3.12/site-packages/vllm/model_executor/layers/fused_moe/cpu_fused_moe.py", line 446, in cpu_fused_moe_torch (Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932] gate_up = layer.gate_up_lineari # type: ignore (Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932] ~~~~~~~~~~~~~~~~~~~~^^^ (Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932] IndexError: list index out of range

Fix Action

Fix / Workaround

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

Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 144 On-line CPU(s) list: 0-143 Vendor ID: ARM BIOS Vendor ID: NVIDIA Model name: Neoverse-V2 BIOS Model name: Grace A02 AOM-SCM-NV CPU @ 3.4GHz BIOS CPU family: 258 Model: 0 Thread(s) per core: 1 Core(s) per socket: 72 Socket(s): 2 Stepping: r0p0 BogoMIPS: 2000.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm ssbs sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti L1d cache: 9 MiB (144 instances) L1i cache: 9 MiB (144 instances) L2 cache: 144 MiB (144 instances) L3 cache: 228 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-71 NUMA node1 CPU(s): 72-143 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: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected

PR fix notes

PR #38055: [Bugfix][CPU][v1] Fix IndexError in CPUWorker for multi-node DP/EP on CPU-only nodes

Description (problem / solution / changelog)

Purpose

Fix IndexError in CPU Worker when using multi-node distributed inference with Data Parallelism (DP) or Expert Parallelism (EP).

Fixes #38033

Problem: In multi-node DP/EP scenarios, CPUWorker.init_device() uses global self.rank to index omp_cpuids_list, which has been sliced to local scope. This causes IndexError: list index out of range on worker nodes (e.g., node 1 with rank 2, 3).

Example scenario:

  • 2 nodes, TP=2, DP/EP enabled
  • Node 0: rank 0, 1 → works fine
  • Node 1: rank 2, 3 → IndexError when accessing sliced list (length=2, but trying to access index 2, 3)

Solution:

  • Use rank % world_size to calculate local index in DP mode
  • Add defensive checks for misconfigured VLLM_CPU_OMP_THREADS_BIND
  • Provide clear error messages instead of generic IndexError

Test Plan

  1. Unit tests: Added 3 unit tests to verify the fix
  2. Manual testing: Simulate multi-node DP scenario with the fix
# Run unit tests
pytest tests/v1/worker/test_cpu_worker.py -v

# Run linter checks
python -m ruff check vllm/v1/worker/cpu_worker.py

Test Result

collected 3 items

tests/v1/worker/test_cpu_worker.py::test_omp_threads_bind_dp_mode_multi_node PASSED [ 33%]

tests/v1/worker/test_cpu_worker.py::test_omp_threads_bind_misconfigured_non_dp PASSED [ 66%] tests/v1/worker/test_cpu_worker.py::test_omp_threads_bind_misconfigured_dp_mode PASSED [100%]

Changed files

  • tests/v1/worker/test_cpu_worker.py (added, +191/-0)
  • vllm/v1/worker/cpu_worker.py (modified, +33/-4)

Code Example

==============================
        System Info
==============================
OS                           : Ubuntu 24.04.3 LTS (aarch64)
GCC version                  : (Ubuntu 11.5.0-1ubuntu1~24.04.1) 11.5.0
Clang version                : Could not collect
CMake version                : version 3.31.6
Libc version                 : glibc-2.39

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

==============================
      Python Environment
==============================
Python version               : 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.8.0-90-generic-aarch64-with-glibc2.39

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : False
CUDA runtime version         : No CUDA
CUDA_MODULE_LOADING set to   : N/A
GPU models and configuration : No CUDA
Nvidia driver version        : No CUDA
cuDNN version                : No CUDA
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         aarch64
CPU op-mode(s):                       64-bit
Byte Order:                           Little Endian
CPU(s):                               144
On-line CPU(s) list:                  0-143
Vendor ID:                            ARM
BIOS Vendor ID:                       NVIDIA
Model name:                           Neoverse-V2
BIOS Model name:                      Grace A02 AOM-SCM-NV CPU @ 3.4GHz
BIOS CPU family:                      258
Model:                                0
Thread(s) per core:                   1
Core(s) per socket:                   72
Socket(s):                            2
Stepping:                             r0p0
BogoMIPS:                             2000.00
Flags:                                fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm ssbs sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti
L1d cache:                            9 MiB (144 instances)
L1i cache:                            9 MiB (144 instances)
L2 cache:                             144 MiB (144 instances)
L3 cache:                             228 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-71
NUMA node1 CPU(s):                    72-143
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:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; __user pointer sanitization
Vulnerability Spectre v2:             Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Not affected

==============================
Versions of relevant libraries
==============================
[pip3] numpy==2.2.6
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torchaudio==2.11.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.6
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.16.0rc2.dev19+gd9206135d (git sha: d9206135d)
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
  Could not collect

==============================
     Environment Variables
==============================
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_root

---

vllm serve Qwen/Qwen1.5-MoE-A2.7B --tensor-parallel-size 2 --enable-expert-parallel --nnodes 2 --node-rank 0 --master-addr <ip-addr>
vllm serve Qwen/Qwen1.5-MoE-A2.7B --tensor-parallel-size 2 --enable-expert-parallel --nnodes 2 --node-rank 1 --master-addr <ip-addr> --headless

---

(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932]   File "/root/venv/lib/python3.12/site-packages/vllm/model_executor/layers/fused_moe/cpu_fused_moe.py", line 446, in cpu_fused_moe_torch
(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932]     gate_up = layer.gate_up_linear[i](tokens_for_this_expert)  # type: ignore
(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932]               ~~~~~~~~~~~~~~~~~~~~^^^
(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932] IndexError: list index out of range
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>

Not sure why it shows my version number is 0.16.0rc2.dev19+gd9206135d, while I'm on 0.18.0. The output of vllm --version shows the correct version of 0.18.0.

==============================
        System Info
==============================
OS                           : Ubuntu 24.04.3 LTS (aarch64)
GCC version                  : (Ubuntu 11.5.0-1ubuntu1~24.04.1) 11.5.0
Clang version                : Could not collect
CMake version                : version 3.31.6
Libc version                 : glibc-2.39

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

==============================
      Python Environment
==============================
Python version               : 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.8.0-90-generic-aarch64-with-glibc2.39

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : False
CUDA runtime version         : No CUDA
CUDA_MODULE_LOADING set to   : N/A
GPU models and configuration : No CUDA
Nvidia driver version        : No CUDA
cuDNN version                : No CUDA
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         aarch64
CPU op-mode(s):                       64-bit
Byte Order:                           Little Endian
CPU(s):                               144
On-line CPU(s) list:                  0-143
Vendor ID:                            ARM
BIOS Vendor ID:                       NVIDIA
Model name:                           Neoverse-V2
BIOS Model name:                      Grace A02 AOM-SCM-NV CPU @ 3.4GHz
BIOS CPU family:                      258
Model:                                0
Thread(s) per core:                   1
Core(s) per socket:                   72
Socket(s):                            2
Stepping:                             r0p0
BogoMIPS:                             2000.00
Flags:                                fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm ssbs sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti
L1d cache:                            9 MiB (144 instances)
L1i cache:                            9 MiB (144 instances)
L2 cache:                             144 MiB (144 instances)
L3 cache:                             228 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-71
NUMA node1 CPU(s):                    72-143
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:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; __user pointer sanitization
Vulnerability Spectre v2:             Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Not affected

==============================
Versions of relevant libraries
==============================
[pip3] numpy==2.2.6
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torchaudio==2.11.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.6
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.16.0rc2.dev19+gd9206135d (git sha: d9206135d)
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
  Could not collect

==============================
     Environment Variables
==============================
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_root
</details>

🐛 Describe the bug

Launching TP=2 with EP enabled on 2 CPU-only nodes

vllm serve Qwen/Qwen1.5-MoE-A2.7B --tensor-parallel-size 2 --enable-expert-parallel --nnodes 2 --node-rank 0 --master-addr <ip-addr>
vllm serve Qwen/Qwen1.5-MoE-A2.7B --tensor-parallel-size 2 --enable-expert-parallel --nnodes 2 --node-rank 1 --master-addr <ip-addr> --headless

It fails when warming up the model with the following error message:

(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932]   File "/root/venv/lib/python3.12/site-packages/vllm/model_executor/layers/fused_moe/cpu_fused_moe.py", line 446, in cpu_fused_moe_torch
(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932]     gate_up = layer.gate_up_linear[i](tokens_for_this_expert)  # type: ignore
(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932]               ~~~~~~~~~~~~~~~~~~~~^^^
(Worker_TP0_EP0 pid=45559) ERROR 03-24 20:08:07 [multiproc_executor.py:932] IndexError: list index out of range

When EP is enabled, it should only be allowed to access experts on its local rank, and gather the outputs from other ranks if needed for following layers.

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

Fix Plan

To fix the IndexError: list index out of range issue, we need to ensure that the gate_up_linear list is accessed within its valid index range.

Here are the steps to resolve the issue:

  • Check the cpu_fused_moe_torch function in cpu_fused_moe.py to see how gate_up_linear is defined and used.
  • Verify that the index i is within the valid range of gate_up_linear.
  • Modify the code to handle cases where i might be out of range.

Example code changes:

# cpu_fused_moe.py
def cpu_fused_moe_torch(self, tokens_for_this_expert):
    # ...
    for i in range(len(self.gate_up_linear)):
        if i < len(self.gate_up_linear):  # Check if i is within range
            gate_up = self.gate_up_linear[i](tokens_for_this_expert)
            # ...
        else:
            # Handle out of range case
            print(f"Index {i} is out of range for gate_up_linear")
            # You can either skip this iteration or raise a custom error
            continue
    # ...

Alternatively, you can also modify the code to dynamically adjust the index i based on the length of gate_up_linear.

Verification

To verify that the fix worked, you can:

  • Run the vllm serve command with the modified code and check if the IndexError is resolved.
  • Test the model with different inputs and expert parallelism settings to ensure that the fix does not introduce any new issues.

Extra Tips

  • Make sure to test the modified code thoroughly to ensure that it does not introduce any new bugs or performance issues.
  • Consider adding additional error handling and logging to help diagnose any future issues.
  • If you are still experiencing issues, try to isolate the problem by testing individual components of the model and expert parallelism setup.

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