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
omega-mv / om / gpu / dsv41 / decoder / README.md
| 1 | # Native single-stream decoder |
| 2 | |
| 3 | The offline tensor index and text ingress target DeepSeek-V4.1-Flash revision `314113f8a7dadb388215396ba5fbee2c610a04d6`. The index verifies each shard's exact length and SHA-256 of its JSON header before reading its tensor descriptors. Full payload qualification also requires the verified weight digests. The ingress accepts little-endian u32 text IDs and emits four BF16 embedding rows followed by the FP32 identity pre-mix. |
| 4 | |
| 5 | Build from the clean repository root on AArch64 Linux with the seeded compiler. Keep build outputs outside the checkout. |
| 6 | |
| 7 | ```sh |
| 8 | out=$(mktemp -d) |
| 9 | d=om/gpu/dsv41/decoder |
| 10 | (echo om2 && cat seed/json/json.om seed/ng/sha256.om "$d/checkpoint.om" "$d/io.om" "$d/index.om") | |
| 11 | seed/out/omc > "$out/index" |
| 12 | (echo om2 && cat seed/json/json.om om/gpu/dsv41/head/weights.om "$d/embed.om" "$d/embed-cli.om") | |
| 13 | seed/out/omc > "$out/embed" |
| 14 | chmod +x "$out/index" "$out/embed" |
| 15 | "$out/index" "$checkpoint"/model-?????-of-00048.safetensors > "$out/tensors.bin" |
| 16 | ``` |
| 17 | |
| 18 | Each 160-byte tensor descriptor contains the one-based shard ID at byte 0, rank at byte 2, absolute u64 offset and length at bytes 8 and 16, up to four u32 dimensions at byte 24, a zero-terminated dtype at byte 40 and a zero-terminated tensor name at byte 56. Integers are little-endian. Discard partial output on any nonzero exit. |
| 19 | |
| 20 | Checkpoint configuration activates Engram at zero-based layers 1 and 14. Layer 0 has a sliding window and no Engram contribution. Its real-weight parity check must preserve that behavior. The first integrated Engram parity check belongs at layer 1. |
| 21 | |
| 22 | ## Expert and Engram payload index |
| 23 | |
| 24 | Build the shard worker and the real-weight resolver control on the same head. |
| 25 | |
| 26 | ```sh |
| 27 | (echo om2 |
| 28 | sed '/^om2$/d;s/^export fn /fn /' om/sha256/sha256-om2.om |
| 29 | cat seed/ng/sha256.om "$d/checkpoint.om" "$d/io.om" "$d/payload-index.om") | |
| 30 | seed/out/omc > "$out/payload-index" |
| 31 | (echo om2 |
| 32 | sed -n '/^layout /,/^end$/p' om/sha256/sha256-om2.om om/runtime/slab_arena.om |
| 33 | sed '/^layout /,/^end$/d;/^om2$/d;s/^export fn /fn /' om/sha256/sha256-om2.om om/runtime/slab_arena.om |
| 34 | cat gpu/nvidia/native/arboris/compute-lock.om "$d/io.om" "$d/lease.om" "$d/resolve.om" "$d/check-resolve.om") | |
| 35 | seed/out/omc > "$out/check-resolve" |
| 36 | chmod +x "$out/payload-index" "$out/check-resolve" |
| 37 | "$out/payload-index" "$out/tensors.bin" 03 "$checkpoint/model-00003-of-00048.safetensors" > "$out/layer0.bin" |
| 38 | "$out/check-resolve" "$out/layer0.bin" "$checkpoint/model-00003-of-00048.safetensors" |
| 39 | ``` |
| 40 | |
| 41 | Run the worker for each shard 03 through 42 and for the two Engram shards 47 and 48. The worker requires the pinned tensor-index digest. Verify the complete source shard against its published digest before starting the worker. |
| 42 | |
| 43 | Expert records have 64 bytes. Bytes 0 and 1 hold shard and layer, bytes 4..7 the expert ID, bytes 8..15 the first eight bytes of SHA-256 in digest order, and six little-endian u64 offsets start at byte 16. The digest covers W1, W2 and W3 weights followed by W1, W2 and W3 scales. The resolver verifies these same bytes in Zone 4 before it claims a FIFO victim. It publishes the slot only after the entire copy completes. A checksum mismatch leaves the resident slot and FIFO cursor intact. |
| 44 | |
| 45 | The decoder opens `engram1.bin` and `engram14.bin` in the expert sidecar directory. Generate them from shards 47 and 48 respectively. It checks each header against the pinned tensor index and verifies each row before uploading it. The Engram sidecar starts with a 32-byte header containing shard, layer, row count, weight base and scale base. Each row contributes an eight-byte digest prefix in row order. Row i reads 256 weight bytes at weight_base + 256i and eight scale bytes at scale_base + 8i. The hash covers the two extents in that order. |
| 46 | |
| 47 | ## Native build controls |
| 48 | |
| 49 | The backbone catalog uses the same 28 emitter functions as the checkpoint operator export. Its QMD recorder supports three grid dimensions and keeps the six native head entries. The host catalog control emits the aligned instruction image without opening the driver. |
| 50 | |
| 51 | The CPU Engram path uses the original tokenizer's fixed remap data in `engram-token-map.u32`. The table and the constants in `engram-layout.om` were exported from the pinned reference's `build_compressed_token_map`, `compute_hash_multipliers` and `EngramLayout.from_args`. The native loader verifies the remap SHA-256 before accepting a token. A verified 264-byte row comprises its original FP8 weight plane and E8M0 scales. |
| 52 | |
| 53 | The trace writer takes the six IDs and original FP32 weight bits after the native gate, without issuing another GPU kernel. Each 80-byte record has u32 turn, turn-local token, layer and reserved words, six u32 IDs, six u32 weight bit patterns, and u64 gate-ready and consumer-need timestamps. The static ring retains one context page of 2,048 tokens. Drain committed entries on the CPU lease before reusing their storage, and finalize the stream SHA-256 after a complete token. |
| 54 | |
| 55 | The resident checkpoint planner packs the original embedding, head, norms, routers, shared experts, attention and Engram auxiliary tensors on 256-byte boundaries. Its host control accepts the tensor directory alone to serialize the planned allocation, original payload bytes and tensor count and context-2048 KV reservation as four u64 words. Supply the 48 verified shard paths as further arguments to populate the whole mapping and measure process RSS. KV and execution workspace allocations are separate. |
| 56 | |
| 57 | ```sh |
| 58 | (echo om2 |
| 59 | sed '/^om2$/d;s/^export fn /fn /' om/sha256/sha256-om2.om |
| 60 | cat seed/ng/sha256.om "$d/checkpoint.om" "$d/io.om" "$d/core.om" "$d/kv.om" "$d/check-core.om") | |
| 61 | seed/out/omc > "$out/check-core" |
| 62 | (echo om2 |
| 63 | sed '/^om2$/d;s/^export fn /fn /' om/sha256/sha256-om2.om |
| 64 | cat seed/ng/sha256.om gpu/nvidia/native/arboris/compute-lock.om "$d/io.om" "$d/engram-layout.om" "$d/engram.om" "$d/check-engram.om") | |
| 65 | seed/out/omc > "$out/check-engram" |
| 66 | (echo om2 |
| 67 | sed '/^om2$/d;s/^export fn /fn /' om/sha256/sha256-om2.om |
| 68 | cat gpu/nvidia/native/arboris/compute-lock.om "$d/io.om" "$d/trace.om" "$d/check-trace.om") | |
| 69 | seed/out/omc > "$out/check-trace" |
| 70 | (echo om2 |
| 71 | cat gpu/nvidia/native/nvrm/context.om gpu/nvidia/native/blackwell/vector.om gpu/nvidia/native/blackwell/launch.om gpu/nvidia/native/blackwell/batch.om om/encoder/bw_enc_sm121.om om/gpu/dsv41/emit.om om/gpu/dsv41/head/launch.om "$d/native.om" "$d/check-catalog.om") | |
| 72 | seed/out/omc > "$out/check-catalog" |
| 73 | chmod +x "$out"/check-* |
| 74 | "$out/check-core" "$out/tensors.bin" "$checkpoint"/model-?????-of-00048.safetensors > "$out/core.bin" |
| 75 | "$out/check-engram" "$d/engram-token-map.u32" > "$out/engram-control.ids" |
| 76 | "$out/check-trace" > "$out/trace-control.bin" 2> "$out/trace-control.sha256.raw" |
| 77 | "$out/check-catalog" > "$out/code.bin" |
| 78 | ``` |
| 79 | |
| 80 | ## Full 40-layer native decoder |
| 81 | |
| 82 | `dsv41-decode` composes the seeded SM121 backbone catalog, Zone 1 resident planner, paged KV layout, `slab_arena.om` FIFO expert resolver, CPU Engram lookup, native router trace tap, and final LM head into a single static AArch64 executable with zero external libraries. |
| 83 | |
| 84 | ```sh |
| 85 | (echo om2 |
| 86 | sed -n '/^layout /,/^end$/p' om/sha256/sha256-om2.om om/runtime/slab_arena.om |
| 87 | sed '/^layout /,/^end$/d;/^om2$/d;s/^export fn /fn /' om/sha256/sha256-om2.om om/runtime/slab_arena.om |
| 88 | cat seed/ng/sha256.om gpu/nvidia/native/arboris/compute-lock.om gpu/nvidia/native/nvrm/context.om \ |
| 89 | gpu/nvidia/native/blackwell/vector.om gpu/nvidia/native/blackwell/launch.om gpu/nvidia/native/blackwell/batch.om \ |
| 90 | om/encoder/bw_enc_sm121.om om/gpu/dsv41/emit.om om/gpu/dsv41/head/launch.om \ |
| 91 | "$d/checkpoint.om" "$d/io.om" "$d/core.om" "$d/kv.om" "$d/lease.om" "$d/resolve.om" \ |
| 92 | "$d/engram-layout.om" "$d/engram.om" "$d/trace.om" "$d/native.om" \ |
| 93 | "$d/layer-map.om" "$d/rope.om" "$d/workspace.om" "$d/forward.om" "$d/prefetch-switch.om" "$d/decode-cli.om") | |
| 94 | seed/out/omc > "$out/dsv41-decode" |
| 95 | chmod +x "$out/dsv41-decode" |
| 96 | ``` |
| 97 | |
| 98 | ### Arboris look-ahead prefetcher and switch |
| 99 | |
| 100 | `gen` and `chat` run the look-ahead Arboris prefetcher by default. Set `DSV41_ARBORIS_PREFETCH=0` to turn it off for a matched A/B run; unset or `1` keeps it on. `spark-window run` passes the caller's environment through (verified in `evidence/DSV41-ARBORIS-PF-AB-20261123/envcheck.txt`), so set the variable on that command. |
| 101 | |
| 102 | The decoder reads the variable once, before it opens any input. It refuses any other value, a repeated entry, or an environment entry it cannot read whole with exit 64 and the line `dsv41-decode: DSV41_ARBORIS_PREFETCH must be unset, 0 or 1`. `dfStartWorkers` sets the switch when it starts the payload workers; `layer0` always starts them with the prefetcher off. |
| 103 | |
| 104 | With prefetch on: |
| 105 | - **Look-ahead routing (GPU, `BLOCKED_OPERATOR` / `NOT_RUN` on GB10 until an authorized window is run):** in the batch that routes layer `L`, the routers of `dfSpecN` (3) later layers (`L+2`, `L+3`, `L+4`) are applied to layer `L`'s FFN input through folded FP32 tables (`dwMaps[5]`, allocated only when prefetch is on). The guesses never reach the model's arithmetic: routing, weights, and outputs come only from each layer's true router. |
| 106 | - **Never-wait staging pipeline (host-qualified by `check-arboris-prefetch.om`):** six prefetch workers stage SHA-256-verified expert payloads in 64 shared-memory slots (`dfPfSlots`). With prefetch off, no prefetch workers are forked and no staging memory is mapped. The decoder harvests completed prefetches with a zero-interval poll, never waits for a guess the current gate does not need, starts on-demand reads before waiting for any needed in-flight prefetch, and drops any payload that fails digest verification without publishing it. |
| 107 | |
| 108 | The final stats lines of `gen` and `chat` on stderr are: |
| 109 | - `ARBORIS pf_dispatched=N pf_hits=N pf_enabled=0|1` (`pf_enabled` reports the setting, not that anything was prefetched; a valid off arm has `pf_dispatched=0 pf_hits=0`). |
| 110 | - `ARBORIS-PF waited=N wait_ns=N dropped_unused=N failed=N no_idle_worker=N` (all zero with prefetch off). |
| 111 | - When `pf_enabled=1`, one `ARBORIS-LOOKAHEAD depth=D right=N of=N` line per look-ahead depth. |
| 112 | |
| 113 | `pfcheck <tensors> <engram_map> <sidecar_dir> <ckpt_dir>` is a host preflight that opens no GPU. It parses the variable, loads the inputs, and starts and stops the payload workers as `gen` does. It prints `ARBORIS pf_enabled=0|1` on stderr. Run it before a timed arm to confirm which arm the binary will run. Like every decoder mode it claims the host lock `/tmp/omega-arboris-compute-v1.lock`, so it exits 74 while another `dsv41-decode` is running. |
| 114 | |
| 115 | Qualification, host only (no GPU), from a clean tree: |
| 116 | |
| 117 | ```sh |
| 118 | bash "$d/check-prefetch-mutants.sh" "$out/pf" "$out/tensors.bin" "$sidecars" "$checkpoint" |
| 119 | ``` |
| 120 | |
| 121 | It builds the decoder from the composition above and through `om/gpu/dsv41/build.sh`, which must agree byte for byte. It runs three controls: |
| 122 | - `check-prefetch-switch.sh` checks 18 environment cases, including names that share the prefix, malformed values, a maximum-size entry, 70,000 entries, and repeated names delivered through `execenv`. |
| 123 | - `check-decoder-prefetch.sh` runs the real binary in `pfcheck` mode. |
| 124 | - `check-arboris-prefetch.om` replaces `decode-cli.om` in the composition and takes the layer-3 sidecar, shard 06, and a bad-digest copy of the layer-3 sidecar. It checks staging-slot selection (free first, else longest-waiting verified, never in-flight), look-ahead bookkeeping (depth counts, launch counts, guess scoring, guess reading), the off arm (no prefetch workers, no staging memory, no dispatch), and the on arm (worker staging, never waiting for unneeded guesses, byte-exact publication from staging without polluting the slot table, and rejection of bad-digest payloads). |
| 125 | |
| 126 | The driver also builds 36 mutants (25 pipeline mutants, 8 switch mutants, and 3 decoder-CLI mutants) and requires each to be rejected by the exact check or case named for it. Its header lists the switch cases and pipeline exits that have no mutant of their own. It prints the compiler digest and every binary digest, and passes only on `PREFETCH-MUTANTS PASS`. No gate under `tests/gates` runs it; run it before any review of a change to these files. What requires a physical GB10 (the look-ahead GPU launches, folded FP32 tables, and off-vs-on timing) is not exercised by this host driver. |
| 127 | |
| 128 | Inside an authorized Spark GB10 window: |
| 129 | |
| 130 | ```sh |
| 131 | # Gate 2: Layer 0 real-weight parity |
| 132 | spark-window run "$out/dsv41-decode" layer0 "$out/tensors.bin" "$d/engram-token-map.u32" \ |
| 133 | "$sidecars" "$checkpoint" 1234 "$out/layer0-out.bin" |
| 134 | python3 "$d/check-layer0.py" "$checkpoint" 1234 "$out/layer0-out.bin" |
| 135 | |
| 136 | # Gate 3: Full 40-layer deterministic greedy generation + SHA-256 router trace archive |
| 137 | spark-window run "$out/dsv41-decode" gen "$out/tensors.bin" "$d/engram-token-map.u32" \ |
| 138 | "$sidecars" "$checkpoint" "$out/trace.bin" 32 0 671 6102 294 8760 344 |
| 139 | python3 "$d/trace-to-csv.py" "$out/trace.bin" "$out/trace.csv" |
| 140 | ``` |
| 141 | |
| 142 | Conversational capture accepts little-endian u32 words. The first word gives the turn count. Each turn contains its ID, maximum generated tokens, prompt token count and prompt IDs. The decoder retains the generated conversation between turns. The payload resolver hashes all six planes before publishing a slot. On Linux it can stream them through AF_ALG SHA-256. When the algorithm is unavailable at open, it uses seeded Omega SHA-256. A read, hash or digest error rejects the miss. |
| 143 | |
| 144 | The decoder keeps one unpublished physical slot. A miss fills and verifies that slot under the CPU lease. Publication swaps its physical index with the selected FIFO victim and retains the same resident capacity. Slots needed by the current six-expert gate cannot be selected as victims. To test the exchange without opening a GPU, replace the CLI in the decoder composition with `check-slot-exchange.om` and pass the layer-zero index and shard 03. The test checks refusal after a digest mismatch, FIFO and residency preservation, and successful publication under eviction pressure. |