Skip to main content

Diagnostic toolkit for scientific foundation models. Understand what your model learned, where it will fail, and how representations evolve across layers.

Project description

MatScope

Diagnostic toolkit for scientific foundation models.

MatScope brings mechanistic interpretability to atomistic ML. Understand what your model learned, where it will fail, and how representations evolve across layers.

Paper: Information Routing in Atomistic Foundation Models: A Composition Projection Decomposition Analysis (Steier, 2026)

What MatScope Does

Most atomistic foundation model benchmarks test performance — energies, forces, stability. MatScope tests representations: what information is encoded, at which layer, and in what form.

The central method is Composition Projection Decomposition (CPD), which separates composition-encoded from geometry-encoded information in model representations. Key finding: equivariant models (MACE) produce linearly disentangled composition/geometry representations, while invariant models (ANI-2x) require nonlinear access to geometric information.

Installation

pip install matscope

With model backends:

pip install matscope[mace]      # MACE support
pip install matscope[pyg]       # SchNet, DimeNet++, PaiNN
pip install matscope[ani]       # ANI-2x (TorchANI)
pip install matscope[full]      # Everything

Quick Start

CPD Analysis

from matscope import CompositionProjectionDecomposition
from matscope.datasets import composition_features
import numpy as np

# Your model representations at each layer (n_samples × hidden_dim)
representations = {
    "interaction_0": layer_0_reps,
    "interaction_1": layer_1_reps,
    "readout": readout_reps,
}

# Composition features from atomic structures
compositions = composition_features(structures, method="fractional")

# Run CPD
cpd = CompositionProjectionDecomposition()
profile = cpd.profile(
    representations, compositions, targets,
    model_name="MACE-MP-0",
    target_property="HOMO-LUMO gap"
)

print(profile.summary())
# CPD Profile: MACE-MP-0
# Target: HOMO-LUMO gap
# Best geometric layer: interaction_2 (R²_resid=0.782)
# Most nonlinear layer: interaction_0 (gap=0.031)

Compare Architectures

# Run CPD on multiple models
profiles = {
    "MACE": mace_profile,
    "SchNet": schnet_profile,
    "ANI-2x": ani_profile,
}

comparison = CompositionProjectionDecomposition.compare_profiles(profiles)
# MACE: rank 1 (high residual R², low gap — linearly disentangled)
# ANI-2x: rank 3 (negative residual R², high gap — nonlinearly entangled)

Probing

from matscope import MatScope

# Load model and probe
ms = MatScope.from_model("mace-mp-0")
reps = ms.extract(dataset, layers=["interaction_0", "interaction_1", "readout"])
result = ms.probe("coordination_number", representations=reps, labels=labels)
ms.report(result, save="probing_results.pdf")

Representation Comparison

# Compare what two models learn
sim = ms_mace.compare(ms_chgnet, dataset=structures, method="cka")
ms_mace.report(sim, save="cka_matrix.pdf")

Distribution Shift Detection

shift = ms.detect_shift(
    train_data=bulk_crystals,
    deploy_data=surface_slabs,
    method="mmd"
)
print(f"Shift hits hardest at: {shift.most_affected_layer}")

Supported Models

Model Backend Architecture Type
MACE-MP-0 mace-torch Equivariant (E(3))
CHGNet chgnet Graph neural network
SchNet torch-geometric Learned invariant
DimeNet++ torch-geometric Directional message passing
PaiNN torch-geometric Equivariant (E(3))
ANI-2x torchani Handcrafted invariant
Any PyTorch model built-in Generic hook registration

API Reference

Core Classes

  • MatScope — Main orchestrator. Load models, extract representations, probe, compare, detect shift.
  • CompositionProjectionDecomposition — CPD methodology. Separates composition/geometry in representations.
  • LinearProbe / MLPProbe — Probing classifiers/regressors with cross-validation.
  • SelectivityProbe — Linear probe with feature selectivity analysis.
  • RepresentationSimilarity — CKA, CCA, Procrustes comparison across models/layers.
  • ShiftAnalyzer — MMD, Fisher, cosine drift detection.
  • LayerwiseAnalyzer — Effective dimensionality, isotropy, entropy per layer.

Dataset Utilities

  • composition_features(structures) — Extract fractional/count/onehot composition vectors.
  • load_qm9() — Load QM9 with all 19 properties.
  • load_from_ase(atoms_list) — Wrap ASE Atoms for MatScope.
  • train_test_split(dataset_dict) — Split with consistent indexing.

Relationship to Other Tools

  • mlipx (BASF): Benchmarks performance (energy curves, MD stability). Complementary — mlipx asks "how accurate?", MatScope asks "what did it learn?"
  • LAMBench / MLIP-Arena: Leaderboard comparisons. MatScope goes deeper into representations.
  • TransformerLens / SAELens: LLM interpretability. MatScope is the atomistic equivalent.

Citation

@article{steier2026information,
  title={Information Routing in Atomistic Foundation Models: A Composition Projection Decomposition Analysis},
  author={Steier, Joshua},
  journal={arXiv preprint arXiv:XXXX.XXXXX},
  year={2026}
}

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matscope-0.2.0.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matscope-0.2.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file matscope-0.2.0.tar.gz.

File metadata

  • Download URL: matscope-0.2.0.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for matscope-0.2.0.tar.gz
Algorithm Hash digest
SHA256 25c2a9a265e4cd51f3abdb1325934cb47c73c21c84df36b724ca51b59216a052
MD5 45ddc4b8f9e55cdcb8d910a435d4dced
BLAKE2b-256 157d1c97e2951c982d4fced7273758b0f1fbc51526b793ac2b76fa9a3db9a003

See more details on using hashes here.

File details

Details for the file matscope-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: matscope-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for matscope-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9545e0ea61835876b7c6db05e6208c35d18b0ce041d6b9a358bc30576549c79
MD5 e3ef01ae59385e39c8a1a5c1ea047fd8
BLAKE2b-256 a3a19b84392773f4c3f92845a3dc5d98630e00f57f62fd85fe6fdda7f7c6e26b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page