vllm - ✅(Solved) Fix [Bug]: [CPU Backend] No CPU profiler summary equivalent; CUDA summary flag is silently disabled on CPU [3 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#38131Fetched 2026-04-08 01:32:08
View on GitHub
Comments
1
Participants
2
Timeline
13
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3labeled ×2project_v2_item_status_changed ×2subscribed ×2

Fix Action

Fix / Workaround

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

Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 96 On-line CPU(s) list: 0-95 Vendor ID: ARM Model name: Neoverse-V2 Model: 1 Thread(s) per core: 1 Core(s) per socket: 96 Socket(s): 1 Stepping: r0p1 BogoMIPS: 2000.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti L1d cache: 6 MiB (96 instances) L1i cache: 6 MiB (96 instances) L2 cache: 192 MiB (96 instances) L3 cache: 36 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-95 Vulnerability Gather data sampling: Not affected Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: 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: Mitigation; CSV2, BHB Vulnerability Srbds: Not affected Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected

PR fix notes

PR #38324: [Bugfix] Preserve torch profiler summary output on CPU

Description (problem / solution / changelog)

Purpose

Fixes #38131.

On the CPU backend, torch_profiler_dump_cuda_time_total=True was being silently overridden to False in CpuPlatform.check_and_update_config, which meant CPU torch profiling produced trace files but did not write a human-readable profiler_out_<rank>.txt summary even though CPU summary data was available.

This PR preserves the existing flag on CPU and, for CPU-only torch profiling, writes the summary file using self_cpu_time_total. GPU behavior remains unchanged.

I also updated the profiler docs to reflect that this flag now produces a backend-specific self-time summary, and added a regression test covering CPU summary file generation.

I checked the linked issue and searched open PRs referencing #38131 and related CPU profiler summary terms before preparing this change, and did not find an overlapping open PR.

This PR includes AI-assisted code generation/editing. I reviewed all changed lines, validated the behavior locally, and ran the tests below myself.

I kept this change intentionally minimal by reusing the existing flag rather than introducing new profiler config surface; happy to follow up with a separate PR adding a CPU-specific flag if maintainers would prefer that direction.

Test Plan

Run the profiler regression test file:

.venv/bin/python -m pytest tests/v1/worker/test_gpu_profiler.py -v

Run file-scoped linting/formatting/docs checks:

pre-commit run --files vllm/platforms/cpu.py vllm/profiler/wrapper.py vllm/config/profiler.py docs/contributing/profiling.md tests/v1/worker/test_gpu_profiler.py

Test Result

pytest result:

============================== 26 passed, 3 warnings in 4.59s ==============================

pre-commit result:

  • ruff check passed
  • ruff format passed
  • typos passed
  • markdownlint-cli2 passed
  • mypy hook passed
  • all other relevant file-scoped hooks passed or were skipped when not applicable

Documentation

Updated:

  • vllm/config/profiler.py
  • docs/contributing/profiling.md

to reflect that torch_profiler_dump_cuda_time_total now emits a backend-specific self-time summary, using CUDA self time on GPU backends and CPU self time on CPU backends.

Changed files

  • docs/contributing/profiling.md (modified, +1/-1)
  • tests/v1/worker/test_gpu_profiler.py (modified, +70/-2)
  • vllm/config/profiler.py (modified, +3/-1)
  • vllm/platforms/cpu.py (modified, +0/-2)
  • vllm/profiler/wrapper.py (modified, +5/-1)

PR #38366: [BugFix][CPU] Add CPU profiler summary file output

Description (problem / solution / changelog)

Purpose

Fixes #38131. Currently, when using torch profiler on CPU:

  • torch_profiler_dump_cuda_time_total is disabled internally
  • No equivalent CPU summary file is written
  • Only log output is available (self_cpu_time_total)

This PR adds a CPU-side fallback that:

  • Writes a profiler summary sorted by self_cpu_time_total
  • Saves it to profiler_out_<rank>.txt (same as CUDA path)
  • limits output to rank 0 to avoid redundant data and file contention

This improves consistency between CPU and GPU profiling and avoids silent loss of profiler output on CPU.

Test Plan

Manually tested on CPU using the following repro script:

from vllm import LLM, SamplingParams
from vllm.config import ProfilerConfig


def main():
    prof_cfg = ProfilerConfig(
        profiler="torch",
        torch_profiler_dir="/tmp/ignored",
        torch_profiler_dump_cuda_time_total=True,
        delay_iterations=0,
        warmup_iterations=0,
        active_iterations=1,
        wait_iterations=0,
    )

    llm = LLM(
        model="meta-llama/Llama-3.1-8B-Instruct",
        dtype="bfloat16",
        skip_tokenizer_init=False,
        trust_remote_code=True,
        tensor_parallel_size=1,
        max_model_len=448,
        max_num_seqs=2,
        max_num_batched_tokens=512,
        disable_log_stats=True,
        profiler_config=prof_cfg,
    )

    sampling_params = SamplingParams(
        max_tokens=32,
        temperature=0.0,
        top_p=1.0,
    )

    llm.start_profile()
    llm.generate(["Hello", "Test"], sampling_params)
    llm.stop_profile()


if __name__ == "__main__":
    main()

Run python profiler.py

Then verify the profiler output directory:

ls /home/ubuntu/tmp/ignored/
cat /home/ubuntu/tmp/ignored/profiler_out_0.txt

Test Result

Before this change:

  • CPU profiling did not generate profiler_out_0.txt
  • no human-readable CPU profiler summary file was written

After this change:

  • CPU profiling generates profiler_out_0.txt
  • the file contains a profiler summary sorted by self_cpu_time_total
  • file writing is limited to rank 0
  • CUDA behavior remains unchanged

This addresses the missing CPU profiler summary described in #38131.

cc: @fadara01

<details> <summary> Essential Elements of an Effective PR Description Checklist </summary>
  • [Y] The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • [Y] The test plan, such as providing test command.
  • [Y] The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.
</details>

Changed files

  • vllm/profiler/wrapper.py (modified, +33/-15)

PR #38466: [Bugfix] Add CPU profiler summary equivalent to CUDA summary

Description (problem / solution / changelog)

Purpose

Fixes #38131

On CPU backends, torch_profiler_dump_cuda_time_total was silently overridden to False with no alternative CPU summary, leaving users without any human-readable profiler summary file even when they explicitly enabled it.

Changes

  1. vllm/config/profiler.py: Added torch_profiler_dump_cpu_time_total config field that mirrors the CUDA summary behavior for CPU
  2. vllm/platforms/cpu.py: When the user requests CUDA summary on CPU, automatically enable the CPU summary instead of silently disabling
  3. vllm/profiler/wrapper.py: Write CPU summary (sorted by self_cpu_time_total) to profiler_cpu_out_{rank}.txt and print to stdout on rank 0, exactly mirroring the CUDA summary path

Test Plan

# Run with CPU profiling enabled
python -c "
from vllm import LLM, SamplingParams
from vllm.config import ProfilerConfig

prof_cfg = ProfilerConfig(
    profiler='torch',
    torch_profiler_dir='/tmp/vllm_profile',
    torch_profiler_dump_cuda_time_total=True,
)
llm = LLM(model='meta-llama/Llama-3.1-8B-Instruct', dtype='bfloat16', max_model_len=448)
llm.start_profile()
llm.generate(['Hello'], SamplingParams(max_tokens=32))
llm.stop_profile()
"
# Verify profiler_cpu_out_0.txt exists and contains self_cpu_time_total table
ls /tmp/vllm_profile/profiler_cpu_out_*.txt

Test Result

The CPU summary file is now generated with the same format as the CUDA summary, sorted by self_cpu_time_total.

Changed files

  • vllm/config/profiler.py (modified, +6/-0)
  • vllm/platforms/cpu.py (modified, +4/-1)
  • vllm/profiler/wrapper.py (modified, +24/-23)

Code Example

--2026-03-25 16:53:09--  https://raw.githubusercontent.com/vllm-project/vllm/main/vllm/collect_env.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|: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 0s      

2026-03-25 16:53:09 (90.3 MB/s) - ‘collect_env.py’ saved [27835/27835]

Collecting environment information...
==============================
        System Info
==============================
OS                           : Ubuntu 24.04.3 LTS (aarch64)
GCC version                  : (Ubuntu 12.4.0-2ubuntu1~24.04.1) 12.4.0
Clang version                : Could not collect
CMake version                : version 4.3.0
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.10.20 (main, Mar  3 2026, 09:24:47) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.14.0-1018-aws-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):                                  96
On-line CPU(s) list:                     0-95
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per socket:                      96
Socket(s):                               1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               6 MiB (96 instances)
L1i cache:                               6 MiB (96 instances)
L2 cache:                                192 MiB (96 instances)
L3 cache:                                36 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-95
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: 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:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

