explaingit

facebookresearch/sparse-delta-memory

Analysis updated 2026-05-18

31PythonAudience · researcherComplexity · 5/5LicenseSetup · hard

TLDR

Meta's research code for a new AI memory component that helps language models recall information across very long text.

Mindmap

mindmap
  root((SDM))
    What it does
      Sparse memory bank
      Product key lookup
      Gated delta updates
    Tech stack
      PyTorch
      Triton
      CUDA
      Meta Lingua fork
    Use cases
      Long context recall research
      Benchmark reproduction
      Custom LLM architectures
    Audience
      ML researchers
    Limits
      Non-commercial license
      Needs modern GPU
      Research code not a product

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Study a new sparse memory mechanism for long-context language models.

USE CASE 2

Reproduce the paper's perplexity and RULER retrieval benchmark results.

USE CASE 3

Plug the Sparse Delta Memory layer into a Meta Lingua based training run.

USE CASE 4

Run a smoke test to check that the custom GPU kernels compile and work.

What is it built with?

PythonPyTorchTritonCUDA

How does it compare?

facebookresearch/sparse-delta-memoryalluxio/alluxio-pycase211/skill-remnawave-xray
Stars313131
LanguagePythonPythonPython
Last pushed2025-09-29
MaintenanceQuiet
Setup difficultyhardmoderateeasy
Complexity5/53/53/5
Audienceresearcherdatadeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1day+

Requires an SM 80+ GPU (Ampere or Hopper), PyTorch 2.8+, Triton 3.4+, CUDA toolkit, and a C++ compiler for JIT kernel builds.

Can be used and shared for non-commercial purposes only, under the Creative Commons Attribution NonCommercial 4.0 license.

In plain English

Sparse-Delta-Memory, or SDM, is Meta's research code released alongside an academic paper about a new way for AI language models to remember information across very long pieces of text. Most large language models struggle to recall details from far earlier in a long document or conversation, and this project proposes a new kind of memory component meant to help with exactly that problem. The core idea is a large, sparse memory bank that the model reads from and writes to using something called product keys, combined with a gating mechanism, similar in spirit to a technique called deltanet, that controls when the memory forgets old information and when it accepts new information. This is not an end user application. It is a research component meant to be plugged into a larger language model architecture, and the repository is built as a fork of Meta's existing Lingua research codebase, reusing its data preparation and training tools. The README includes benchmark results comparing this method against other memory approaches called Mamba2 and GDN, measured on perplexity, which is a measure of how well a model predicts text, and on a long context retrieval test called RULER. Across most of the reported tasks, SDM performs better than the comparison methods, especially at longer context lengths, though it does worse on a couple of individual tasks. Running this code requires real machine learning infrastructure: a modern GPU from Nvidia's Ampere or Hopper generation, a specific and fairly recent version of PyTorch and Triton, a working CUDA toolkit, and a compiler, since custom GPU kernels are compiled the first time they run. The README does provide a quick smoke test that exercises the GPU kernels without needing any real training data, plus instructions for a minimal training run using randomly generated text, before pointing to the steps needed for full scale training with real datasets. The code is released under a Creative Commons Attribution NonCommercial license, meaning it can be used and shared but not for commercial purposes.

Copy-paste prompts

Prompt 1
Explain how Sparse Delta Memory's gated product-key memory differs from standard attention.
Prompt 2
Help me set up the environment and GPU requirements to run tests/smoke_sdm.py.
Prompt 3
Walk me through running a minimal training job with synthetic data using debug_sdm.yaml.
Prompt 4
Summarize how SDM compares to Mamba2 and GDN on the RULER benchmark.
Prompt 5
What GPU and software versions do I need to get the CUDA kernels to compile?

Frequently asked questions

What is sparse-delta-memory?

Meta's research code for a new AI memory component that helps language models recall information across very long text.

What language is sparse-delta-memory written in?

Mainly Python. The stack also includes Python, PyTorch, Triton.

What license does sparse-delta-memory use?

Can be used and shared for non-commercial purposes only, under the Creative Commons Attribution NonCommercial 4.0 license.

How hard is sparse-delta-memory to set up?

Setup difficulty is rated hard, with roughly 1day+ to a first successful run.

Who is sparse-delta-memory for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.