Speculative decoding

Speculative decoding makes supported models write their replies faster, without changing what they say. You don't set anything up. Your worker tunes it for each model on its own hardware, and uses it only where it really is faster.

How it works

A small, fast draft guesses the next few tokens. The full model then checks all of them in one step, keeps the ones it would have written, and replaces the first wrong one with its own.

One token at a time
The cat satstep 1onstep 2astep 3
3 steps
With a draft
The cat satonthe The draft guesses ahead
The cat saton the a The model checks them in one step
1 step

The draft is either a small model installed alongside, or built into the model itself. Every token you get is one the full model chose, using your temperature and other settings.

Tuned for you

Whether a draft helps depends on the model and the GPU. On a large model it saves a lot. On a small, already fast model it can cost more than it saves. So the worker times each model both ways on the requests you're already sending, then:

  • uses it for a model that's faster with it;
  • picks how far ahead the draft guesses, from one to three tokens;
  • leaves it off for a model that isn't faster, so nothing is slowed down;
  • checks again when the model reloads, the worker updates, or your traffic changes.

In our tests on a 24 GB GPU, Gemma 4 12B replied 35 to 45% faster. The much smaller Gemma 4 E2B, with a badly chosen draft length, was 30% slower. That's what the tuning protects you from.

What the console shows

Open a worker and expand a supported model under Models & context. Its Speculative decoding line shows what the worker decided:

StatusMeaning
On, +24%Faster on this worker, so it's in use. The figure is the measured speed-up.
Off, −18%No faster on this worker, so it's not used. The figure is what it would have cost.
MeasuringThe worker is timing the model on its first requests.
AutomaticThe model hasn't served a request since it loaded.
UnavailableIt can't be used for this model right now, usually for lack of memory. The line says why.
After the next loadIt starts the next time the model loads.
PausedThis worker's version can't use it with Run requests together on. Update the worker.
Off (worker's Settings)Someone in your organisation turned it off for this worker.
Off (by Pendra)Pendra turned it off for this worker, usually while looking into a problem.
StartingIt begins within moments.
Needs a worker updateUpdate the worker to use it.

Which models support it

ModelRuns on
Gemma 4, every sizeEvery worker. Its draft downloads with the model.
Ornith 1.5, qwen3.8:27bNVIDIA GPUs and Apple Silicon, worker 3.168.0 or later.
GLM 5.3 FlashLinux with NVIDIA GPUs, worker 3.180.0 or later.

On other GPUs these models run as normal. The console only shows the line for models that can use it.

Good to know

  • It works with any temperature, with tools and JSON output, alongside the KV cache, and with Run requests together where memory allows.
  • Predictable text, such as code, speeds up the most. Creative text at a high temperature speeds up less.
  • A reply isn't always word for word the same as one written without it, though it's just as good. Turn it off if you need replies you can reproduce exactly.
  • The draft uses a little GPU memory, and a built-in draft takes a little context. A context you set yourself is never reduced for it.

See how well it's doing

Each reply that used it reports draft_acceptance_rate, the share of the draft's guesses the model kept, from 0 to 1. Find it in the reply under pendra.timing and in the usage log, which also records whether each request used speculative decoding.

Turn it off

You shouldn't need to, because a model that doesn't benefit is left alone. To turn it off anyway, open the worker's Settings and set Speculative decoding to Off. It applies to every model on the worker from the next request. Set it back to Automatic to turn it on again.

From code, use a key with the workers:write permission. mode is "off" or "auto".

bash
curl -X PATCH https://api.pendra.ai/api/v1/workers/$WORKER_ID/speculative-decoding \
  -H "Authorization: Bearer $PENDRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode": "off"}'