Conversation
Two small additions on top of the Laguna model: - make_cache(): the sliding_attention layers (the majority) never attend beyond their window, so return a bounded RotatingKVCache(max_size= sliding_window) for them and a full KVCache only for the full_attention (global) layers. Without this, make_prompt_cache allocates a full cache on every layer, so long-context runs store and attend over history the sliding layers can't use (measured ~2.7x decode and ~4 GB less KV at 32k on the 8-bit repack); bitwise-identical to a full cache at <= window context. - sanitize(): strip the VLM-style `language_model.` prefix that some repacks (e.g. AtomicChat/Laguna-XS-2.1-MLX-8bit) put on every tensor, so a stock load finds the weights. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @Blaizzy — the two small additions I mentioned on ml-explore#1223, as a ready-to-merge follow-up onto your branch (merging this updates the PR). Both are tested against your current
pc/add-lgandblack==25.1.0clean.1.
make_cache()for the sliding-window layers. Thesliding_attentionlayers (the majority) never attend beyond their window, so this returns a boundedRotatingKVCache(max_size=sliding_window)for them and a fullKVCacheonly for thefull_attention(global) layers. Without it,make_prompt_cacheallocates a full cache on all 40 layers — storing/attending over history the sliding layers can't use. Measured ~2.7x decode and ~4 GB less KV at 32k on the 8-bit repack; bitwise-identical to a full cache at ≤ window context. Falls back to a full cache if a config omitssliding_window.2.
language_model.prefix strip insanitize(). Some repacks (e.g.AtomicChat/Laguna-XS-2.1-MLX-8bit) wrap every tensor under a VLM-stylelanguage_model.prefix, so a stock load misses all weights. This strips it up front when present.Verified locally:
make_cache()returns the right cache type perlayer_types, forward + single-step decode run with those caches, andsanitize()strips the prefix. Happy to adjust to your preferences, or drop it if you'd rather fold these in yourself.