# Logits from generate and model call different

**URL:** <https://discuss.huggingface.co/t/logits-from-generate-and-model-call-different/81692>\
**Category:** 🤗Transformers\
**Created:** [April 14, 2024, 1:48pm UTC](https://discuss.huggingface.co/t/logits-from-generate-and-model-call-different/81692 "2024-04-14T13:48:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 26, 2025, 1:45pm UTC](https://discuss.huggingface.co/t/logits-from-generate-and-model-call-different/81692/3 "2025-01-26T13:45:02Z")

</div>

It seems that logits are affected when using KVCache, but if that’s not the case, it’s a different matter…

> [@Outputs change if re-using KVCache (past\_key\_values) for model.forward and generation](https://discuss.huggingface.co/t/outputs-change-if-re-using-kvcache-past-key-values-for-model-forward-and-generation/136556/5):
>
> I have found a post that could explain this: [Possible Bug with KV Caching in Llama (original) model · Issue #25420 · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/issues/25420#issuecomment-1775317535) In short: Using KV cache will change the logits, especially when the model is loaded in 16-bit precision.

---

_[View the full topic](https://discuss.huggingface.co/t/logits-from-generate-and-model-call-different/81692)._
