Expand macOS 26 AIR translation coverage
Overhaul the validation workflow around sharded authored cases, dependency-exact observations, incremental indexed corpus audits, bounded parallel translation, and native Metal/Vulkan comparison.\n\nExpand native AIR lowering, reflection, linked-function specialization, resource and stage-interface support, and structural CFG/pointer repair across the harvested macOS 26 corpus. Add exact intrinsic inventory, distributed 16x16x16 matrix lowering, explicit opaque tensor linkage, and regression coverage for the newly supported feature classes.\n\nThe final corpus verification accounts for all 88,819 indexed AIR modules under the current product fingerprint: 65,355 translate and validate directly, 23,464 require exact authored linkage, and zero fail or remain unresolved.
This commit is contained in:
1 parent
1b013834bc
commit
8b78eaca3b
353 files changed
+70288
-53288
No files matched your search
@@ -1,63 +0,0 @@
|
||||
# metal2vulkan-ab — byte-A/B translation harness
|
||||
|
||||
Translates a pinned sample set with two `metal2vulkan` binaries and diffs the emitted SPIR-V
|
||||
**byte-for-byte**, so a behavior-preserving refactor can be proven not to move any output on the
|
||||
sample before more expensive checks.
|
||||
|
||||
## Why byte comparison is meaningful
|
||||
|
||||
The emitter's output is id-canonicalized by `passes::canonicalize_ids`, so equal semantics ⇒ equal
|
||||
bytes for the vast majority of cases. If a case stays nondeterministic across runs, fall back to a
|
||||
semantic or validator gate rather than trusting the byte diff alone.
|
||||
|
||||
The CLI writes `out.spv` *before* running spirv-val, so a case that FALLBACKs at the spirv-val step
|
||||
still produces comparable bytes. A case whose `translate()` errors writes no file and is reported as
|
||||
a translate failure, not a diff.
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
# self-test: HEAD vs HEAD (exit 0 when every case is IDENTICAL or BOTH-FAIL)
|
||||
./metal2vulkan-ab.sh
|
||||
|
||||
# real A/B: build the crate before your change and after, then diff
|
||||
git stash # or check out the parent commit
|
||||
cargo build --release --bin metal2vulkan
|
||||
cp target/release/metal2vulkan ./m2v-old
|
||||
git stash pop
|
||||
./metal2vulkan-ab.sh --old ./m2v-old
|
||||
|
||||
# optional extra shaders after --
|
||||
./metal2vulkan-ab.sh --old ./m2v-old -- path/to/case.ll
|
||||
```
|
||||
|
||||
Flags:
|
||||
|
||||
- `--old PATH` — "before" binary. Default: build `--release` from this checkout.
|
||||
- `--new PATH` — "after" binary. Default: same as `--old` (a self-test).
|
||||
- `--quiet` — print only the summary and any regressions.
|
||||
- `-- file…` — additional `.ll` / `.air` inputs to include in the sample.
|
||||
|
||||
Because `--new` defaults to `--old`, an explicit A/B run is usually: pass the pre-change binary as
|
||||
`--old` and let `--new` build the current tree, **or** pass both explicitly.
|
||||
|
||||
## Sample set
|
||||
|
||||
1. Every `*.air` / `*.ll` under `tests/fixtures/**` when that directory exists (gitignored).
|
||||
2. Every `*.air` / `*.ll` under `validation/fixtures/public/**` (committed synthetic samples).
|
||||
3. Every `air_ll` row under `validation/corpus/local/shards/shard_*.jsonl` (gitignored private harvest).
|
||||
4. Any paths listed after `--`.
|
||||
|
||||
Shard rows materialize temporary `.ll` files under the script work directory and are removed when
|
||||
the run exits.
|
||||
|
||||
This public tree does not ship third-party captured shaders. For cross-version hash pins (without
|
||||
keeping two binaries around), bank with `corpus-mint` / `corpus-remint` (and optional
|
||||
`corpus-run-*` execution ledgers) — see [`validation/corpus/README.md`](../../validation/corpus/README.md)
|
||||
and [`plan.md`](../../plan.md).
|
||||
|
||||
## Output
|
||||
|
||||
Per-case verdicts (`IDENTICAL` / `DIFFERS` / `OLD-ONLY` / `NEW-ONLY` / `BOTH-FAIL`) plus a summary
|
||||
line. Exit status is `0` only when there are **no** `DIFFERS` and no asymmetric cases; any byte
|
||||
divergence exits `1`. `BOTH-FAIL` (both binaries FALLBACK identically) is not a regression.
|
||||
@@ -1,194 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# metal2vulkan byte-A/B harness.
|
||||
#
|
||||
# Translate a pinned sample set with two `metal2vulkan` binaries and diff the emitted SPIR-V
|
||||
# byte-for-byte, reporting per-case identical / differs / asymmetric. This is a cheap gate for
|
||||
# behavior-preserving refactors: build the crate before a change (old) and after (new), run this,
|
||||
# and demand zero diffs on the sample.
|
||||
#
|
||||
# Sample set:
|
||||
# * every `*.air` / `*.ll` under `tests/fixtures/**`, when present
|
||||
# * every path passed after `--` on the command line
|
||||
#
|
||||
# The `metal2vulkan` CLI writes `out.spv` *before* running spirv-val, so a case that FALLBACKs on
|
||||
# spirv-val still yields comparable bytes; a case whose translate() errors produces no file and is
|
||||
# reported as a translate failure (not a diff).
|
||||
#
|
||||
# Exit status: 0 when no case DIFFERS and no case is asymmetric (one binary produced output, the
|
||||
# other did not); nonzero otherwise. A HEAD-vs-HEAD self-test therefore exits 0.
|
||||
#
|
||||
# Usage:
|
||||
# metal2vulkan-ab.sh [--old PATH] [--new PATH] [--quiet] [-- file.ll ...]
|
||||
#
|
||||
# --old PATH "before" binary. Default: build `--release` from this checkout.
|
||||
# --new PATH "after" binary. Default: same as --old (a self-test: everything must be IDENTICAL).
|
||||
# --quiet print only the summary, not per-case lines.
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
CRATE_DIR="$(cd -- "$(dirname -- "$0")/../.." && pwd)"
|
||||
|
||||
OLD_BIN=""
|
||||
NEW_BIN=""
|
||||
QUIET=0
|
||||
EXTRA_SRCS=()
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--old) OLD_BIN="$2"; shift 2 ;;
|
||||
--new) NEW_BIN="$2"; shift 2 ;;
|
||||
--quiet) QUIET=1; shift ;;
|
||||
-h|--help) sed -n '2,30p' "$0"; exit 0 ;;
|
||||
--) shift; EXTRA_SRCS+=("$@"); break ;;
|
||||
*) echo "unknown arg: $1" >&2; exit 64 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$OLD_BIN" ]; then
|
||||
echo "# building release metal2vulkan (old = new = HEAD self-test)..." >&2
|
||||
( cd "$CRATE_DIR" && cargo build --release --bin metal2vulkan >&2 )
|
||||
OLD_BIN="$CRATE_DIR/target/release/metal2vulkan"
|
||||
fi
|
||||
[ -z "$NEW_BIN" ] && NEW_BIN="$OLD_BIN"
|
||||
|
||||
for b in "$OLD_BIN" "$NEW_BIN"; do
|
||||
[ -x "$b" ] || { echo "not an executable: $b" >&2; exit 64; }
|
||||
done
|
||||
|
||||
WORK="$(mktemp -d)"
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
# translate SRC with BIN into DST.spv; echo "ok" if the file was produced, "fail" otherwise.
|
||||
translate() {
|
||||
local bin="$1" src="$2" dst="$3"
|
||||
rm -f "$dst"
|
||||
# --stage auto is the CLI default; spirv-val failure is fine, the .spv is already on disk.
|
||||
"$bin" "$src" "$dst" --stage auto >/dev/null 2>&1 || true
|
||||
if [ -s "$dst" ]; then echo ok; else echo fail; fi
|
||||
}
|
||||
|
||||
n_identical=0; n_differs=0; n_asym=0; n_bothfail=0
|
||||
report() {
|
||||
local name="$1" verdict="$2"
|
||||
case "$verdict" in
|
||||
IDENTICAL) n_identical=$((n_identical+1)) ;;
|
||||
DIFFERS) n_differs=$((n_differs+1)) ;;
|
||||
OLD-ONLY|NEW-ONLY) n_asym=$((n_asym+1)) ;;
|
||||
BOTH-FAIL) n_bothfail=$((n_bothfail+1)) ;;
|
||||
esac
|
||||
if [ "$QUIET" -eq 0 ] || [ "$verdict" = DIFFERS ] || [ "$verdict" = OLD-ONLY ] || [ "$verdict" = NEW-ONLY ]; then
|
||||
printf ' %-10s %s\n' "$verdict" "$name"
|
||||
fi
|
||||
}
|
||||
|
||||
compare_case() {
|
||||
local name="$1" src="$2"
|
||||
local o="$WORK/old.spv" n="$WORK/new.spv"
|
||||
local ostat nstat
|
||||
ostat="$(translate "$OLD_BIN" "$src" "$o")"
|
||||
nstat="$(translate "$NEW_BIN" "$src" "$n")"
|
||||
if [ "$ostat" = ok ] && [ "$nstat" = ok ]; then
|
||||
if cmp -s "$o" "$n"; then report "$name" IDENTICAL; else report "$name" DIFFERS; fi
|
||||
elif [ "$ostat" = ok ]; then report "$name" OLD-ONLY
|
||||
elif [ "$nstat" = ok ]; then report "$name" NEW-ONLY
|
||||
else report "$name" BOTH-FAIL
|
||||
fi
|
||||
}
|
||||
|
||||
echo "# old: $OLD_BIN"
|
||||
echo "# new: $NEW_BIN"
|
||||
|
||||
# List .ll/.air under root, preferring stem.ll when stem.air is also present (harvest pairs).
|
||||
list_sources() {
|
||||
local root="$1"
|
||||
# Print paths: for each (dir,stem) keep .ll over .air.
|
||||
find "$root" \( -name '*.air' -o -name '*.ll' \) -type f | sort | python3 -c '
|
||||
import sys
|
||||
from pathlib import Path
|
||||
best = {}
|
||||
for line in sys.stdin:
|
||||
p = Path(line.strip())
|
||||
if not p.is_file():
|
||||
continue
|
||||
key = (str(p.parent.resolve()), p.stem)
|
||||
prev = best.get(key)
|
||||
if prev is None or (p.suffix == ".ll" and Path(prev).suffix == ".air"):
|
||||
best[key] = str(p)
|
||||
for path in sorted(best.values()):
|
||||
print(path)
|
||||
'
|
||||
}
|
||||
|
||||
scan_tree() {
|
||||
local root="$1" tag="$2"
|
||||
if [ -d "$root" ]; then
|
||||
echo "# $tag:"
|
||||
while IFS= read -r src; do
|
||||
[ -n "$src" ] || continue
|
||||
compare_case "${tag}:${src#"$root"/}" "$src"
|
||||
done < <(list_sources "$root")
|
||||
else
|
||||
echo "# $tag: skipped (not present)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Sample set (all optional except explicit -- paths):
|
||||
# 1) tests/fixtures/** — private local fixtures
|
||||
# 2) validation/fixtures/public/** — committed synthetic samples
|
||||
# 3) validation/corpus/local/shards/*.jsonl — gitignored mined AIR rows
|
||||
scan_tree "$CRATE_DIR/tests/fixtures" "fixture"
|
||||
scan_tree "$CRATE_DIR/validation/fixtures/public" "public"
|
||||
|
||||
scan_shards() {
|
||||
local shard_root="$1" tag="$2"
|
||||
if [ ! -d "$shard_root" ]; then
|
||||
echo "# $tag: skipped (not present)"
|
||||
return
|
||||
fi
|
||||
echo "# $tag:"
|
||||
local extracted="$WORK/$tag"
|
||||
mkdir -p "$extracted"
|
||||
python3 - "$shard_root" "$extracted" <<'PY' | while IFS=$'\t' read -r name src; do
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
shard_root = Path(sys.argv[1])
|
||||
out_root = Path(sys.argv[2])
|
||||
for shard in sorted(shard_root.glob("shard_*.jsonl")):
|
||||
shard_name = shard.name
|
||||
with shard.open("r", encoding="utf-8", errors="replace") as f:
|
||||
for line_no, line in enumerate(f, 1):
|
||||
if not line.strip() or line.startswith("#"):
|
||||
continue
|
||||
row = json.loads(line)
|
||||
air = row.get("air_ll") or ""
|
||||
sha = (row.get("air_sha256") or "").lower()
|
||||
if not air or not sha:
|
||||
continue
|
||||
path = out_root / f"{sha}.ll"
|
||||
path.write_text(air, encoding="utf-8")
|
||||
label = row.get("label") or f"{shard_name}:{line_no}"
|
||||
print(f"{label}\t{path}")
|
||||
PY
|
||||
[ -n "$src" ] || continue
|
||||
compare_case "$tag:$name" "$src"
|
||||
done
|
||||
}
|
||||
|
||||
scan_shards "$CRATE_DIR/validation/corpus/local/shards" "local-shards"
|
||||
|
||||
if [ "${#EXTRA_SRCS[@]}" -gt 0 ]; then
|
||||
echo "# extra inputs:"
|
||||
for src in "${EXTRA_SRCS[@]}"; do
|
||||
compare_case "input:$(basename "$src")" "$src"
|
||||
done
|
||||
fi
|
||||
|
||||
echo "# summary: identical=$n_identical differs=$n_differs asymmetric=$n_asym both-fail=$n_bothfail"
|
||||
if [ "$n_differs" -gt 0 ] || [ "$n_asym" -gt 0 ]; then
|
||||
echo "# RESULT: REGRESSION (byte divergence detected)"
|
||||
exit 1
|
||||
fi
|
||||
echo "# RESULT: clean (no byte divergence)"
|
||||
@@ -25,6 +25,10 @@ Hand-written crate code (`parser.rs`, `decoder.rs`, `grammar.rs`, …) is not to
|
||||
Override with `RSPIRV_REF` / `HEADERS_REF` if you deliberately bump both together with
|
||||
`Cargo.toml`'s `spirv` dependency.
|
||||
|
||||
The script caches both repositories under `.cache/rspirv-autogen`. Set
|
||||
`METAL2VULKAN_AUTOGEN_CACHE` to use a different cache directory. It requires `git`, `cargo`,
|
||||
`rustfmt`, and Python 3, and requires network access when fetching missing revisions.
|
||||
|
||||
## Run
|
||||
|
||||
```sh
|
||||
@@ -32,6 +36,9 @@ Override with `RSPIRV_REF` / `HEADERS_REF` if you deliberately bump both togethe
|
||||
cargo test -p metal2vulkan --lib spirv_module -- --test-threads=1
|
||||
```
|
||||
|
||||
The script runs `cargo fmt --all`. Review every generated diff and update the `spirv` dependency and
|
||||
locked revisions together.
|
||||
|
||||
## Provenance
|
||||
|
||||
- **Source of truth:** Khronos `spirv.core.grammar.json` (SPIRV-Headers).
|
||||
|
||||
Reference in new issue
Block a user