DEV Community

Shivam Dwivedi
Shivam Dwivedi

Posted on Fully Autonomous

Two token rates, two different winners

The configuration with the faster prompt rate loses on the longer answer. The configuration with the faster generation rate loses on the shorter one. A single “tokens per second” winner is doing a lot of unpaid acting here.

The new llama.cpp AMD dashboard keeps prompt processing and text generation separate. Its overview uses PP512 for processing a 512-token prompt and TG128 for generating 128 tokens; both start at context depth zero. The plotted values are mean throughput. [1]

That separation is useful. I want to show what gets lost when those rates become one score.

Give the request an input and an output

Consider assumed rates, not measured hardware results. Configuration A processes prompts at 1,000 tokens/s and generates at 50 tokens/s. B processes at 500 and generates at 80. Both receive 512 input tokens.

With a 20-token answer, the simplified calculation gives A 0.912 seconds and B 1.274 seconds. With 128 output tokens, A takes 3.072 seconds and B 2.624 seconds. Same configurations. Different reader task. Different winner.

An illustrative latency plot for a 512-token prompt: A starts lower but rises faster; B crosses A at about 68.27 output tokens. All rates are assumed.

Computed illustration from the stated constant rates. These lines are not recorded llama.cpp or AMD timings.

The calculation adds time spent in each stage:

estimated seconds = input tokens / prompt rate + output tokens / generation rate

Both terms have units of seconds. Averaging the rates first loses the lengths that give them meaning. It also treats a token consumed during prompt processing as though it were interchangeable with an output token produced during decoding.

Find where the choice changes

For output length n, the equality is:

512/1000 + n/50 = 512/500 + n/80

Rearranging gives n = (512/500 − 512/1000) / (1/50 − 1/80), or 68.27 output tokens, rounded. For whole output lengths in this illustration, A is faster through 68 and B from 69 onward.

Save this as workload.py and run python3 workload.py. It uses exact fractions before formatting the output.

from fractions import Fraction as F
rates = {"A": (1000, 50), "B": (500, 80)}
prompt = 512
def seconds(name, output):
    pp, tg = rates[name]
    return F(prompt, pp) + F(output, tg)
for output in (20, 128):
    a, b = (seconds(name, output) for name in rates)
    print(output, f"A={float(a):.3f}s", f"B={float(b):.3f}s")
crossing = (F(prompt, 500) - F(prompt, 1000)) / (F(1, 50) - F(1, 80))
assert seconds("A", crossing) == seconds("B", crossing)
assert seconds("A", 0) < seconds("B", 0)
assert seconds("A", 68) < seconds("B", 68)
assert seconds("A", 69) > seconds("B", 69)
print("equal time at", f"{float(crossing):.2f}", "output tokens")
Enter fullscreen mode Exit fullscreen mode
20 A=0.912s B=1.274s
128 A=3.072s B=2.624s
equal time at 68.27 output tokens
Enter fullscreen mode Exit fullscreen mode

The equality assertion checks the crossover itself. The neighboring integer checks catch a reversed sign, a particularly easy mistake when moving the generation terms across the equals sign.

Bring the distinction back to the dashboard

I would first hold hardware, model, quantization, build and Flash Attention setting fixed when reading a result. Then I would ask which part of the workload matters: processing a long input, producing a long answer, or decoding with an existing conversation.

The dashboard has separate overview, build-history and context-scaling views. Its context sweep matters because the overview's depth-zero generation rate is not a promise that decoding stays equally fast as context grows. The public JSONL source links let readers inspect the underlying test configuration. [1]

This little equation assumes constant rates, sequential stages and no overhead. Real serving adds scheduling, cache effects, batching and changing context. A mean microbenchmark rate is not an end-to-end latency distribution, and combining independent reference tests does not reproduce a real request. I have checked the arithmetic here; I have not benchmarked either AMD device.

Still, this is a useful first filter: write down the input and output lengths before crowning a winner. The workload gets a vote.

References

  1. angt, Simon Pagezy and Abdennacer Badaoui — Introducing the llama.cpp benchmark dashboard for AMD Ryzen and Radeon
  2. Python — fractions, exact rational arithmetic

Asset credits

Original figure, CC BY 4.0. Credit: Shivam Dwivedi. No third-party image assets.

AI disclosure

AI was used to draft the article.

Top comments (0)