Skip to content

[Bug]: Performance regression when use PyTorch regional compilation #12410

@anko-intel

Description

@anko-intel

Your current environment

Run on hpu backend on version from https://github.com/HabanaAI/vllm-fork
INFO 01-24 15:38:37 __init__.py:188] Automatically detected platform hpu.
Collecting environment information...
PyTorch version: 2.5.1a0+git354fc07
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-113-generic-x86_64-with-glibc2.35
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:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      52 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             224
On-line CPU(s) list:                0-223
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8480+
CPU family:                         6
Model:                              143
Thread(s) per core:                 2
Core(s) per socket:                 56
Socket(s):                          2
Stepping:                           8
CPU max MHz:                        3800.0000
CPU min MHz:                        800.0000
BogoMIPS:                           4000.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          5.3 MiB (112 instances)
L1i cache:                          3.5 MiB (112 instances)
L2 cache:                           224 MiB (112 instances)
L3 cache:                           210 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-55,112-167
NUMA node1 CPU(s):                  56-111,168-223
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 Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
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; Enhanced IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] habana-torch-dataloader==1.20.0.357
[pip3] habana-torch-plugin==1.20.0.357
[pip3] numpy==1.26.4
[pip3] pynvml==8.0.4
[pip3] pytorch-lightning==2.5.0.post0
[pip3] pyzmq==26.2.0
[pip3] torch==2.5.1a0+git354fc07
[pip3] torch_tb_profiler==0.4.0
[pip3] torchaudio==2.5.1a0+1661daf
[pip3] torchdata==0.9.0+d4bb3e6
[pip3] torchmetrics==1.6.1
[pip3] torchtext==0.18.0a0+9bed85d
[pip3] torchvision==0.20.1a0+3ac97aa
[pip3] transformers==4.48.1
[pip3] triton==3.1.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.3.dev1995+gf78b021c
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
Could not collect

LD_LIBRARY_PATH=/usr/local/lib/python3.10/dist-packages/cv2/../../lib64:/opt/habanalabs/libfabric-1.22.0/lib:/opt/amazon/openmpi/lib:/usr/lib/habanalabs:

Model Input Dumps

No response

🐛 Describe the bug

Performance regression occurs when use regional compilation after #11967

When run :

 python -u benchmarks/benchmark_throughput.py \
                                --model /path_to_model/Llama-2-7b-hf \
                                --device hpu \
                                --seed 2024 \
                                --backend vllm \
                                --dataset /path_to_dataset/ShareGPT_V3_unfiltered_cleaned_split.json \
                                --num-prompts 1000 \
                                --dtype bfloat16 \
                                --max-model-len 4096 \
                                --max-num-batched-tokens 8192 \
                                --max-num-seqs 128 \
                                --use-padding-aware-scheduling

The regional compilation is used in the code I observe big throughput degradation due to recompilation happened due to indexing in attention layer:

torch/_dynamo/guards.py:2813] [1/4] [__recompiles] Recompiling function forward in /software/users/akotlowski/vllm-fork/vllm/model_executor/models/llama.py:267
torch/_dynamo/guards.py:2813] [1/4] [__recompiles]     triggered by the following guard failure(s):
torch/_dynamo/guards.py:2813] [1/4] [__recompiles]     - 1/3: L['self']._modules['self_attn']._modules['attn'].layer_name == 'model.layers.3.self_attn.attn'  # self = forward_context.attn_layers[layer_name]  # oftware/users/akotlowski/vllm-fork/vllm/attention/layer.py:244 in unified_attention
torch/_dynamo/guards.py:2813] [1/4] [__recompiles]     - 1/2: L['self']._modules['self_attn']._modules['attn'].layer_name == 'model.layers.2.self_attn.attn'  # self = forward_context.attn_layers[layer_name]  # oftware/users/akotlowski/vllm-fork/vllm/attention/layer.py:244 in unified_attention
torch/_dynamo/guards.py:2813] [1/4] [__recompiles]     - 1/1: L['self']._modules['self_attn']._modules['attn'].layer_name == 'model.layers.1.self_attn.attn'  # self = forward_context.attn_layers[layer_name]  # oftware/users/akotlowski/vllm-fork/vllm/attention/layer.py:244 in unified_attention
torch/_dynamo/guards.py:2813] [1/4] [__recompiles]     - 1/0: L['self']._modules['self_attn']._modules['attn'].layer_name == 'model.layers.0.self_attn.attn'  # self = forward_context.attn_layers[layer_name]  # oftware/users/akotlowski/vllm-fork/vllm/attention/layer.py:244 in unified_attention

self = forward_context.attn_layers[layer_name]

When we partially revert the change #11967, dynamo compilation treats layers as the same, which originally bring performance boost and reduce time of compilation.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions