Skip to content

[Usage]: trying to use generation_tokens_total and prompt_tokens_total to get total tokens in the current batch #12330

Description

@annapendleton

Your current environment

I'm testing this with a single A100 40GB GPU using meta-llama/Meta-Llama-3-8B model weights. The server prints out the following info around expected memory reserved for the kv cache on startup:

INFO 01-13 11:35:21 model_runner.py:1099] Loading model weights took 14.9595 GB
INFO 01-13 11:35:23 worker.py:241] Memory profiling takes 1.32 seconds
INFO 01-13 11:35:23 worker.py:241] the current vLLM instance can use total_gpu_memory (39.50GiB) x gpu_memory_utilization (0.90) = 35.55GiB
INFO 01-13 11:35:23 worker.py:241] model weights take 14.96GiB; non_torch_memory takes 0.10GiB; PyTorch activation peak memory takes 9.37GiB; the rest of the memory reserved for KV Cache is 11.12GiB.
INFO 01-13 11:35:23 gpu_executor.py:76] # GPU blocks: 5691, # CPU blocks: 2048
INFO 01-13 11:35:23 gpu_executor.py:80] Maximum concurrency for 8192 tokens per request: 11.12x

How would you like to use vllm

I'm currently trying to use the sum of these two metrics, prompt_tokens_total and generation_tokens_total, to track how many tokens are in the current kv cache (aka how many tokens in the current batch per iteration).

Based on the above environment information, I would expect the max total tokens in the kv cache to be around 8192 * 11.12 = ~91k tokens. Note I've set the max concurrent requests allowed high enough to enable the full kv cache to be utilized.

However, in my load test where I max out the kv cache utilization, I am seeing both prompt_tokens_total and generation_tokens_total max out at around ~4k when the batch is full, summing to ~8k tokens. That's ~10x less than the expected 90k tokens summed.

I'm curious if the sum of these metrics represent the total tokens in the batch? If so, why is there a mismatch between the expected tokens for a full kv cache and the actual metrics emitted? If not, is there any metric that exists today that can give me the total tokens in the batch?

cc @robertgshaw2-redhat @DarkLight1337 who have worked with the total tokens metric that relies on these two metrics

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

    usageHow to use vllm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions