Skip to main content

Lattice topology benchmarks: what happens when you replace the cube

Project description

rhombic banner

PyPI CI Python 3.10+ License: MPL 2.0

rhombic

The bottleneck is not the processor. It is the shape of the cell.

A benchmarking library that compares cubic (6-connected) and FCC/rhombic dodecahedral (12-connected) lattice topologies across graph theory, spatial operations, and signal processing.

The Numbers

Metric FCC vs Cubic Scale
Average shortest path 30% shorter 125 – 8,000 nodes
Graph diameter 40% smaller 125 – 8,000 nodes
Algebraic connectivity 2.4× higher 125 – 8,000 nodes
Flood fill reach 55% more nodes 125 – 8,000 nodes
NN query speed 17% faster 125 – 8,000 nodes
Signal reconstruction 5-10× lower MSE 216 – 1,000 samples
Reconstruction isotropy 5-20× more uniform 216 – 1,000 samples
Embedding neighbor recall +15-26pp at 1-hop 125 – 1,000 nodes
Information diffusion 1.4-2× faster 125 – 1,000 nodes
Edge cost ~2× more edges (the price)

These ratios are stable across all tested scales. They hold at every size tested, consistent with derivation from Voronoi cell geometry rather than sample size.

Graph theory dashboard Spatial operations dashboard Signal processing dashboard Context architecture dashboard

The Question

Computation is built on the cube. Memory is linear. Pixels are square. Voxels are cubic. Nobody chose this — it accumulated. Descartes gave us orthogonal coordinates. Von Neumann gave us linear memory. The cubic lattice is the spatial expression of Cartesian geometry.

Is the cube optimal? This library measures the alternative: the face-centered cubic lattice, whose Voronoi cells are rhombic dodecahedra. 12 faces instead of 6. The densest sphere packing in three dimensions (Kepler, proved by Hales 2005, formally verified 2017). The lattice that nature uses for copper, aluminum, and gold.

Read the full thesis →

Quick Start

pip install rhombic            # minimal (numpy + networkx)
pip install "rhombic[viz]"     # add matplotlib for plots
pip install "rhombic[all]"     # everything including dev tools

Reproduce all results:

python -m rhombic.benchmark

Use in code:

from rhombic.lattice import CubicLattice, FCCLattice

cubic = CubicLattice(n=10)     # 1000 nodes, 6-connected
fcc = FCCLattice(n=6)          # ~864 nodes, 12-connected

# Convert to networkx for any graph analysis
G_cubic = cubic.to_networkx()
G_fcc = fcc.to_networkx()

Results

Rung 1: Graph Theory (complete)

Four metrics, three scales, consistent ratios. The FCC lattice outperforms the cubic lattice on every measure of routing efficiency and structural robustness. The cost is bounded: ~2× edges for ~30% shorter paths and ~2.4× robustness.

Rung 2: Spatial Operations (complete)

The routing advantage translates. FCC flood fill reaches 55% more nodes per hop. Nearest-neighbor queries are 17% faster. Range queries return 24% more nodes per volume (denser packing). The cost: range query time scales with density — 3-5× slower for sphere/box queries at 8,000 nodes.

Rung 3: Signal Processing (complete)

Direct empirical measurements confirm the FCC advantage. FCC spatial sampling produces 5-10× lower MSE and 5-20× more isotropic reconstruction than cubic sampling at matched sample counts. The advantage peaks in the mid-frequency range (10-60% of Nyquist) and grows with scale — from +6 dB at 216 samples to +10 dB at 1,000. Above Nyquist, both lattices alias and cubic's axis alignment accidentally helps.

Rung 4: Context Architecture (complete)

Does the FCC advantage survive when the lattice organizes high-dimensional embedding data? FCC captures 15-26 more percentage points of an embedding's true nearest neighbors at 1-hop. Information diffuses 1.4-2× faster. Consensus converges 1.58× faster at moderate scale (500 nodes), though per-neighbor weight dilution reduces the advantage at 1,000 nodes.

Full experimental ladder →

FCC Embedding Index (complete)

A proof-of-concept ANN index that organizes high-dimensional embeddings on lattice topology. At matched node counts, the FCC index captures +7 to +20 percentage points more true nearest neighbors at 1-hop than the cubic index. The only variable is the connectivity pattern.

from rhombic.index import FCCIndex, CubicIndex, brute_force_knn

fcc = FCCIndex.from_target_nodes(dim=384, target_nodes=500).build(embeddings)
results = fcc.query(query_vector, k=10, hops=1)
recall = fcc.recall_at_k(queries, ground_truth, k=10, hops=1)

Synthesis

The complete argument across all four rungs — cultural genealogy, empirical evidence, cybernetic interpretation, and practical recommendations.

Philosophy

  • Reproducible by default. Every result has code that generates it.
  • The geometry is the argument. The numbers are the evidence.
  • Cost is always reported alongside benefit.
  • Sparse results are data, not failure.

Ecosystem

Contributing

See CONTRIBUTING.md. We're looking for new topologies, new metrics, and new rungs on the experimental ladder.

License

MPL-2.0 — Use freely. Modifications to library files shared back to the commons.

Built by Promptcrafted

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

rhombic-0.2.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

rhombic-0.2.0-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file rhombic-0.2.0.tar.gz.

File metadata

  • Download URL: rhombic-0.2.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rhombic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a24ad59d79319dda9a45a3c2bbed19d52c1491eedcc5e16ae41fd3171cd475fc
MD5 9f57e2810258315b5e5908e0a99f0148
BLAKE2b-256 5db5187f0b2dd8b1881608efd15fd0de0ab8ad26f140ec2a41aae5eda55e5109

See more details on using hashes here.

Provenance

The following attestation bundles were made for rhombic-0.2.0.tar.gz:

Publisher: publish.yml on promptcrafted/rhombic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rhombic-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rhombic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 43.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rhombic-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a3ecdaf0851d947a031015ae30c2bf3a2e737b34ffbe5ef59a793ab5b99e0cb
MD5 ad0bca27175d96795d1be0b763576d51
BLAKE2b-256 3735cfc9ba52971594ef3628797b6ad0be595639ae94f90990bbfe60358bcac2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rhombic-0.2.0-py3-none-any.whl:

Publisher: publish.yml on promptcrafted/rhombic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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