Skip to main content

SMGP — Spectral Memory Graph Processor

Python 3.10+ SystemVerilog License: Apache 2.0 CI Tests Tests RTL Sim PyPI PyPI - Downloads Code style: ruff

Persistent, hallucination-free AI reasoning through spectral graph theory, hyperdimensional computing, and dedicated hardware acceleration.

SMGP combines spectral graph theory, topological data analysis (TDA), hyperdimensional computing (HDC), and category-theoretic graph rewriting to achieve persistent memory, sublinear context processing, and verifiable reasoning. The framework ships with a complete Python software stack and an open-source hardware accelerator design (SMGPU) in SystemVerilog, enabling transparent offloading of compute-intensive kernels to an FPGA.

GitHub · Documentation · Issues


Installation

pip install smgp

With optional extras:

# Topological analysis (requires gudhi)
pip install "smgp[topology]"

# REST API + JWT auth
pip install "smgp[integration,auth]"

# HuggingFace / ONNX
pip install "smgp[huggingface,onnx]"

# Vector database sync (Qdrant)
pip install "smgp[vectordb]"

# Everything
pip install "smgp[all]"

Quick Start

from smgp.core.graph import SpectralMemoryGraph

# Build a knowledge graph with 10,000-dimensional HD addressing
graph = SpectralMemoryGraph(hd_dim=10000, seed=42)
graph.add_node("Socrates", label="person", properties={"era": "ancient Greece"})
graph.add_node("Plato",    label="person", properties={"era": "ancient Greece"})
graph.add_edge("Socrates", "Plato", "taught")

# Verify claims against the graph
from smgp.reasoning.verifier import ClaimVerifier
verifier = ClaimVerifier(graph)
result = verifier.verify("Socrates taught Plato")
print(result["verified"], result["reasoning"])

Spectral Analysis

from smgp.core.spectral import SpectralMethods

spectral = SpectralMethods(graph, num_eigenvalues=8)
L        = spectral.compute_laplacian()
evals, evecs = spectral.compute_eigen()
signal   = spectral.graph_fourier_transform(node_signal, evecs)

Hyperdimensional Memory

from smgp.core.hyperdim import HyperdimensionalMemory

hd = HyperdimensionalMemory(dim=10000, seed=42)
v1, v2 = hd.random_vectors(2)
bound  = hd.bind(v1, v2)
print(hd.similarity(hd.unbind(bound, v2), v1))  # ≈ 1.0

Hardware-Accelerated (FPGA)

from hardware.sw.smgp_hal.executor import HWExecutor
from hardware.sw.smgp_hal.hw_session import HWSession

session  = HWSession(device="/dev/smgpu0", fallback=True)
executor = HWExecutor(session=session)

# Drop executor into any core class — pure Python fallback when executor=None
graph    = SpectralMemoryGraph(hd_dim=10000, seed=42, executor=executor)
spectral = SpectralMethods(graph)          # inherits executor from graph
hd       = HyperdimensionalMemory(dim=10000, executor=executor)

Or via config:

from smgp.config import SMGPConfig, create_executor_from_config

cfg      = SMGPConfig.from_dict({"hd_dim": 10000,
           "hardware": {"enabled": True, "device": "/dev/smgpu0"}})
executor = create_executor_from_config(cfg)
graph    = SpectralMemoryGraph(hd_dim=cfg.hd_dim, executor=executor)

Features

Category Component Description
Core SpectralMemoryGraph Typed property graph with HD vector addressing
Core SpectralMethods Laplacian, GFT, Chebyshev convolution, wavelets
Core HyperdimensionalMemory 10,000-dim bipolar vectors, bind/bundle/similarity
Core TopologicalAnalyzer Persistent homology, Betti numbers, barcode
Core GraphRewriter Category-theoretic DPO graph rewriting
Memory MemoryStore Key-value persistence backend
Memory AssociativeMemory O(1) content-addressable HD recall
Memory MemoryLifecycle Persistence-based forgetting & eviction
Attention SpectralAttention O(N log N) multiscale spectral attention
Attention StreamingSpectralAttention Incremental online attention
Reasoning ClaimVerifier Path-based fact verification with proof subgraphs
Reasoning NeuroSymbolicPlanner Goal decomposition + symbolic constraint solving
Integration HuggingFace SMGPForCausalLM drop-in adapter
Integration LangChain SMGPMemory, SMGPVerifierTool
Integration REST API FastAPI server with JWT auth + rate limiting
Integration Vector DB Qdrant / Pinecone / Weaviate bidirectional sync
Integration ONNX/vLLM Export-ready attention wrapper
Hardware SMGPU RTL Open SystemVerilog 2017 FPGA accelerator
Hardware Python HAL HWExecutor — transparent FPGA offload
Hardware Bitstream make xclbin target for Alveo U280
CLI smgp version, graph-stats, verify, server

Configuration

from smgp.config import SMGPConfig

cfg = SMGPConfig(
    hd_dim=10000,
    hidden_dim=256,
    num_heads=8,
    num_scales=3,
    max_eigenvalues=64,
    memory_capacity=100000,
    pruning_threshold=0.1,
    seed=42,
)

# Load from file
cfg = SMGPConfig.from_yaml("config.yaml")
cfg = SMGPConfig.from_dict({"hd_dim": 5000, "hardware": {"enabled": False}})

Testing

pip install "smgp[dev,topology]"
python -m pytest tests/ tests_enhanced/ -v
Suite Tests Notes
tests/ 112 Core, spectral, HD, reasoning, integration, hardware wiring
tests_enhanced/ 123 CLI, distributed, event log, ONNX, streaming, vector DB, Hypothesis
Total 235 230 passed / 5 skipped (torch-dependent, no PyTorch required)

Hardware Acceleration

SMGPU is a domain-specific accelerator targeting Xilinx Alveo U280 (250 MHz, 8 GB HBM2).

All 6 RTL testbenches verified with Verilator 5.048:

Testbench Status
tb_spectral_engine ✅ PASS
tb_hd_engine ✅ PASS
tb_topology_engine ✅ PASS
tb_graph_rewrite ✅ PASS
tb_associative_memory ✅ PASS
tb_system_end_to_end ✅ PASS

Build targets:

cd hardware/fpga/build
make synth        # Vivado synthesis
make impl         # Place & route
make xclbin       # Generate Alveo U280 .xclbin
make bit_script   # Generate .bit bitstream

Links

Metadata

Release files for smgp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smgp 1.0.0
File Size Uploaded
smgp-1.0.0.tar.gz 217.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smgp 1.0.0
File Interpreter ABI Platform
smgp-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 314.5 kB

Release files / smgp-1.0.0.tar.gz

Download URL smgp-1.0.0.tar.gz
Size 217.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cf6d530def5a85a9618d01fe4c0079b75c57923b9d8f462420c8e386021136ee
BLAKE2b-256 checksum
How to use checksums
5b6076e12452fb0796db2c742df4afb559dfe79832ac613c5b4ceb208f091ec8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 18, 2026.

Transparency log

Release files / smgp-1.0.0-py3-none-any.whl

Download URL smgp-1.0.0-py3-none-any.whl
Size 97.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70d794ad1e0839625c8423f4da3f5c5c2c4eb61646cb6e346f8d1ef977131a93
BLAKE2b-256 checksum
How to use checksums
45aaf6f3b9ad2f77fd7a8c589098f6b0baa3980df5968f20026c7e707e13df1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page