Skip to main content

Manifold: Geometric Intelligence via Symplectic Geodesic Flows | GFN: Geometric Flow Networks

Project description

THIS IS A PROJECT IN DEVELOPMENT, WE DO NOT RECOMMEND USING IT FOR PRODUCTION YET.

Manifold: Geometric Sequence Modeling via Symplectic Flows

Infinite Context. Constant Memory. Hamiltonian Dynamics.

Latent Geodesic Trajectories
Figure 1: The Geometry of Thought. Visualization of the semantic state evolution ($x_t, v_t$) traversing a learned high-dimensional Riemannian manifold. Unlike discrete state transitions in traditional RNNs, Manifold models intelligence as a continuous symplectic flow, conserving momentum and information over infinite horizons.

License Framework Status


Documentation

Manifold provides comprehensive documentation to help users understand, implement, and extend the Geometric Flow Network architecture. The documentation is organized into several guides covering different aspects of the system.

Getting Started

Guide Description
Getting Started Complete guide to installing, configuring, and running your first Manifold model. Covers environment setup, basic configuration, and quick-start examples.
Tutorial Step-by-step tutorial demonstrating how to build a complete sequence modeling project using Manifold. Includes practical code examples and best practices.

Core Concepts

Guide Description
Mathematical Foundations In-depth exploration of the geometric mechanics principles underlying Manifold. Covers Hamiltonian dynamics, symplectic flows, Riemannian geometry, and the physical interpretation of sequence modeling.
Architecture Comprehensive technical reference describing the system architecture, components, data flow, and implementation details. Essential for understanding how Manifold processes sequences internally.

Reference & Advanced Topics

Guide Description
API Reference Complete API documentation for all Manifold modules, classes, and functions. Includes parameter descriptions, return values, and usage examples for integration into production systems.
Benchmarking Detailed documentation of performance evaluations and comparison studies. Covers methodology, metrics, datasets, and results comparing Manifold against Transformers, Mamba, and other state space models.
Troubleshooting Solutions to common issues, numerical instability guides, performance optimization tips, and frequently asked questions. Essential for debugging and production deployment.

Documentation Map

├── Getting Started
│   ├── Installation & Setup
│   └── Quick Start Tutorial
│
├── Core Concepts
│   ├── Mathematical Foundations
│   └── Architecture Deep Dive
│
├── Reference
│   ├── API Documentation
│   ├── Benchmarking Results
│   └── Troubleshooting Guide

1. Introduction: The Memory Bottleneck

The fundamental limitation of modern Large Language Models (LLMs) is the Key-Value (KV) Cache. To generate the next token, a Transformer must explicitly attend to its entire history. This results in a memory complexity of $O(N)$, creating a hard physical ceiling on context length and inference throughput.

Manifold introduces a paradigm shift by reformulating sequence modeling through the lens of Geometric Mechanics. Instead of storing a history of discrete tokens, Manifold encodes context into the momentum of a dynamic massive particle moving through a curved semantic space.

This approach yields a Physically-Structured State Space Model (SSM) that achieves:

  • $O(1)$ Inference Memory: Constant state complexity (~30MB) regardless of sequence length ($L=10$ or $L=1,000,000$).
  • Infinite Context Horizon: Information is preserved via symplectic conservation laws rather than explicit storage.
  • Symplectic Stability: Energy-conserving integrators prevent the vanishing/exploding gradient problem inherent in standard RNNs.

2. The Superiority Benchmark

To rigorously evaluate the state-tracking capabilities of this architecture, we conducted the Manifold Superiority Benchmark. This benchmark utilizes the Cumulative Parity (XOR) Task, a problem that is computationally irreducible and requires perfect, lossless memory retention over the entire sequence duration. A single bit-flip error at $t=0$ propagates to invert the target at $t=\infty$, making it the ultimate test of long-term dependency handling.

We compared Manifold (v2.6.0) against a standard Transformer (MicroGPT) with equivalent parameter counts.

2.1. Infinite Length Generalization

