Skip to main content

Kinetic AI

A unified library for game-theoretic LLM training: Magnetic Mirror Descent, Deep Equilibrium Models, and Mechanism Design.

Tests Python 3.10+ License: MIT

The Thesis

Current AI systems are trained via dictatorial optimization — a single loss function forces updates on every parameter. But real-world deployment environments are adversarial, multi-agent, and strategic. Game theory, not optimization, is the correct mathematical framework.

Kinetic AI implements the transition from static optimization to dynamic equilibrium:

Component What it replaces Validated status (see research/memory/findings.md)
Magnetic Mirror Descent Simultaneous gradient play Linear last-iterate convergence to its magnetic fixed point where GDA cycles (F1); RND resets reach Nash (F3); asymmetric-game attractor gap discovered (F2)
Deep Equilibrium Models Explicit transformer layers O(1) activation memory vs O(N) measured (F4); Anderson wins on stiff fixed points (F5)
Token Auctions Winner-take-all generation Second-price empirically truthful, regret exactly 0 (F6); weighted aggregation measurably manipulable
Magnetic Preference Optimization DPO drift control H3 PARTIAL: magnet provably applied but second-order to the DPO gradient across tau in [1e-3, 10] (F21 + rider); DPO shown to damage unseen phenomena (0.74 to 0.61 held-out); EqLM 1655x more drift-resistant than explicit under identical updates
Auction decoding Fixed model / uniform ensembling H4 MET 3/3 seeds: second-price per-token auction of two 30M domain specialists beats the best single model by 23% and logit-average ensembling by 12% on mixed-domain perplexity (F22)
EqLM (new architecture) Stacked GPT-class LMs H1 honestly missed: 93.0% of explicit-baseline BLiMP at 11M params (F18), 78.7% at 121M (F20) — the fixed-solver-budget truncation penalty widens with width. Confirmed at 121M: -23% peak memory (O(1) depth), 79% cheaper warm-started decoding (F19). Open problem named: contraction that survives width

Released 121M checkpoints: kinetic-eqlm-121m-babylm · kinetic-explicitlm-124m-babylm. Findings site: https://sharathsphd.github.io/game-llm/

Everything above traces to committed runs under results/ (config hashes + seeds). The research process is spec-driven and adversarially reviewed — see CLAUDE.md, research/specs/, and docs/decisions/. Paper: paper/kinetic_ai.tex. Site: site/. Researcher app: apps/web + app/server.py (see apps/web/DEPLOY.md).

Installation

pip install -e ".[all]"

Quick Start

Strategy-Space MMD on Rock-Paper-Scissors

import torch
from kinetic_ai.games.payoff import rock_paper_scissors
from kinetic_ai.games.qre import nash_conv
from kinetic_ai.optim.bregman import NegativeEntropy
from kinetic_ai.optim.mmd import mmd_strategy_update

game = rock_paper_scissors()
bregman = NegativeEntropy()

s1 = torch.tensor([0.7, 0.2, 0.1])  # Biased initial strategy
s2 = torch.tensor([0.1, 0.7, 0.2])
ref = torch.ones(3) / 3  # Uniform reference (magnet)

for step in range(500):
    # Sequential (alternating) updates with reduced learning rate
    # ensure convergence. Simultaneous updates require tighter stepsizes.
    g1 = game.utility_gradient(1, s1, s2)
    s1 = mmd_strategy_update(s1, g1, ref, bregman, lr=0.1, tau=0.05)
    
    g2 = game.utility_gradient(2, s2, s1)
    s2 = mmd_strategy_update(s2, g2, ref, bregman, lr=0.1, tau=0.05)

print(f"NashConv: {nash_conv(game, s1, s2):.6f}")  # Converges to τ-regularized QRE (≈Nash for RPS)

DEQ Layer with Anderson Acceleration

import torch
import torch.nn as nn
from kinetic_ai.config import DEQConfig, SolverType
from kinetic_ai.models.deq_layer import DEQLayer

transform = nn.Linear(32, 16)
def f(z, x):
    return torch.tanh(transform(torch.cat([z, x], dim=-1)))

deq = DEQLayer(f, DEQConfig(solver=SolverType.ANDERSON, max_iter=50))
z_star = deq(torch.randn(1, 16))  # Finds equilibrium state

Token Auction

import torch
from kinetic_ai.config import AuctionConfig, AuctionType
from kinetic_ai.mechanisms.auctions import TokenAuction

auction = TokenAuction(AuctionConfig(
    auction_type=AuctionType.WEIGHTED_AGGREGATION,
    vocab_size=1000,
))

bids = torch.tensor([2.0, 5.0, 1.0])
dists = torch.softmax(torch.randn(3, 1000), dim=-1)
result = auction.run_auction(bids, dists)
print(f"Selected token: {result.sampled_token}")

Architecture

kinetic_ai/
├── optim/          # Magnetic Mirror Descent + Bregman divergences
├── models/         # Deep Equilibrium Layers (Anderson, Broyden, Picard)
├── mechanisms/     # Token auctions, mechanism design
├── games/          # Game definitions, QRE computation, self-play
├── eval/           # Convergence diagnostics, statistical testing
└── config.py       # Config-driven experiment system

Running Tests

pytest tests/ -v                    # All tests
pytest tests/ -v -m "not slow"      # Skip slow convergence tests

Running the Full Simulation

python simulate.py

References

  1. Sokota et al. "A Unified Approach to RL, QRE, and Two-Player Zero-Sum Games" (NeurIPS 2023)
  2. Bai et al. "Deep Equilibrium Models" (NeurIPS 2019)
  3. Duetting et al. "Mechanism Design for Large Language Models" (WWW 2024, Best Paper)
  4. Wu et al. "Self-Play Preference Optimization for Language Model Alignment" (2024)
  5. McKelvey & Palfrey "Quantal Response Equilibria for Normal Form Games" (1995)

License

MIT

Download files

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

Source Distribution

kinetic_ai-1.0.0.tar.gz (124.8 kB view details)

Uploaded Source

Built Distribution

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

kinetic_ai-1.0.0-py3-none-any.whl (77.6 kB view details)

Uploaded Python 3

File details

Details for the file kinetic_ai-1.0.0.tar.gz.

File metadata

  • Download URL: kinetic_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 124.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for kinetic_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a54e3c62b408e328d217513f519b53133823f1cedb8ec20732fa1c4494598636
MD5 49e526798a100642c68a97978ee2015f
BLAKE2b-256 71c2c8ec377f76423e847fc159db352d951b100eccfae1a62c1a93c52be6fc78

See more details on using hashes here.

File details

Details for the file kinetic_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kinetic_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 77.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for kinetic_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af5456c311a8a3bc8b150a423c9feb9c73611b8f6463160fc89c84935e1a5e22
MD5 07de37499b0600a6e6bf077e8d81b031
BLAKE2b-256 85bd09a682ae1b0019b1eae55e4d54a98958bf04cc344bf05c4615acde231509

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.2.0

2 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