Skip to main content

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

Project description

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


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{manifold2026,
  title={Manifold: Geometric Sequence Modeling via Symplectic Flows},
  author={Manifold Laboratory},
  journal={arXiv preprint},
  year={2026}
}

Manifold Laboratory
Geometric Intelligence via Physical Principles

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.1.tar.gz (53.2 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.1-cp313-cp313-win_amd64.whl (160.8 kB view details)

Uploaded CPython 3.13Windows x86-64

File details

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

File metadata

  • Download URL: gfn-2.6.1.tar.gz
  • Upload date:
  • Size: 53.2 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.1.tar.gz
Algorithm Hash digest
SHA256 572064ebb75ba00b708d4e3cf7e1010193f06145a7619480bfcc73802d43d62e
MD5 a1903980a82825e395f17ec9f159a312
BLAKE2b-256 e251c2697e7e456a8f2e617a76608d1dfe684b4b1bd1a4333b2f67af3d91813a

See more details on using hashes here.

File details

Details for the file gfn-2.6.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: gfn-2.6.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 160.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for gfn-2.6.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a5527cce0a21098430b28657d227203303217787b8140c3c9b7851ea2b4d7642
MD5 b5319685eb886a7fc067520205d4c26d
BLAKE2b-256 7461c49e45bdc3987d61ff20b74ff1a695f3835dc575167b7e8a4e906d8309f5

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