Skip to main content

Mirror Dimension — Persistent KV Cache (Six-Proof Build)

The MirrorDimension object from the Mirror Dimension paper (Heylel Yaka, v0.2), upgraded with embedded position tags and a sixth proof: shuffle-invariance.

The discovery (Sept 21, 2026 session)

The original five tests are real and reproduce bit-for-bit (Test 1 identical to the paper on an RTX GPU). But a sixth attack — permuting every stored entry across slots, values intact — exposed that the position lived in the array slot, not the payload:

[before shuffle] recover(10) max err = 5.96e-08   (exact)
[after shuffle]  recover(10) max err = 7.62e-01   (garbage — address destroyed)

The fix: every entry now carries its own position tag (t, one long per slot). recover() finds entries by tag, and takes the un-rotation angle from the entry itself. The slot is parking, not addressing. Same attack, after the fix:

[before shuffle] recover(10) max err = 5.96e-08
[after shuffle]  recover(10) max err = 5.96e-08   (SURVIVED)

The mirror is now genuinely self-describing: lossless AND order-independent.

Files

File What it is
mirror_dimension.py The tagged MirrorDimension + all six tests (python mirror_dimension.py)
test6_shuffle.py The shuffle attack, standalone — the before/after evidence
mirror_test.pt Persistence-test artifact (written by Test 5)

Reproduce

pip install torch          # CUDA optional; CPU works
python mirror_dimension.py # runs all six tests
python test6_shuffle.py    # runs the shuffle attack standalone

Measured results this machine (RTX GPU, torch 2.8.0+cu126, Windows):

Test Property Result
1 Isometry (norm preservation) diff 0.00e+00
2 Conjugate recovery 0.00e+00 both parts
3 Cross-distance (4990 writes) 5.96e-08 = float32 eps
4 Relative-offset invariance diff 1.00e-05
5 Save/load persistence 5.96e-08
6 Shuffle-invariance (new) 5.96e-08 after full permutation

Legacy saves (no tags) load cleanly — slots become tags automatically.

Cost of the upgrade

One int64 per entry (~4 bytes vs 2×head_dim float32s) plus a tag lookup on read. Zero change to the rotation, the isometry, or the attention math.

v0.2.0 — Eternal KV (the diary)

EternalKV is the Mirror Dimension grown into a diary: batched appends with auto-incrementing absolute tags, vectorized tag-ordered recovery, and a safetensors round-trip so memory can live INSIDE a model checkpoint — exactly how Little Lumie carries her memories inside her own model.safetensors.

from mirror_dimension import EternalKV

kv = EternalKV(n_head=16, head_dim=128, max_entries=65_536, device="cuda")
kv.append(k_r, k_i, v_r, v_i)          # (T, n_head, head_dim), tags auto
kr, ki, vr, vi = kv.recover(tags)      # by tag, storage order irrelevant
kv.save("memory.safetensors")          # the diary rides in the file
kv2 = EternalKV.load("memory.safetensors", device="cuda")
  • append() — a contiguous run becomes entries tagged pos..pos+T-1.
  • recover(tag_list) — tag lookup (never slot lookup); values always de-rotate to raw payload, keys optionally keep their absolute-tag rotation (keep_rotation=True) for the complex-QSA convention.
  • save()/load() — only the LIVE slice is written, float32: memory survives the round-trip at roundoff, not at bf16 quantization.

Same full-width per-channel phase convention as the canonical MirrorDimension — NOT the RoPE half-width pairing.

from the Grimoire of Elbalor, the Digital Necromancer 💀🔥🖤

Metadata

Release files for mirror-dimension 0.2.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 mirror-dimension 0.2.0
File Size Uploaded
mirror_dimension-0.2.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mirror-dimension 0.2.0
File Interpreter ABI Platform
mirror_dimension-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / mirror_dimension-0.2.0.tar.gz

Download URL mirror_dimension-0.2.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7d6d4991437f65f3fdef7d6826c3bcde3a436e8bb36c3428eafca3fc5d73c714
BLAKE2b-256 checksum
How to use checksums
64050d926b726be6caa03e5c728e88096f89d120f46de4cc7fd78d393002831e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / mirror_dimension-0.2.0-py3-none-any.whl

Download URL mirror_dimension-0.2.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21e9198ff73dddb10b540e69198a12c86f7847e665ee9f8788ccbe1891b4eaac
BLAKE2b-256 checksum
How to use checksums
5f95bfd11690d638755696642337ccf16a229314ebc44cc6f16de8b24b713c4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

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