ホーム 暮らし The story of how BF16 was 1000x slower when I installed vLLM on a CPU server without a GPU

The story of how BF16 was 1000x slower when I installed vLLM on a CPU server without a GPU

三浦 拓海 三浦 拓海 • 更新: • 公開: • 読了約 23 分
目次

I run LLMs locally on my home server. I currently use LM Studio, but I wondered if vLLM might be faster, so I decided to install it and measure it.

To put it briefly, LM Studio won on all metrics.

Environment

na54ac3f0df9e
CPU    AMD Ryzen 9 5900X (Zen3 / AVX2)  ※8コアを割り当て
RAM    64 GB
GPU    なし
OS     Ubuntu 24.04 (Proxmox の LXC コンテナ)

This is a CPU inference environment without a GPU. It is no exaggeration to say that this is the crux of the whole story.

I am currently running Qwen3.6-35B-A3B (Q4_K_M, 21GB) on LM Studio.

I hit a wall right away in the comparison design

I thought, "I'll just run the 35B-A3B I'm currently using in vLLM and compare them," but this was impossible from the start.

The vLLM CPU backend can only handle FP32 / FP16 / BF16 and cannot read GGUF Q4 quantization. While vLLM does have GGUF support, it is a path intended for GPUs, and the CPU backend lacks the corresponding kernels.

In other words, the 21GB GGUF file I have cannot be used as-is, and it must be loaded in BF16. If you hold 35B weights in BF16, it takes about 70GB. It won't fit in 64GB of memory. Note that even with an MoE model where only 3B are active, all 35B weights must be placed in memory.

Therefore, I changed the comparison target to Qwen3-1.7B and decided to measure with consistent weight precision.

vLLM        : FP32 (safetensors)
LM Studio   : BF16 (GGUF)      ← 対等比較の相手
LM Studio   : Q4_K_M (GGUF)    ← 実運用構成の参考値

Since both provide an OpenAI-compatible API, I hit them with the same parameters from the same benchmark script. I standardized the context length at 16384, the parallel limit at 16, and the temperature at 0.

First, it wouldn't start

The CPU version of the vLLM wheel can be installed as follows. Since the standard version on PyPI is a CUDA build, you must specify the index for CPU.

uv pip install vllm \
  --extra-index-url https://wheels.vllm.ai/nightly/cpu \
  --index-strategy first-index --torch-backend cpu

The installation went through. However, the server would not start.

torch._inductor.exc.InductorError: InvalidCxxCompiler:
No working C++ compiler found

g++ was required. Because the vLLM CPU backend uses torch.compile (Inductor) to generate and compile C++ kernels at runtime, a compiler is needed in the execution environment. This is in contrast to LM Studio, which runs with just the bundled binaries.

When I installed g++ and tried again, this happened next.

fatal error: Python.h: No such file or directory

python3-dev was also required. After installing these two, it finally started.

By the way, --disable-log-requests has been deprecated in the current version and is rejected as an unknown argument. This is a point where you get stuck if you copy and paste commands from old articles.

It started. But it was abnormally slow

It took 427 seconds (7 minutes) to start. This is because the torch.compile compilation runs.

And when I tried generating, the 200-token output didn't finish even after several minutes. Thinking something was wrong, I checked the CPU usage and found this.

Worker プロセスのCPU使用率: 100.0%

Even though 8 cores were allocated, it was constantly using only one core's worth of capacity.

Even explicitly setting OMP_NUM_THREADS didn't change anything. Re-reading the logs, I found a concerning warning.

Failed to create oneDNN linear, fallback to torch linear.
Exception: could not create a primitive descriptor for the matmul primitive.

