ATOMiK delta-state algebra — O(1) state reconstruction for any processor
Project description
atomik-core
O(1) state reconstruction. 99% less bandwidth. Formally proven.
ATOMiK is a delta-state algebra that replaces snapshots, event replay, and full-state replication with four operations. Works on any processor — no FPGA required.
Install
pip install atomik-core
Zero dependencies. Python 3.9+.
Quick Start
from atomik_core import AtomikContext
# Create a context and set initial state
ctx = AtomikContext()
ctx.load(0xDEADBEEF)
# Accumulate deltas (XOR — order doesn't matter)
ctx.accum(0x000000FF)
print(f"State: 0x{ctx.read():08x}") # 0xdeadbe10
# Undo any delta by re-applying it (self-inverse)
ctx.rollback(0x000000FF)
assert ctx.read() == 0xDEADBEEF
The 4 Operations
| Operation | What it does | Complexity |
|---|---|---|
load(value) |
Set reference state, clear accumulator | O(1) |
accum(delta) |
XOR delta into accumulator | O(1) |
read() |
Reconstruct state: reference ^ accumulator | O(1) |
swap() |
Atomic snapshot + new epoch | O(1) |
Everything else — rollback, merge, fingerprinting, streaming — is built on these four.
Why ATOMiK?
99% Less Network Traffic
Send 8-byte deltas instead of full state copies.
from atomik_core import DeltaStream
# Sender and receiver start with same reference
sender = DeltaStream()
receiver = DeltaStream()
sender.load(0, initial_state=0xCAFE)
receiver.load(0, initial_state=0xCAFE)
# Sender produces a delta (8 bytes, not full state)
msg = sender.accum(0, delta=0x00FF)
# Receiver applies it — converges to same state
receiver.apply(msg)
assert sender.read(0) == receiver.read(0)
| State Size | Full Replication (10K updates) | ATOMiK Deltas | Reduction |
|---|---|---|---|
| 1 KB | 10.2 MB | 80 KB | 99.2% |
| 64 KB | 655 MB | 80 KB | 99.99% |
333,333x Less Memory for Rollback
ATOMiK uses 24 bytes regardless of history length. No snapshot stack.
ctx = AtomikContext()
ctx.load(0xAAAA)
# Apply 1 million deltas...
for i in range(1_000_000):
ctx.accum(i)
# Undo all of them (XOR self-inverse)
for i in range(1_000_000):
ctx.rollback(i)
assert ctx.read() == 0xAAAA # Back to original
# Memory used: 24 bytes. Snapshot approach: 8 MB.
1,291x Faster Change Detection
Track changes incrementally in O(1), not O(n).
from atomik_core import Fingerprint
fp = Fingerprint(width=64)
fp.load(reference_data) # Set reference fingerprint
# When a field changes, update in O(1):
fp.accumulate_delta(old_value, new_value)
if fp.changed:
print("Data modified!")
No Consensus Protocol
XOR is commutative — deltas can arrive in any order. All nodes converge.
# Three nodes, each produces deltas independently
nodes = [DeltaStream() for _ in range(3)]
for n in nodes:
n.load(0, 0xAAAA)
m0 = nodes[0].accum(0, 0x0001)
m1 = nodes[1].accum(0, 0x0010)
m2 = nodes[2].accum(0, 0x0100)
# Broadcast all-to-all (any order)
for i, node in enumerate(nodes):
for j, msg in enumerate([m0, m1, m2]):
if i != j:
node.apply(msg)
# All converge — no Raft, no Paxos, no leader election
assert nodes[0].read(0) == nodes[1].read(0) == nodes[2].read(0)
Multi-Context Table
Track state across 256 independent addresses:
from atomik_core import AtomikTable
table = AtomikTable(num_contexts=256)
table.load(addr=0, initial_state=0x1000)
table.load(addr=1, initial_state=0x2000)
table.accum(addr=0, delta=0x0001)
assert table.read(0) == 0x1001
assert table.read(1) == 0x2000 # Independent
# Batch update multiple addresses at once
table.batch_accum({0: 0x0010, 1: 0x0020, 2: 0x0030})
# Snapshot all non-zero contexts
active = table.snapshot()
Formally Proven
Every algebraic property is proven in Lean4 — not tested, proven:
- Commutativity:
accum(a); accum(b) == accum(b); accum(a) - Associativity:
(a ^ b) ^ c == a ^ (b ^ c) - Self-inverse:
accum(d); accum(d) == identity - Identity:
accum(0) == identity
92 theorems total. See proofs →
C Library
Single-header C99 library with the same API:
#define ATOMIK_IMPLEMENTATION
#include "atomik_core.h"
atomik_ctx_t ctx;
atomik_init(&ctx);
atomik_load(&ctx, 0xDEADBEEFCAFEBABEULL);
atomik_accum(&ctx, 0x00000000000000FFULL);
uint64_t state = atomik_read(&ctx);
Hardware Upgrade Path
When software performance isn't enough:
| Implementation | Throughput | Latency |
|---|---|---|
Python (atomik-core) |
5M ops/sec | ~200 ns |
C (atomik_core.h) |
500M ops/sec | ~2 ns |
| FPGA (ATOMiK hardware) | 69.7 Gops/sec | 10.6 ns/op |
Same API. Same algebra. Same proofs. Just faster.
Examples
- Distributed Cache Sync — 3-node convergence without consensus
- IoT Sensor Fusion — 99.2% bandwidth reduction
- Real-Time Analytics — Trading P&L tracking at 2.5M ops/sec
License
Apache 2.0 for evaluation and non-commercial use. Commercial license required for production deployment. Patent pending.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file atomik_core-0.4.0.tar.gz.
File metadata
- Download URL: atomik_core-0.4.0.tar.gz
- Upload date:
- Size: 45.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
935a61434dbf9af827aba0e2fa624a02d30cafaf3dbe2818d8996ae4ed88d68d
|
|
| MD5 |
8735aee4120ded778b6486c9eb2cbb36
|
|
| BLAKE2b-256 |
0eb1d97dc6efb46dd2ffc65327a1ceb135789483ad9f32618d41d003e80ead78
|
File details
Details for the file atomik_core-0.4.0-py3-none-any.whl.
File metadata
- Download URL: atomik_core-0.4.0-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb9ff6a0fc4b82a03e96c8935ad7f4f2c07981b6b7205c47bab9559783a55c6e
|
|
| MD5 |
1212b3115ba87fe08d684e8e879827e5
|
|
| BLAKE2b-256 |
46deca7e9ca12cfbc931b9d5a2cf123de4e5a6875ae402b7ca41db88afa1906d
|