==============================
Versions of relevant libraries
==============================
[pip3] numpy==2.0.1
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0+cpu
[pip3] transformers==4.57.6
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.17.1rc1.dev214+gc88ea8338.d20260325 (git sha: c88ea8338, date: 20260325)
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_ubuntu

---

is silently overridden to False on CPU, and no alternative CPU summary is written to file.
As a result, users explicitly enabling profiler summary output do not get a corresponding CPU summary file and the behavior differs between CPU and GPU without clear documentation or warning.

Minimal reproducer

---

What is being observers
- The frontend config shows:

---

- On CPU, this flag is overridden internally:
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>
--2026-03-25 16:53:09--  https://raw.githubusercontent.com/vllm-project/vllm/main/vllm/collect_env.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|: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 0s      

2026-03-25 16:53:09 (90.3 MB/s) - ‘collect_env.py’ saved [27835/27835]

Collecting environment information...
==============================
        System Info
==============================
OS                           : Ubuntu 24.04.3 LTS (aarch64)
GCC version                  : (Ubuntu 12.4.0-2ubuntu1~24.04.1) 12.4.0
Clang version                : Could not collect
CMake version                : version 4.3.0
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.10.20 (main, Mar  3 2026, 09:24:47) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.14.0-1018-aws-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):                                  96
On-line CPU(s) list:                     0-95
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per socket:                      96
Socket(s):                               1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               6 MiB (96 instances)
L1i cache:                               6 MiB (96 instances)
L2 cache:                                192 MiB (96 instances)
L3 cache:                                36 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-95
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: 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:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

