[FEATURE] Add speculative decoding to the decoder algorithm family
@mohityadav8 ya está trabajando en esto.
Desde el 23/11/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- huggingface, python
- Área
- ai, machine-learning
Línea de trabajo
Start by reading kvpress.py and the existing zipar decoder algorithm to learn how algorithms register with AlgorithmTag.DECODER, then trace how SAVE_FUNCTIONS.reapply, model_check_fn and compatible_before are wired. Read the decoder tests in tests/algorithms/testers/ and test_compatibility_symmetry.py to see the expected coverage. Done means a registered speculative_decoding wrapper around generate with both drafting modes, plus passing tests for identical greedy output, save/load, diffusers rejection and compatibility symmetry on llama_3_tiny_random.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Is your feature request related to a problem? Please describe.
Pruna has no speculative decoding algorithm. The decoder family added in 0.3.2 only contains zipar, which supports Janus LlamaGen image models only, so ordinary causal LLMs can't get a faster decoding strategy through Pruna. The April 2025 optimization techniques post said speculative decoding wasn't implemented yet, and I couldn't find an implementation, open PR or branch for it in the repo.
Describe the solution you'd like
Add a speculative_decoding algorithm tagged AlgorithmTag.DECODER for causal LMs and transformers text-generation pipelines. It is lossless: the target model verifies every drafted token, so greedy outputs stay identical.
from pruna import SmashConfig, smash
# base_model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-1.7B")
smash_config = SmashConfig(["speculative_decoding"])
smash_config.add({
"speculative_decoding_method": "draft_model", # or "prompt_lookup" (default)
"speculative_decoding_draft_model": "HuggingFaceTB/SmolLM-135M",
"speculative_decoding_num_draft_tokens": 5,
})
smashed_model = smash(model=base_model, smash_config=smash_config)
Design, modelled on kvpress.py:
- Two drafting methods, both using transformers' built-in assisted generation (no new dependency).
prompt_lookupneeds no extra model.draft_modelpasses a smaller model with the same tokenizer asassistant_model. _applywrapsmodel.generate, keeps the original, and only injects the options when the caller hasn't set them. Assisted generation doesn't support batched inputs, so those fall back to plaingeneratewith a log message.model_check_fn:is_causal_lm(model) or is_transformers_pipeline_with_causal_lm(model).save_fn = SAVE_FUNCTIONS.reapply.compatible_before: the LLM quantizers that pass the combination tests (candidates:awq,gptq,half,hqq,llm_int8,quanto,torchao), mirrored in theircompatible_aftersotest_compatibility_symmetry.pypasses.torch_compilestays out of the first PR unless its combination tests pass.- Tests in
tests/algorithms/testers/onllama_3_tiny_random: wrapper applied, identical greedy output with and without the algorithm, save/load round trip, diffusers models rejected. - A short tutorial comparing latency, throughput and energy with
EvaluationAgent.
Out of scope, possible follow-ups: trained draft heads (EAGLE-style), universal assisted decoding for mismatched tokenizers, batched speculative decoding.
Additional context
A few questions before I start:
- Do you want speculative decoding in the open-source package, or is it planned for Pruna Pro?
- Is
prompt_lookupan acceptable default, since it needs no extra weights? - For
draft_model, isreapplywith the draft referenced by id/path fine, or should the draft weights be saved with the target?
I'd like to implement this myself. Could I be assigned? I'll follow the AI contribution policy: test locally, reuse existing utilities, and mark the PR as AI-assisted if it applies.
- Lenguaje dominante
- Python
- Estrellas
- 1.4k
- Forks
- 129
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PrunaAI/pruna
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
[BUG] set_to_eval calls Llama.eval() on llama.cpp models, so latency/energy/memory metrics log a warning on every runPosiblemente ocupada @zuhalsicim la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
[BUG] kvpress algorithm: KVzipPress and FastKVzipPress never compress during generateQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertostale
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Todos los issues de PrunaAI/pruna
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
enhancement feature/signals self-driving team/self-driving
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PostHog/posthog#144208 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
LMPrado-DZ23/open_notas_br#14 ·
Los mantenedores suelen responder en 1 día