Inkling-2-Mini-MLA-LatentKV-Looping-4Layer-HealProbe
3.5x KV cache compression
2 min readupdated
An experimental research patch based on the multimodal model (VLM) thinkingmachines/Inkling-2-Mini (26.4B parameters, inkling2_loop architecture) by RESMP-DEV. The author replaced key and value projections across all four full-attention layers with a rank-512 latent representation using the MLA (Multi-Head Latent Attention memory-compression method) principle to radically reduce context memory consumption. To compensate for the loss of accuracy after the weight restructuring, the model underwent a 32-step "heal probe" fine-tuning with LoRA (small trainable adapters) using just 16,384 tokens. Important: this is not a production-ready model after full training, but a research artifact demonstrating a method for rapid weight recovery following architectural surgery.
Key features
- KV cache savings: the cache volume per token is reduced from 32,768 to 9,216 bytes in BF16, which decreases the required memory from 30.674 GiB to 8.739 GiB on a 1M token context.
- Cyclic architecture handling: in
inkling2_loop, layers 6–17 run three times per pass, so patching the looped layers 11 and 17 provides a triple memory gain. - 32-step recovery: initialization via SVD (singular value decomposition) and a short rank-64 LoRA probe restored 98.0% of the lost accuracy on a validation slice.
- Dequantized BF16 weights: unlike the base checkpoint in NVFP4/MXFP8 formats, this version has been converted to BF16 and is ready for further fine-tuning.
What you can do
- Explore model recovery recipes: use the code and configs from the repository (
heal/config.json,modeling_inkling2_loop_patched.py) as a base for experimenting with KV cache compression in cyclic architectures. - Run full fine-tuning: take the ready BF16 checkpoint with merged LoRA weights for full SFT (supervised fine-tuning) or RL, as the author only limited themselves to a 32-step check.
- Compare the memory-quality trade-off: contrast this 4-layer version with the 3-layer variant (
[5, 11, 17]), which sacrifices part of the memory savings for lower cross-entropy.
Example
import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer
model_id = "RESMP-DEV/Inkling-2-Mini-MLA-LatentKV-Looping-4Layer-HealProbe"
model = AutoModelForImageTextToText.from_pretrained(
model_id, torch_dtype=torch.bfloat16, trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
Read more
DetailsCross-entropy on a held-out agent slice (4096 tokens): 1.5088 for the base, 1.9731 before healing, and 1.5183 after the heal probe (+0.0095 from base).
Calculated concurrency with a 40 GiB KV cache budget on a 1M context: up to 4.58 sessions versus 1.30 for the base (upper estimate excluding weights and activations).
Requirements:
transformers library version 5.24.1 or newer and the trust_remote_code=True flag; inference speed measurements on accelerators were not conducted.License: Apache 2.0.










Comments