Mamba trades attention for a selective state — linear time, fixed memory, and what the trade costs
Mamba is a sequence model from Albert Gu (Carnegie Mellon) and Tri Dao (Princeton), published on arXiv in December 2023 as "Mamba: Linear-Time Sequence Modeling with Selective State Spaces". It removes the attention block that makes a Transformer compare every token with every other token, and replaces it with a selective state-space model: a compressed hidden state that is updated once per token, with the update rule itself depending on the input. Compute and memory grow linearly with sequence length instead of quadratically, the paper reports about five times the inference throughput of a same-size Transformer, and a 3-billion-parameter Mamba matches Transformers of twice its size on language benchmarks. The SaM Solutions explainer in the 2026-09-18 Gemini briefing is the source of this item; the numbers were checked against the paper and later summaries.
For Jayverse the useful part is the shape of the trade, not the architecture. Attention keeps the whole context and pays for it every step; a state-space model keeps a fixed-size summary and pays nothing extra for length, but it has to decide, token by token, what to forget. That is the same design choice as an indexer that keeps a rolling aggregate instead of replaying the log, or a rail that keeps a running balance instead of the ledger. Where the summary is enough, the linear model wins on cost; where an exact lookup far back is required, it loses. The industry answer since 2024 has been hybrids, such as AI21's Jamba, that interleave a few attention layers into a mostly state-space stack. Status on 2026-09-18: Mamba and Mamba-2 are open source under the state-spaces GitHub organisation; the hybrid pattern is what ships in production long-context models.
Why
Context length is priced in the attention block. Doubling the context of a Transformer quadruples the compute of that block and doubles the key-value cache it must hold per token, which is why long documents, contracts and streams are expensive and why "context engineering" exists as a discipline. Mamba's argument is that most of that work is wasted: a model that reads left to right and keeps a well-chosen compressed state can do the job of attention for many tasks at a fraction of the cost, the way a human reader carries a summary rather than re-reading every earlier sentence. The word selective is the contribution. Earlier state-space models had fixed update rules and could not decide what to keep; Mamba makes the update parameters functions of the current token, so the model can hold on to a name and let go of filler.
The cost is recall. A fixed-size state cannot store an arbitrary number of exact facts, and tasks that need a precise copy of something far back, such as retrieving a key from a long list, are where pure state-space models fall behind. That is why the practical outcome is not "Mamba replaces Transformers" but "a few attention layers buy back exact recall inside a cheap linear stack".
How it works
The two blocks side by side
Attention (Transformer)
Selective state space (Mamba)
Per-token work
compare with every previous token
one state update
Cost in sequence length N
O(N²) compute, cache grows with N
O(N) compute, fixed-size state
What it keeps
everything, addressable
a learned compressed summary
Weakness
long contexts are expensive
exact recall of distant detail
Typical fix
sparse or windowed attention, KV-cache tricks
hybrid stacks with some attention layers
The numbers in the paper
Five times higher inference throughput than a Transformer of the same size; linear scaling in sequence length on real data up to a million tokens; Mamba-3B outperforming same-size Transformers and matching ones twice its size on downstream language evaluations; strong results on audio and genomics as well as text. Mamba-2 (2024) reframed the state-space update as a form of structured attention and made it faster on GPUs.
Where it lands in Jayverse
Rabbit and the agent stack: choose context strategy by recall need, not by fashion. Where an agent needs exact recall of a specific earlier tool result, keep it in the prompt or in retrieval; where it needs a running summary of a long session, a compressed state is the right tool and cheaper. Write the distinction into the context-engineering notes.
Number: long streams are a state-space problem. A reading computed over a long price or flow series is a rolling aggregate, which is exactly what a selective state does well; the Number pipeline should store the rolling state and the rule that updates it, and replay the raw series only when an exact past value is disputed.
Devnet indexer: summary versus log is the same trade. Ponder-style indexers keep aggregates and replay on reorg; document which queries need exact history so the aggregate is never asked for something it forgot.
Theory: link this item from the attention and KV-cache curriculum stubs. It is the counter-example those pages need: what a model looks like when the quadratic block is removed and what it gives up.
Verified and unverified
Verified on 2026-09-18: authors, title and December 2023 arXiv posting (arXiv 2312.00752); the five-times throughput, linear scaling and Mamba-3B-versus-twice-its-size claims (paper abstract, later summaries); open-source repository under state-spaces; hybrid designs such as Jamba. From the SaM Solutions video via the Gemini briefing, not independently checked: the "fixed memory footprint" phrasing and the claim about edge execution and cloud cost reductions, which are inferences from the architecture rather than measurements in the paper. Not covered here: Mamba-3 or later variants.
Mamba는 어텐션을 선택적 상태로 바꾼다 — 선형 시간, 고정 메모리, 그리고 그 교환의 비용
Mamba는 Albert Gu(카네기멜런)와 Tri Dao(프린스턴)가 2023년 12월 arXiv에 "Mamba: Linear-Time Sequence Modeling with Selective State Spaces"로 발표한 시퀀스 모델입니다. 트랜스포머가 모든 토큰을 다른 모든 토큰과 비교하게 만드는 어텐션 블록을 없애고, 선택적 상태공간 모델로 대체합니다. 토큰마다 한 번 갱신되는 압축된 은닉 상태이고, 갱신 규칙 자체가 입력에 따라 달라집니다. 계산과 메모리가 시퀀스 길이에 대해 이차가 아니라 선형으로 늘고, 논문은 같은 크기 트랜스포머의 약 5배 추론 처리량을 보고하며, 30억 파라미터 Mamba가 언어 벤치마크에서 두 배 크기의 트랜스포머와 맞먹습니다. 2026-09-18 Gemini 브리핑의 SaM Solutions 설명 영상이 이 항목의 출처이고, 숫자는 논문과 이후 요약들로 확인했습니다.
Jayverse에 유용한 부분은 아키텍처가 아니라 교환의 형태입니다. 어텐션은 전체 문맥을 보관하고 매 단계 그 값을 치릅니다. 상태공간 모델은 고정 크기 요약을 보관하고 길이에 대해 추가 비용을 내지 않지만, 토큰마다 무엇을 잊을지 결정해야 합니다. 로그를 재생하는 대신 롤링 집계를 유지하는 인덱서, 원장 대신 잔고를 유지하는 레일과 같은 설계 선택입니다. 요약으로 충분한 곳에서는 선형 모델이 비용에서 이기고, 멀리 뒤의 정확한 조회가 필요한 곳에서는 집니다. 2024년 이후 업계의 답은 AI21의 Jamba처럼 대부분 상태공간인 스택에 어텐션 층 몇 개를 끼워 넣는 하이브리드였습니다. 2026-09-18 기준 상태: Mamba와 Mamba-2는 state-spaces GitHub 조직에서 오픈소스이고, 프로덕션 장문맥 모델에 실리는 것은 하이브리드 패턴입니다.
왜
문맥 길이의 가격은 어텐션 블록에 매겨집니다. 트랜스포머의 문맥을 두 배로 늘리면 그 블록의 계산은 네 배, 토큰마다 들고 있어야 하는 키-값 캐시는 두 배가 됩니다. 긴 문서, 계약서, 스트림이 비싼 이유이고 "컨텍스트 엔지니어링"이 하나의 분야로 존재하는 이유입니다. Mamba의 주장은 그 작업 대부분이 낭비라는 것입니다. 왼쪽에서 오른쪽으로 읽으며 잘 고른 압축 상태를 유지하는 모델은, 앞 문장을 전부 다시 읽는 대신 요약을 들고 가는 사람처럼, 많은 과제에서 어텐션의 일을 훨씬 낮은 비용으로 할 수 있습니다. 선택적이라는 단어가 기여입니다. 이전 상태공간 모델은 갱신 규칙이 고정되어 무엇을 남길지 결정할 수 없었고, Mamba는 갱신 파라미터를 현재 토큰의 함수로 만들어 이름은 붙잡고 군말은 흘려보낼 수 있게 했습니다.
비용은 회상입니다. 고정 크기 상태는 임의 개수의 정확한 사실을 저장할 수 없고, 긴 목록에서 키를 찾는 것처럼 멀리 뒤의 것을 정확히 복사해야 하는 과제가 순수 상태공간 모델이 뒤처지는 곳입니다. 그래서 실제 결과는 "Mamba가 트랜스포머를 대체한다"가 아니라 "어텐션 층 몇 개가 싼 선형 스택 안에서 정확한 회상을 되사온다"입니다.
동작 방식
두 블록 나란히
어텐션(트랜스포머)
선택적 상태공간(Mamba)
토큰당 작업
이전 모든 토큰과 비교
상태 갱신 한 번
길이 N에 대한 비용
O(N²) 계산, 캐시가 N에 비례
O(N) 계산, 고정 크기 상태
보관하는 것
전부, 주소 지정 가능
학습된 압축 요약
약점
긴 문맥이 비쌈
먼 세부의 정확한 회상
흔한 해법
희소·윈도 어텐션, KV 캐시 기법
어텐션 층을 일부 넣은 하이브리드
논문의 숫자
같은 크기 트랜스포머 대비 5배 높은 추론 처리량. 실제 데이터에서 백만 토큰까지 시퀀스 길이에 선형. Mamba-3B가 같은 크기 트랜스포머를 앞서고 두 배 크기와 맞먹음. 텍스트뿐 아니라 오디오와 유전체에서도 강한 결과. Mamba-2(2024)는 상태공간 갱신을 구조화된 어텐션의 한 형태로 재정식화해 GPU에서 더 빨라졌습니다.
Jayverse에서의 위치
Rabbit과 에이전트 스택: 문맥 전략은 유행이 아니라 회상 필요로 고른다. 에이전트가 특정 이전 도구 결과를 정확히 회상해야 하면 프롬프트나 검색에 두고, 긴 세션의 흐르는 요약이 필요하면 압축 상태가 맞는 도구이고 더 싸다. 이 구분을 컨텍스트 엔지니어링 노트에 적는다.
Number: 긴 스트림은 상태공간 문제다. 긴 가격·흐름 시계열에서 계산되는 읽기는 롤링 집계이고, 그것이 선택적 상태가 잘하는 일이다. Number 파이프라인은 롤링 상태와 그 갱신 규칙을 저장하고, 과거의 정확한 값이 다툼이 될 때만 원시 시계열을 재생한다.
Devnet 인덱서: 요약 대 로그는 같은 교환이다. Ponder식 인덱서는 집계를 유지하고 재구성 때 재생한다. 어떤 질의가 정확한 이력을 필요로 하는지 문서화해서 집계에 잊어버린 것을 묻지 않게 한다.
Theory: 어텐션과 KV 캐시 커리큘럼 스텁에서 이 항목을 링크한다. 그 페이지들에 필요한 반례다. 이차 블록을 뺀 모델이 어떤 모습이고 무엇을 포기하는가.
확인된 것과 미확인
2026-09-18에 확인한 것: 저자, 제목, 2023년 12월 arXiv 게재(arXiv 2312.00752); 5배 처리량, 선형 확장, Mamba-3B 대 두 배 크기 주장(논문 초록, 이후 요약); state-spaces의 오픈소스 저장소; Jamba 같은 하이브리드 설계. Gemini 브리핑의 SaM Solutions 영상에서 온 것으로 독립 확인하지 않은 것: "고정 메모리 풋프린트" 표현, 엣지 실행과 클라우드 비용 절감 주장. 논문의 측정이 아니라 아키텍처에서의 추론이다. 다루지 않은 것: Mamba-3 이후 변형.