interplane.Get Omega
Read in your language

omega-bridge

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

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / max-cpu / mogg-cache-repro.sh

32 lines · 1954 bytes Raw Blame History
1#!/bin/sh
2# MAX 26.7.0 observation: a custom-op kernel compiled from one Mojo source is reused after that
3# source changes, when the package path and MODULAR_CACHE_DIR stay the same. Needs max-cpu/run.sh
4# to have built $BUILD first (lib/ and extcall/kernels). Prints one line per step; exit 0 always
5# reports what it saw, it does not gate anything.
6# TMPDIR=/dev/shm taskset -c 5-9 nice -n 19 ionice -c3 max-cpu/mogg-cache-repro.sh
7set -eu
8export CUDA_VISIBLE_DEVICES= # MAX 26.7.0 Graph() opens a visible GPU; see run.sh
9cd "$(dirname "$0")/.."
10MAXPY=${MAXPY:-$HOME/workspace/maxinterop/venv/bin/python}
11BUILD=${BUILD:-/dev/shm/omega-max-cpu}
12R=$BUILD/mogg-repro
13L=$BUILD/lib/libomega_native.so
14rm -rf "$R"
15mkdir -p "$R/pkg/kernels" "$R/other/kernels"
16step() { # step NAME CACHE KERNELS: prints the error or "ran"
17 MODULAR_CACHE_DIR=$3 "$MAXPY" max-cpu/omega_max.py neg-load --lib "$L" --kernels "$2" \
18 --want 'Failed to materialize symbols' >"$R/$1.log" 2>&1 || true
19 printf '%-26s %s\n' "$1" "$(grep '^got:' "$R/$1.log" | cut -c1-90)"
20}
21cp "$BUILD/extcall/kernels/__init__.mojo" "$R/pkg/kernels/"
22step 1-extcall-cacheA "$R/pkg/kernels" "$R/cacheA"
23find "$R/cacheA" -type f | sed "s|$R/||" | sort >"$R/cacheA-after-1.txt"
24cp max-cpu/kernels/__init__.mojo "$R/pkg/kernels/" # the fixed glue, same path
25step 2-fixed-cacheA "$R/pkg/kernels" "$R/cacheA"
26find "$R/cacheA" -type f | sed "s|$R/||" | sort >"$R/cacheA-after-2.txt"
27step 3-fixed-cacheB-fresh "$R/pkg/kernels" "$R/cacheB"
28cp max-cpu/kernels/__init__.mojo "$R/other/kernels/" # the fixed glue, another path
29step 4-fixed-otherpath-cacheA "$R/other/kernels" "$R/cacheA"
30sha256sum "$R/pkg/kernels/__init__.mojo" "$BUILD/extcall/kernels/__init__.mojo"
31if diff "$R/cacheA-after-1.txt" "$R/cacheA-after-2.txt" >/dev/null; then echo "cacheA: no new files in step 2"
32else echo "cacheA: step 2 added $(comm -13 "$R/cacheA-after-1.txt" "$R/cacheA-after-2.txt" | wc -l) files"; fi