← Glossaire · Intelligence artificielle Décodage spéculatif Intelligence artificielle · Avancé
Une astuce qui accélère un gros LLM : un petit modèle propose plusieurs mots d'avance, que le gros modèle valide d'un coup.
Comment ça marche Le petit modèle (brouillon) génère par exemple 4 tokens ; le gros modèle les vérifie en parallèle dans un seul passage et garde ceux qui conviennent. La sortie est identique à celle du gros modèle seul, mais obtenue plus vite.
standard
decode: 199 steps × 25 ms (tick = 4 steps)
5.02 s
speculative k=4
≈59 steps × 25 ms, 3.36 tokens/step
1.52 s
TTFT 40 ms
0
1
2
3
4
5
time (s)
0
100
200
300
400
500
600
0
1
2
3
4
5
time (s)
KV cache (tokens held)
400 tokens per sequence
Metric
Formula
Value
TTFT (time to first token)
P / prefill_tps = 200 / 5,000
40 ms
TPOT (time per output token)
1 / decode_tps = 1 / 40
25 ms
End-to-end latency
TTFT + (N − 1) × TPOT = 40 ms + 199 × 25 ms
5.02 s
Throughput per sequence
decode_tps
40 tok/s
Throughput, batch 1
B × decode_tps = 1 × 40
40 tok/s
Spec.: tokens per target step
(1 − a^(k+1)) / (1 − a), a = 0.8, k = 4
3.36
Spec.: effective TPOT
TPOT × (1 + k × c) / E, c = 0
7.44 ms
Spec.: end-to-end latency
TTFT + (N − 1) / E × step time
1.52 s
Spec.: speed-up
end-to-end standard / speculative
×3.30
TTFT = P / prefill_tps; TPOT = 1 / decode_tps; latency = TTFT + (N − 1) × TPOT
throughput = B × decode_tps
speculative: E = (1 − a^(k+1)) / (1 − a) tokens per target step
where
P
prompt tokens (200)
N
output tokens (200)
prefill_tps
prompt tokens processed per second (one request)
decode_tps
output tokens per second per sequence
B
sequences decoded together (1)
k
draft tokens proposed per step
a
probability a draft token is accepted
E
expected tokens produced per target step (accepted + 1 corrected)
c
draft cost per token as a share of a target step
Décodage spéculatif : un petit modèle propose, le grand valide
standard
decode: 199 steps × 25 ms (tick = 4 steps)
5.02 s
speculative k=4
≈59 steps × 25 ms, 3.36 tokens/step
1.52 s
TTFT 40 ms
0
1
2
3
4
5
time (s)
0
100
200
300
400
500
600
0
1
2
3
4
5
time (s)
KV cache (tokens held)
400 tokens per sequence
Metric
Formula
Value
TTFT (time to first token)
P / prefill_tps = 200 / 5,000
40 ms
TPOT (time per output token)
1 / decode_tps = 1 / 40
25 ms
End-to-end latency
TTFT + (N − 1) × TPOT = 40 ms + 199 × 25 ms
5.02 s
Throughput per sequence
decode_tps
40 tok/s
Throughput, batch 1
B × decode_tps = 1 × 40
40 tok/s
Spec.: tokens per target step
(1 − a^(k+1)) / (1 − a), a = 0.8, k = 4
3.36
Spec.: effective TPOT
TPOT × (1 + k × c) / E, c = 0
7.44 ms
Spec.: end-to-end latency
TTFT + (N − 1) / E × step time
1.52 s
Spec.: speed-up
end-to-end standard / speculative
×3.30
TTFT = P / prefill_tps; TPOT = 1 / decode_tps; latency = TTFT + (N − 1) × TPOT
throughput = B × decode_tps
speculative: E = (1 − a^(k+1)) / (1 − a) tokens per target step
where
P
prompt tokens (200)
N
output tokens (200)
prefill_tps
prompt tokens processed per second (one request)
decode_tps
output tokens per second per sequence
B
sequences decoded together (1)
k
draft tokens proposed per step
a
probability a draft token is accepted
E
expected tokens produced per target step (accepted + 1 corrected)
c
draft cost per token as a share of a target step
Décodage spéculatif : un petit modèle propose, le grand valide
Qui l'utilise, et pourquoi Technique d'optimisation des serveurs d'inférence pour réduire la latence sans changer les réponses.