Skip to content

bug fix: handle saving/loading null layers in recurrent memory #14675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

l3utterfly
Copy link
Contributor

Currently saving loading kv cache of recurrent memory crashes because layers can be null.

This mainly applies to the new LiquidAI/LFM2 models.

Tested with: https://huggingface.co/LiquidAI/LFM2-350M-GGUF

handle saving/loading null layers in recurrent memory
@ggerganov ggerganov requested a review from compilade July 14, 2025 11:01
Copy link
Collaborator

@compilade compilade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @l3utterfly! I've tested this with a Jamba model and llama-save-load-state, and it was indeed failing before, and is fixed by this change.

I'll add a test case to #14139 (once I also add variants for hybrid models) to help automatically detecting this kind of regression with hybrid architectures in the future.

@@ -1005,6 +1017,9 @@ bool llama_memory_recurrent::state_read_data(llama_io_read_i & io, uint32_t cell
} else {
// For each layer, read the values for each cell (transposed)
for (uint32_t il = 0; il < n_layer; ++il) {
// skip null layers
if(s_l[il] == nullptr) continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(s_l[il] == nullptr) continue;
if (s_l[il] == nullptr) continue;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants