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

オープン
#5,202 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
49/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, pytorch

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
8.2k
フォーク
797
平均マージ
3日 15時間
マージ済み PR(30日)
52

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

InternLM/lmdeploy のほかの issue

InternLM/lmdeploy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。