Both models were trained exclusively on sequences of length $L=20$. We then evaluated their ability to generalize to sequences up to $L=100,000$ (5,000x longer than training).

Superiority Benchmark Result
Figure 2: The Generalization Gap. (Left) Accuracy on Cumulative Parity task relative to sequence length. (Right) VRAM usage scaling. Manifold generalizes perfectly to 100,000+ tokens (~5000x training length) while maintaining O(1) memory.

2.2. Vocabulary Scaling (O(1) Parameters)

Manifold's Functional Embeddings allow the vocabulary to grow indefinitely without increasing parameter count.

Infinite Vocab Scaling
Figure 3: Infinite Vocabulary. Proving O(1) memory scaling with respect to vocabulary size (up to 1 Million tokens).

Empirical Conclusion: Manifold demonstrates true algorithmic generalization. It has learned the underlying generative law of the data (the XOR operator) rather than simply memorizing patterns. This capability is enabled by its momentum-based memory, which acts as a robust, noise-resistant carrier of logical state.


3. Dynamic Physics: Forgetting & Remembering

Standard RNNs struggle to forget ("catastrophic memory"), while Transformers must explicitly mask history. Manifold employs a Dynamic Forget Gate (thermodynamic friction) that adapts to the input energy.

3.1. Context-Aware Forgetting

  • Stable Context: Friction $\approx 0$ (Symplectic Conservation). The model remembers.
  • Context Switch: Friction spikes (Energy Dissipation). The model forgets.

Dynamic Friction Response
Figure 3: The Physics of Forgetting. (Left) When a high-energy "Context Switch" occurs (Blue), the Learnable Friction (Red) spikes immediately to dissipate previous state momentum. (Right) The learned activation function shows a clear phase transition from conservation to dissipation based on input magnitude.


4. Theoretical Foundations

Manifold diverges from standard connectionsist architectures by imposing Hamiltonian constraints on the latent update rule. The network learns to shape the geometry of the solution space, such that the "natural motion" of the state vector corresponds to the desired computation.

4.1. The Geodesic Equation

The latent state update is governed by the discrete-time approximation of the geodesic equation on a Riemannian manifold:

$$ \frac{d^2x}{dt^2} + \Gamma^k_{ij}(x) \frac{dx^i}{dt} \frac{dx^j}{dt} = F(u_t) $$

Where:

  • $x_t \in \mathbb{R}^d$: The Position (Semantic State).
  • $v_t = \dot{x}_t \in \mathbb{R}^d$: The Velocity (Contextual Momentum).
  • $\Gamma(x)$: The Christoffel Symbols (Learned Interaction Tensor), defining the local curvature and feature interactions ($O(d^2)$ complexity).
  • $F(u_t)$: The External Force derived from the input token embedding.

4.2. Symplectic Stability & Conservation

Standard Euler integration used in Residual Networks is energy-dissipative, leading to signal loss. Manifold employs a Leapfrog Integrator, a symplectic solver designed to strictly conserve phase-space volume.

Symplectic Stability Metrics
Figure 3: Conservation Laws. Analysis of the Hamiltonian energy drift over long horizons. Unlike standard integration which diverges (Green), Manifold's symplectic solver (Blue) keeps energy bounded, ensuring gradient stability for $L \to \infty$.


5. Latent Space Analysis

We perform a deep diagnostic of the model's internal representation to understand how it solves complex tasks.

5.1. Manifold Trajectories vs. Random Walks

By projecting the high-dimensional hidden states into 3D, we observe that Manifold learns smooth, deterministic orbits, whereas traditional RNNs often exhibit chaotic or collapsing trajectories.

Trajectory Comparison
Figure 4: Latent Dynamics Comparison. Left: The chaotic state evolution of a standard RNN. Right: The coherent, orbital structure of a Manifold trained on the same task. The geometric prior forces the state to follow smooth geodesic paths.

5.2. The Geometry of Optimization

Why does Manifold converge faster on complex tasks? The answer lies in the Loss Landscape. By constraining parameters to the manifold, we convexify the optimization surface.

