[Doc][Misc] Add metrics usage documentation and example (#6962)
## What this PR does / why we need it?
This PR addresses issue #5027 where users find that `output.metrics`
returns `None` when using the vLLM offline inference API.
**Root Cause**: vLLM disables log stats by default
(`disable_log_stats=True`), which causes `output.metrics` to be `None`.
**Changes**:
1. Added a NOTE comment in `examples/offline_inference_npu.py`
explaining how to enable metrics
2. Created a new example `examples/offline_inference_metrics.py`
demonstrating how to access request-level metrics (`first_token_time`,
`finished_time`, etc.) by setting `disable_log_stats=False`
## Does this PR introduce _any_ user-facing change?
Yes - adds documentation and example code to help users understand how
to access output metrics.
## How was this patch tested?
- Documentation/example change only
- Verified example code follows the same patterns as existing examples
Closes #5027
- vLLM version: v0.16.0
- vLLM main:
15d76f74e2
Signed-off-by: NJX-njx <3771829673@qq.com>
This commit is contained in:
@@ -37,6 +37,9 @@ def main():
|
||||
# Create a sampling params object.
|
||||
sampling_params = SamplingParams(max_tokens=100, temperature=0.0)
|
||||
# Create an LLM.
|
||||
# NOTE: To access output.metrics (e.g., first_token_time, finished_time),
|
||||
# set disable_log_stats=False. By default, vLLM disables log stats and
|
||||
# output.metrics will be None. See issue #5027 for details.
|
||||
llm = LLM(model="Qwen/Qwen2.5-0.5B-Instruct")
|
||||
|
||||
# Generate texts from the prompts.
|
||||
|
||||
Reference in New Issue
Block a user