interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tests / attention_kgen_gate.py

54 lines · 2766 bytes Raw Blame History
1#!/usr/bin/env python3
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3"""Serialize the attention migration host gates and capture exact receipts.
4Invoke only inside bwrap with private /dev and CPU affinity 10-14. Production
5code is seeded Omega; this Python program is a read-only verification oracle.
6"""
7import os
8from pathlib import Path
9import shlex
10import subprocess
11import sys
12
13root = Path(__file__).resolve().parents[1]
14out = root / 'evidence/api-kernel-gen-attn/2026-11-06'
15out.mkdir(parents=True, exist_ok=True)
16if Path('/dev/nvidiactl').exists() or Path('/dev/nvidia0').exists():
17 raise SystemExit('FAIL attention gates require bwrap private /dev')
18commands = [
19 ('differential', ['make', '-j3', '-f', 'Makefile', '-f', 'tests/attention_kgen.mk', 'test-api-kgen-attention']),
20 ('mutants', ['make', '-j3', '-f', 'Makefile', '-f', 'tests/attention_kgen.mk', 'test-api-kgen-attention-mutants']),
21 ('attention', ['make', '-j3', 'test-gpu-attention']),
22 ('decode', ['make', '-j3', 'test-gpu-decode-attn']),
23 ('maxpos', ['make', '-j3', 'test-gpu-decode-attn-maxpos']),
24 ('decode256', ['make', '-j3', 'test-gpu-decode-attn256']),
25 ('prefill', ['make', '-j3', 'test-gpu-prefill-host']),
26 ('units', ['sh', 'om/units.sh', '--check']),
27 ('crumb-compile', ['crumb', 'compile', '.']),
28 ('crumb-verify', ['crumb', 'verify', '.']),
29]
30selected = set(sys.argv[1:])
31if selected - {name for name, _ in commands}:
32 raise SystemExit('unknown attention gate selection')
33if not selected or 'differential' in selected:
34 (root / 'build/api-kgen/attention_diff.gcda').unlink(missing_ok=True)
35receipt = out / 'rc.tsv'
36rows = {}
37if selected and receipt.exists():
38 rows = {line.split('\t', 1)[0]: line for line in receipt.read_text().splitlines()[1:]}
39for name, command in commands:
40 if selected and name not in selected:
41 continue
42 print('RUN ' + name + ': ' + shlex.join(command), flush=True)
43 result = subprocess.run(command, cwd=root, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
44 text = result.stdout.replace(str(Path.home()), '~')
45 (out / (name + '.log')).write_text(text)
46 final = next((line for line in reversed(text.splitlines()) if line.strip()), '(no output)')
47 row = f'{name}\t{result.returncode}\t{shlex.join(command)}\t{final}'
48 rows[name] = row
49 print(row, flush=True)
50 if result.returncode:
51 receipt.write_text('name\trc\tcommand\tfinal line\n' + '\n'.join(rows[key] for key, _ in commands if key in rows) + '\n')
52 raise SystemExit(result.returncode)
53receipt.write_text('name\trc\tcommand\tfinal line\n' + '\n'.join(rows[key] for key, _ in commands if key in rows) + '\n')
54print('PASS attention migration host acceptance; chip NOT_RUN', flush=True)