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 / docs / pipeline / CONTRACT.md

279 lines · 17480 bytes Raw Blame History Rendered
1# Deterministic dual-pipeline policy (#57)
2
3This is a pure native Omega predicate, not another tuner, qualification service,
4GPU runtime, or activation gate. It scans at most sixteen owner-resolved records.
5No M cutoff exists. Direct GEMV (family 1), register-fed warp MMA (2), and staged
6GEMM (3) compete only on a frozen complete-workload cost. A family number does
7not establish hardware support. The incumbent is preserved on ties and failed
8alternative admission; an inapplicable incumbent causes refusal, not an unsafe
9fallback. PR #139 remains unqualified: its filed full-cost gate fails small
10cells. Nothing in this policy imports that branch or changes current defaults.
11
12## Trust boundary
13
14`pl_select(request[64], records[1024], output[16])` consumes trusted inputs from
15the existing #35 realization/#54 candidate, #53 evaluator, and #17 measurement
16owners. Matching digests and gate bits do **not** authenticate evidence. The
17owner must resolve a single immutable qualification bundle whose subjects bind
18the canonical realization, exact emitted code and launch, quant descriptor,
19compiler/encoder/spec pins, frozen workload, graph dependencies, numerical mode,
20physical execution, full-path performance and model quality. Candidate writers
21must not supply or modify these records. No new signer or trust store is added.
22
23The predicate cannot turn arbitrary caller assertions into physical evidence.
24Synthetic tests are policy controls only and are not production-consumable
25qualification bundles. No production registry is populated by this change.
26
27## Request cells (unsigned 64-bit)
28
29| Cells | Meaning |
30| --- | --- |
31| 0 | Version 1 |
32| 1 | Active record count, 1..16 |
33| 2 | Incumbent zero-based record ordinal |
34| 3..6 | Session generation, exact target/driver profile, buffer ownership generation, lifecycle context (cold/warm/prepared identity) |
35| 7..10 | Available workspace bytes, register ceiling, shared bytes, thread ceiling |
36| 11 | Exact admitted capability bits; never inferred from SM number |
37| 12 | Reviewed minimum absolute complete-path benefit, ns |
38| 13 | Reviewed maximum complete-path cost, ns |
39| 14..17 | Frozen workload-equivalence SHA256 |
40| 18..21 | Current graph/dependency closure SHA256 |
41| 22..25 | Reviewed policy SHA256 (includes per-workload constraints and aggregation protocol) |
42| 26..29 | Frozen measurement/comparison protocol SHA256 |
43| 30..33 | Incumbent artifact SHA256; invalidates dependent evidence on replacement |
44| 34..37 | Exact applicability SHA256 from canonical dependency adapter |
45| 38..63 | Reserved zero |
46
47All digest groups contain four canonical little-endian unsigned 64-bit limbs and
48must be nonzero. Applicability binds exact semantic/quant/shape/routing/layout/
49strides/alignment/tails/alias/numerical contract and compiler/encoder/spec pins.
50Alternative tile/warp/stage/pipeline/code identities are excluded **only** from
51workload equivalence, never from individual qualification subjects. Resource and
52lifecycle fields are checked separately, not discarded from receipt scope.
53
54## Record cells (sixteen rows, stride 64)
55
56| Offset | Meaning |
57| --- | --- |
58| 0 | Family 1 direct GEMV, 2 warp MMA, 3 staged GEMM; unknown refuses |
59| 1 | Independent semantic, byte/launch, physical, full-workload, quality gates: exact mask 31 |
60| 2 | Known nonoverlapping phase mask, exactly 63; zero durations mean measured zero, not unknown |
61| 3 | Complete-path cost, ns, positive |
62| 4..9 | Packing/conversion, upload/transfer, preparation (compile/cache invalidation), dispatch, synchronization/barriers, complete execution, ns |
63| 10 | Microkernel-only cost, diagnostic; never used to rank |
64| 11..14 | Workspace bytes, registers, shared bytes, threads |
65| 15 | Required hardware feature bits, subset of admitted exact profile |
66| 16 | Charged resident allocation bytes, including actual upload padding (exact cache request size) |
67| 17..20 | Same lifecycle/generation fields as request 3..6 |
68| 21..24 | Artifact SHA256 |
69| 25..28 | Launch SHA256 |
70| 29..32 | Immutable resolved qualification-bundle SHA256 |
71| 33..36 | Workload-equivalence SHA256 |
72| 37..40 | Graph/dependency closure SHA256 |
73| 41..44 | Reviewed policy SHA256 |
74| 45..48 | Measurement protocol SHA256 |
75| 49..52 | Incumbent dependency artifact SHA256 |
76| 53..56 | Canonical applicability SHA256 |
77| 57..60 | Final code SHA256, separate from canonical realization artifact digest |
78| 61..63 | Reserved zero |
79
80Unsigned phase addition is checked before every operation; overflow or a phase
81sum exceeding measured complete-path cost rejects the row. Components must be
82nonoverlapping under the measurement protocol; amortization is supplied by its
83frozen lifecycle record, never calculated from a guessed reuse count. Packing,
84upload and preparation may not be silently omitted for a cold candidate.
85
86Duplicate artifact identities refuse the set, avoiding ambiguous slot reuse or
87bundle choice. Strictly lower complete cost wins; incumbent wins equal cost.
88Other ties use ascending canonical digest limb order. Array order cannot change
89the chosen identity. Unknown/unqualified alternatives cannot replace incumbent.
90No TMA or tcgen05/TMEM support is inferred on SM121: the target owner and physical
91receipt must explicitly qualify each required feature and exact artifact.
92
93## Result and consumption
94
95Return 0 means a policy result, 65 malformed/ambiguous set, 69 no qualified exact
96incumbent. Output is cleared on every refusal. Success output: 0 valid marker 1;
971 ordinal; 2 family; 3 complete cost; 4..7 artifact digest; 8..11 qualification
98bundle digest; 12..15 session/profile/buffer/lifecycle snapshot.
99
100This result is advisory, **not** a kernel handle or launch capability. Before
101recording, Main's existing graph/cache owner must revalidate the exact bundle,
102request snapshot and generations and atomically acquire/pin the artifact and
103all tensor/resource dependencies through existing completion. Cache slot reuse,
104eviction, recovery, tensor changes or budget changes invalidate the result.
105Do not retry the incumbent after any partial candidate execution: state rollback
106belongs to the existing KV/recurrent state owner, not this selector.
107
108`pl_realcheck(request_real[4096], candidate_real[4096], row[64])` consumes the
109Composer's exact `compose_match`, `compose_codeid`, and `compose_launchid` and
110Cache's `kc_sha` over precisely 1152 canonical bytes. Quant validation is the
111Composer validator's exact `quant_check` dependency. No parallel descriptor
112serializer exists here. Return 69 rejects changed applicability/code/launch or
113artifact identity. `pl_pin(request, records, cache[528], output, lease[16])`
114then takes a recorded-code reference on an already prepared hit. It never
115compiles, uploads, evicts or prewarms during graph recording. Miss/stale/busy
116returns 75 and clears result/lease. Lease contains valid marker, slot, revision,
117generation, artifact/bundle digests, profile/buffer/lifecycle context, reserved.
118The existing runtime must use `kc_acquire` before submission, `kc_retire` only
119after observed completion, and `kc_unpin` when the recorded list is discarded.
120All calls require the existing session lock; this is not cross-process isolation.
121Resident charge in row16 is the existing allocator's actual budget charge,
122including its allocation padding, not the raw instruction payload length.
123The latter remains independently checked by `kc_validate` sizes/code SHA.
124`kc_find` must retain exact size matching: never hide an allocation difference
125behind a key hit or silently detach resident accounting from the real allocation.
126
127`pl_graph(q, rows, pool, request_real, selected_real, decision[32])` is the
128actual native graph-admission caller: select, validate canonical realization and
129declared family/features/GPR/shared/threads, then pin. Decision cells0..15 are
130the policy output and16..31 the lease. Refusal clears all32 cells. The graph
131owner resolves `selected_real` from the exact chosen artifact, not a shape
132lookup. It must also check `compose_launch` and actual code/templates through the
133existing artifact loader; matching stored digests alone does not check blobs.
134
135The frozen Composer schema `2e93f998b70852abcd425f8865d842a05dad76ea`
136used by these host receipts admits native direct1 and row-pipelined2 only.
137These receipts exercise family3 policy with synthetic records and explicit
138canonical staged refusal. Newer Composer #166 adds structural family3 support;
139it does not confer candidate qualification or device/full-model evidence.
140Unknown families/features remain refused.
141
142The shared integration binds the selected immutable artifact to the actual
143FP8/GEMM cache upload and recorded code handle under the existing session lock.
144The private `src/omega_gpu_q36_native.h` resolves exact graph-owned contexts,
145prepared artifacts, canonical requests and immutable owner observations.
146The call binding additionally checks actual tensor allocation epoch against
147current session epoch and its independently assigned owner generation.
148Failed canonical, artifact, session, ownership or qualification checks refuse;
149they do not retry an incumbent after partial candidate work.
150
151The actual `rec_fp8`, `rec_gemm` and paired expert recording paths consume that
152selection instead of discarding it. A generic standalone selected expert
153record refuses when a paired GROUP/window contract is required. No API lets
154candidate writers populate accepted records. Production graph state remains
155NULL/count0 until the existing independent evaluator/receipt owners accept
156exact artifacts; current defaults and the incumbent path are unchanged.
157
158## Predeclared measurement families
159
160Use actual `omega_gpu_q36_graph.h` contracts: decode M=1; supported conversation
161strokes through MAX_HEADS; batch v2 dense and nine-group experts; prefill through
162PREFILL_MAX_ROWS including boundary and ragged expert segments. Dense shapes are
163GDN mix N=12288,K=2048; attention mix N=9216,K=2048; output N=2048,K=4096;
164gate/up N=1024,K=2048; down N=2048,K=512. Freeze real checkpoint/target/config,
165per-workload bounds, warm/cold policy, aggregation weights, numerical thresholds
166and minimum benefit through #17 before final measurements. No invented timing
167threshold or paper-derived performance ratio is adopted here.
168
169Predeclare decode head counts1..8 and prefill row counts
170`{1,2,4,8,16,32,64,128}`, plus ragged/empty expert segments at
171`{0,1,7,8,9,127,128}` where each existing API's capacity permits. These are
172measurement cells, never selection thresholds. Include existing #139 failing
173small cells unchanged; a new family does not inherit that PR's correctness
174receipt or erase its failed performance evidence. Compare both cold and
175already-prepared cache lifecycles, one-shot and frozen repeated-use requests.
176
177Measure preprocessing, repack, compile, upload, dispatch, synchronization and
178complete execution using paired/interleaved complete paths, then full-model
179quality/latency against the filed #604 baseline. Preserve every failure and
180inconclusive result. Host policy controls are not device or serving evidence.
181
182## Host controls and reproduction
183
184`tests/pipeline/host-evidence.json` records exact ordered source hashes, pinned
185compiler, all three native caller exits0, and five compiled guard mutants
186rejected by those same controls. `fixture.om` and Composer's `fixture.om` are
187test-only synthetic declarations. They never enter a trusted production registry.
188The current source/file-content dependency pins are in `dependencies.lock`;
189Main integrates the exact peer commits before bridge registration.
190`tests/pipeline/pin-invalidation-evidence.json` adds the exact compiler-digest
191mutation at canonical byte544, recording the final graph-test source/binary
192and successful control plus caught bypass mutant. The earlier receipt preserves
193the preceding semantic-digest mutation rather than rewriting that evidence.
194`tests/pipeline/final-source-evidence.json` is the final-source run of all three
195controls and five mutants after aligning with existing session recovery
196generation0. Cache initial generation0, pin/inflight/completion and later
197invalidation are exercised. Earlier source receipts remain historical;
198dependency lock and this final receipt identify the integrated source exactly.
199
200Compile each test by concatenating Quant's `quant.om`, Composer's `realize.om`,
201Cache's `digest.om` and `residency.om`, this lane's `select.om`, `graph.om`,
202`consume.om`, and `tests/pipeline/fixture.om`, followed by the test source.
203For `graph-caller.om` insert Composer's shared `fixture.om` before the test.
204Feed that source to the exact pinned `omc`; execute the host AArch64 output.
205The policy, cache-caller and graph-caller expected exit is0. Mutation definitions
206and observed nonzero exits are retained in the JSON receipt; a mutant compile
207failure would not count as detection.
208
209Independent symbolic synthetic cost oracle, through the mounted parent proxy:
210`WolframLanguageEvaluator:
211{Simplify[packing+upload+prepare+dispatch+barriers+execution,Assumptions->And@@Thread[{packing,upload,prepare,dispatch,barriers,execution}>=0]],Total[{2,3,5,7,11,13}],Total[{1,1,1,1,1,100}],Total[{20,20,20,20,20,1}],100-41,100-105,100-101}`
212`-> {barriers + dispatch + execution + packing + prepare + upload,41,105,101,59,-5,-1}`.
213These costs are explicit synthetic policy controls, not observed nanoseconds,
214speedups, GB10 measurements or serving evidence.
215
216## Private graph context lookup
217
218`om/pipeline/context.om` exports
219`native_context(keys view ulong128, count ulong, actual view ulong4) -> long`
220for the existing ABI1 bridge. Up to thirty-two active private graph-owned tuples
221have stride4: `{operation kind, layer index, window start, window rows}`.
222Return is the unique 1-based ordinal,0 absent,-1 for count above32 or multiple
223matches. Count0 is a normal absent binding. Unused cells are ignored; no portable
224serialization, padding convention or artifact schema is introduced.
225
226Each selected ordinal identifies its own immutable existing query, rows, wanted
227canonical record, candidates and prepared artifacts under the existing session
228lock. This lookup must never derive a new wanted/query from the selected code.
229The graph actual execution tuple supplies the lookup key; candidate/tensor
230lifetimes remain owned by the graph. Unknown operation kinds may match raw
231registered tuples here; support and exact MNK/launch are independently refused
232by the existing binding validator. Matching a tuple never authenticates a
233qualification, joint MoE closure, router/permutation/combine semantics, or a
234production registration. With no accepted receipt-authority construction path,
235production context count remains0.
236
237`tests/pipeline/context.om` exercises count32/33, every ordinal including31/32,
238empty/invalid counts, every tuple field, late excluded entries, a duplicate at
239the final active slot and unrelated duplicate isolation. Current focused
240controls and compiled old-cap/tuple/duplicate/count-guard mutants are recorded
241in `tests/pipeline/context32-evidence.json`. The original sixteen-context
242`context-evidence.json` remains historical, unchanged. Compile the test after
243only the exact context unit; it has no Quant/Composer/Cache dependency. This
244bounded private arena does not promise a model-wide context organization.
245
246## Actual recording and mode-final closure binding
247
248`omega_gpu_cmdlist_owner` and `omega_gpu_cmdlist_entry` project real borrowed
249owner descriptors, successful-add ordinals, code VA, argument count, generation,
250bank and QMD slots. Observers execute once under the session lock after every
251slot has its final consumed PCAS/INLINE mode, before any synchronization or
252queue commit. INLINE emits those same mode-final bytes, including list reuse
253after PCAS. An observer refusal queues nothing. Uncertain completion retains
254in-flight and recorded references; reset cannot revoke pending code.
255
256For selected native additions, generated `native_mcseal` freezes the complete
257active bank prefix and arguments plus both active384-byte QMDs before publishing
258the successful add. Only the two mode-dependent QMD1 fields are normalized.
259The private GU/DN `native_mcintent` guard binds roles6/7, actual ordinal and
260generation, code VA, final mode and actual typed QMD-slot VA to that seal.
261Legacy recording gains no extra seal computation. Seals are owner-intent
262bindings, not signatures, manifest replacements, or qualification statements.
263
264The graph projects actual router/directory/tensor/code owners. Six nested
265canonical hashes are recomputed from those observations, and native coverage
266checks the actual same-list role sequence and every GU/DN occurrence against
267the graph-owned window plan. Neither expected wire bytes nor candidate flags
268manufacture provenance. Missing owner provenance or an unsupported full-chunk
269closure refuses. The canonical MC family3 refusal remains unchanged; structural
270staged emission is not a qualified MoE closure or full-model capability.
271
272`om/pipeline/test_mccover.om` exercises positive coverage and normalized mode
273reuse, wrong identity/generation/count/order, missing GU/DN, active bank/QMD
274mutation, and malformed mode/slot bindings. The independent native observer
275fixture consumes actual existing host-runtime owner wires against intent hashes
276frozen by the legacy C oracle before recording. Synthetic role0 labels and
277fake-device completion prove host caller/byte binding only, not GROUP semantics,
278kernel execution, physical correctness, performance or qualification.
279