==============================
Versions of relevant libraries
==============================
[pip3] numpy==2.0.1
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0+cpu
[pip3] transformers==4.57.6
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.17.1rc1.dev214+gc88ea8338.d20260325 (git sha: c88ea8338, date: 20260325)
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_ubuntu
</details>

🐛 Describe the bug

When using the torch profiler with vLLM on CPU, there is no equivalent to the CUDA profiler summary (self_cuda_time_total) and instead, the existing flag torch_profiler_dump_cuda_time_total=True is silently overridden to False on CPU, and no alternative CPU summary is written to file. As a result, users explicitly enabling profiler summary output do not get a corresponding CPU summary file and the behavior differs between CPU and GPU without clear documentation or warning.

Minimal reproducer

from vllm import LLM, SamplingParams
from vllm.config import ProfilerConfig


def main():
    prof_cfg = ProfilerConfig(
        profiler="torch",
        torch_profiler_dir="/tmp/ignored",
        torch_profiler_dump_cuda_time_total=True,
        delay_iterations=0,
        warmup_iterations=0,
        active_iterations=1,
        wait_iterations=0,
    )

    print("FRONTEND CONFIG:", prof_cfg, flush=True)

    llm = LLM(
        model="meta-llama/Llama-3.1-8B-Instruct",
        dtype="bfloat16",
        skip_tokenizer_init=False,
        trust_remote_code=True,
        tensor_parallel_size=1,
        max_model_len=448,
        max_num_seqs=2,
        max_num_batched_tokens=512,
        disable_log_stats=True,
        profiler_config=prof_cfg,
    )

    sampling_params = SamplingParams(
        max_tokens=32,
        temperature=0.0,
        top_p=1.0,
    )

    llm.start_profile()
    llm.generate(["Hello", "Test"], sampling_params)
    llm.stop_profile()


if __name__ == "__main__":
    main()

What is being observers

  • The frontend config shows: torch_profiler_dump_cuda_time_total=True
  • On CPU, this flag is overridden internally:
vllm/platforms/cpu.py
vllm_config.profiler_config.torch_profiler_dump_cuda_time_total = False

A profiler trace directory is created (e.g. TensorBoard traces), but:

  • No human-readable profiler summary file is generated
  • No CPU equivalent of self_cuda_time_total summary is written

Expected behavior

Provide a CPU equivalent summary (e.g. sorted by self_cpu_time_total) and write it to file, similar to CUDA behavior.

cc @fadara01

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 address the issue, we need to modify the vllm code to handle CPU profiling similarly to CUDA profiling.

  • Modify vllm/platforms/cpu.py to not override torch_profiler_dump_cuda_time_total when on CPU. Instead, introduce a new flag torch_profiler_dump_cpu_time_total to control CPU profiling summary output.
  • Update vllm to use the new flag and generate a CPU profiling summary file when torch_profiler_dump_cpu_time_total is True.
  • Modify the ProfilerConfig class to include the new torch_profiler_dump_cpu_time_total flag.

Example code changes:

# vllm/platforms/cpu.py
# Remove the override
# vllm_config.profiler_config.torch_profiler_dump_cuda_time_total = False

# vllm/config.py
class ProfilerConfig:
    def __init__(self, ...):
        # ...
        self.torch_profiler_dump_cpu_time_total = False  # New flag

# vllm/profiler.py
def stop_profile(self):
    # ...
    if self.profiler_config.torch_profiler_dump_cpu_time_total:
        # Generate CPU profiling summary file
        cpu_time_total = self.get_cpu_time_total()
        with open("cpu_summary.txt", "w") as f:
            f.write("self_cpu_time_total: {}\n".format(cpu_time_total))

Verification

To verify the fix, run the minimal reproducer with the updated vllm code and check that a CPU profiling summary file is generated when torch_profiler_dump_cpu_time_total is True.

Extra Tips

  • Make sure to update the documentation to reflect the new torch_profiler_dump_cpu_time_total flag and its behavior.
  • Consider adding a warning or log message when torch_profiler_dump_cuda_time_total is True on CPU to inform users of the override.

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…

FAQ

Expected behavior

Provide a CPU equivalent summary (e.g. sorted by self_cpu_time_total) and write it to file, similar to CUDA behavior.

cc @fadara01

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Bug]: [CPU Backend] No CPU profiler summary equivalent; CUDA summary flag is silently disabled on CPU [3 pull requests, 1 comments, 2 participants]