Loss Landscape 3D
Figure 5: Optimization Topography. (Left) The sharp, non-convex landscape of a standard Transformer trained on Parity. (Right) The smooth, quasi-convex basin of Manifold, enabled by RiemannianAdam and geometric regularization.


6. Advanced Dynamics: Beyond Text

The geometric framework is domain-agnostic. By projecting inputs into the tangent space of the manifold, the model processes text, images, and audio as unified force vectors. Current experiments demonstrate convergence in multimodal tasks, suggesting that geometric mechanics is a universal prior for sequential data.

Fractal Dynamics
Figure 6: Fractal State Space. Investigating the self-similar properties of the learned manifold. The model learns to organize information hierarchically, exhibiting fractal structures in its decision boundaries.


7. Implementation & Usage

Manifold provides a production-ready implementation with a PyTorch-native API.

7.1. Installation

pip install gfn
# OR for development
git clone https://github.com/Manifold-Laboratory/manifold.git
cd manifold
pip install -e "."

7.2. Geodesic Training Loop

The optimizer must respect the geometry of the parameter space. Standard Adam optimization assumes a Euclidean flat space, which is suboptimal for Riemannian models. We provide RiemannianAdam to perform covariant gradient updates.

import torch
from gfn.model import Manifold
from gfn.optim import RiemannianAdam

# Initialize the Geometric Engine
model = Manifold(
    vocab_size=50257,
    dim=512,
    depth=12,
    heads=8,
    integrator_type='leapfrog'  # Symplectic Solver
).cuda()

# Optimizer: RiemannianAdam is required for manifold constraints
optimizer = RiemannianAdam(model.parameters(), lr=1e-4, max_norm=10.0)

# Training with symplectic conservation
model.train()
for input_ids, targets in dataloader:
    optimizer.zero_grad()
    
    # Forward pass: Evolve state along geodesics
    logits, (x_final, v_final), _ = model(input_ids)
    
    loss = torch.nn.functional.cross_entropy(logits.view(-1, 50257), targets.view(-1))
    loss.backward()
    
    # Gradient clipping is essential for differential stability around singularities
    torch.nn.utils.clip_grad_norm_(model.parameters(), 0.05)
    optimizer.step()

8. Citation

Manifold is an active research project. If you utilize this framework or its findings in your research, please cite:

@article{sturtz2026manifold,
  title={Manifold: Geometric Sequence Modeling via Symplectic Flows},
  author={Stürtz, Joaquín},
  journal={arXiv preprint},
  year={2026}
}

Joaquín Stürtz
Manifold Laboratory

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

gfn-2.6.5.1.tar.gz (134.1 kB view details)

Uploaded Source

Built Distribution

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

gfn-2.6.5.1-py3-none-any.whl (152.9 kB view details)

Uploaded Python 3

File details

Details for the file gfn-2.6.5.1.tar.gz.

File metadata

  • Download URL: gfn-2.6.5.1.tar.gz
  • Upload date:
  • Size: 134.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for gfn-2.6.5.1.tar.gz
Algorithm Hash digest
SHA256 bdf194dd99c10acdad05e034e35e52bb3fefaf388ab91ca3b3dc126a9a67c8a0
MD5 fd5e6bc6ebd0866587b73998c1a6347f
BLAKE2b-256 658c30921ef57df33b720bb0c384ff6f1ec340dc098ef40501b4e03c3454b5db

See more details on using hashes here.

File details

Details for the file gfn-2.6.5.1-py3-none-any.whl.

File metadata

  • Download URL: gfn-2.6.5.1-py3-none-any.whl
  • Upload date:
  • Size: 152.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for gfn-2.6.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 66e61f0dd4dc7b49001fc8a369e3a1f3aa4711b5e33d1c8572e0f15c59c156ce
MD5 12378d45b953fe1889b465d9c0587a4a
BLAKE2b-256 e630e39324d0288648a1a495c9cfa96275f8d76ef55c9d6479f1ec140dabc7e1

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