﻿# inferscope: aligning local LLM latency with GPU measurements

inferscope aligns streamed arrivals, process resources and NVIDIA energy on one clock. Its examples and version limits explain what the measurements can establish.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/inferscope-client-latency-gpu-energy-attribution/
Language: en

When a local language model responds slowly, average tokens per second are insufficient: a user may wait for the answer to start or experience pauses during generation. The open Rust tool [inferscope](https://github.com/MicheleCampi/inferscope) places these delays alongside process and GPU activity. It sends requests to an OpenAI-compatible streaming HTTP API and collects response timestamps and resource readings on a shared timeline. Targets include local llama.cpp, Ollama, and vLLM servers.

The first public release, v0.1.0, appeared on May 16, 2026, with latency and process measurements; v0.2.0 added NVIDIA NVML sampling on May 20. Version v0.4.0, dated July 25, introduced energy accounting and allocation across phases and steps. The project uses Apache-2.0. These details come from the [author and changelog](https://github.com/MicheleCampi/inferscope/blob/main/CHANGELOG.md); an independent reproduction of the measurements below was not established.

## What the timeline contains

The profiler measures TTFT, from request submission to the first observed result, subsequent arrival intervals, and total latency. The interval distribution reveals streaming behavior: p95, for example, can expose occasional long pauses hidden by a mean. With a specified PID, the tool periodically reads Linux `/proc` for resident memory (RSS), CPU usage, and thread count. The initial release defaulted to 50 ms sampling. JSON reports contain raw timestamps and derived metrics, while text reports support quick inspection. [README](https://github.com/MicheleCampi/inferscope) and [changelog](https://github.com/MicheleCampi/inferscope/blob/main/CHANGELOG.md).

A model token and a chunk received over the network are different observations. The author describes token-stream measurement, but HTTP delivery and buffering also affect observed times. The [vLLM documentation](https://docs.vllm.ai/en/v0.31.0/design/metrics/) warns that streamed-output intervals approximate token intervals only when each output contains exactly one token. Combining several tokens, for example with speculative decoding, breaks this correspondence. Comparing systems requires checking the particular server and client behavior. The [benchmark methodology guide](/journal/inference-benchmark-method/) helps fix this measurement contract before comparing results.

Built with `gpu-nvidia` and GPU monitoring enabled, inferscope polls visible NVIDIA devices through NVML for utilization, memory, power, and other available readings. It requires the NVIDIA driver; v0.2 continued with CPU data when NVML was unavailable. Process and GPU telemetry observe the server externally. An incorrect PID can describe an unrelated process; the documented descendant aggregation includes immediate children only. [v0.2.0 release](https://github.com/MicheleCampi/inferscope/releases/tag/v0.2.0), [changelog](https://github.com/MicheleCampi/inferscope/blob/main/CHANGELOG.md).

This is useful when changing a model, quantization, or server settings to see whether pauses coincide with growing memory or changing utilization. Temporal coincidence creates a hypothesis, rather than directly revealing scheduler behavior, attention execution, or a pause's cause. Sampling every few dozen milliseconds may miss shorter events; device readings can also include other processes.

## What the author's examples show

The README demonstrates llama.cpp with Qwen 2.5 0.5B Q4 on a four-vCPU AMD EPYC virtual machine. For 80 output tokens it reports TTFT of 25 ms, generation at 82.7 tokens/s, and total latency of 981 ms. Across 79 intervals, the mean was 12 ms and p95 was 14 ms; 21 process samples showed RSS of 588 MiB and mean CPU utilization of 371%. Values above 100% reflect multiple cores. This is one illustrative run, rather than an independent benchmark or a promise for different hardware. [Project README](https://github.com/MicheleCampi/inferscope).

A separate [v0.2.0 example](https://github.com/MicheleCampi/inferscope/releases/tag/v0.2.0) describes the same small model through llama.cpp on an NVIDIA L4: 80 tokens, TTFT of 19 ms, and 367.6 tokens/s. The author reports six GPU samples and 1.25 GiB of used VRAM. Such a short example demonstrates telemetry collection, but its conditions and observation count do not establish a universal GPU advantage over the preceding CPU run.

## Energy, cache, and attribution limits

Since v0.4, the tool can subtract NVML hardware energy-counter readings, falling back to integration of sampled power when unavailable. It derives metrics such as tokens per joule. The author reports checking the counter on an A10 with llama.cpp, and separately checking trajectory-step energy allocation with an A10, vLLM, and Qwen2.5-7B-Instruct. These are developer checks; additional attempts did not retrieve the underlying A10 artifacts, so their exact results and conditions are not reproduced here. [README](https://github.com/MicheleCampi/inferscope), [changelog](https://github.com/MicheleCampi/inferscope/blob/main/CHANGELOG.md).

According to [NVIDIA's documentation](https://docs.nvidia.com/deploy/archive/R470/nvml-api/group__nvmlDeviceQueries.html), the counter measures GPU energy since driver reload. Its interval difference includes the whole device and background work; it is not a direct per-request energy counter. The [GPU and server energy-boundary guide](/journal/gpu-board-server-power-boundary/) also prevents interpreting this as whole-machine energy. Allocation to prefill/decode or agent steps uses time boundaries and additional counters. The author limits step attribution to one concurrent trajectory and steps longer than the sampling period; shorter steps report missing data. An early A10 run exposed a counter-boundary alignment defect, subsequently fixed. [Author's description and qualifications](https://github.com/MicheleCampi/inferscope).

The tool also reads prefix/KV-cache metrics from a Prometheus-compatible endpoint. The author explicitly states that a real vLLM hit rate remains unmeasured. July A10 figures were zero because metric names were incorrect; a later run used a mode that did not start the required scrape. Simulator readings cannot establish real-server validation. Version v0.5 added a SGLang schema: vLLM rounds hit tokens to block boundaries, while SGLang at its default page size counts exact tokens. The current README separately reports SGLang 0.5.19 validation on an A10 on September 10, 2026: 420 hits in 426 queries, a rate of 0.9859. This author-run check of another engine does not close the vLLM gap; percentages need their accounting semantics. [README](https://github.com/MicheleCampi/inferscope).

Finally, the project supports OpenTelemetry export, with a version caveat: the feature did not compile in tag v0.4.0 despite being announced. The fix and build verification are documented for v0.5.0 on July 29. inferscope provides an external measurement layer, particularly for controlled single requests. Explaining observed pauses still requires engine-internal metrics and profiling. [Changelog](https://github.com/MicheleCampi/inferscope/blob/main/CHANGELOG.md).

## Sources

- [inferscope README and author examples](https://github.com/MicheleCampi/inferscope).
- [inferscope changelog](https://github.com/MicheleCampi/inferscope/blob/main/CHANGELOG.md).
- [v0.2.0 release and NVIDIA L4 example](https://github.com/MicheleCampi/inferscope/releases/tag/v0.2.0).
- [vLLM latency metric definitions](https://docs.vllm.ai/en/v0.31.0/design/metrics/).
- [NVIDIA NVML API reference, R470 archive](https://docs.nvidia.com/deploy/archive/R470/nvml-api/group__nvmlDeviceQueries.html).