oneDNN (Intel's optimization library) could not create matrix multiplication primitives and was falling back to the raw torch implementation.

To isolate the cause, I stopped vLLM and measured torch's matrix multiplication directly.

About 1,000 times

torch matmul (256×2048×2048, 7スレッド, 中央値)

FP32        4.58 ms    468.9 GFLOP/s
BF16     4,937 ms        0.43 GFLOP/s
FP16     4,942 ms        0.43 GFLOP/s

BF16 matrix multiplication was about 1/1000th the speed of FP32. FP16 was the same. (The FP32 side is affected by other processes running simultaneously, so the ratio fluctuates between 800x and 1,200x depending on the load during measurement.)

The reason is clear. Zen3 does not have native instructions for BF16 or FP16. AVX512-BF16 came with Zen4, and AVX512 itself also started with Zen4. Since there were no instructions, torch was processing them via scalar emulation. This was the true identity of the "1 core at 100% and abnormally slow" issue.

Actually, the official vLLM documentation also states this:

So Zen3 was officially unsupported. AVX2 is treated as "limited features"; it runs, but it is not guaranteed.

When I switched to FP32, the oneDNN warning disappeared, and the startup time was reduced from 427 seconds to 114 seconds. Only then was I finally in a state where I could make a proper comparison.

Measurement Results

Generation Speed (tok/s, higher is better)
vLLM FP32           3.95
LM Studio BF16     11.35   ← 2.9倍
LM Studio Q4_K_M   28.87   ← 7.3倍

Even under equal conditions (FP32 vs BF16), there was a 2.9x difference.

Parallel Throughput (total tok/s, higher is better)

This is the area where vLLM is supposed to excel the most.

             vLLM    LMS BF16   LMS Q4_K_M
並列 1        3.80      11.27       27.48
並列 4        9.74      30.08       42.01
並列 8       14.13      40.25       42.91
並列16       17.89      39.97       46.16

Looking only at the scaling rate, vLLM shows the best improvement (at 1 to 16 parallel, 4.7x, while LM Studio's BF16 is 3.5x). Continuous batching is indeed working.

However, the starting point was too low. The 17.89 tok/s that vLLM finally reaches at 16 parallel is a level that LM Studio has already exceeded at 4 parallel (30.08 tok/s).

Prompt Processing (prefill, tok/s, higher is better)
             vLLM    LMS BF16   LMS Q4_K_M
1,024 tok    39.4       76.9       109.0
4,096 tok    30.6       68.6        91.6
8,192 tok    24.6       58.8        74.9

In real-time terms, it took vLLM 5 minutes and 34 seconds to read an 8,192-token input, while LM Studio (Q4_K_M) took 1 minute and 49 seconds.

Memory and startup time
                  メモリ(PSS)    起動時間
vLLM FP32          19.24 GB      114秒 (初回427秒)
LM Studio BF16      9.70 GB        7.3秒
LM Studio Q4_K_M    8.13 GB        4.0秒

Because FP32 is forced, memory usage is nearly doubled. The difference in startup time is also significant, and furthermore, vLLM runs a compilation every time the model or settings are changed.

A trap encountered during measurement: Prompt caching

In the initial measurement, the prefill numbers were behaving strangely.

8,192トークンの入力を 0.148秒で処理 = 55,526 tok/s

Calculated back from the actual performance of this CPU (approximately 470 GFLOP/s in FP32), this speed is impossible. The cause was that I was sending the same prompt three times and taking the median. From the second time onward, the prefix cache of both engines hit and skipped the prefill.

The numbers posted above were measured again by inserting a unique ID at the beginning of the prompt. I think this is a point to be careful about when benchmarking local LLMs.

Why is there such a big difference?

To summarize, three factors are overlapping.

1. Zen3 lacks BF16/FP16 instructions

The only dtypes vLLM can use are FP32/FP16/BF16. Since the latter two are effectively unusable, FP32 is the only choice.

2. The cost of being forced into FP32

Decoding is memory bandwidth-bound. With FP32, the memory weight doubles, which directly affects generation speed. Since llama.cpp can reduce bandwidth consumption to 1/8 with int4 quantization, the outcome is decided at this point.

3. Different directions of optimization

vLLM's PagedAttention and continuous batching are designed to handle many requests on GPUs with high computational density. On CPUs, the bottleneck shifts to memory bandwidth, so the advantages of this design are hard to realize.

On the other hand, llama.cpp has kernels hand-optimized for AVX2. The runtime selected by LM Studio was llama.cpp-linux-x86_64-avx2, which was a build specifically for this configuration.

In short, the playing field was different.

Conclusion

In a Zen3 environment without a GPU, I could not find a reason to introduce vLLM. I will continue to use LM Studio as is.

I believe it is worth reconsidering vLLM when one of the following changes.

  • Install a GPU — The environment vLLM was originally designed for. This is where PagedAttention and continuous batching finally take effect.

  • Update the CPU to Zen4 or later — AVX512 and BF16 instructions are included, bringing it into the scope of official support. However, as long as it is CPU inference, I don't think the gap with llama.cpp will be easily closed.

It is a fact that "vLLM is fast," but that was with the assumption of using a GPU. For CPU inference, llama.cpp, which was built for that purpose, is naturally stronger. It is a conclusion that might seem obvious, but I didn't fully grasp it until I saw the 1,000x figure with my own eyes.

I hope this serves as a reference for those considering a similar configuration.

Measurement date: August 25, 2026
vLLM 0.26.1.dev (nightly CPU wheel) / torch 2.13.0+cpu
LM Studio: llama.cpp-linux-x86_64-avx2 2.25.2
Model: Qwen3-1.7B / Context length 16384 / Max parallel 16 / Temperature 0 / Each measurement is the median

同じカテゴリの記事

三浦 拓海
コンテンツディレクター 三浦 拓海
プロフィールを見る →

映画と連続ドラマの公開情報を追う担当。配給会社のプレスシートと公式サイトの発表日を確認したうえで執筆します。

おすすめの関連記事