Skip to content

[CPU][Profiler] Group torch profiler tables by input shape when record_shapes is on - #56016

Merged
bigPYJ1151 merged 2 commits into
vllm-project:mainfrom
Chinmay-Kulkarni-AMD:profiler-shapes-info
Sep 14, 2026
Merged

bigPYJ1151 merged 2 commits into
vllm-project:mainfrom
Chinmay-Kulkarni-AMD:profiler-shapes-info

Conversation

@Chinmay-Kulkarni-AMD

@Chinmay-Kulkarni-AMD Chinmay-Kulkarni-AMD commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Purpose

Group PyTorch profiler key_averages tables by input shape on the CPU platform when the user enables --profiler-config.torch_profiler_record_shapes=true.

Without this, CPU dumps collapse every call of an op into one row, which hides prefill vs decode and GEMM size differences. GPU dumps are unchanged: group_by_input_shape is only set when current_platform.is_cpu() and torch_profiler_record_shapes are both true. Recording shapes remains user-controlled; it is not forced on the CPU platform.

Test Plan

CPU throughput bench with torch profiler, shapes on:

export CUDA_VISIBLE_DEVICES=""
export VLLM_CPU_KVCACHE_SPACE=8

vllm bench throughput \
  --model Qwen/Qwen3.5-4B --language-model-only --dtype bfloat16 \
  --max-model-len 2048 --max-num-seqs 8 --num-prompts 16 \
  --random-input-len 16 --random-output-len 16 \
  --profile \
  --profiler-config "{\"profiler\": \"torch\", \"torch_profiler_dir\": \"torch-logs\", \"torch_profiler_with_stack\": false, \"torch_profiler_use_gzip\":false, \"torch_profiler_record_shapes\":true}"

Also confirm that "torch_profiler_record_shapes": false still prints an ungrouped table, and that a GPU run does not pass group_by_input_shape=True.

Test Result

CPU dump (torch_profiler_record_shapes=true) now has an Input Shapes column. The same op is split by GEMM / sequence shape (decode 8 vs prefill 128):

Name                                   Self CPU %   Self CPU    # of Calls   Input Shapes
vllm::cpu_gdn_attention_core             2.15%       77.060ms  720          [[8, 8192], [8, 32], [8, 32], [8, 32, 128], []]
vllm::cpu_gdn_attention_core             0.59%       21.323ms   48          [[128, 8192], [128, 32], [128, 32], [128, 32, 128], []]
_C::cpu_attention_with_kv_cache        0.25%        8.829ms  240          [[8, 16, 256], [409, 4, 640, 256], ...]

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • 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.

@Chinmay-Kulkarni-AMD
Chinmay-Kulkarni-AMD marked this pull request as ready for review September 9, 2026 06:28

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@amukho amukho left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me...

@dllehr-amd
dllehr-amd self-requested a review September 9, 2026 16:32
@bigPYJ1151 bigPYJ1151 added the verified Run pre-commit for new contributors without triggering other tests label Sep 11, 2026
@mergify

mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Hi @Chinmay-Kulkarni-AMD, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@bigPYJ1151 bigPYJ1151 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Chinmay-Kulkarni-AMD , LGTM :)
Please fix the pre-commit check.

…d_shapes is on

Signed-off-by: Chinmay Kulkarni <Chinmay.Kulkarni@amd.com>
@Chinmay-Kulkarni-AMD

Copy link
Copy Markdown
Contributor Author

Thanks @Chinmay-Kulkarni-AMD , LGTM :) Please fix the pre-commit check.

Hello @bigPYJ1151 , the pre-commit/linter issues are now fixed.
I had missed one check. Apologies for the inconvenience.

@bigPYJ1151

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #88758 for commit 22bd55b9d567.

@bigPYJ1151
bigPYJ1151 merged commit dc89fdf into vllm-project:main Sep 14, 2026
81 checks passed
Shreya-gaur pushed a commit to Shreya-gaur/vllm_private that referenced this pull request Sep 14, 2026
…d_shapes is on (vllm-project#56016)

Signed-off-by: Chinmay Kulkarni <Chinmay.Kulkarni@amd.com>
Co-authored-by: Li, Jiang <jiang1.li@intel.com>
ItsRoy69 pushed a commit to ItsRoy69/vllm that referenced this pull request Sep 15, 2026
…d_shapes is on (vllm-project#56016)

Signed-off-by: Chinmay Kulkarni <Chinmay.Kulkarni@amd.com>
Co-authored-by: Li, Jiang <jiang1.li@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

verified Run pre-commit for new contributors without triggering other tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants