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/aien-sovereign-core-mv/patches/eb62c012a48660cf # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aien-sovereign-core-mv#779 (code only) closed derived `eb62c012a48660cf` #779 Imported from GitHub aien-dev/aien-sovereign-core-mv#779 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `00a5593282afb425140162c4288a3aeb536f4270` · Head `6c9865a393a9cd2012ee5a25a3703f759d120520` ### Fetch it A git bundle of the pull request's head, 15348 bytes. ``` curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/eb62c012a48660cf.bundle -o eb62c012a48660cf.bundle git fetch eb62c012a48660cf.bundle refs/pull/779/head ``` Raw bundle · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/aien-sovereign-core-mv 779 6c9865a393a9cd2012ee5a25a3703f759d120520 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":779,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/779","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:58Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 9b8c809f..31fc33c8 100644 --- a/.crumb +++ b/.crumb @@ -119,20 +119,20 @@ }, { "digest": "7e5a49f47b2cf3b202760e4ebda72417c314b841db70ff3b49d2c4ce03e53ec7", - "last_commit": "c4c8abf6", + "last_commit": "0e643254", "name": "tools/aien-local-ci", "purpose": "Local CI sandbox exec contract (C8), aien-run user/caches install, Forgejo trigger hook, health " } ], "children_root": "sha256:3b54a54aa0b1c75dac59ea3656c912bbf6951ae6e657b2068ea27ceb833c32f1", - "compiled_at": "2026-10-30T05:15:32Z", + "compiled_at": "2026-10-30T05:24:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:b0c81af77ec76ce66a8779bf089d0c8429beb131d2905ba196b245a0ebfb0b9b", + "digest": "sha256:aa4e3a45c84bf659c76d8960c8f27e99aa02c6dd17c5f650a9597f636f0d050d", "evidence_files": 3602, "evidence_root": "sha256:1b8069934a4cc67803874ebd2ad5de32671fae5ccce1a3ea70aeb532fe8ea86b", - "files": 8094, - "generated_at_commit": "2015edda1c6ffe90880b77eb8fd847ce0242732e", - "source_tree": "sha256:4fb5df73520d8d6e2f18e0490560be8fce3dd01aa935971eee49133fcf8c4b2f" + "files": 8100, + "generated_at_commit": "812c17ffbf3ef7a0b7e1f7c882714d94c2bbd795", + "source_tree": "sha256:7388eeba64ba69cab64dcd255de24cf67a36d426bc986c9376fb9448b53997c3" } }, "history": [], diff --git a/om/README.md b/om/README.md index 1c07953a..9a0b08b9 100644 --- a/om/README.md +++ b/om/README.md @@ -14,6 +14,7 @@ aien-architecture-mv#300). | `vendor/sha256.om` | Incremental SHA-256 in Omega, vendored from benchmarks-mv. | Exercised through `world.om` and `tur-ledger.om`. | | `vendor/ec.om` | Native Omega ECDSA P-256/P-384 verification, byte-identical to omega-mv `6999fa9e6dae4847c155ef4eacaece74f491d3ca` `om/tls/ec.om`. | P-256/SHA-256 strict DER verification used by `tur-ledger.om`; OpenSSL is a test-only signing oracle, not a runtime dependency. | | `vendor/json.om` | Seeded JSON tape parser, byte-identical to omega-mv `bf54b19fa590e8ae925c0e80815516dbf41e7326` `seed/json/json.om`. | Used by `flint/manifest.om` for config and safetensors headers. | +| `residency/residency.om` | MoE expert residency simulator (sc#630 question): replays a recorded router trace against a per-layer expert cache and counts hits and misses for LRU and Belady OPT at 25-90 % resident. | Host only. Matches an independent Wolfram LRU/OPT on a real 35B trace slice and a synthetic trace; 9 refusals and 2 policy mutants checked (`OMEGA_OMC= bash om/residency/run.sh`). Not wired into the pager. | Run: `OMEGA_OMC= bash om/effects/run.sh` (needs the offline cargo cache for the Rust reference, `crates/aien-runtime/examples/om_world_reference.rs`). diff --git a/om/residency/fixtures/real-p4-L4T64.txt b/om/residency/fixtures/real-p4-L4T64.txt new file mode 100644 index 00000000..77b60b54 --- /dev/null +++ b/om/residency/fixtures/real-p4-L4T64.txt @@ -0,0 +1,65 @@ +256 4 8 64 +209 43 104 30 95 206 105 147 146 112 11 217 155 205 250 62 167 43 158 20 52 49 179 72 226 39 225 199 233 25 236 27 +29 32 207 115 148 151 60 120 167 124 153 71 251 191 19 242 188 79 60 58 170 49 139 223 242 243 56 197 36 16 215 228 +141 79 81 208 235 115 61 221 11 97 155 205 216 123 62 47 164 74 24 88 17 158 40 50 37 199 225 39 230 206 59 34 +252 25 238 43 112 42 170 176 112 250 129 46 224 189 147 213 74 98 10 128 158 176 61 245 226 233 26 225 230 236 39 25 +209 104 30 43 206 105 147 95 47 46 129 11 205 112 138 155 20 82 179 97 172 167 217 24 226 27 233 183 103 216 39 212 +115 207 29 151 32 224 120 60 191 167 73 153 7 124 203 105 61 79 24 76 148 243 170 223 243 3 33 90 216 242 63 240 +141 81 208 115 79 235 125 221 11 97 47 177 216 15 205 207 74 27 245 12 4 17 24 98 12 27 225 49 39 205 160 97 +252 25 238 43 112 42 170 147 46 250 129 112 224 189 147 105 74 98 245 128 24 176 140 27 233 225 226 26 230 164 39 103 +209 30 104 43 206 105 147 95 46 47 129 205 138 41 105 36 82 98 245 186 73 213 251 128 226 27 103 233 183 225 12 244 +115 29 151 32 224 222 207 41 167 191 223 153 124 105 197 73 61 79 245 76 170 24 27 51 12 4 63 216 252 240 36 243 +132 158 81 141 125 79 115 192 250 11 112 155 244 205 224 197 74 158 29 17 88 109 164 27 225 25 199 59 37 230 233 39 +77 37 138 75 173 184 26 232 214 112 250 172 224 147 129 97 49 219 217 11 29 153 158 129 6 224 225 69 87 25 61 159 +81 115 140 206 235 86 192 95 112 224 94 250 172 129 19 147 41 153 129 29 106 49 11 217 26 230 233 225 25 199 117 69 +106 66 43 236 238 218 212 157 112 224 19 86 124 147 242 250 11 49 188 133 153 217 106 60 19 214 159 225 25 199 60 223 +93 210 228 14 84 57 88 102 195 251 3 29 182 100 127 33 49 11 217 133 153 64 106 33 19 225 214 246 70 237 219 20 +136 180 14 78 241 238 68 56 234 94 127 107 172 147 102 16 153 217 41 1 172 233 179 237 246 255 225 45 12 216 3 244 +134 36 124 151 175 231 188 31 113 245 101 254 118 33 7 8 64 237 153 150 182 117 94 106 25 159 87 199 225 202 246 219 +175 199 13 151 204 231 134 178 16 253 49 234 254 162 209 10 108 252 123 173 19 120 153 106 236 188 166 79 199 159 25 65 +101 35 197 242 79 108 11 135 146 155 27 97 16 231 11 150 117 90 20 75 109 149 252 52 225 236 119 37 199 25 53 117 +132 81 158 115 177 235 182 47 217 155 146 11 250 233 182 118 167 121 123 109 43 153 20 217 119 117 225 190 41 236 37 214 +238 252 43 25 205 95 147 112 250 217 224 140 146 112 182 147 49 11 167 217 20 106 153 43 236 119 130 117 41 225 38 53 +43 209 30 206 95 104 105 147 155 146 11 217 62 47 118 233 52 49 20 167 43 153 106 217 226 225 117 119 39 233 199 236 +32 206 238 95 168 181 30 200 140 182 192 201 86 146 118 176 49 52 11 20 218 153 41 167 199 225 113 118 129 39 214 119 +238 200 112 88 95 43 173 140 181 233 128 155 140 152 118 47 49 52 20 218 72 11 253 217 113 119 106 41 225 226 236 117 +78 120 236 136 68 16 56 191 252 124 186 240 118 1 224 211 49 60 188 11 92 217 52 150 190 189 41 155 219 119 225 4 +93 209 228 210 14 240 84 102 195 215 252 128 211 68 127 182 217 49 1 233 92 11 188 153 244 68 216 237 255 45 39 1 +139 192 175 222 223 151 13 31 48 153 98 245 171 40 118 234 120 193 2 3 223 106 253 108 199 184 159 225 19 33 192 197 +151 175 124 13 231 199 30 204 251 111 49 245 202 171 23 239 200 120 31 15 3 89 212 135 199 137 159 25 166 28 197 225 +79 35 34 101 197 179 48 242 155 146 107 97 62 16 47 75 39 210 125 200 38 252 43 120 166 37 230 199 26 225 236 129 +141 81 235 115 208 192 253 221 217 155 146 182 62 152 82 11 95 106 109 217 128 153 43 167 119 219 237 117 37 158 199 35 +38 167 238 54 193 112 30 94 140 217 62 182 117 122 146 152 217 11 121 106 153 167 127 8 91 128 34 35 26 129 199 230 +238 140 112 43 200 95 30 173 146 217 140 155 70 62 182 181 217 11 121 72 167 106 43 49 117 236 226 26 225 230 199 233 +107 181 82 106 83 99 236 59 124 132 242 128 73 86 193 191 49 188 153 217 238 11 255 72 227 169 119 41 131 166 92 150 +139 24 109 151 225 72 175 192 85 236 22 226 33 118 233 211 3 77 221 5 58 49 153 72 167 184 19 17 225 199 121 11 +144 188 234 172 186 111 92 242 111 198 211 251 239 233 33 66 230 15 200 150 86 31 92 212 19 166 28 137 30 199 116 70 +233 226 117 96 93 80 171 149 40 120 234 57 96 171 92 13 84 120 178 165 39 129 142 128 162 148 225 166 91 95 188 186 +241 57 135 108 88 133 242 61 11 192 97 146 95 233 70 99 84 159 36 8 13 236 120 178 225 106 236 224 29 211 199 25 +186 191 144 70 92 175 199 180 191 163 167 124 205 243 21 42 92 223 150 86 84 170 133 188 225 25 155 159 11 39 157 95 +1 212 218 136 3 65 157 67 40 234 153 183 222 209 41 48 232 120 200 84 96 2 253 178 45 166 0 25 224 225 109 159 +136 86 41 29 134 2 207 1 41 116 101 234 6 92 193 121 96 139 71 180 232 157 98 158 224 39 157 215 201 72 165 159 +134 151 124 231 175 207 5 198 88 101 23 44 17 230 166 69 77 43 83 97 71 96 94 81 226 39 72 242 243 213 229 159 +197 108 135 79 249 35 179 101 97 11 139 75 64 62 216 27 17 88 249 158 210 180 164 37 59 211 37 129 226 224 88 225 +141 235 115 221 190 208 253 81 155 93 182 21 146 11 62 68 194 129 34 179 109 17 88 145 187 235 37 133 128 34 35 230 +38 167 54 193 112 238 94 44 46 105 122 47 117 58 140 201 128 121 129 179 158 145 104 217 26 230 233 210 78 91 128 34 +238 112 140 43 200 173 58 30 46 47 181 217 70 155 188 146 121 72 217 128 186 167 20 179 233 26 230 117 226 236 210 103 +57 165 56 157 127 83 66 236 128 124 73 132 233 242 191 179 238 49 234 255 60 188 219 133 70 19 171 55 217 30 119 166 +111 144 234 172 92 84 188 242 198 111 92 120 239 29 255 193 15 234 230 150 110 92 86 72 30 19 177 25 116 20 92 155 +136 78 241 14 56 89 68 33 234 183 166 228 40 6 96 186 178 56 125 1 209 94 172 189 105 166 229 153 41 143 50 169 +41 134 36 2 207 151 62 76 254 101 91 187 22 221 252 198 139 182 201 56 157 77 178 95 25 39 243 36 159 199 154 167 +151 239 116 175 199 70 159 13 230 253 44 254 206 10 94 101 225 226 39 106 218 97 69 161 131 127 25 162 15 79 39 240 +101 35 197 242 108 9 135 213 27 150 97 62 231 146 155 11 90 210 232 39 36 200 109 164 37 226 211 106 31 236 29 212 +141 235 190 115 221 253 158 208 217 62 146 155 182 47 152 46 121 255 109 128 8 43 167 39 35 106 128 34 37 190 187 12 +193 38 54 167 44 112 94 238 217 117 140 122 105 62 46 152 167 121 128 43 20 8 153 72 26 91 106 128 34 35 12 230 +206 168 255 238 181 246 30 200 140 129 217 86 112 192 146 19 72 11 167 49 121 41 219 153 106 226 224 69 225 41 39 129 +252 25 42 205 147 238 12 165 189 217 129 112 250 140 224 86 167 72 11 49 43 97 106 121 226 106 236 233 199 130 41 117 +209 104 206 43 30 95 105 154 146 217 62 47 11 155 46 70 167 43 72 49 97 20 52 218 226 233 236 225 117 224 26 106 +29 115 207 32 151 148 60 224 167 71 251 153 124 170 191 204 79 188 170 143 91 218 223 60 56 243 36 197 242 16 44 224 +190 235 141 253 115 208 158 221 47 155 46 0 184 93 12 197 164 88 24 25 40 74 37 175 37 59 91 84 142 235 187 34 +193 38 54 167 44 94 112 30 105 117 122 46 47 140 201 188 128 222 245 16 24 104 176 88 34 91 35 128 129 183 12 59 +206 255 168 246 181 30 238 149 99 36 136 148 129 110 105 207 233 1 41 217 156 72 231 171 244 222 183 12 161 1 162 85 +252 25 42 21 238 45 183 165 46 129 189 250 147 112 224 213 72 245 61 167 135 186 148 98 233 26 78 230 140 164 41 107 +209 104 206 30 105 43 154 147 46 47 36 129 99 156 207 138 97 82 156 186 215 251 160 24 226 233 103 143 210 27 253 124 +115 207 29 224 151 32 2 41 167 7 153 73 191 204 203 105 61 79 24 148 76 170 243 181 243 3 33 90 240 216 44 63 +190 141 235 115 208 253 158 221 47 46 184 177 93 197 182 155 74 245 27 4 17 24 12 51 12 231 181 59 235 187 142 205 diff --git a/om/residency/fixtures/real-p4-L4T64.want b/om/residency/fixtures/real-p4-L4T64.want new file mode 100644 index 00000000..3abe631c --- /dev/null +++ b/om/residency/fixtures/real-p4-L4T64.want @@ -0,0 +1,17 @@ +trace E=256 L=4 K=8 T=64 +lru cap=64 pct=25 hits=1130 miss=918 warm_miss=507 warm_acc=1024 +lru cap=102 pct=40 hits=1355 miss=693 warm_miss=315 warm_acc=1024 +lru cap=128 pct=50 hits=1419 miss=629 warm_miss=251 warm_acc=1024 +lru cap=153 pct=60 hits=1458 miss=590 warm_miss=212 warm_acc=1024 +lru cap=163 pct=64 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +lru cap=179 pct=70 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +lru cap=204 pct=80 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +lru cap=230 pct=90 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=64 pct=25 hits=1402 miss=646 warm_miss=268 warm_acc=1024 +opt cap=102 pct=40 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=128 pct=50 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=153 pct=60 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=163 pct=64 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=179 pct=70 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=204 pct=80 hits=1461 miss=587 warm_miss=209 warm_acc=1024 +opt cap=230 pct=90 hits=1461 miss=587 warm_miss=209 warm_acc=1024 diff --git a/om/residency/fixtures/syn-E40L3K4T200.txt b/om/residency/fixtures/syn-E40L3K4T200.txt new file mode 100644 index 00000000..072157e4 --- /dev/null +++ b/om/residency/fixtures/syn-E40L3K4T200.txt @@ -0,0 +1,2 @@ +40 3 4 200 +19 30 34 35 38 25 15 30 5 9 21 34 17 36 0 38 15 22 11 7 7 35 15 28 12 30 5 1 18 4 12 38 8 20 12 17 34 2 19 9 0 8 16 17 28 34 33 37 37 0 8 2 37 21 30 36 1 6 21 37 5 6 31 37 11 31 22 39 20 15 34 2 19 32 10 13 31 28 5 39 20 29 32 39 19 31 34 8 21 7 18 33 20 16 35 22 10 4 8 35 19 0 39 32 26 0 12 39 8 4 23 37 3 18 27 9 23 24 16 19 31 37 13 12 7 33 32 36 5 12 22 33 30 36 7 4 31 39 20 2 19 20 32 31 37 34 7 33 1 2 20 18 24 30 15 5 16 0 28 39 22 36 14 31 22 2 32 35 3 22 23 14 21 4 33 16 13 14 1 16 30 9 28 3 34 38 22 9 0 26 32 1 32 6 22 35 37 26 20 30 29 13 39 8 36 11 28 38 28 18 22 31 1 2 12 23 36 4 11 23 26 12 35 10 22 31 8 2 13 31 29 10 13 7 22 17 4 19 29 5 34 8 4 19 39 23 16 6 2 35 31 25 1 39 8 23 19 14 34 12 26 21 32 31 38 29 19 8 35 22 3 29 28 5 31 11 28 38 4 24 2 37 17 18 37 35 30 34 15 5 17 28 9 17 34 14 38 39 27 36 32 6 37 39 20 5 24 39 32 39 31 23 35 30 36 23 11 0 39 37 10 38 26 17 39 32 6 18 2 19 3 8 4 38 9 20 5 32 15 31 14 30 31 1 15 8 30 37 12 10 32 29 35 30 5 17 15 8 34 22 4 18 21 12 12 29 26 37 19 32 26 33 15 13 37 21 20 8 25 17 24 31 5 26 13 3 15 1 27 19 39 12 5 33 7 29 15 18 0 16 38 34 14 32 1 0 16 17 14 36 24 35 12 19 30 16 0 4 25 21 3 24 20 27 29 8 20 33 4 5 19 25 0 18 27 15 28 15 13 18 36 33 13 10 37 22 19 4 32 25 29 33 29 11 20 17 1 14 11 6 0 30 16 2 27 29 26 1 37 39 10 1 31 2 19 29 22 31 28 2 16 20 13 18 15 25 21 39 18 33 9 15 22 39 35 13 12 32 19 21 28 12 38 32 26 23 6 11 0 6 39 29 21 7 24 1 11 4 29 2 39 2 33 22 30 23 10 28 33 37 11 32 35 4 5 32 9 14 30 4 22 24 12 29 36 35 34 32 1 34 35 25 32 39 1 18 27 31 22 9 0 5 37 27 23 33 24 3 11 4 37 10 12 8 9 11 10 8 5 35 10 36 31 11 6 15 30 24 8 29 5 34 16 26 0 35 16 1 11 21 17 30 19 7 2 17 34 6 38 17 22 3 37 11 20 23 19 0 34 29 7 22 6 4 38 32 22 0 11 20 13 4 4 6 38 13 16 36 27 8 17 28 15 31 18 14 27 32 38 37 12 1 22 10 0 28 27 4 15 30 1 7 21 10 19 11 2 18 37 19 34 12 19 8 9 24 36 20 6 13 20 11 19 9 37 12 26 36 12 37 28 30 11 31 22 15 29 14 16 7 25 8 4 33 7 39 5 12 7 35 4 8 10 31 21 6 26 0 4 16 10 35 8 29 23 30 16 1 1 17 14 39 16 31 36 27 31 17 18 34 11 33 30 9 10 22 2 9 29 34 32 31 32 34 9 6 17 12 34 21 39 12 16 35 36 25 37 2 32 6 14 12 17 14 23 20 22 19 10 34 23 27 3 2 37 8 35 28 21 31 30 9 37 29 15 36 7 23 11 29 0 15 14 25 8 18 15 38 5 21 19 0 26 37 31 8 33 0 15 21 23 6 32 21 5 11 0 20 8 4 29 28 6 18 37 22 34 2 37 14 15 7 10 12 14 8 23 24 4 3 25 13 3 34 11 28 22 31 11 23 29 2 36 39 16 24 18 20 0 27 32 29 25 18 5 38 27 3 20 6 39 21 23 15 35 39 33 9 23 25 34 13 22 23 0 28 16 17 24 25 33 22 34 1 26 2 24 38 6 37 26 14 30 32 38 11 3 15 29 38 14 34 11 2 9 28 18 39 35 2 30 26 3 21 31 10 24 11 39 5 34 0 7 33 35 0 22 28 37 18 23 9 10 39 16 24 26 11 8 2 20 1 39 0 23 30 1 2 24 0 29 25 18 27 29 20 17 19 28 25 1 29 3 37 6 20 37 38 37 38 18 39 34 36 29 13 27 29 13 2 24 16 12 6 33 13 4 20 14 20 38 19 36 29 8 30 27 20 14 35 17 33 28 25 4 34 37 30 11 2 1 26 21 32 34 22 32 31 2 1 39 20 17 30 23 10 5 17 37 25 10 0 34 36 16 38 15 3 11 17 39 1 15 30 19 28 18 9 27 0 2 34 23 17 22 7 24 12 19 14 11 2 17 23 18 23 8 27 18 21 34 4 9 10 4 12 6 20 39 18 4 10 14 39 12 27 14 9 24 5 31 4 22 25 26 21 36 7 24 38 8 7 23 36 27 5 39 26 25 0 9 20 28 5 19 24 7 24 10 29 16 30 33 9 32 8 6 15 27 36 9 21 7 19 24 8 20 16 24 19 6 23 39 25 21 22 26 32 18 15 25 11 39 38 21 16 19 13 2 24 36 15 18 27 28 13 29 11 5 11 34 10 2 17 25 14 26 37 27 3 10 29 13 37 6 8 38 4 26 8 13 10 14 15 23 5 2 17 6 30 28 24 25 8 20 29 3 15 19 17 38 15 8 4 35 17 39 15 8 28 28 5 1 36 35 39 3 31 8 16 26 18 14 1 7 22 22 7 30 18 1 3 23 38 27 19 21 13 15 35 20 19 9 0 27 6 1 39 25 23 0 13 25 35 5 22 38 25 20 21 7 2 11 10 0 25 14 13 33 6 23 34 3 10 14 23 31 5 4 30 33 3 13 7 31 12 8 32 21 28 10 21 2 13 26 25 22 5 10 29 13 33 32 35 3 36 27 38 30 12 13 7 2 27 5 38 0 32 0 35 22 9 20 32 6 36 39 38 15 20 28 33 0 20 1 25 0 2 12 25 29 17 21 15 9 27 36 37 4 21 14 37 33 36 33 35 28 31 20 29 39 12 15 7 36 21 10 5 37 7 33 29 35 12 15 16 33 21 32 10 39 2 0 37 14 28 37 19 35 4 2 20 3 21 16 26 20 13 1 10 38 22 26 34 37 18 35 6 28 39 3 22 39 20 16 39 22 11 2 3 36 34 13 23 36 29 16 7 22 24 0 25 38 4 26 0 17 37 21 2 14 25 30 32 37 16 9 16 22 18 39 17 29 15 30 16 25 33 13 25 16 8 0 15 4 17 27 4 36 24 21 8 13 29 17 18 20 34 8 4 26 25 19 29 23 24 26 24 4 38 15 7 6 30 27 1 9 29 6 23 16 2 0 2 11 21 29 11 30 16 36 32 5 39 17 7 39 29 19 14 30 36 10 6 27 12 27 2 16 14 5 29 31 32 24 3 19 34 12 16 31 36 15 33 9 30 5 34 38 7 12 16 18 30 29 11 9 16 37 23 30 27 38 16 11 36 5 29 26 28 18 11 33 24 13 18 9 29 9 25 15 5 0 26 21 2 39 4 30 25 21 11 29 7 5 17 2 12 36 7 33 22 15 9 12 38 15 35 23 30 2 33 7 14 4 0 39 33 20 15 13 29 33 9 11 17 39 4 10 28 17 38 8 34 0 5 14 24 18 12 11 32 5 3 20 11 8 1 31 10 39 9 35 31 36 2 0 11 22 15 11 4 18 21 3 27 36 24 20 29 8 15 5 7 17 29 36 12 8 35 26 14 31 39 17 2 21 2 12 18 39 3 38 11 6 12 15 13 38 14 33 17 39 25 24 34 5 29 22 16 11 16 1 21 25 37 35 28 35 27 31 19 4 31 17 37 19 39 24 37 10 18 31 36 32 39 26 3 10 23 22 9 3 18 28 37 18 29 22 0 31 3 33 9 23 1 28 7 33 20 30 31 12 17 15 38 14 8 19 32 25 11 37 31 38 15 25 35 23 34 15 25 31 34 27 17 27 31 21 24 21 0 38 26 21 30 19 8 5 13 27 22 9 17 26 34 37 25 38 3 36 18 28 9 16 24 30 36 13 22 37 7 37 2 13 34 2 39 35 25 9 25 18 1 15 34 27 6 10 27 30 35 3 34 37 29 19 12 36 28 31 19 35 29 21 39 4 22 21 15 5 18 14 11 1 24 23 15 10 11 20 24 37 30 28 21 2 14 20 12 22 6 0 33 21 26 2 5 21 33 31 19 26 12 36 20 11 23 23 12 20 39 15 1 4 26 25 38 37 21 21 19 14 23 37 23 36 33 10 12 19 15 10 20 32 22 18 30 6 10 38 28 15 33 26 3 23 29 31 9 30 8 39 37 18 13 16 29 20 2 13 32 33 7 37 34 3 19 1 37 34 0 23 32 18 38 2 19 10 24 12 16 3 38 38 3 33 2 23 15 24 28 27 23 34 3 16 28 10 7 9 16 14 15 34 17 9 35 28 10 4 5 29 31 18 13 6 34 16 39 12 10 32 28 3 8 0 39 0 38 7 13 38 36 4 23 16 15 0 27 1 22 18 8 38 14 17 33 5 21 20 38 32 7 35 16 26 20 15 19 11 2 39 18 11 3 15 21 28 5 16 11 9 5 13 4 38 0 39 9 13 2 5 35 12 24 10 19 5 28 33 24 10 5 4 12 31 38 4 5 38 24 3 25 10 27 1 6 26 15 30 19 23 38 36 30 38 5 19 29 10 36 24 37 19 22 16 29 19 1 23 24 20 23 8 31 4 24 30 32 28 33 37 19 9 34 31 12 30 28 0 33 28 35 26 3 10 22 31 11 17 19 11 15 14 22 24 35 24 7 17 10 16 32 39 34 31 23 0 36 21 28 10 2 9 12 18 33 37 22 12 3 38 32 3 8 12 18 14 15 21 14 7 18 19 18 11 38 2 23 12 6 12 33 31 15 9 35 27 37 37 32 11 21 4 9 31 30 1 28 29 10 26 32 8 33 37 25 36 0 33 3 9 19 5 1 30 38 28 10 20 3 35 5 24 1 13 25 7 36 30 3 33 29 27 39 3 5 21 1 6 0 11 2 4 35 14 32 28 29 19 30 21 14 28 36 6 9 39 8 24 27 34 19 28 11 1 12 28 24 7 16 39 23 23 24 21 27 17 6 7 34 31 8 16 18 25 16 27 21 12 24 21 36 25 24 10 21 31 39 28 37 13 12 33 26 9 13 37 6 22 27 2 29 16 33 35 32 32 39 4 29 13 18 22 29 39 14 17 1 10 39 3 5 0 32 3 12 25 3 1 38 20 39 2 34 16 10 13 34 diff --git a/om/residency/fixtures/syn-E40L3K4T200.want b/om/residency/fixtures/syn-E40L3K4T200.want new file mode 100644 index 00000000..3d817510 --- /dev/null +++ b/om/residency/fixtures/syn-E40L3K4T200.want @@ -0,0 +1,17 @@ +trace E=40 L=3 K=4 T=200 +lru cap=10 pct=25 hits=536 miss=1864 warm_miss=924 warm_acc=1200 +lru cap=16 pct=40 hits=881 miss=1519 warm_miss=752 warm_acc=1200 +lru cap=20 pct=50 hits=1114 miss=1286 warm_miss=634 warm_acc=1200 +lru cap=24 pct=60 hits=1354 miss=1046 warm_miss=514 warm_acc=1200 +lru cap=25 pct=64 hits=1407 miss=993 warm_miss=487 warm_acc=1200 +lru cap=28 pct=70 hits=1581 miss=819 warm_miss=400 warm_acc=1200 +lru cap=32 pct=80 hits=1818 miss=582 warm_miss=273 warm_acc=1200 +lru cap=36 pct=90 hits=2063 miss=337 warm_miss=141 warm_acc=1200 +opt cap=10 pct=25 hits=1185 miss=1215 warm_miss=594 warm_acc=1200 +opt cap=16 pct=40 hits=1582 miss=818 warm_miss=391 warm_acc=1200 +opt cap=20 pct=50 hits=1768 miss=632 warm_miss=297 warm_acc=1200 +opt cap=24 pct=60 hits=1920 miss=480 warm_miss=217 warm_acc=1200 +opt cap=25 pct=64 hits=1955 miss=445 warm_miss=197 warm_acc=1200 +opt cap=28 pct=70 hits=2043 miss=357 warm_miss=146 warm_acc=1200 +opt cap=32 pct=80 hits=2139 miss=261 warm_miss=89 warm_acc=1200 +opt cap=36 pct=90 hits=2227 miss=173 warm_miss=36 warm_acc=1200 diff --git a/om/residency/residency.om b/om/residency/residency.om new file mode 100644 index 00000000..547661ad --- /dev/null +++ b/om/residency/residency.om @@ -0,0 +1,333 @@ +note SPDX-License-Identifier: Apache-2.0 +note Expert residency simulator in seeded Omega (sc#630 residency question, host only). +note Replays a recorded MoE router trace against a per-layer expert cache of capacity C and counts +note hits and misses for two eviction policies: LRU (online) and OPT (Belady, offline bound). +note Input on stdin, ASCII decimal numbers separated by spaces, tabs or newlines: +note E L K T, then T*L*K expert ids in step-major order (step t, layer l, slot k), each below E. +note Limits: 1 <= E <= 1024, 1 <= K <= 16, 1 <= L, 2 <= T, T*K <= 1048576, T*L*K <= 8388608, +note input at most 16 MiB. Ids inside one step and layer must be distinct. +note Output: one header line, then one line per policy and capacity percent in pc: +note POLICY cap=C pct=P hits=H miss=M warm_miss=W warm_acc=A +note warm counts only steps t >= T/2, so compulsory first-touch misses mostly fall outside them. +note Eviction never removes an expert already used in the current step (all K are needed at once). +note Exit: 0 ok, 2 read error, 3 input over 16 MiB, 4 header out of range, 5 bad or missing number, +note 6 trailing bytes, 7 id out of range, 8 repeated id in one step, 9 write error. +global inb uchar 16777216 +global ids ushort 8388608 +global nxt ulong 1048576 +global stp ulong 1024 +global nu ulong 1024 +global lst ulong 1024 +note hd: 0 E, 1 L, 2 K, 3 T, 4 parse position, 5 input length. +global hd ulong 8 +note ac: 0 hits, 1 misses, 2 warm misses, 3 resident count. +global ac ulong 8 +global pc ulong 8 +global ob uchar 8192 +global ow ulong 1 +text lit "trace E=~ L=~ K=~ T=~\n~lru ~opt ~cap=~ pct=~ hits=~ miss=~ warm_miss=~ warm_acc=~ " + +note slurp: read all of stdin into inb. Each inner pass adds at least one byte or ends, so +note 64 outer passes of 999999 cover the 16777216-byte buffer. +fn slurp to int +n = ulong 0 +for r ulong 64 +while lt n len inb bound 999999 +k = read 0 inb n sub len inb n +if lt k 0 +ret 2 +end +if eq k 0 +put hd 5 n +ret 0 +end +n = add n ulong k +end +end +ret 3 +end + +note isws: byte c is a space, tab, carriage return or newline. +fn isws c uchar to bool +ret or or eq c 32 eq c 10 or eq c 9 eq c 13 +end + +note skip: advance the parse position past white space; return the new position. +fn skip to ulong +p = get hd 4 +n = get hd 5 +while lt p n bound 999999 +if not isws get inb p +break +end +p = add p 1 +end +put hd 4 p +ret p +end + +note num: next decimal number (at most 20 digits); exit 5 when none is there. +fn num to ulong +p = skip +n = get hd 5 +v = ulong 0 +d = ulong 0 +while lt p n bound 21 +c = get inb p +if or lt c 48 gt c 57 +break +end +v = add mul v 10 ulong sub c 48 +p = add p 1 +d = add d 1 +end +if eq d 0 +exit 5 +end +if lt p n +if not isws get inb p +exit 5 +end +end +put hd 4 p +ret v +end + +note badd: append byte c to ob. +fn badd c uchar to void +w = get ow 0 +if ge w len ob +exit 9 +end +put ob w c +put ow 0 add w 1 +end + +note frag: append fragment k of lit (fragments separated by ~, byte 126). +fn frag k ulong to void +c = ulong 0 +for i ulong len lit +b = get lit i +if eq b 126 +c = add c 1 +else +if eq c k +badd b +end +end +end +end + +note dec: append v in decimal. +fn dec v ulong to void +p = ulong 1 +while le p div v 10 bound 20 +p = mul p 10 +end +while ne p 0 bound 21 +badd uchar add div v p 48 +v = rem v p +p = div p 10 +end +end + +note kv: append fragment k, then v in decimal. +fn kv k ulong v ulong to void +frag k +dec v +end + +note flush: write ob to stdout, looping over partial writes. +fn flush to int +o = ulong 0 +w = get ow 0 +while lt o w bound 8193 +k = write 1 ob o sub w o +if le k 0 +ret 9 +end +o = add o ulong k +end +ret 0 +end + +note slot: index of (step t, layer l, slot k) in ids. +fn slot t ulong l ulong k ulong to ulong +ret add mul add mul t get hd 1 l get hd 2 k +end + +note prep: nxt[t*K+k] = next step after t whose layer-l ids contain the id at (t,l,k), else T. +fn prep l ulong to void +t0 = get hd 3 +k0 = get hd 2 +for e ulong get hd 0 +put lst e t0 +end +for j ulong t0 +t = sub sub t0 1 j +for k ulong k0 +id = ulong get ids slot t l k +put nxt add mul t k0 k get lst id +end +for k ulong k0 +put lst ulong get ids slot t l k t +end +end +end + +note score: eviction preference of resident expert e at step t (larger evicts first). +note LRU (pol 0): least recently used; OPT (pol 1): next use farthest away. +fn score e ulong t ulong pol ulong to ulong +if eq pol 0 +ret sub add t 2 get stp e +end +ret get nu e +end + +note evict: drop the resident expert with the largest score, lowest id on ties, never one +note already used in step t (stamp t+1). +fn evict t ulong pol ulong to void +best = ulong 0 +bv = ulong 0 +fnd = false +for e ulong get hd 0 +s = get stp e +if and ne s 0 ne s add t 1 +v = score e t pol +if or not fnd gt v bv +best = e +bv = v +fnd = true +end +end +end +if not fnd +exit 8 +end +put stp best 0 +end + +note access: one router choice (t,l,k) against cache capacity c. +fn access t ulong l ulong k ulong c ulong pol ulong to void +id = ulong get ids slot t l k +if eq get stp id add t 1 +exit 8 +end +if ne get stp id 0 +put ac 0 add get ac 0 1 +else +put ac 1 add get ac 1 1 +if ge t div get hd 3 2 +put ac 2 add get ac 2 1 +end +if ge get ac 3 c +evict t pol +else +put ac 3 add get ac 3 1 +end +end +put stp id add t 1 +put nu id get nxt add mul t get hd 2 k +end + +note simlayer: replay layer l from an empty cache of capacity c. +fn simlayer l ulong c ulong pol ulong to void +for e ulong get hd 0 +put stp e 0 +put nu e 0 +end +put ac 3 0 +for t ulong get hd 3 +for k ulong get hd 2 +access t l k c pol +end +end +end + +note run: every layer at capacity c under policy pol; append the result line. +fn run c ulong p ulong pol ulong to void +put ac 0 0 +put ac 1 0 +put ac 2 0 +for l ulong get hd 1 +prep l +simlayer l c pol +end +frag add 5 pol +kv 7 c +kv 8 p +kv 9 get ac 0 +kv 10 get ac 1 +kv 11 get ac 2 +t = get hd 3 +kv 12 mul mul get hd 1 get hd 2 sub t div t 2 +badd 10 +end + +note load: parse the header and the ids; return 0 or an exit code. +fn load to int +e = num +l = num +k = num +t = num +if or or lt e 1 gt e 1024 or lt k 1 gt k 16 +ret 4 +end +if or lt l 1 lt t 2 +ret 4 +end +if or gt t 1048576 gt mul t k 1048576 +ret 4 +end +if gt l div 8388608 mul t k +ret 4 +end +put hd 0 e +put hd 1 l +put hd 2 k +put hd 3 t +for i ulong mul mul t l k +v = num +if ge v e +ret 7 +end +put ids i ushort v +end +if lt skip get hd 5 +ret 6 +end +ret 0 +end + +fn main to int +r = slurp +if ne r 0 +ret r +end +r = load +if ne r 0 +ret r +end +put pc 0 25 +put pc 1 40 +put pc 2 50 +put pc 3 60 +put pc 4 64 +put pc 5 70 +put pc 6 80 +put pc 7 90 +kv 0 get hd 0 +kv 1 get hd 1 +kv 2 get hd 2 +kv 3 get hd 3 +frag 4 +for pol ulong 2 +for j ulong 8 +c = div mul get hd 0 get pc j 100 +if ge c get hd 2 +run c get pc j pol +end +end +end +ret flush +end diff --git a/om/residency/run.sh b/om/residency/run.sh new file mode 100755 index 00000000..21d82385 --- /dev/null +++ b/om/residency/run.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Host test of the seeded .om expert residency simulator (om/residency/residency.om). +# Expected outputs in fixtures/*.want were computed by an independent LRU and Belady (OPT) +# implementation in the Wolfram Language, not by residency.om: +# real-p4-L4T64: first 64 decode steps and first 4 layers of +# evidence/l355-w4/routes/forced-fp8-p4.json (Qwen3.6-35B-A3B FP8, top-8 of 256 experts). +# syn-E40L3K4T200: SeedRandom[630]; RandomSample[Range[0,39],4] per step and layer, 200 steps. +# Also checks every refusal exit code and that two policy mutants are caught. +# Usage: OMEGA_OMC= bash om/residency/run.sh [TRACE.txt ...] +# Extra TRACE arguments are replayed after the checks and their output printed (not compared). +set -u +ROOT=$(cd "$(dirname "$0")/../.." && pwd) +# omega-mv main 0b77e6ea294aa3d69ccbdb86b9c14d133abea689, seed/out/omc +PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +OMC=${OMEGA_OMC:?set OMEGA_OMC to the seed compiler (omega-mv seed/out/omc)} +D=$ROOT/om/residency +O=$ROOT/target/om-residency +got=$(sha256sum < "$OMC" | cut -d' ' -f1) +[ "$got" = "$PIN" ] || { echo "FAIL omc sha256 $got, pinned $PIN"; exit 1; } +rm -rf "$O"; mkdir -p "$O" +fails=0 +pass() { echo "PASS $1"; } +fail() { echo "FAIL $1"; fails=$((fails + 1)); } +build() { "$OMC" < "$1" > "$2" 2> "$2.err" && chmod +x "$2"; } +build "$D/residency.om" "$O/sim" || { echo "FAIL build residency.om: $(cat "$O/sim.err")"; exit 1; } + +for f in real-p4-L4T64 syn-E40L3K4T200; do + "$O/sim" < "$D/fixtures/$f.txt" > "$O/$f.out"; rc=$? + if [ $rc = 0 ] && cmp -s "$O/$f.out" "$D/fixtures/$f.want"; then pass "$f matches the Wolfram oracle" + else fail "$f (exit $rc)"; diff "$D/fixtures/$f.want" "$O/$f.out" | head -5; fi +done + +refuse() { + printf '%b' "$2" | "$O/sim" > /dev/null; rc=$? + if [ $rc = "$3" ]; then pass "refuse $1 (exit $rc)"; else fail "refuse $1: exit $rc, want $3"; fi +} +refuse "id equal to E" '4 1 1 2\n0 4\n' 7 +refuse "repeated id in one step" '4 1 2 2\n0 0 1 2\n' 8 +refuse "K above 16" '64 1 17 2\n' 4 +refuse "E zero" '0 1 1 2\n' 4 +refuse "one step" '4 1 1 1\n0\n' 4 +refuse "missing ids" '4 1 1 3\n0 1\n' 5 +refuse "letter in a number" '4 1 1 2\n0 1x\n' 5 +refuse "trailing number" '4 1 1 2\n0 1 2\n' 6 +refuse "empty input" '' 5 + +# Mutants: each must build, run to completion on the synthetic fixture and change its output. +mutant() { + sed "$2" "$D/residency.om" > "$O/m.om" + cmp -s "$O/m.om" "$D/residency.om" && { fail "mutant $1 did not change the source"; return; } + build "$O/m.om" "$O/m" || { fail "mutant $1 did not build"; return; } + "$O/m" < "$D/fixtures/syn-E40L3K4T200.txt" > "$O/m.out"; rc=$? + if [ $rc != 0 ]; then fail "mutant $1 did not complete (exit $rc)" + elif cmp -s "$O/m.out" "$D/fixtures/syn-E40L3K4T200.want"; then fail "mutant $1 not caught" + else pass "mutant $1 caught"; fi +} +mutant "LRU evicts most recent" 's/^ret sub add t 2 get stp e$/ret get stp e/' +mutant "OPT evicts nearest next use" 's/^ret get nu e$/ret sub get hd 3 get nu e/' + +echo "residency.om $(sha256sum < "$D/residency.om" | cut -d' ' -f1)" +echo "sim binary $(sha256sum < "$O/sim" | cut -d' ' -f1)" +echo "omc $got" +for t in "$@"; do echo "== $t"; "$O/sim" < "$t"; echo "exit $?"; done +[ $fails = 0 ] && echo "ALL PASS" || { echo "$fails FAILED"; exit 1; } ```