Mechanistic interpretability for hybrid Mamba-Attention LLMs (Jamba, Zamba2): cross-component SAEs, ablation attribution, and a Hub registry.
Project description
hybridlens
Mechanistic interpretability for hybrid Mamba-Attention LLMs — Jamba, Zamba2 — with cross-component SAEs, ablation attribution, and a Hub registry.
hybridlens is the recurrentlens
sibling for mixed-architecture models, where attention layers, SSM layers,
and MoE routers coexist in a single forward pass. Pure-transformer tools
(SAELens, OpenMOSS) and pure-SSM tools (recurrentlens) both assume a single
component family; hybrid models need per-component analysis.
Why hybrid-specific tooling
2026's mainline open-weight LLMs are no longer pure transformers: AI21's
Jamba 1.5, Zyphra's Zamba2, NVIDIA's Nemotron Nano 2, and Microsoft's Samba
all ship Mamba+Attention+MoE in a single stack. The existing mechanistic
interpretability toolchain (SAELens, OpenMOSS, circuit-tracer) was
written against decoder-only transformers and silently mis-attributes
features when an SSM layer or MoE router is present. hybridlens fills
that gap with per-component SAEs trained on the actual hidden stream
each layer carries, plus attribution that respects the component boundary.
Solo-maintained OSS. Best-effort response. No production SLA. Released 2026 by @hinanohart under Apache-2.0.
v0.1.0 scope
Eight public APIs covering Jamba + Zamba2:
load_hybrid_model— load and tag attention / SSM / MoE componentsHybridLensModel— wrapper that composes (does not subclass) therecurrentlensprimitives (BaseSAE,HookManager,ActivationCache)LayerLayout— pydantic schema for per-layer component maptrain_component_sae— train an SAE on one component's hidden streamComponentSAEBundle— save/load a per-component SAE collectionattribute(method='ablation')— zero-ablation attribution to target metricsteer_component— context-managed activation steeringhub_push_bundle/hub_load_bundle— HF Hub I/O for bundles
Deferred to v0.1.1+: captum integrated-gradients attribution, MoE expert routing trace, Sankey cross-component flow viz, Nemotron / Samba adapters, pretrained Hub bundles, HF Space deploy.
v0.1.0a0 alpha — what runs vs what raises
The alpha freezes the eight public signatures and ships the bookkeeping half of the library — anything that does not need a live forward pass through a hybrid LLM. Concretely:
| API | v0.1.0a0 status |
|---|---|
LayerLayout / LayerSlot |
runs |
JambaAdapter.discover_layout / Zamba2Adapter.discover_layout |
runs (config-driven) |
hooks.resolve_site |
runs |
ComponentSAEBundle (in-memory + save / load round-trip) |
runs |
viz.render_hybrid_explorer |
runs |
hub_push_bundle / hub_load_bundle |
runs (lazy HfApi import) |
load_hybrid_model |
NotImplementedError until v0.1.0 final |
train_component_sae |
NotImplementedError until v0.1.0 final |
attribute(method='ablation') |
NotImplementedError until v0.1.0 final |
steer_component (scale ≠ 0 branch) |
NotImplementedError until v0.1.0 final |
hooks.install_capture_hook |
NotImplementedError until v0.1.0 final |
The five remaining APIs require torch + transformers +
recurrentlens to be installed in the same environment; they land in
v0.1.0 (final) after the Phase 5 release-verify venv exercises them
end-to-end. The signatures are frozen — you can write code against them
today.
Install
pip install hybridlens
# Optional Mamba kernels (CUDA only):
pip install "hybridlens[mamba]"
Quick look
import hybridlens as hl
model = hl.load_hybrid_model("ai21labs/Jamba-tiny-dev", family="jamba")
bundle = hl.train_component_sae(
model,
component="attn",
layer=4,
n_tokens=200_000,
)
print(bundle.summary())
⚠️ HF Hub anonymous rate limit (100 req/h) — set
HF_TOKENfor steady-state usage.
Known limitations (v0.1.0)
- Only Jamba and Zamba2 adapters. Nemotron-Nano / Samba arrive in v0.1.1.
- Attribution is zero-ablation only; captum IG is v0.1.1.
- MoE expert tracing and cross-component Sankey viz are v0.2.
- Default training dataset is Pile-uncopyrighted; users supplying their own corpora are responsible for license compliance.
- Bundle Hub assets are user-uploaded; no pretrained release ships with v0.1.0.
Citation
@software{hinanohart_hybridlens_2026,
author = {hinanohart},
title = {hybridlens: cross-component SAE attribution for hybrid LLMs},
year = {2026},
url = {https://github.com/hinanohart/hybridlens},
version = {0.1.0a0},
}
Related
recurrentlens— sibling project for pure-SSM models.hybridlensreuses itsBaseSAE,HookManager,ActivationCache, andhub.ioprimitives.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hybridlens-0.1.0a2.tar.gz.
File metadata
- Download URL: hybridlens-0.1.0a2.tar.gz
- Upload date:
- Size: 38.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41845c971b7d94a1947e87b0f38d130f25f15fe8d10011f13c81c5eed1869eae
|
|
| MD5 |
c50a46e48582a04b114ca0d3b571d3b7
|
|
| BLAKE2b-256 |
c13404938400ec984d3c1445eb76ac7fba19e9a24ee32086608599fd88ac756d
|
Provenance
The following attestation bundles were made for hybridlens-0.1.0a2.tar.gz:
Publisher:
release.yml on hinanohart/hybridlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hybridlens-0.1.0a2.tar.gz -
Subject digest:
41845c971b7d94a1947e87b0f38d130f25f15fe8d10011f13c81c5eed1869eae - Sigstore transparency entry: 1635376030
- Sigstore integration time:
-
Permalink:
hinanohart/hybridlens@cbb38c72490b1d8499f1b3b446d37a5d003ad3dd -
Branch / Tag:
refs/tags/v0.1.0a2 - Owner: https://github.com/hinanohart
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cbb38c72490b1d8499f1b3b446d37a5d003ad3dd -
Trigger Event:
push
-
Statement type:
File details
Details for the file hybridlens-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: hybridlens-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b790f0d9d330a04cacbc0e47fd4bd49d02c467328609c0fceb6f112a0b3da34d
|
|
| MD5 |
09a2d80f06eab763e340560933155677
|
|
| BLAKE2b-256 |
a894a0d25f12a5fe9c5a4136ab84a3c8f02ed3b122e84e639bd53025690936e3
|
Provenance
The following attestation bundles were made for hybridlens-0.1.0a2-py3-none-any.whl:
Publisher:
release.yml on hinanohart/hybridlens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hybridlens-0.1.0a2-py3-none-any.whl -
Subject digest:
b790f0d9d330a04cacbc0e47fd4bd49d02c467328609c0fceb6f112a0b3da34d - Sigstore transparency entry: 1635376039
- Sigstore integration time:
-
Permalink:
hinanohart/hybridlens@cbb38c72490b1d8499f1b3b446d37a5d003ad3dd -
Branch / Tag:
refs/tags/v0.1.0a2 - Owner: https://github.com/hinanohart
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cbb38c72490b1d8499f1b3b446d37a5d003ad3dd -
Trigger Event:
push
-
Statement type: