Advancing LLM efficiency with innovative memory solutions.
Project details
Mixture of Scars (MoS) combines static weight compression with a constant O(1) KV-cache replacement system to enhance the performance of large language models. This project seeks to minimize the resource gap in deploying transformer models by optimizing memory usage, ultimately enabling faster processing and more accessible AI applications.
Overview: Mixture of Scars (MoS) and SCache aim to address the dual memory limitations faced by autoregressive Transformers ranging from 0.5B to 72.71B parameters. This project presents an innovative solution to the problems of static parameter bloat and the increasing resource demands of traditional memory techniques.
Mixture of Scars (MoS): This technique combines canonical Block-64 INT4 weights with Activation-Aware SVD (ASVD) based low-rank scar experts, facilitating efficient training and inference. It utilizes streaming shards to enhance the speed and efficiency of GPU computations, achieving a significant memory reduction and speed improvement across multiple architectures, including Apple Silicon and NVIDIA CUDA Triton.
135.43 GiB to 38.12 GiB) at 72.71B, with reports indicating up to 195,720× reduction in outliers when compared to standard implementations, ensuring 100% top-5 agreement on accuracy.SCache (Dynamic Cache): This feature acts as a drop-in solution for HuggingFace Transformers, bringing a constant (\mathcal{O}(1)) memory consumption model which leverages a unique FIFO mechanism and advanced memory management techniques. The SCache system efficiently manages memory by capturing context and utilizing fast weights without the traditional bloat associated with larger Transformers.
A brief overview of how to utilize these systems effectively:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from scar_cache import SCacheDynamicCache
model_id = "Qwen/Qwen2.5-3B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
# Establishing a constant O(1) cache
cache = SCacheDynamicCache(window_size=256, num_sink_tokens=4, num_slots=256)
inputs = tokenizer("Your 32k+ token context here...", return_tensors="pt").to(model.device)
out = model.generate(**inputs, past_key_values=cache, max_new_tokens=64)
For detailed research, performance benchmarks, and theoretical foundations, the full documentation is available:
This project strives to enable more efficient and scalable AI solutions, empowering applications that were previously constrained by the size and complexity of language models.
Comments
0Start the conversation
Share the first comment.