Collecting environment information...
PyTorch version: 2.1.2+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.4
Libc version: glibc-2.31
Python version: 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-1055-aws-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A10G
Nvidia driver version: 535.104.12
cuDNN version: Could not collect
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
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 64
On-line CPU(s) list: 0-63
Thread(s) per core: 2
Core(s) per socket: 32
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 23
Model: 49
Model name: AMD EPYC 7R32
Stepping: 0
CPU MHz: 2799.996
BogoMIPS: 5599.99
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 1 MiB
L1i cache: 1 MiB
L2 cache: 16 MiB
L3 cache: 128 MiB
NUMA node0 CPU(s): 0-63
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: Mitigation; untrained return thunk; SMT enabled with STIBP protection
Vulnerability Spec rstack overflow: Mitigation; safe RET
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; Retpolines, IBPB conditional, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch topoext ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr rdpru wbnoinvd arat npt nrip_save rdpid
Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] onnxruntime==1.17.1
[pip3] torch==2.1.2
[pip3] torch-model-archiver==0.7.1b20230208
[pip3] torch-workflow-archiver==0.2.11b20231012
[pip3] torchaudio==2.1.0
[pip3] torchdata==0.7.0
[pip3] torchserve==0.9.0b20231012
[pip3] torchtext==0.16.0
[pip3] torchvision==0.16.0
[pip3] triton==2.1.0
[conda] blas 2.121 mkl conda-forge
[conda] blas-devel 3.9.0 21_linux64_mkl conda-forge
[conda] libblas 3.9.0 21_linux64_mkl conda-forge
[conda] libcblas 3.9.0 21_linux64_mkl conda-forge
[conda] liblapack 3.9.0 21_linux64_mkl conda-forge
[conda] liblapacke 3.9.0 21_linux64_mkl conda-forge
[conda] mkl 2024.0.0 ha957f24_49657 conda-forge
[conda] mkl-devel 2024.0.0 ha770c72_49657 conda-forge
[conda] mkl-include 2024.0.0 ha957f24_49657 conda-forge
[conda] numpy 1.26.4 py310hb13e2d6_0 conda-forge
[conda] pytorch-cuda 12.1 ha16c6d3_5 https://aws-ml-conda.s3.us-west-2.amazonaws.com
[conda] pytorch-mutex 1.0 cuda https://aws-ml-conda.s3.us-west-2.amazonaws.com
[conda] torch 2.1.2 pypi_0 pypi
[conda] torch-model-archiver 0.7.1 py310_0 pytorch
[conda] torch-workflow-archiver 0.2.11 py310_0 pytorch
[conda] torchaudio 2.1.0 py310_cu121 https://aws-ml-conda.s3.us-west-2.amazonaws.com
[conda] torchdata 0.7.0 py310 https://aws-ml-conda.s3.us-west-2.amazonaws.com
[conda] torchserve 0.9.0 py310_0 pytorch
[conda] torchtext 0.16.0 py310 https://aws-ml-conda.s3.us-west-2.amazonaws.com
[conda] torchvision 0.16.0 py310_cu121 https://aws-ml-conda.s3.us-west-2.amazonaws.com
[conda] triton 2.1.0 pypi_0 pypiROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.3.3
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X 0-63 N/A N/A
Legend:
X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks
🐛 Describe the bug
from vllm import LLM, SamplingParams
import torch
# Sample prompts.
prompts = [
"How do OpenAI and Meta differ on AI tools?",
]
# Create a sampling params object.
sampling_params = SamplingParams(temperature=0.2, top_p=0.95)
model_name = "mistralai/Mistral-7B-Instruct-v0.1"
# Create an LLM.
llm = LLM(model=model_name, device="cuda", dtype= torch.bfloat16, )
# Generate texts from the prompts. The output is a list of RequestOutput objects
# that contain the prompt, generated text, and other information.
import time
start = time.time()
outputs = llm.generate(prompts, sampling_params)
end = time.time()
duration = end - start
print(f"duration:{duration}")
# Print the outputs.
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
i use the command(nsys profile -w true -t cuda,nvtx,osrt,cudnn,cublas -s cpu -o mistral_vllm -f true -x true --cuda-graph-trace node python3 vllm_mistral.py) to profile the vllm.
first question
what's the fill_reverse_indices_kernel
second question
For the red block, I think it's one iteration that will generate one token. But for the green block, the time gap is 85ms, why does this gap exist and why is the gap so large? i think after the green block, it's the next iteration that will generate next token.
for the first question, the real kernel runtime can be found inside the CUDA HW line above
In vllm, they will do a profile first, so the red box may not be the first token prediction. You can push nvtx into model's forward and disable CUDA graph, that may give you a more clear result.
Your current environment
🐛 Describe the bug
i use the command(
nsys profile -w true -t cuda,nvtx,osrt,cudnn,cublas -s cpu -o mistral_vllm -f true -x true --cuda-graph-trace node python3 vllm_mistral.py
) to profile the vllm.first question
what's the
fill_reverse_indices_kernel
second question
For the red block, I think it's one iteration that will generate one token. But for the green block, the time gap is 85ms, why does this gap exist and why is the gap so large? i think after the green block, it's the next iteration that will generate next token.