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