Skip to content

Ash-code183/ogi-ising-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OGI × Ising on GitHub

Thesis (OGI whitepaper §3, §5). Every agent occupies a position in a 14-dimensional value-space. From that position, the highest-leverage next-moves number exactly three: Compound (deepen current trajectory), Pivot (cross to a different basin), Defect (exit the reachable set).

Hypothesis tested here. GitHub's 14 public event types form a natural 14-dim value-space. If the OGI thesis is correct, transitions in a user's event-mix from week t to week t+1 should fall into the three-door typology with the fractions reported in OGI Table 1 (Compound ≈ 0.62, Pivot ≈ 0.31, Defect ≈ 0.07 at pilot-basin scale).

Tools. NVIDIA's GPU Ising implementation (NVIDIA/ising-gpu, arXiv:1906.06297) provides the 2D population-spread backend. A small CPU port of the same Metropolis algorithm runs the per-agent 14-spin model locally.

What's in the repo

ogi-ising-simulation/
├── README.md
├── LICENSE                         MIT
├── requirements.txt                numpy, pandas, requests, matplotlib
├── data/
│   ├── query.sql                   ClickHouse SQL — weekly user × 14-event spins
│   └── fetch.py                    Hits play.clickhouse.com (no auth)
├── ising/
│   ├── coupling.py                 Fit J, h via mean-field inverse Ising
│   └── metropolis.py               Per-agent 14-spin Metropolis (CPU)
├── analysis/
│   ├── three_doors.py              Compound / Pivot / Defect classifier
│   └── validate.py                 Compare to OGI Table 1 fractions
├── scripts/
│   └── run_demo.py                 End-to-end pipeline (1 command)
├── notebooks/
│   └── 01-pipeline.ipynb           Interactive walk-through
├── docs/
│   └── CLOUD.md                    Colab T4 runner for vendor/ising-gpu
├── outputs/                        Plots and JSON from the demo run
└── vendor/
    └── ising-gpu/                  Submodule → NVIDIA/ising-gpu (MIT)

The mapping

OGI concept GH Archive realization
14-dim value-space The 14 GitHub public event types
Agent state σ_u(t) +1 if user u's count of event-type i in week t exceeds the population median for that axis, else −1
Coupling matrix J Mean-field inverse Ising on the empirical connected correlation matrix
Compound transition Hamming(σ(t), σ(t+1)) ≤ 1, orthant preserved
Pivot transition Hamming ≥ 4 with rotation > 60° in the J-eigenbasis (top-4 modes)
Defect transition No events recorded for ≥ 4 weeks (8 in production, per whitepaper §4.5)
Population-spread phase 2D Ising critical β with per-event-type lattice (NVIDIA backend, cloud)

Quick start

git clone --recurse-submodules https://github.com/Ash-code183/ogi-ising-simulation
cd ogi-ising-simulation
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python scripts/run_demo.py --since 2024-01-01 --until 2024-01-02

Runs in roughly one minute on a 2024 MacBook (no GPU). Writes outputs/J_matrix.png, outputs/magnetization.png, outputs/summary.json.

Results from the included demo run

A single-day, 50,000-user-week slice (2024-01-01) yielded:

  • Empirical magnetizations dominated by extreme rarity — most users do very few of most event types, so the binarized spin space concentrates near the all-−1 orthant.

    Axis m Axis m
    push −0.176 release_event −0.987
    pr −0.888 member −0.994
    issue −0.967 public_event −0.991
    issue_comment −0.952 wiki (Gollum) −0.996
    pr_review_comment −0.986 commit_comment −0.998
    fork −0.965 star (Watch) −0.897
    create_event −0.934 delete_event −0.987
  • Coupling matrix J — max off-diagonal magnitude 3.56, structure dominated by push-correlated activity. See outputs/J_matrix.png.

  • Three-door fractions (simulated 2000-agent population, 200 Metropolis sweeps, β = 0.6):

    Door Measured OGI pilot_basin Δ
    Compound 0.512 0.620 −0.108
    Pivot 0.000 0.310 −0.310
    Defect 0.000 0.070 −0.070
    Σ Δ² 0.112

    Honest read. Compound is in the right neighborhood. Pivot collapses because Hamming-distance-4 transitions are extremely rare when all 14 marginals are near −1. Defect is zero because a single-day slice can't observe four-week silence.

    This is the small-slice limitation, not a refutation of the thesis. To see Pivot transitions at the OGI-predicted rate (≈0.31), the experiment needs (i) multi-week user trajectories, (ii) per-user thresholding instead of population median, (iii) a larger cohort that spans both low- and high-activity regimes. See docs/CLOUD.md.

How to scale

The local demo is a sanity test. To run the proper experiment:

  1. Pull a wider window. python scripts/run_demo.py --since 2023-01-01 --until 2024-01-01 (after raising --limit in data/fetch.py).
  2. Use per-user thresholding. Tweak ising/coupling.py:binarize to compute the median per user across their event vector rather than globally.
  3. Add silence tracking. Pass a silence_mask to classify_transitions based on weeks where a user has zero events.
  4. Run the 2D population backend. See docs/CLOUD.md for vendor/ising-gpu on Colab T4.

Citations

License

MIT. NVIDIA's ising-gpu is included as a submodule under its own MIT license.

About

OGI thesis simulation: NVIDIA's 2D Ising GPU code applied to the GH Archive event stream. Tests the three-door (Compound/Pivot/Defect) prediction against empirical user-state transitions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors