By Sagar Shankaran, Founder of CallSphere
Hybrid architectures that interleave transformer attention layers with state-space model blocks like Mamba deliver faster inference and lower memory usage. Learn how they work and when to use them.
Key takeaways
Transformers have dominated language modeling since 2017, and for good reason — self-attention is remarkably effective at capturing long-range dependencies in sequences. But attention comes with a cost that scales quadratically with sequence length, and the key-value cache grows linearly during autoregressive generation. For long sequences and high-throughput serving scenarios, these costs become the dominant bottleneck.
State-space models (SSMs) offer an alternative. Rooted in control theory, SSMs process sequences through learned linear recurrences, achieving linear-time complexity with constant memory per step during inference. The Mamba architecture, introduced in late 2023, demonstrated that selective SSMs could match transformer quality on many benchmarks while being dramatically faster at long-sequence generation.
The question that has driven architecture research since then: what if you combine both?
An SSM processes a sequence by maintaining a hidden state that evolves according to learned dynamics:
flowchart LR
CALLER(["Client"])
subgraph TEL["Telephony"]
SIP["Twilio SIP and PSTN"]
end
subgraph BRAIN["Salon AI Agent"]
STT["Streaming STT<br/>Deepgram or Whisper"]
NLU{"Intent and<br/>Entity Extraction"}
TOOLS["Tool Calls"]
TTS["Streaming TTS<br/>ElevenLabs or Rime"]
end
subgraph DATA["Live Data Plane"]
CRM[("CRM and Notes")]
CAL[("Calendar and<br/>Schedule")]
KB[("Knowledge Base<br/>and Policies")]
end
subgraph OUT["Outcomes"]
O1(["Appointment booked"])
O2(["Reschedule completed"])
O3(["Stylist handoff"])
end
CALLER --> SIP --> STT --> NLU
NLU -->|Lookup| TOOLS
TOOLS <--> CRM
TOOLS <--> CAL
TOOLS <--> KB
NLU --> TTS --> SIP --> CALLER
NLU -->|Resolved| O1
NLU -->|Schedule| O2
NLU -->|Escalate| O3
style CALLER fill:#f1f5f9,stroke:#64748b,color:#0f172a
style NLU fill:#4f46e5,stroke:#4338ca,color:#fff
style O1 fill:#059669,stroke:#047857,color:#fff
style O2 fill:#0ea5e9,stroke:#0369a1,color:#fff
style O3 fill:#f59e0b,stroke:#d97706,color:#1f2937
# Simplified SSM recurrence (discretized)
def ssm_forward(x, A, B, C, D, delta):
"""
x: input sequence (batch, seq_len, d_model)
A, B, C, D: learned SSM parameters
delta: step size (input-dependent in Mamba)
"""
h = torch.zeros(x.shape[0], A.shape[0]) # hidden state
outputs = []
for t in range(x.shape[1]):
# Discretize continuous parameters
A_bar = torch.exp(delta[:, t:t+1] * A)
B_bar = delta[:, t:t+1] * B
# Update hidden state
h = A_bar * h + B_bar * x[:, t]
# Compute output
y = C @ h + D * x[:, t]
outputs.append(y)
return torch.stack(outputs, dim=1)
The critical innovation in Mamba is making the SSM parameters (B, C, and delta) input-dependent — they are computed as functions of the current token. This selectivity allows the model to decide what information to retain and what to discard, analogous to how attention selects relevant context.
Despite their efficiency advantages, pure SSM architectures have limitations:
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
Hybrid architectures interleave transformer attention layers with SSM layers, combining the strengths of both. The typical pattern dedicates a minority of layers (20-40%) to full attention while using SSM layers for the majority of the network.
Layer 1: SSM (Mamba) ─── Fast sequence processing
Layer 2: SSM (Mamba) ─── Efficient feature extraction
Layer 3: SSM (Mamba) ─── Linear-time context building
Layer 4: Attention ─── Full pairwise token interaction
Layer 5: SSM (Mamba) ─── Continue efficient processing
Layer 6: SSM (Mamba) ─── Compress and propagate
Layer 7: SSM (Mamba) ─── Near-constant memory per step
Layer 8: Attention ─── Global context integration
...repeat pattern...
The attention layers serve as "global synchronization points" where the model can perform precise information retrieval and complex reasoning over the full context. The SSM layers handle the bulk of sequence processing efficiently.
Benchmarks from hybrid model releases demonstrate significant improvements:
| Metric | Pure Transformer | Pure SSM | Hybrid (75% SSM / 25% Attention) |
|---|---|---|---|
| Inference throughput (tokens/sec) | 1x | 2.8x | 2.1x |
| KV cache memory at 32K context | 100% | 0% (no KV cache) | ~25% |
| Perplexity (language modeling) | 8.2 | 8.7 | 8.3 |
| In-context learning accuracy | 94% | 78% | 91% |
| Training FLOPs to convergence | 100% | 85% | 88% |
The hybrid captures most of the SSM speed advantage while retaining most of the transformer's in-context learning capability.
The memory savings from hybrid architectures are particularly impactful during inference. In a pure transformer, the KV cache for a 70B model at 128K context can exceed 40 GB. In a hybrid model where only 25% of layers use attention, the KV cache shrinks to approximately 10 GB — the SSM layers maintain a fixed-size hidden state regardless of sequence length.
This means hybrid models can serve longer contexts on the same hardware, or equivalently, handle higher concurrency on fixed GPU budgets.
The throughput advantage of hybrids is most pronounced during the generation (decode) phase, when the model produces one token at a time. In a pure transformer, each generated token requires computing attention over the entire KV cache. In hybrid layers that use SSM, each step is a constant-time operation that updates the hidden state.
For applications like real-time conversational AI, code generation with long context, or streaming document analysis, this speed difference translates directly into better user experience.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Training hybrid architectures introduces some engineering challenges:
Hybrid architectures are especially compelling when:
For short-context, latency-insensitive applications, the added architectural complexity of hybrids may not be justified. A standard transformer fine-tuned for the task may be simpler to deploy and maintain.
The transformer vs SSM debate is resolving not with a winner, but with a synthesis. The most capable architectures in 2026 use both mechanisms where each is strongest. Attention handles the tasks that require precise, global information access. SSMs handle the tasks that benefit from efficient, streaming sequence processing.
For engineering teams selecting model architectures, understanding this hybrid paradigm is becoming essential. The next generation of foundation models will not be purely one thing or another — they will be carefully designed compositions of complementary mechanisms.
Hybrid architectures interleave transformer attention layers with state-space model (SSM) layers like Mamba, combining the strengths of both approaches. The typical design dedicates 20 to 40 percent of layers to full attention while using SSM layers for the majority of the network. Benchmarks show hybrid models achieve 2.1x inference throughput compared to pure transformers while retaining 91% of in-context learning accuracy versus 78% for pure SSMs.
State-space models process sequences through learned linear recurrences, achieving linear-time complexity with constant memory per step during inference, compared to transformers' quadratic attention complexity. The Mamba architecture introduced input-dependent SSM parameters that allow the model to selectively decide what information to retain and discard, analogous to how attention selects relevant context. However, pure SSMs struggle with precise information retrieval and in-context learning tasks where transformers excel.
In a pure transformer, the KV cache for a 70B model at 128K context can exceed 40 GB, while a hybrid model where only 25% of layers use attention reduces the KV cache to approximately 10 GB. SSM layers maintain a fixed-size hidden state regardless of sequence length, eliminating cache growth for those layers. This means hybrid models can serve longer contexts on the same hardware or handle higher concurrency on fixed GPU budgets.

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
The evolution of attention from the original transformer to 2026's multi-query and grouped-query variants — what changed and why it matters.
Positional encodings dropped sinusoidal embeddings years ago. The 2026 RoPE, ALiBi, NoPE, and emerging positional patterns explained.
Sparse attention patterns are back in production for long-context inference. The 2026 implementations and where each pattern wins.
Mamba-3 and the state-space-model family now power production deployments. Where they beat transformers, where they lose, and what's next.
Design a hybrid agent system that runs fast local inference on edge devices for simple tasks and routes complex requests to cloud models, with seamless fallback and synchronization patterns.
Rwkv vs mamba 2025: technical comparison of emerging transformer alternatives including Mamba's selective state spaces, RWKV's linear attention, and hybrid architectures that combine the best of both worlds.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI