ValueError: `has_previous_state` can only be called on LinearAttention layers, and the current Cache seem to only contain Attention layers.

用户使用 Hugging Face Transformers 加载 ibm-granite/granite-4.0-350m-base 模型,调用 model.generate() 进行文本生成时触发该错误。系统环境为 Ubuntu 24.04 with Python 3.12.12、Transfo







![Claude寓言 5 vs. Kimi K3 vs. GPT 5.6 Sol [视频]](https://www.chat-gpts.plus/wp-content/uploads/2026/07/ai_cover_4-599-768x403.jpg)
