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 / docs / GPU-ADAPTER.md

176 lines · 6913 bytes Raw Blame History Rendered
1# Omega Bridge GPU adapter protocol v1
2
3Status: implemented and host-qualified (`src/gpu_adapter.om`, 47 checks). No
4device is opened by the adapter. Hardware load/execution is **NOT_RUN** until a
5coordinated Spark window; see [GPU-SUPPORT-MATRIX.md](GPU-SUPPORT-MATRIX.md).
6
7## 1. What this is, and what it is not
8
9Bridge is the attachment and translation/interop owner. This adapter decides
10whether a named consumer may attach to a named GPU adapter under declared
11capabilities. It is a pure boundary:
12
13- it does not encode instructions, load a cubin, allocate device memory, submit
14 work or synchronize a device;
15- it never returns a device pointer, virtual address, DMA handle or capability;
16- it never falls back to CPU, to another backend, or to a less capable adapter;
17- it has no network, telemetry or install path.
18
19Native ownership follows ARCH-0042 (Omega owns computation, CUDA++ owns GPU
20execution, Omega Bridge owns compatibility). CUDA++ (aien-dev/CUDApp) owns the
21sm_121 encoder, GPU code generator, QMD template, driver client, kernel runtime,
22artifact exporter and cubin verifier. Omega (aien-dev/omega-mv) owns the language,
23the compiler and the declared kernel contract. MAX/Mojo extensions, if any, remain
24isolated third-party artifacts.
25
26## 2. Activation
27
28The adapter is **disabled by default** because nothing invokes it unless a
29caller runs the binary. There is no daemon, no environment hook, no automatic
30attachment and no write outside the caller's own files. A caller must read the
31verdict and may only proceed on `ACCEPT`. `REFUSE` is final for that request.
32
33Build (source-only, pinned seed):
34
35```sh
36sh tools/build-gpu-adapter.sh # uses build/omc or $OMEGA_SEED
37python3 tests/gpu/test_gpu_adapter.py # 47 checks, no device
38# With --artifact PREFIX (a CUDApp exported manifest) the test adds one ACCEPT
39# verdict worth 2 checks: 49, as recorded in evidence/MAX-INTEROP/3/tests.log.
40```
41
42## 3. Wire format
43
44One request on stdin, one response on stdout. UTF-8/ASCII, one `key=value` per
45line, LF line endings. The first line is the protocol identifier. Key order is
46part of the contract: unknown, duplicate or out-of-order keys are refused.
47
48### 3.1 Negotiation (14 lines)
49
50```
51omega-bridge-gpu-adapter/1
52mode=negotiate
53adapter=gb10-native-cubin|fake-gpu
54consumer=omega|max
55backend=nvidia|fake
56isa=sm_121|fake-1
57driver=MAJOR.MINOR.PATCH
58abi=omega-gpu-platform/1.2
59dtypes=bf16,f32
60capabilities=cubin-load,launch-template,memory-handoff
61rights=read,execute
62sync=explicit
63telemetry=off
64contract_id=<64 lowercase hex>
65```
66
67`gb10-native-cubin` requires `backend=nvidia`, `isa=sm_121` and a driver at
68least `580.173.02`. `fake-gpu` requires `backend=fake` and `isa=fake-1`; it is
69nonexecuting and exists for deterministic round-trip fixtures. The capability,
70dtype, rights, sync and telemetry strings are exact sets: a request for a subset
71or a superset is refused, never silently downgraded. `telemetry=off` means the
72adapter itself initiates nothing; a consumer's own telemetry remains the
73consumer's declared policy.
74
75### 3.2 Artifact admission (20 lines)
76
77Same 14 lines, then:
78
79```
80artifact_id=<64 lowercase hex>
81kernel_format=nvidia-cubin-elf64
82qmd_template=zero-va-v1
83receipt=valid
84ownership=producer
85alias=none
86```
87
88`adapter=fake-gpu` cannot admit a native artifact (`E_ADAPTER`). `receipt` must
89be `valid`; `stale` and `missing` are refused. `ownership=producer` means the
90artifact producer (Omega/CUDApp) owns the realization and the consumer receives
91only the declared rights. `alias=none` declares no overlapping inputs/outputs.
92The QMD template must carry zero device addresses; a live-address QMD is
93refused. Text, cubin, QMD and cbank digests are bound by the artifact manifest
94and checked by the admitting loader (CUDApp `omega_native_artifact_admit`), not
95re-derived here.
96
97### 3.3 Response
98
99`ACCEPT` (exit 0):
100
101```
102omega-bridge-gpu-adapter/1
103verdict=ACCEPT
104adapter=<value>
105consumer=<value>
106isa=<value>
107contract_id=<64 hex>
108request_sha256=<64 hex>
109```
110
111`REFUSE` (exit 3):
112
113```
114omega-bridge-gpu-adapter/1
115verdict=REFUSE
116code=E_<NAME>
117request_sha256=<64 hex>
118```
119
120`request_sha256` is SHA-256 over the exact request bytes. It binds the verdict
121to the request and makes replay/round-trip tests deterministic.
122
123## 4. Named refusals
124
125| code | meaning |
126|---|---|
127| `E_VERSION` | reserved |
128| `E_ORDER` | wrong line count/order, duplicate or unknown key, bad header |
129| `E_MODE` | unknown mode |
130| `E_ADAPTER` | unknown adapter, or a nonexecuting adapter asked to admit |
131| `E_BACKEND` | backend does not match the adapter |
132| `E_ISA` | ISA/profile does not match the adapter |
133| `E_DRIVER` | driver malformed or older than the adapter's minimum |
134| `E_ABI` | platform ABI mismatch |
135| `E_DTYPES` | tensor dtype set mismatch |
136| `E_CAPABILITY` | requested capability set not supported (includes unknown consumer) |
137| `E_RIGHTS` | rights set mismatch |
138| `E_SYNC` | implicit ordering requested |
139| `E_TELEMETRY` | telemetry policy not `off` |
140| `E_CONTRACT` | contract id malformed |
141| `E_ARTIFACT` | artifact id malformed |
142| `E_FORMAT` | kernel format other than the cubin container |
143| `E_RELOC` | QMD template declares a live device address |
144| `E_RECEIPT` | receipt stale, missing or not `valid` |
145| `E_OWNERSHIP` | ownership declaration not `producer` |
146| `E_ALIAS` | alias declaration not `none` |
147| `E_LIMIT` | input too large / hash failure |
148| `E_IO` | stdin read failure |
149
150A refusal carries no partial acceptance and no fallback target.
151
152## 5. Memory, streams and lifetime (contract, not implementation)
153
154- **Address spaces are not shared.** Omega's device VAs and a consumer's
155 context VAs are distinct. Nothing in this protocol licenses reuse of a raw
156 pointer, DMA handle or allocation across contexts.
157- **Ownership is explicit.** The producer owns the realization and its
158 resources; the consumer holds only `read,execute` for the admitted artifact.
159 Transfer of a buffer requires a separate, explicit handoff with its own
160 identity and lifetime; this protocol carries no buffers.
161- **Synchronization is explicit.** `sync=explicit` means the consumer must
162 complete the producer's declared ordering before reading results. The adapter
163 does not create events or fences.
164- **Failure is terminal for the request.** The adapter never retries, never
165 substitutes a backend and never reports success for an unqualified device.
166
167## 6. Reproducibility and evidence
168
169`tools/build-gpu-adapter.sh` enforces the seed fingerprint
170`191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9` and records the
171source and binary hashes. `tests/gpu/test_gpu_adapter.py` covers acceptance,
172determinism, request binding, every named refusal, structural corruption and the
173no-fallback rule. Raw logs live in `evidence/MAX-INTEROP/3/`.
174
175No universal compatibility, no cross-vendor execution and no performance claim
176is made. Host tests are not hardware evidence.