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

192 lines · 11359 bytes Raw Blame History Rendered
1# Speculation component contract v1
2
3All quantities are unsigned 64-bit integers. Time is microseconds. Probabilities
4are unconditional accepted-prefix survival in millionths, monotonically
5nonincreasing with depth. There is no floating-point input or nonfinite value;
6out-of-range encodings are rejected. Converting an external clock/probability
7representation is the caller's responsibility, with its precision disclosed.
8
9## Identity and calibration
10
11`sid[0..31]` contains eight SHA-256 identities, four little-endian words each:
12weights; tokenizer; numerical/sampling recipe; CUDA++ backend/library build;
13Omega/AIENOS executable build; drafter; candidate generator; experiment and
14measurement contract. `sid[32..63]` contains the independently expected values.
15Each digest must be nonzero. These are equality checks, not a hash implementation
16or authenticated discovery. The existing owner must provide real identities.
17
18`sprofile` contains version (1), nonzero epoch, inclusive context lower bound,
19exclusive context ceiling, evidence class (1 synthetic, 2 declared device), and
20shape kind (1 chain). The context ceiling is at most 131072. An epoch change
21invalidates learned state. Tree verification is explicitly unsupported.
22
23`srows` has seven rows of eleven words. Candidate draft lengths are
240, 1, 2, 4, 8, 16, 31. A row contains:
25
26| Offset | Meaning |
27| --- | --- |
28| 0 | Supported: 0 or 1. Unsupported rows have no measured cost claim |
29| 1 | Draft length |
30| 2 | Verification rows, including anchor: draft length + 1 |
31| 3..8 | Draft, verify, commit/rollback, host, policy, preparation microseconds |
32| 9 | Peak memory bytes required by this shape |
33| 10 | Calibration sample count, 5 through 1,000,000 |
34
35Ordinary row zero must be supported with zero draft time. Every enabled row
36requires positive verify time and memory; individual phase costs are at most
371,000,000,000 us. Zero in other phases means measured zero, never unknown.
38The collector requires an explicit complete phase mask. Total row cost includes
39all six phases; cross products are bounded below the unsigned 64-bit limit.
40
41`sprior[31]` is the frozen development estimate. `sbegin(0)` validates and starts
42a cold request. `sbegin(1)` retains learned costs/survival only for the same
43identity and epoch, resets request counts and probe scheduling, and requires an
44already initialized instance. No hidden shared learning is allowed: one instance
45per caller-controlled session. The warm flag must be recorded in trial data.
46
47## Selection and observation
48
49Set `scontrol[0]` to require declared device evidence (1), or permit synthetic
50diagnostics (0). `scontrol[1]` is sampling mode; zero means greedy and any other
51value explicitly selects ordinary decoding.
52
53`sselect(context, remaining, memory, epoch, mode, fixed)` takes six values. Mode
540 is ordinary, 1 is fixed, 2 is adaptive; `fixed` is a draft length. At most
55256 output tokens are admitted per request. Candidate rows must fit remaining
56output, context and memory. Unsupported fixed lengths are refused rather than
57silently changed. Ties retain the smaller length, including ordinary.
58
59The decision's five words are draft length, verification rows, expected output
60millionths, predicted whole-round us, and reason. Reasons: 0 predicted gain,
611 explicit mode, 2 unsupported sampling, 3 ordinary fallback, 4 recovery probe.
62For a chain of length k, expected output is 1 plus the first k survival values.
63This requires the existing verifier's anchor/correction/bonus convention.
64Predicted ordinary-normalized gain is derivable from these values and row zero;
65it is not an observed speedup.
66
67`sobserve(accepted, emitted, elapsed, eos, complete)` accepts only a completed
68round. Accepted is at most k. Normally emitted is accepted+1; EOS may truncate
69it. The full elapsed cost must be positive and at most 6,000,000,000 us. This
70cost, including adaptation overhead, replaces the last observed cost for that
71shape. Prefix survival uses a 7/8 previous + 1/8 observed update, clamped
72monotonically. Only completed past rounds teach the policy. Frozen development
73costs guide probes; no future fixture result is inspected.
74
75The observed cost deliberately uses the latest single sample, without smoothing.
76It responds promptly to a cost step but is sensitive to timing noise; this is a
77policy choice to evaluate on development trials, not an established advantage.
78Recovery probes are eligible when ordinary wins and at least eight total rounds
79have completed since the previous probe (or request start). Eight bounds probing
80to at most one in eight completed rounds while permitting recovery within a
81256-token request. This is an initial engineering choice, not a tuned optimum.
82Any tuning must use development data and a new frozen experiment identity.
83
84`sstate[6]` counts emitted tokens, `[7]` consumed tokens, `[8]` an emitted but
85unconsumed correction/bonus. `sresume()` acknowledges that the actual state owner
86consumed that token. Selection is refused until that acknowledgement. Context
87and remaining-budget checks follow this boundary. EOS/output exhaustion ends
88the request. `scancel()` ends the request without learning or accepting output.
89It does not roll back device memory. The caller must use the existing complete
90KV, recurrent, convolution and drafter-state owner. These counters cannot prove
91that physical state was committed correctly.
92
93## Observation collector
94
95`cstart()` freezes identities, epoch and evidence class and clears collection.
96Only supported-shape descriptors are needed; costs may initially be unknown.
97Each `cadd()` consumes `cobs[16]`: row index, zero-based ordinal within row,
98complete flag, outcome (0 success), six phase durations, full wall duration,
99peak memory, verification rows, epoch, evidence class, phase-known mask (63).
100Only nonoverlapping phase times may be supplied. Wall duration must cover their
101sum and be at most 1,000,000,000 us. Residual wall time is attributed to host
102overhead. Duplicate/out-of-order/incomplete/stale observations are refused.
103
104At most 32 observations per shape are retained verbatim in `craw`, row-major,
105with 32 records of 16 words per shape. `ccount` is the count per row; `csum`
106keeps six phase totals plus wall total; `crange` keeps min/max wall and peak
107memory. `cseal()` needs at least five samples for every enabled row and no
108active round. It publishes conservatively rounded-up mean phases and peak
109memory, then invalidates prior request state. Keep the raw samples and ranges;
110a mean alone is insufficient evidence of a hardware cost step.
111
112## Paired report
113
114Each group is one fixture at one initial context (1024 or 32768 tokens) and one
115controller cold/warm mode. `pconfig` holds context, warm flag, fixture ID,
116minimum usable output length and require-device flag. `parmids` contains the
11732 expected identity words for each arm: base, ordinary, fixed, adaptive.
118Every digest must be nonzero, including differing baseline build identities.
119An unused component binds the digest of an explicitly named absent identity.
120Weights/tokenizer/numerical recipe/protocol must match across all arms. The base
121may have a different backend/executable; ordinary/fixed/adaptive share those.
122Fixed/adaptive additionally share drafter and candidate generator. `pstart(n)`
123freezes these identities and config, for 5 through 32 paired repetitions.
124
125`pobs` has 56 words:
126
127| Offset | Meaning |
128| --- | --- |
129| 0..2 | Pair, arm (0..3), fixture ID |
130| 3..6 | Prompt-token SHA-256 |
131| 7..10 | Committed-output-token SHA-256 |
132| 11 | Actual generated count, 1..256 |
133| 12..14 | Request start, first committed token, request end us |
134| 15 | Peak memory bytes |
135| 16 | Stop reason: 1 natural EOS, 2 maximum 256 reached |
136| 17..19 | Correctness checked (1), complete (1), contamination (0) |
137| 20..23 | Profile epoch, cold/warm flag, trial ordinal, initial context |
138| 24..55 | Actual arm identity words |
139
140Order rotates the four arms by pair index; exact ordinals are required. Every
141attempt, including invalid ones, is retained in `praw` (at most 256). Invalid
142attempts poison the group; an accepted-looking retry cannot erase them. Retain
143the original group and explain any new campaign separately. Prompt identity is
144fixed across pairs. Within each pair all arms must have identical greedy token
145digest, length and stop reason. Divergence blocks performance interpretation.
146The runtime must supply first-divergence logits/state separately; digests cannot
147explain a numerical error.
148
149`preport(0|1|2)` compares adaptive with base/ordinary/fixed. `summary` contains:
150pair count, comparator, median paired speed ratio in millionths, lower/upper
15195% interval for the population median ratio, adaptive median/p95 full request
152time, adaptive median/p95 TTFT, adaptive peak memory, verdict, evidence class.
153Output counts agree within pairs, so the time ratio equals the committed-token
154throughput ratio. Ratios are rounded down to millionths. Percentiles use nearest
155rank; an even-count median averages its two central values.
156Time and TTFT quantiles are each sorted independently. They are not the time or
157TTFT of the pair at the median speed ratio; the speed ratio remains paired.
158
159The interval uses [exact binomial order statistics](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/mediancl.htm): choose the largest k whose
160lower-tail probability is at most 1/40, then use sorted ratios k and n-k+1.
161It assumes independent paired repetitions. Five pairs cannot give a finite
162distribution-free 95% interval, so they produce an inconclusive result with
163unbounded upper endpoint. More repeats improve resolution; noise is retained.
164The wire representation of that endpoint is `18446744073709551615`, a sentinel
165for no finite bound, not a measured ratio. Its lower endpoint and verdict are 0.
166Verdicts: 0 inconclusive, 1 improvement (entire interval above 1), 2 no detectable
167improvement (both bounds exactly 1 at the stated resolution), 3 regression
168(entire interval below 1). A too-short EOS output makes the result inconclusive.
169Synthetic evidence remains synthetic regardless of its numerical verdict.
170
171## Native diagnostic stream
172
173`replay.om` reads one bounded binary message from stdin and emits a binary
174decision, sealed table or three reports. It performs no model execution and no
175hardware verification. Maximum input is 65536 bytes; words are little-endian u64.
176
177Common input: magic 827867987 (`SCX1`), version 1, operation, reserved 0; then
17864 identity, 6 profile, 77 row and 31 prior words. The first operation-specific
179word is index 182.
180
181- Operation 1: two `scontrol` words followed by the six selection arguments.
182- Operation 2: sample count followed by that many 16-word cost observations.
183- Operation 3: five `pconfig` words, pair count, attempt count, 128 `parmids`
184 words, then that many 56-word trial observations.
185
186Output header: magic, version, operation, evidence class, payload word count.
187Operation 1 returns five decision words. Operation 2 returns 77 row words,
1887 counts and 21 range words. Operation 3 returns three 12-word summaries in
189base/ordinary/fixed order. No partial successful response is emitted after an
190admission error. Keep the original input alongside the output as the raw record.
191Statuses: 0 success, 65 malformed/range, 69 identity/version/correctness,
19274 I/O, 75 incomplete/order/state, 77 unsupported/capacity.