Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/spec/branch-state-reuse.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / spec / branch-state-reuse.md` 155 lines ยท 8420 bytes Raw Blame History Rendered 1 # Branch-native shared cognitive state 2 3 Status: see the receipt the gate writes (`BRANCH_REUSE/rx_branch_reuse_receipt.json` 4 under the run's evidence directory; a reviewed copy lives in `evidence/BRANCH_REUSE/`). 5 Only a run on a clean tree, with at least 100 branches, every correctness check 6 passing, all four comparisons won for every realizer and all eight actions taken 7 by construction and policy may print `OMEGA_BRANCH_STATE_REUSE_PASS`. 8 9 ## Problem 10 11 J-Space explores many candidate branches that share most of their past. If each 12 branch realizes its whole state on its own, memory, compute, latency and energy 13 all grow with the number of branches times the length of the shared past. The 14 shared part should be realized once and reused, without tying what a state 15 *means* to how it is held. 16 17 ## Two layers 18 19 **Semantic.** A branch is an ordered sequence of state units. 20 21 | Field | Meaning | 22 |---|---| 23 | `branch_id` | this branch | 24 | `parent_branch` | the branch it forked from (none for a root) | 25 | `common_ancestor` | the root of its lineage | 26 | shared semantic state | units inherited at the fork, still held in common | 27 | branch-local state | units this branch derived or edited itself | 28 | `divergence_point` | number of units inherited at the fork | 29 30 A unit's semantic identity is a SHA-256 chain over the semantic events that made 31 it: the root seed, a derive step and its token, or an edit (offset and patch 32 digest). A branch's identity is SHA-256 over its ordered unit identities. No 33 identity mentions a realization type, bytes, placement or residency. 34 35 **Physical.** A realization (`JsReal`, reported per branch as 36 `JsSharedStateRealization`) is one way the bytes of one semantic unit are held 37 right now. 38 39 | Field | Meaning | 40 |---|---| 41 | `semantic_state_id` | the unit it realizes | 42 | `realization_type` | latent checkpoint, activation checkpoint, KV state, compiled features, World projection, Cortex projection, physical tensor | 43 | `parent_realization` | recipe input: the realization it is rebuilt from | 44 | shared / private segments | a realization held by more than one holder is shared and immutable | 45 | `placement` | hot arena, cold arena, compressed (delta against parent), spilled (file), evicted (recipe only) | 46 | residency | bytes held in memory now | 47 | recompute / transfer / retain / eviction cost | measured, see below | 48 49 A realizer is a vtable (`type`, `unit_bytes`, `derive(prev, token)`). The store 50 and the policy never look inside the bytes and have no case for any type. The 51 test uses four realizers with different cost shapes: an integer latent 52 recurrence, a dense 128x128 neural layer, a sliding KV window, and a sparse World 53 projection where each step changes 8 of 128 objects. 54 55 ## Operations and the rules that keep the ancestor safe 56 57 - `fork` gives the child references to every parent unit and freezes the parent. 58 A frozen branch refuses derive and edit (`JS_ERR_FROZEN`): it is now a shared 59 ancestor. Exploration continues in children. 60 - `derive` appends a unit computed from the last one. If a realization of the 61 same semantic unit and type already exists anywhere, it is reused instead. 62 - `edit` never writes a realization anyone else holds. It makes a new 63 realization with an EDIT recipe. The bytes come from a copy when the old unit 64 is resident, from a rebuild when it is not, or from taking the old buffer when 65 this branch was its only holder and nothing depends on it. 66 - A read returns the realized bytes wherever they are. Every rebuilt unit is 67 checked against the content check recorded when it was first realized. 68 69 ## Policy (FORGE) 70 71 `js_calibrate` measures on this machine, per realizer: derive time, copy, 72 compress and decompress per byte and the delta ratio of a derive step, spill 73 write and read per byte, and the price of residency (faulting fresh memory per 74 byte). The policy reads nothing else. 75 76 | Action | When | 77 |---|---| 78 | reference | fork: the child points at the parent's realization | 79 | reuse | derive or edit whose semantic unit is already realized with that type | 80 | copy | edit of a shared resident unit | 81 | recompute | rebuild an evicted unit (or chain) from its recipe | 82 | move | hot arena over its share: move to the cold arena | 83 | compress | under pressure, when predicted delta size and decode cost win | 84 | spill | under pressure, when file write and read win | 85 | evict | under pressure, when rebuilding later wins | 86 87 Under pressure, for each resident realization the policy prices every way of 88 giving up its bytes. The price is the work now plus the expected reads times the 89 restore cost, per byte given back. Restoring a delta includes producing its 90 parent's bytes, and rebuilding includes the chain to the nearest unit that is 91 held. It applies the cheapest action, cheapest candidates first, until resident 92 bytes are under budget. Keeping wins when the retain price is lower than the 93 best alternative. Expected reads are the number of branches holding the unit. 94 95 ## Test and gate 96 97 `make test-branch-reuse PHYSICS_DIR=...` runs `build/rx_branch_reuse` 98 (defaults: 128 branches, 512-unit prefix plus root, 16 private units and 2 edits 99 per branch, 64 KiB units, so a 32 MiB shared prefix). Branch k and branch k+96 100 take the same steps. For every realizer the same branch program runs twice, each 101 in a fresh child process pinned to one Cortex-X925 core: 102 103 - independent: every branch recomputes and holds its whole state; 104 - shared: prefix once, fork by reference, copy on write, reuse, then the policy 105 under a budget of a quarter of the resident bytes. 106 107 Measured: bytes held and resident-set growth; derive calls and processor time; 108 time until all branches are ready, first branch ready, and per-branch ready; 109 energy from the GB10 `aien_spbm` counters (package, efficiency and performance 110 clusters). The counters tick every 100 ms. A run shorter than 2 s is repeated 111 (whole construction and teardown), starting and ending on a tick, and energy is 112 reported per construction. Package energy includes the rest of the machine. 113 Branch creation time is also measured: for shared, the fork call; for 114 independent, building that branch's whole state. 115 116 Correctness checked: 117 118 1. every shared branch's bytes (SHA-256 over all units) equal its independent 119 recomputation, before and after the policy moved them around; 120 2. the ancestor's identity and bytes equal a fresh prefix built from scratch; 121 writes to it are refused and change nothing; 122 3. copy on write: exactly the edited units differ from the ancestor's 123 realizations, in every branch; 124 4. branches that took the same steps hold the same realizations; branches that 125 did not, do not; 126 5. semantic identities do not change when the policy changes placement, and one 127 branch's every unit survives restore, move, compress, spill, evict, restore 128 with identical bytes and identity; 129 6. the same branch program gives identical semantic identities under all four 130 realizers and different bytes. 131 132 The gate also requires the shared realization to use less memory, less compute, 133 less time and less package energy than independent recomputation for every 134 realizer, and all eight actions to have been taken by construction, policy and 135 the reads that followed. The forced placement cycle in check 5 is not counted. 136 137 ## Not claimed 138 139 - Graphics-processor residency. Both arenas and the spill file are host memory 140 and a host file. On GB10 the processor and graphics memory are the same 141 LPDDR5X, but no graphics realization is exercised here. 142 - Integration with the ADR 0016 object world (`rx_world`), the R9 generation 143 store or the existing FORGE numeric pipeline. This is a standalone store and 144 policy. Wiring J-Space candidates into World branches is later work. 145 - Concurrency. The store is single-threaded; both runs are too. 146 - Real models. The realizers are deterministic stand-ins with the cost shapes 147 of the named representations. They are not trained networks. 148 - The policy's reuse estimate (expected reads = holders) is a simple prior, not 149 a learned one. The spill file is never compacted. 150 - Energy isolation. Package energy includes whatever else the machine was doing. 151 152 If the `aien_spbm` counters cannot be read, the energy leg is reported as 153 `NOT_RUN` and the gate result is `PASS_ENERGY_NOT_RUN`, which never prints 154 `OMEGA_BRANCH_STATE_REUSE_PASS`. Memory, compute, latency and correctness stay 155 hard checks. When the counters are readable, energy must still measure lower.