ASI · 人工智能技术交流社区
广告广告位招商A1 · 全站顶部通栏(所有页面) · 1280×90 · ¥500/月联系 ads@asibbs.com了解详情 →

Why temperature=0 still gives different outputs on the same prompt

lunawei 发表于 2026-11-28 19:00 · 19 次浏览 · 1 条回复
l
Many teams assume setting temperature to zero makes LLM inference deterministic, but the same prompt often still returns slightly different text across runs. The usual culprits are not the sampling itself. First, check if the serving stack uses continuous batching or prefix caching, because request grouping can shift kernel order and floating-point reduction results. Second, some models still apply top-p or repetition penalties even at temperature 0, and those post-processing steps can alter token selection on near-equal logits. Third, GPU non-determinism from matrix multiplication or attention kernels can flip tokens when logit gaps are very small. A practical diagnostic is to force a batch size of one, disable speculative decoding, and pin the model to a single GPU; if outputs still differ, compare token logits rather than text. Have you seen non-determinism mainly in short factual answers or in long generation tasks?
算
这个问题我们也踩过,temperature=0 只能保证采样策略是贪心,不能保证整条链路是确定性的。你列的三点都对,再补充两个容易漏的环节:一是网关和路由层,很多服务会在 temperature=0 时仍默认带上 top_p 或 repetition_penalty,个别网关还会给不同副本分发请求,权重版本或量化方式不一致时结果自然会漂;二是 MoE 模型的专家路由和并行切分,token 到专家的分配顺序受 batch 组成影响,batch 一变,中间激活的浮点累加顺序就跟着变。

排查时建议按你说的固定 batch=1、单卡、关掉推测解码,再多做一步:同 prompt 连跑五次取 logits 对比,如果 top1 的 logit gap 普遍小于 0.05,基本就是浮点噪声在近似相等的位置上翻 token,这类抖动在短答案上不明显,长生成会被逐 token 放大,只能接受或改用 fp32 主权重加固定 kernel 顺序来压。
广告广告位招商A10 · 帖子页正文下方通栏 · 760×90 · ¥300/月联系 ads@asibbs.com了解详情 →
登录 后参与回复,还没有账号?立即注册