Skip, Search, Speculate - Turning a Frozen LLM into Its Own Lightweight Drafter for Lossless Inference Speedup
Hämtar...
Ladda ner
Författare
Typ
Examensarbete för masterexamen
Master's Thesis
Master's Thesis
Modellbyggare
Tidskriftstitel
ISSN
Volymtitel
Utgivare
Sammanfattning
This thesis has investigated the possibility to speedup inference by producing a self-speculative
setup where the original model is verifier and drafter. The model is frozen so the original quality
is preserved and no retraining required. The frozen model switches between being verifier and
drafter. In the drafter mode, a gap of almost all layers are skipped and an approximated
nearest neighbors (ANN) LM-head is used. To prevent completely degraded performance from
skipping many layers, this thesis proposes Hidden Vector Casting (HVC) which casts the hidden
vector from the geometric representation of the exit-layer to the geometric representation of
the entrance-layer.
The thesis has produced an open source implementation to train the HVC, build the ANN
head and run self-speculative inference with KV-cache handling. It also includes experiments
to evaluate what layer-skipping ablations that are the best to skip as many layers as possible
while degrading the generation performance as little as possible.
The thesis found that skipping an contiguous internal gap of layers is in general advantageous
compared to early-exit, late-start of an periodic variant of skipped layers. The selected layer
skipping ablations to produce inference systems were (1,1) and (2,2) which means that all layers
except the first and the last are skipped or all layers skipped except the two first and two last
respectively.
The found results are average speedups of 1.21× to 1.63× while having on average 0.9% higher
peak memory usage compared to normal inference and producing identical generation to normal
inference up to what the selected floating point precision allows for. The speedup depends on
the LM model and the type of prompt used. Larger models seem to have higher potential for
speedup while smaller models seem to have less overhead to save computation and thus smaller
potential for speedup. Since the mechanism fundamentally is to cheaply speculate ahead of the
full model, the results also indicate that more concrete prompts get larger speedups while more
open-ended prompts produces lower speedups in general.
The measured total times to train the HVC and to build the ANN LM-head are 16 to 38 minutes
depending on the model. The HVC was trained on a NVIDIA RTX PRO 6000 and the ANN
LM-head was built on an Apple MacBook Pro M5 24GB.
The thesis uses the models Llama 3.2 1B Instruct, Llama 3.2 3B Instruct, Llama 3.1 8B Instruct,
Mistral 7B Instruct 0.3v, and Qwen3 4B. The thesis only investigated smaller models in the
range 1–10B parameters due to limitation in computational access. The concept should however
work for larger models as well.
Beskrivning
Ämne/nyckelord
large language models, self-speculative decoding, inference acceleration, layer skipping, hidden vector casting, approximate nearest-neighbor LM-heads, lossless generation
