[Feature] Avoid gathering full vocabulary logits for plain greedy TP decoding

Abierto
#5,202 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
49/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

Start by reading ParallelLMHead and the decode sampling path to find where the model agent passes sampling decisions to the LM head. Check how tensor-parallel ranks coordinate selection and how existing tests cover greedy decoding, logits, and processors. Done means the fast path is limited to eligible plain greedy decode requests, produces the same token IDs across the TP group, and has serving latency measurements against the current path.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Motivation

On a four-GPU PCIe machine I noticed that DeepSeek's ParallelLMHead gathers the entire vocabulary on every rank even when the request only needs a greedy token ID. With DeepSeek-V2-Lite and 32 decoding rows, that materializes 6.25 MiB of BF16 logits per rank before sampling. Each rank already has enough information to choose its best local token.

I tried a small prototype on LMDeploy main at 4a8bdbc0. Each rank finds its local max, exchanges one (score, global token ID) pair per row, and picks the winning rank. Rank order breaks ties the same way as argmax on the concatenated vocabulary. I kept the existing broadcast of the leader's token in both measurements.

What I measured

Four RTX 5090s on one host, no CUDA peer access between these four devices, PyTorch 2.8.0+cu128, NCCL. I loaded the published BF16 lm_head.weight from deepseek-ai/DeepSeek-V2-Lite (102400 × 2048) into LMDeploy's actual ParallelLMHead. Inputs were seeded hidden states. Two fresh four-rank launches gave these median times for projection, selection and broadcast:

Decode rows Current path Local max + gather pairs
2 0.512–0.517 ms 0.325–0.512 ms
8 1.186–1.273 ms 0.389–0.520 ms
32 2.169–2.801 ms 0.504–0.518 ms

Each launch checked 504 selected IDs across batch sizes 1, 2, 4, 8, 16 and 32. All matched. The machine had other workloads, and small batches were noisy. In an earlier collective-only measurement with a 152064-token vocabulary, the prototype was slower at batch 1. These are output-layer measurements. I haven't measured serving throughput or TPOT yet.

Proposed scope

Would you be open to a decode-only fast path for larger batches using ParallelLMHead and plain greedy selection? I'd start with ordinary autoregressive decoding, leaving requests that need logits, logprobs, constraints, token masking or custom processors on the current path. The choice would need to be identical across the TP group. Models with a replicated output head wouldn't use it.

I can work on the integration and compare generated IDs and serving latency. Is there a preferred place for the model agent to pass that sampling decision to the LM head? I found #4915, which improves the full gather on supported hardware; this proposal reduces the amount gathered for this specific sampling case.

Lenguaje dominante
Python
Estrellas
8.2k
Forks
797
Merge medio
3 d 15 h
PR fusionados (30 d)
52

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de InternLM/lmdeploy

Todos los issues de InternLM/lmdeploy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.