interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

GitHub aien-dev/omega-bridge#51 (code only)

closed derived c394abfd7884258a #51

Imported from GitHub aien-dev/omega-bridge#51 (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 654305fa9cf585a8d0af974516afb06e1c72addb · Head 5f7492fff138a931599e467c6f50eade1e857ade

Apply it

git checkout -b patch-c394abfd7884258a 654305fa9cf585a8d0af974516afb06e1c72addb
curl -fsSL https://interplane.io/drakestapleton/omega-bridge/patches/c394abfd7884258a.patch | git am

Raw patch (mbox) · 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/omega-bridge
51
5f7492fff138a931599e467c6f50eade1e857ade
{"kind":"github-import","owner":"aien-dev","repo":"omega-bridge","number":51,"url":"https://github.com/aien-dev/omega-bridge/pull/51","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:01Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/evidence/MAX-CPU/README.md b/evidence/MAX-CPU/README.md
index 6895de9..60edcea 100644
--- a/evidence/MAX-CPU/README.md
+++ b/evidence/MAX-CPU/README.md
@@ -1,8 +1,17 @@
 # MAX CPU route: an Omega kernel as a MAX 26.7.0 graph custom op
 
 Status: **EXERCISED(host CPU)** on the DGX Spark's Grace aarch64 host, 2026-10-30/31. This is a
-host-CPU run, not a hardware qualification and not a GPU result. Nothing here opened the GPU:
-every graph is built on `DeviceRef.CPU()` and the session is `InferenceSession(devices=[CPU()])`.
+host-CPU run, not a hardware qualification and not a GPU result. Every graph is built on
+`DeviceRef.CPU()` and the session is `InferenceSession(devices=[CPU()])`, so no kernel ran on the
+GPU. That alone does not keep the GPU closed: MAX 26.7.0 `Graph()` (`_populate_device_info_mapping`)
+creates an `Accelerator()`, a CUDA context, whenever `accelerator_count() > 0`. The run of record
+did not hide the GPU, so [INFERENCE] each of its graph processes opened a GB10 context. On
+2026-10-31 a rerun at `6ec6dab7` exited 1 for that reason: the last `measure` child (matmul
+256x256x256 warm) failed in `Accelerator()` with `CUDA_ERROR_OUT_OF_MEMORY` while the GPU was busy;
+every check and negative control had passed. `run.sh` and `mogg-cache-repro.sh` now export
+`CUDA_VISIBLE_DEVICES=` and `omega_max.py` exits 2 while an accelerator is visible. With the GPU
+hidden, the 2026-10-31 rerun exited 0 (`OMEGA MAX CPU: PASS`, 16 of 16 measurements) and the warm
+omega 16x16x8 `maxrss_kib` was 495648 against 589472 in the GPU-visible rerun.
 
 ## What runs
 
@@ -36,8 +45,8 @@ the same f32 values.
 ## Reproduce
 
 ```sh
-TMPDIR=/dev/shm taskset -c 10-14 nice -n 19 ionice -c3 max-cpu/run.sh            # ~11 min
-TMPDIR=/dev/shm taskset -c 10-14 nice -n 19 ionice -c3 max-cpu/mogg-cache-repro.sh  # after run.sh
+TMPDIR=/dev/shm taskset -c 5-9 nice -n 19 ionice -c3 max-cpu/run.sh            # ~11 min
+TMPDIR=/dev/shm taskset -c 5-9 nice -n 19 ionice -c3 max-cpu/mogg-cache-repro.sh  # after run.sh
 ```
 
 `run.sh` extracts both omc stages from git objects and checks their sha256, builds the library and
@@ -103,7 +112,7 @@ ExecutionEngine; the MAX kernel JIT does not resolve symbols from the process im
 `LD_PRELOAD` gave the same error. The Mojo FFI docs at the pin (c-ffi.mdx, Limitations) say
 `external_call()` cannot load dynamic libraries and point to `OwnedDLHandle`.
 
-## Measurements (EXERCISED(host CPU), `taskset -c 10-14`)
+## Measurements (EXERCISED(host CPU), `taskset -c 10-14`; historical run of record. Cores 10-14 are reserved on this host now: rerun on 5-9)
 
 `measure-all` starts one child process per series. `cold_ns` runs from process start to the end
 of the first execute (import, graph build, compile, load, first call); `fresh` = empty
diff --git a/max-cpu/mogg-cache-repro.sh b/max-cpu/mogg-cache-repro.sh
index b543280..02d599a 100755
--- a/max-cpu/mogg-cache-repro.sh
+++ b/max-cpu/mogg-cache-repro.sh
@@ -3,8 +3,9 @@
 # source changes, when the package path and MODULAR_CACHE_DIR stay the same. Needs max-cpu/run.sh
 # to have built $BUILD first (lib/ and extcall/kernels). Prints one line per step; exit 0 always
 # reports what it saw, it does not gate anything.
-#   TMPDIR=/dev/shm taskset -c 10-14 nice -n 19 ionice -c3 max-cpu/mogg-cache-repro.sh
+#   TMPDIR=/dev/shm taskset -c 5-9 nice -n 19 ionice -c3 max-cpu/mogg-cache-repro.sh
 set -eu
+export CUDA_VISIBLE_DEVICES=  # MAX 26.7.0 Graph() opens a visible GPU; see run.sh
 cd "$(dirname "$0")/.."
 MAXPY=${MAXPY:-$HOME/workspace/maxinterop/venv/bin/python}
 BUILD=${BUILD:-/dev/shm/omega-max-cpu}
@@ -27,4 +28,5 @@ step 3-fixed-cacheB-fresh "$R/pkg/kernels" "$R/cacheB"
 cp max-cpu/kernels/__init__.mojo "$R/other/kernels/"    # the fixed glue, another path
 step 4-fixed-otherpath-cacheA "$R/other/kernels" "$R/cacheA"
 sha256sum "$R/pkg/kernels/__init__.mojo" "$BUILD/extcall/kernels/__init__.mojo"
-diff "$R/cacheA-after-1.txt" "$R/cacheA-after-2.txt" >/dev/null && echo "cacheA: no new files in step 2"
+if diff "$R/cacheA-after-1.txt" "$R/cacheA-after-2.txt" >/dev/null; then echo "cacheA: no new files in step 2"
+else echo "cacheA: step 2 added $(comm -13 "$R/cacheA-after-1.txt" "$R/cacheA-after-2.txt" | wc -l) files"; fi
diff --git a/max-cpu/omega_max.py b/max-cpu/omega_max.py
index a8d8f69..515d1e8 100644
--- a/max-cpu/omega_max.py
+++ b/max-cpu/omega_max.py
@@ -7,7 +7,9 @@ Subcommands (run with the MAX venv python, see max-cpu/run.sh):
   measure     one op/shape in this process: cold start, warm latencies, peak RSS
   measure-all spawns one `measure` child per (op, shape, cache state)
 
-Every graph runs on DeviceRef.CPU() only. Exit 0 = the expected outcome was observed.
+Every graph runs on DeviceRef.CPU() only, and main() refuses (exit 2) while an accelerator is
+visible, because MAX 26.7.0 Graph() otherwise opens a CUDA context. Exit 0 = the expected
+outcome was observed.
 """
 
 import argparse
@@ -306,6 +308,14 @@ def main():
             s.add_argument("--cache", default="fresh")
             s.add_argument("--t0", type=int, required=True)
     a = p.parse_args()
+    # MAX 26.7.0 Graph() creates an Accelerator() (a CUDA context) whenever one is visible, even
+    # for an all-CPU graph. Refuse unless the GPU is hidden: run.sh exports CUDA_VISIBLE_DEVICES=.
+    from max.driver import accelerator_count
+
+    if accelerator_count() != 0:
+        print("omega_max.py: an accelerator is visible; export CUDA_VISIBLE_DEVICES= "
+              "(this harness must not open the GPU)", file=sys.stderr)
+        sys.exit(2)
     fn = {"check": cmd_check, "neg-shape": cmd_neg_shape, "neg-load": cmd_neg_load,
           "measure": cmd_measure, "measure-all": cmd_measure_all}[a.cmd]
     sys.exit(fn(a))
diff --git a/max-cpu/run.sh b/max-cpu/run.sh
index 5e1baa1..2bf55f8 100755
--- a/max-cpu/run.sh
+++ b/max-cpu/run.sh
@@ -1,8 +1,10 @@
 #!/bin/sh
 # Reproduce the MAX CPU route for the Omega matmul custom op (evidence/MAX-CPU/README.md).
-# Run from anywhere, pinned:  TMPDIR=/dev/shm taskset -c 10-14 nice -n 19 ionice -c3 max-cpu/run.sh
-# CPU only: every graph is built on DeviceRef.CPU(); nothing here opens the GPU.
+# Run from anywhere, pinned:  TMPDIR=/dev/shm taskset -c 5-9 nice -n 19 ionice -c3 max-cpu/run.sh
+# CPU only: every graph is built on DeviceRef.CPU(). MAX 26.7.0 Graph() still opens a CUDA
+# context when a GPU is visible, so the GPU is hidden here and omega_max.py refuses otherwise.
 set -eu
+export CUDA_VISIBLE_DEVICES=
 cd "$(dirname "$0")/.."
 MAXPY=${MAXPY:-$HOME/workspace/maxinterop/venv/bin/python}
 OMEGA_REPO=${OMEGA_REPO:-$HOME/workspace/omega}