[Bug]: Seeded sampling restarts its random stream when a request resumes from a generated prefix
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
調査の方向性
Start with _SeedManager.observe in tensorrt_llm/_torch/pyexecutor/sampler/seed_manager.py, then read the sampler’s seeded offset handling and its unit tests. Reproduce the resumed request using the issue’s repro.py scenario and compare token streams at matching positions. Done means resumed seeded draws use the intended sequence positions and the relevant tests cover the behavior; an open linked pull request is already addressing this issue.
索引モデルが issue の本文から書いたものです。
説明
System Info
TensorRT-LLM 1.4.0rc5 (pip wheel), PyTorch backend, LLM API, 1x H100 80GB HBM3, torch 2.14.0+cu130. tensorrt_llm/_torch/pyexecutor/sampler/ is identical on main at 06b1cbcd.
Who can help?
Code: _SeedManager.observe in tensorrt_llm/_torch/pyexecutor/sampler/seed_manager.py.
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
Resume a seeded request after k = 8 tokens by sending its prompt plus those tokens as a new prompt with the same seed, as request migration (Dynamo) and RL partial rollouts do:
repro.py (TinyLlama-1.1B-Chat, temperature 1, seed 1234)
from tensorrt_llm import LLM, SamplingParams
from tensorrt_llm.llmapi import KvCacheConfig
def main():
llm = LLM("TinyLlama/TinyLlama-1.1B-Chat-v1.0",
kv_cache_config=KvCacheConfig(enable_block_reuse=False))
prompt = llm.tokenizer.encode("Write a short story about a lighthouse keeper.")
def generate(token_ids, n):
sp = SamplingParams(max_tokens=n, temperature=1.0, seed=1234, ignore_eos=True)
return list(llm.generate([token_ids], sp)[0].outputs[0].token_ids)
k = 8
full = generate(prompt, 16) # one uninterrupted request
resumed = generate(prompt + full[:k], 16 - k) # same seed, resumed after k tokens
print("uninterrupted[k:]", full[k:])
print("resumed ", resumed)
llm.shutdown()
if __name__ == "__main__":
main()
uninterrupted[k:] [29958, 13, 8439, 892, 263, 2846, 1180, 1338]
resumed [29958, 13, 2887, 263, 301, 18919, 1709, 1589]
Expected behavior
The resumed request draws the same random number at each position as the uninterrupted one, so its tokens match wherever the logits match. vLLM (model runner v2) and SGLang (multinomial_with_seed) key each seeded draw to (seed, token position).
actual behavior
Over 64 prompts resumed after 1, 8 and 32 tokens (TinyLlama, temperature 1), the first resumed token matched in 123/192 runs and the whole continuation in 0/192.
_SeedManager.observe sets a seeded request's Philox offset to 0 when it takes its slot, so the resumed request draws its first token with offset 0 instead of k.
additional notes
- Proposed fix: start the offset at the request's token count (prompt included), so each token's offset is its sequence position. The first resumed token then matches in 179/192 runs.
- Replaying the sampler offline on the engine's logits reproduces both tokens with offset
prompt_len + kin every run, so the 13 left come from prefill vs decode logit differences. - The fix renumbers seeded streams: ordinary seeded requests, and n > 1 requests without a seed (C++ seeds them 0..n-1), sample different tokens from the same distribution.
- Greedy and n = 1 unseeded outputs do not change. I have the change with unit tests and will open a PR that references this issue.
- 主要言語
- Python
- スター
- 15.2k
- フォーク
- 3k
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 477
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/TensorRT-LLM のほかの issue
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.x対応中かも @NimaVaziri が今日担当しました。 オープンPytorch
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/TensorRT-LLM#23406 ·
メンテナーはふだん 1 日以内に返信
-
Inference runtime Windows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
NVIDIA/TensorRT-LLM#23394 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: MMLU subsampling changes when evaluators are interleaved対応中かも @LeNeLeNeWo が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NVIDIA/TensorRT-LLM#23273 ·
メンテナーはふだん 1 日以内に返信
-
Trace-replay Pareto window includes the drain when sessions finish out of admission order対応中かも @sbeierle が 3 日前に担当しました。 オープンTesting
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NVIDIA/TensorRT-LLM#23077 ·
メンテナーはふだん 1 日以内に返信
-
LongBench V2 blog command breaks on inline comments after continuations対応中かも @ddlw が 25 日前に担当しました。 オープンDoc
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
NVIDIA/TensorRT-LLM#21879 ·
メンテナーはふだん 1 日以内に返信
NVIDIA/TensorRT-LLM の issue をすべて見る
似ている issue
-
[Resource]: Spaicelyオープンresource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
hesreallyhim/awesome-claude-code#3875 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
bvis/aegis-hass#725 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
メンテナーはふだん 1 日以内に返信