Keep nvbar owned when mapdrop returns an error. Clearing it here loses the handle needed to retry cleanup; combined with resetting nvstate before final cleanup succeeds, the next nvstop returns true without releasing the failed mapping. Retain cleanup-pending state and test a refused unmap followed by a successful retry.
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
GitHub aien-dev/CUDApp#67 (code only)
Static review of 5e037c7e3d0226abadaa10af9d44bc6339109b3f found a teardown retry error in native/nvrm/context.om. In nvstop, a failing mapdrop sets ok = false but still clears nvbar. Later nvstate is set to zero before nvmforce succeeds. A subsequent nvstop then returns true at the idle-state check, so a failed unmap can be reported as cleaned without retrying it. The compiler mapping contract retains ownership when the underlying unmap syscall fails.
Retain failed mapping handles and a cleanup-pending state until release succeeds. Preserve the sticky fault that blocks reopening, and do not repeat a close on a descriptor that may have been reused. Add the existing refusal-injection style of test: unmap refusal, a subsequent successful retry, and a final clean result, with fd-close-once checks.
This is an independent static correctness finding, not a hardware run. Route through existing #65/#67; exact final-source native review and complete-model gates remain required. Merge coordination is now under Drake's authorized takeover in aien-dev/aien-architecture-mv#190 and aien-dev/aien-sovereign-core-mv#724.
Static review of f9cd649c1dca92ad81009bcd05a959f34c25c76e found one additional mapping-ownership failure path in native/nvrm/context.om::nvcpumap (lines 486-493).
After a successful mapping, a failing fclose sets nvfault, calls mapdrop(m), ignores its result, and returns -1. If that unmap is refused, the mapping contract retains the handle, but neither nvalloc nor nvchan registers it because they receive a negative return. nvstop therefore has no retained handle to retry. The earlier teardown repair covers registered BAR/channel/buffer handles, not this unpublished mapping.
Preserve an owned cleanup handle on this path, refuse further mapping allocation while faulted, and retry only mapping cleanup after descriptors are closed. Add an injected close-failure plus unmap-refusal control, then prove successful retry clears ownership without closing the descriptor again. Failed mapbind is separate: the pinned mapping contract already retires that reservation.
An isolated local correction and regression are in preparation. This is a source-level finding, not an executed native or GPU result. Native compilation, refusal/retry execution and full qualification remain NOT_RUN here; the existing changes-requested gate remains in force. No merge or deployment performed.
Apply it
git checkout -b patch-bbf17667649b0b4d 80f3a2492eef315106feebfdffcb32de39be7d95 curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/bbf17667649b0b4d.patch | git am
Provenance
github-import 1
aien-dev/CUDApp
67
f9cd649c1dca92ad81009bcd05a959f34c25c76e
{"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":67,"url":"https://github.com/aien-dev/CUDApp/pull/67","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:23Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/docs/speculation/CONTRACT.md b/docs/speculation/CONTRACT.md new file mode 100644 index 00000000..8f9be7d6 --- /dev/null +++ b/docs/speculation/CONTRACT.md @@ -0,0 +1,192 @@ +# Speculation component contract v1 + +All quantities are unsigned 64-bit integers. Time is microseconds. Probabilities +are unconditional accepted-prefix survival in millionths, monotonically +nonincreasing with depth. There is no floating-point input or nonfinite value; +out-of-range encodings are rejected. Converting an external clock/probability +representation is the caller's responsibility, with its precision disclosed. + +## Identity and calibration + +`sid[0..31]` contains eight SHA-256 identities, four little-endian words each: +weights; tokenizer; numerical/sampling recipe; CUDA++ backend/library build; +Omega/AIENOS executable build; drafter; candidate generator; experiment and +measurement contract. `sid[32..63]` contains the independently expected values. +Each digest must be nonzero. These are equality checks, not a hash implementation +or authenticated discovery. The existing owner must provide real identities. + +`sprofile` contains version (1), nonzero epoch, inclusive context lower bound, +exclusive context ceiling, evidence class (1 synthetic, 2 declared device), and +shape kind (1 chain). The context ceiling is at most 131072. An epoch change +invalidates learned state. Tree verification is explicitly unsupported. + +`srows` has seven rows of eleven words. Candidate draft lengths are +0, 1, 2, 4, 8, 16, 31. A row contains: + +| Offset | Meaning | +| --- | --- | +| 0 | Supported: 0 or 1. Unsupported rows have no measured cost claim | +| 1 | Draft length | +| 2 | Verification rows, including anchor: draft length + 1 | +| 3..8 | Draft, verify, commit/rollback, host, policy, preparation microseconds | +| 9 | Peak memory bytes required by this shape | +| 10 | Calibration sample count, 5 through 1,000,000 | + +Ordinary row zero must be supported with zero draft time. Every enabled row +requires positive verify time and memory; individual phase costs are at most +1,000,000,000 us. Zero in other phases means measured zero, never unknown. +The collector requires an explicit complete phase mask. Total row cost includes +all six phases; cross products are bounded below the unsigned 64-bit limit. + +`sprior[31]` is the frozen development estimate. `sbegin(0)` validates and starts +a cold request. `sbegin(1)` retains learned costs/survival only for the same +identity and epoch, resets request counts and probe scheduling, and requires an +already initialized instance. No hidden shared learning is allowed: one instance +per caller-controlled session. The warm flag must be recorded in trial data. + +## Selection and observation + +Set `scontrol[0]` to require declared device evidence (1), or permit synthetic +diagnostics (0). `scontrol[1]` is sampling mode; zero means greedy and any other +value explicitly selects ordinary decoding. + +`sselect(context, remaining, memory, epoch, mode, fixed)` takes six values. Mode +0 is ordinary, 1 is fixed, 2 is adaptive; `fixed` is a draft length. At most +256 output tokens are admitted per request. Candidate rows must fit remaining +output, context and memory. Unsupported fixed lengths are refused rather than +silently changed. Ties retain the smaller length, including ordinary. + +The decision's five words are draft length, verification rows, expected output +millionths, predicted whole-round us, and reason. Reasons: 0 predicted gain, +1 explicit mode, 2 unsupported sampling, 3 ordinary fallback, 4 recovery probe. +For a chain of length k, expected output is 1 plus the first k survival values. +This requires the existing verifier's anchor/correction/bonus convention. +Predicted ordinary-normalized gain is derivable from these values and row zero; +it is not an observed speedup. + +`sobserve(accepted, emitted, elapsed, eos, complete)` accepts only a completed +round. Accepted is at most k. Normally emitted is accepted+1; EOS may truncate +it. The full elapsed cost must be positive and at most 6,000,000,000 us. This +cost, including adaptation overhead, replaces the last observed cost for that +shape. Prefix survival uses a 7/8 previous + 1/8 observed update, clamped +monotonically. Only completed past rounds teach the policy. Frozen development +costs guide probes; no future fixture result is inspected. + +The observed cost deliberately uses the latest single sample, without smoothing. +It responds promptly to a cost step but is sensitive to timing noise; this is a +policy choice to evaluate on development trials, not an established advantage. +Recovery probes are eligible when ordinary wins and at least eight total rounds +have completed since the previous probe (or request start). Eight bounds probing +to at most one in eight completed rounds while permitting recovery within a +256-token request. This is an initial engineering choice, not a tuned optimum. +Any tuning must use development data and a new frozen experiment identity. + +`sstate[6]` counts emitted tokens, `[7]` consumed tokens, `[8]` an emitted but +unconsumed correction/bonus. `sresume()` acknowledges that the actual state owner +consumed that token. Selection is refused until that acknowledgement. Context +and remaining-budget checks follow this boundary. EOS/output exhaustion ends +the request. `scancel()` ends the request without learning or accepting output. +It does not roll back device memory. The caller must use the existing complete +KV, recurrent, convolution and drafter-state owner. These counters cannot prove +that physical state was committed correctly. + +## Observation collector + +`cstart()` freezes identities, epoch and evidence class and clears collection. +Only supported-shape descriptors are needed; costs may initially be unknown. +Each `cadd()` consumes `cobs[16]`: row index, zero-based ordinal within row, +complete flag, outcome (0 success), six phase durations, full wall duration, +peak memory, verification rows, epoch, evidence class, phase-known mask (63). +Only nonoverlapping phase times may be supplied. Wall duration must cover their +sum and be at most 1,000,000,000 us. Residual wall time is attributed to host +overhead. Duplicate/out-of-order/incomplete/stale observations are refused. + +At most 32 observations per shape are retained verbatim in `craw`, row-major, +with 32 records of 16 words per shape. `ccount` is the count per row; `csum` +keeps six phase totals plus wall total; `crange` keeps min/max wall and peak +memory. `cseal()` needs at least five samples for every enabled row and no +active round. It publishes conservatively rounded-up mean phases and peak +memory, then invalidates prior request state. Keep the raw samples and ranges; +a mean alone is insufficient evidence of a hardware cost step. + +## Paired report + +Each group is one fixture at one initial context (1024 or 32768 tokens) and one +controller cold/warm mode. `pconfig` holds context, warm flag, fixture ID, +minimum usable output length and require-device flag. `parmids` contains the +32 expected identity words for each arm: base, ordinary, fixed, adaptive. +Every digest must be nonzero, including differing baseline build identities. +An unused component binds the digest of an explicitly named absent identity. +Weights/tokenizer/numerical recipe/protocol must match across all arms. The base +may have a different backend/executable; ordinary/fixed/adaptive share those. +Fixed/adaptive additionally share drafter and candidate generator. `pstart(n)` +freezes these identities and config, for 5 through 32 paired repetitions. + +`pobs` has 56 words: + +| Offset | Meaning | +| --- | --- | +| 0..2 | Pair, arm (0..3), fixture ID | +| 3..6 | Prompt-token SHA-256 | +| 7..10 | Committed-output-token SHA-256 | +| 11 | Actual generated count, 1..256 | +| 12..14 | Request start, first committed token, request end us | +| 15 | Peak memory bytes | +| 16 | Stop reason: 1 natural EOS, 2 maximum 256 reached | +| 17..19 | Correctness checked (1), complete (1), contamination (0) | +| 20..23 | Profile epoch, cold/warm flag, trial ordinal, initial context | +| 24..55 | Actual arm identity words | + +Order rotates the four arms by pair index; exact ordinals are required. Every +attempt, including invalid ones, is retained in `praw` (at most 256). Invalid +attempts poison the group; an accepted-looking retry cannot erase them. Retain +the original group and explain any new campaign separately. Prompt identity is +fixed across pairs. Within each pair all arms must have identical greedy token +digest, length and stop reason. Divergence blocks performance interpretation. +The runtime must supply first-divergence logits/state separately; digests cannot +explain a numerical error. + +`preport(0|1|2)` compares adaptive with base/ordinary/fixed. `summary` contains: +pair count, comparator, median paired speed ratio in millionths, lower/upper +95% interval for the population median ratio, adaptive median/p95 full request +time, adaptive median/p95 TTFT, adaptive peak memory, verdict, evidence class. +Output counts agree within pairs, so the time ratio equals the committed-token +throughput ratio. Ratios are rounded down to millionths. Percentiles use nearest +rank; an even-count median averages its two central values. +Time and TTFT quantiles are each sorted independently. They are not the time or +TTFT of the pair at the median speed ratio; the speed ratio remains paired. + +The interval uses [exact binomial order statistics](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/mediancl.htm): choose the largest k whose +lower-tail probability is at most 1/40, then use sorted ratios k and n-k+1. +It assumes independent paired repetitions. Five pairs cannot give a finite +distribution-free 95% interval, so they produce an inconclusive result with +unbounded upper endpoint. More repeats improve resolution; noise is retained. +The wire representation of that endpoint is `18446744073709551615`, a sentinel +for no finite bound, not a measured ratio. Its lower endpoint and verdict are 0. +Verdicts: 0 inconclusive, 1 improvement (entire interval above 1), 2 no detectable +improvement (both bounds exactly 1 at the stated resolution), 3 regression +(entire interval below 1). A too-short EOS output makes the result inconclusive. +Synthetic evidence remains synthetic regardless of its numerical verdict. + +## Native diagnostic stream + +`replay.om` reads one bounded binary message from stdin and emits a binary +decision, sealed table or three reports. It performs no model execution and no +hardware verification. Maximum input is 65536 bytes; words are little-endian u64. + +Common input: magic 827867987 (`SCX1`), version 1, operation, reserved 0; then +64 identity, 6 profile, 77 row and 31 prior words. The first operation-specific +word is index 182. + +- Operation 1: two `scontrol` words followed by the six selection arguments. +- Operation 2: sample count followed by that many 16-word cost observations. +- Operation 3: five `pconfig` words, pair count, attempt count, 128 `parmids` + words, then that many 56-word trial observations. + +Output header: magic, version, operation, evidence class, payload word count. +Operation 1 returns five decision words. Operation 2 returns 77 row words, +7 counts and 21 range words. Operation 3 returns three 12-word summaries in +base/ordinary/fixed order. No partial successful response is emitted after an +admission error. Keep the original input alongside the output as the raw record. +Statuses: 0 success, 65 malformed/range, 69 identity/version/correctness, +74 I/O, 75 incomplete/order/state, 77 unsupported/capacity. diff --git a/docs/speculation/NATIVE-DEVICE.md b/docs/speculation/NATIVE-DEVICE.md new file mode 100644 index 00000000..1e5560be --- /dev/null +++ b/docs/speculation/NATIVE-DEVICE.md @@ -0,0 +1,70 @@ +# Native GPU connection + +`native/nvrm/context.om` continues the canonical NVRM lifecycle from +`349913f17c083996680c72b32f767b225005155d` in seeded Omega. It uses the +NVIDIA580.173.02 public ABI definitions already retained with their notices in +this repository. No C or Rust runtime helper is linked or executed. + +The compiler extension is in Omega PR676. It adds scoped RM parameter binding, +an exact UVM request allowlist, owned memory addresses, ordered mapped words, +unused low-address reservations and binding limited to those reservations. +The source-born compiler has no foreign compiler, assembler or linker in its +construction chain. Independent GCC header-layout and GNU assembler encoding +oracles were used during development; shell and Node coordinated checks. + +The physical probes cover private RM/UVM context creation, a GPU address space, +coherent system-memory objects, their CPU and GPU mappings, an uncached queue, +the compute channel, a mapped notification page, submission and bounded waiting. +`nvstart` queries the device, `nvfull` attaches UVM, `nvalloc` returns an owned +mapping, `nvchan` creates an empty channel, `nvsend` submits one packet and +`nvwait` observes its completion. `nvdrop` releases an allocation and `nvstop` +tears down the entire context. Failed operations retain stage/error information. + +There is one outstanding packet at a time. Pending work prevents buffer release +and another submission. A missed completion latches a fault; further submission +and context reuse are refused. Partial allocation state remains recorded until +cleanup. The table has96 live allocation slots; the compiler has128 mapping +slots. These are bounded runtime resources, not model-sized allocation arenas. + +Teardown has three explicit phases: closed, driver resources live, and +descriptors closed with CPU mapping cleanup pending. A failed unmap retains its +mapping handle. A later `nvstop` retries only those mappings; it does not repeat +RM/UVM operations or descriptor closes. The context fault stays latched even +after cleanup succeeds. The [host refusal fixture](TEARDOWN-HOST.md) checks this +contract with substituted OS effects. Its native compilation and execution +remain NOT_RUN until replayed with the pinned compiler on Linux AArch64; the +earlier physical receipts do not qualify this source change. + +GPU buffers first reserve unused page-aligned CPU addresses below1TiB. File +binding can replace only that owned reservation. The same address is serialized +into the GPU mappings. This matters because a command entry's address field is +40bits; ordinary Linux-selected CPU addresses can exceed it. The existing +canonical GP entry word, including its level bit, is retained. No other runtime +or shared compiler tree was modified. + +The driver reports the GB10 SM identifier as2564, matching the repository's +historical M16 receipt. That field uses a different numbering contract from the +CUDA target name. An initial test incorrectly expected3073 and was corrected. +Its initial negative-value diagnostic also required correction. Both failures +are retained locally. A UVM attempt launched before scheduling confirmation is +excluded from qualified evidence; subsequent probes required confirmed admission. + +| Physical check | Result | +| --- | --- | +| Device and private address-space lifecycle | Three complete cycles per probe passed. | +| Buffer lifecycle | Twelve buffers over three contexts; full written-byte comparison, explicit release and context-owned cleanup passed. | +| Empty channel lifecycle | Three cycles passed, including refusal to free its active queue. | +| FIFO submission | 2,052 distinct completion payloads passed across two contexts, including ring wrap. A deliberately wrong expected payload timed out and latched the fault. | + +These are correctness probes under shared hardware admission. The FIFO test +executes semaphore commands. The subsequent [native kernel qualification](NATIVE-KERNEL.md) +separately covers integer vector arithmetic. There is no model inference, +AIENOS endpoint integration or timing comparison in this device evidence. +Full-state rollback, all four experiment arms and issues63-66 +remain open. Cleanup refusal injection and independent final-source review remain +required alongside the next kernel/model stages. + +To build a probe, concatenate `native/nvrm/context.om` with the selected +`tests/speculation/native-{device,memory,channel,submit}-test.om`, compile it with +the pinned native compiler and run only in an admitted hardware window. Current +source/artifact identities and bounded results are in `evidence/speculation/native-device`. diff --git a/docs/speculation/NATIVE-KERNEL.md b/docs/speculation/NATIVE-KERNEL.md new file mode 100644 index 00000000..a9ac0f03 --- /dev/null +++ b/docs/speculation/NATIVE-KERNEL.md @@ -0,0 +1,48 @@ +# Native Omega compute launch + +`native/blackwell/vector.om` emits the existing seeded SM121 integer vector +program in handwritten Omega. Its 512 bytes match Omega `57f5f425`'s +`seed/sm121/vecadd.bin` exactly. It adds two uint32 arrays, with wraparound, +and exits out-of-range threads before memory access. + +`native/blackwell/launch.om` continues CUDApp `349913f1`'s VECTOR_1D launch +contract over the native NVRM connection. It builds the driver constants, +two launch descriptors, argument upload, completion markers and final cache +flush. The host waits for completion before reading every result. No C or +Rust runtime, foreign assembler, CUDA library or lab-only capsule is used. + +The current interface is deliberately one bounded vector operation, with +64 threads per block and at most 1,048,576 elements. It is not a generic +unvalidated program loader. There is one context and one outstanding packet. +The caller must close the context after a failed open or launch. + +The physical test passes sizes 1, 63, 64, 65, 257, 4097, 65537 and 1048576, +compares every uint32 result, and checks up to 64 words beyond the output. +A fresh program allocation that omits one addend must produce a mismatch. +A subsequent fresh correct program must pass again. Invalid zero and +oversized requests are refused, and final context cleanup succeeds. + +Host checks compare the emitted program byte for byte with the seed artifact. +For five address/size fixtures, all 2,115 driver/descriptor/argument words +match an independently compiled copy of the pinned C QMD builder. That C +program is a test-only oracle and is never part of the native execution path. + +The first physical attempt exited 104 when the test's dynamic CPU loop +exceeded the seeded one-million-iteration guard. A CPU-only reproduction +passed at 1,000,000 and failed at 1,000,001. The shared checker now processes +at most 65,536 values per loop. Its host regression checks 999,999, 1,000,000, +1,000,001 and 1,048,576 elements plus a one-element case. The guard remains +unchanged. The initial failed attempt is retained privately and is not a pass. + +Build the GPU test by concatenating `context.om`, `vector.om`, `launch.om`, +the declarations and `ck` function before `fn trial` in +`native-kernel-test.om`, `vector-checks.om`, and the remainder of the kernel +test. Build the CPU regression from the declarations and `ck` before +`fn supply` in `vector-checks-test.om`, `vector-checks.om`, then its remainder. +Compile with the pinned seeded compiler; require successful compilation +before execution. Hardware tests require a confirmed admitted window. + +The evidence is a shared-window correctness result, with no performance +claim. FP8 arithmetic, the complete 27B model, speculative-state recovery, +AIENOS attachment and the four-arm comparison remain unfinished. Issues +63 through 66 remain open. Independent final-source review is still pending. diff --git a/docs/speculation/OMEGA-RUNTIME.md b/docs/speculation/OMEGA-RUNTIME.md new file mode 100644 index 00000000..2d8b9b5e --- /dev/null +++ b/docs/speculation/OMEGA-RUNTIME.md @@ -0,0 +1,28 @@ +# Strict Omega runtime prerequisites + +The user confirmed strict Omega and authorized extending the existing Omega +compiler/runtime to make this experiment possible. A Rust bridge is not part of +the accepted implementation. This is a component dependency record, not a new +whole-system execution plan. + +[Omega PR676](https://github.com/aien-dev/omega-mv/pull/676) extends the existing +native-host compiler with checked device calls and managed file/memory mappings. +Its source d80b428c reconstructs through the original seed chain. The existing +L605 device request rule is reused. L408's original compiler tree, L605's GPU +launcher ownership, L457's canonical backend and L789's compiler correction are +preserved. The new branch is proposed work, not current merged runtime behavior. + +| Required connection | Current evidence | +| --- | --- | +| Policy process, pipes, clocks and lifecycle | Existing service component passes337 native checks. | +| Managed native memory and checked device calls | PR676 host tests pass, including stale handles, bounds, rights, exhaustion and compiled controls. | +| Reading actual model files | Native read-only probe passes2,442 mapped/file comparisons over66 shards. This proves access only. | +| Native GPU connection | The canonical NVRM lifecycle is continued in `native/nvrm/context.om`. Private RM/UVM contexts, low-address buffers, empty channels and2,052 FIFO completion writes pass physical probes. See [native device evidence](NATIVE-DEVICE.md). A native integer vector kernel also passes full-output physical checks through1,048,576 elements, including a wrong-math control; see [kernel evidence](NATIVE-KERNEL.md). Model execution and full runtime qualification remain open. | +| Complete 27B model and speculative state | Existing historical Rust integration remains a behavioral reference. Its numeric transforms, kernel selection, MTP, cache/recurrent state, rollback and correction-token consumption must be attached through the native path. | +| Final compiler qualification | The existing branch-range correction is integrated in Omega078455c9. Its native gate and full host qualification pass; all seven experiment executables reproduce byte-identically. Final independent source review remains required. | +| Four-arm experiment and issue closure | Requires the complete path, full-state correctness, calibration and held-out physical trials. Still NOT_RUN. | + +The file probe does not substitute for model execution. Historical fixed-chain +whole-model runs do not qualify this new integration. Do not close #63-66 or +claim adaptive speedup from these prerequisites. Source and evidence for this +step are in `evidence/speculation/model-mapping` and the Omega PR. diff --git a/docs/speculation/READINESS.md b/docs/speculation/READINESS.md new file mode 100644 index 00000000..09afe4bf --- /dev/null +++ b/docs/speculation/READINESS.md @@ -0,0 +1,38 @@ +# Execution readiness + +Inspection date: 2026-10-23. Implementation evidence and immutable branch +sources take precedence over an open issue label. + +| Requirement | Evidence and disposition | +| --- | --- | +| Existing 27B model and fixed speculation | Historical sovereign-core `speed2/specdecode` at `68fa1683874899eb0b6b4ab68bb2b9b19fcbcbb1` contains the qwen38 model, MTP, verification and accepted-state work. This is existing Rust integration over native GPU code, not a seeded `.om` adapter. Reuse its contracts and references; do not introduce a second runtime | +| Whole-model correctness | Prior branch evidence contains complete-model checks beyond the two/four-layer evidence in Omega PR #559. This does not qualify a new build or this experiment's two context lengths. Requalification remains required | +| Canonical backend | [CUDApp #5](https://github.com/aien-dev/CUDApp/issues/5), owner L457, has an existing integrated candidate with host evidence. Its actual serving/device gates remain separate. [Omega #618](https://github.com/aien-dev/omega/pull/618) is open | +| Existing timing owner | [CUDApp #17](https://github.com/aien-dev/CUDApp/issues/17), L468, branch `roadmap/17-native-benchmark` at `65948c9c9420391782939e3492b9ed310ec774c7`: graph/request collector interface and raw observations. This change consumes the same timing concepts in `.om`, without copying its C/JS runner or inventing device times | +| Seeded compiler | [omega-bridge source](https://github.com/aien-dev/omega-bridge/tree/0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9) reconstructs compiler SHA-256 `191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9`. This component uses that immutable compiler | +| Real adapter and host facilities | [Omega #636](https://github.com/aien-dev/omega/issues/636), [#637](https://github.com/aien-dev/omega/issues/637), existing L408/L605 and experiment L576. Recent native device-call work exists, but no qualified complete seeded 27B attachment is established by this component. Do not describe all language facilities as absent based on issue labels | +| Native process and clock availability | Omega `f0499f415571bdd7496b6de391096915e78f7556` supplies actual file/process/pipe/clock/TCP/Unix operations. This task independently rebuilt it and checked nine positive groups, 41 refusals and 70 original fixtures. The persistent policy service uses this existing profile. A per-round connection inside the current 27B Rust engine is still absent; see [SERVICE.md](SERVICE.md) | +| First-party language | The experiment requires handwritten seeded `.om` adapters, workload preparation, scheduling, validation, measurement and reporting. Legacy shell development reconstruction is disclosed; a foreign-language model runner cannot silently satisfy the experiment | + +## Remaining acceptance, in order + +1. Resolve the exact checkpoint/tokenizer/precision and all executable/backend + identities locally. Freeze a single ordinary reference and a development-only + fixed-budget choice. Record whether base and ordinary are identical. +2. Connect the existing 27B/MTP/complete-state owner to the qualified seeded + adapter. Prove complete prefill/decode, correction-token consumption, EOS, + cancellation and rollback, wrong-backend refusal, and first-divergence checks. +3. Feed completed native observations into the collector at 1K and 32K. Preserve + real timestamps, stage coverage, raw samples, costs and memory per shape. +4. Run balanced held-out prose/code/edit/copy/Omega fixtures with separate + development data, natural EOS, at most 256 new tokens, and at least five + paired repetitions. Six or more are needed for the report's finite 95% median + interval; eight gives a balanced four-arm order. Report cold/warm separately. +5. Compare engine and served endpoint separately; retain failed/contaminated + groups. Publish public fixtures and reproducible results. Keep checkpoint + paths, private traces and machine-specific configuration local. +6. Obtain independent final-source review and qualify the integrated artifact. + Close #64/#65/#66 only when their remaining gates pass, then #63. + +No production swap, driver change, extra model server or GPU trial is part of +the component receipt. No performance result is inferred from synthetic costs. diff --git a/docs/speculation/README.md b/docs/speculation/README.md new file mode 100644 index 00000000..f2e39971 --- /dev/null +++ b/docs/speculation/README.md @@ -0,0 +1,35 @@ +# 27B adaptive sizing experiment + +Refs #63, #64, #65 and #66. This is a native Omega component and diagnostic +replay, with synthetic tests. It is not a completed model experiment. + +The implementation chooses a chain length using expected committed output +divided by the whole round cost. It keeps ordinary and fixed modes available, +falls back when observed speculation loses, and makes a bounded recovery probe +at most once per eight completed rounds. A separate collector validates and keeps +raw timing observations. The report compares adaptive against base, ordinary and +fixed, checks exact greedy output identity first, and retains failed attempts. + +All new implementation and tests are handwritten `.om`, compiled to native +AArch64 through the pinned seed-built compiler. Development reconstruction uses +the existing shell tools disclosed in [REPRODUCE.md](REPRODUCE.md). Those commands +are not an Omega-native build system or a shipped model runner. + +Read [CONTRACT.md](CONTRACT.md) for the component and stream interfaces, +[READINESS.md](READINESS.md) for actual dependencies, and +[the receipt](../../evidence/speculation/README.md) for executed checks. + +[SERVICE.md](SERVICE.md) describes the persistent native process interface and +its real parent/child pipe tests, including the exact remaining engine boundary. + +## What remains + +The existing model, drafter, accepted-state owner and native benchmark owner +must call these components through a qualified seeded adapter. No new loader, +cache subsystem, GPU runtime or compiler is introduced here. Device completion, +identity discovery, monotonic timing, full-state rollback and actual output +tokens must come from that integration. Caller-supplied metadata alone cannot +prove any of them. + +Real 1K/32K trials, performance results, first-divergence analysis and independent +final-source review remain required. No issue is closed by this component. diff --git a/docs/speculation/REPRODUCE.md b/docs/speculation/REPRODUCE.md new file mode 100644 index 00000000..54d53076 --- /dev/null +++ b/docs/speculation/REPRODUCE.md @@ -0,0 +1,70 @@ +# Native reconstruction + +Use Linux AArch64 and a fresh output directory. These are disclosed development +commands using existing host tools, not a new first-party runtime or installer. +No Python is needed. The native programs use only stdin/stdout and process exit. + +Reconstruct the compiler from immutable `aien-dev/omega-bridge` revision +`0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9`, following its existing +`tools/bootstrap.sh --offline`. Its seed input is Omega revision +`29b12760f4c962606411d6bf25032aedef063301`. Require compiler SHA-256: + +``` +191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9 +``` + +Set `OMC` to that reconstructed executable and `OUT` to an existing private +output directory. Export the exact source revision from the receipt with +`git archive`, then assemble these ordered translation units in the export: + +| Program | Ordered `.om` inputs | +| --- | --- | +| policy-test | native/speculation/policy; tests/speculation/support, policy-test | +| cost-test | native/speculation/policy, costs; tests/speculation/support, cost-test | +| report-test | native/speculation/policy, report; tests/speculation/support, report-test | +| oracle-test | native/speculation/policy; tests/speculation/support, oracle-test | +| replay | native/speculation/policy, costs, report, replay | +| packet-fixture | native/speculation/policy; tests/speculation/support, packet-fixture | +| reply-test | native/speculation/policy; tests/speculation/support, reply-test | + +For example: + +```sh +cat native/speculation/policy.om tests/speculation/support.om tests/speculation/policy-test.om > "$OUT/policy-test.om" +quiet-build timeout 30 "$OMC" < "$OUT/policy-test.om" > "$OUT/policy-test.elf" 2> "$OUT/policy-test.compile.log" +# Require compiler exit 0 before execution. +test -s "$OUT/policy-test.elf" +readelf -h "$OUT/policy-test.elf" +chmod 700 "$OUT/policy-test.elf" +quiet-build timeout 10 "$OUT/policy-test.elf" +sha256sum "$OUT/policy-test.elf" +``` + +Apply the same compile/check/run sequence to each unit. The native fixture +emitter reads one selector byte: 1 policy, 2 cost collector, 3 paired report. +It emits explicitly synthetic records. For the policy replay: + +```sh +printf '\001' | "$OUT/packet-fixture.elf" > "$OUT/policy.bin" +"$OUT/replay.elf" < "$OUT/policy.bin" > "$OUT/policy.reply" +"$OUT/reply-test.elf" < "$OUT/policy.reply" +``` + +Selectors `\002` and `\003` exercise the other modes. Preserve input, output, +stderr, exit status and executable hashes. An empty or truncated message must +return 65 with no stdout. Synthetic input must retain evidence class 1 in the +reply. It cannot satisfy a request requiring device evidence. + +The receipt records compiled behavioral controls. Each applies one change to a +private copy of product source, compiles successfully, and runs the unchanged +tests, which must return 1. A compile error, crash or timeout does not count as +a killed behavioral control. + +Existing regression command, separately from new native tests: + +```sh +quiet-build make -j2 OUT_DIR=build/regression test +``` + +These 33 legacy host targets are regression evidence. They are not new seeded +tests, full-model correctness or GPU qualification. diff --git a/docs/speculation/SERVICE.md b/docs/speculation/SERVICE.md new file mode 100644 index 00000000..026e6a09 --- /dev/null +++ b/docs/speculation/SERVICE.md @@ -0,0 +1,108 @@ +# Persistent native policy process + +`native/speculation/service.om` connects the existing policy to a persistent +stdin/stdout process. It is handwritten Omega, including framing, lifecycle +validation and timing. The native model engine must own and acknowledge all +physical prefill, verification, rollback and token-consumption operations. + +This is a real Linux AArch64 process interface, tested by a second native Omega +process through two pipes. It is not a model adapter or an AienOS device gate. + +## Qualified compiler profile + +This entrypoint uses the existing native-host compiler from Omega commit +`f0499f415571bdd7496b6de391096915e78f7556`, independently reconstructed through +its existing seed chain. Compiler SHA-256: + +``` +e5d60db892c8f21cc8c9128af26d8bded0e96d7f92946f5a549397c43a872649 +``` + +Its published native-host gate covers file, process, pipe, clock and socket +operations. This is a distinct profile from the baseline compiler used for the +original pure components; no union with another compiler profile is assumed. +The dependency is qualified here without editing another owner's compiler. + +For a reconstruction, export the exact pinned seed and original fixture paths, +including their Git file index, and run its existing `seed/host/check.sh`. +Require nine positive groups, 41 negative controls and **70** original fixtures. +A partial source export can misleadingly print a passing comparison of zero +fixtures; zero does not qualify this dependency. + +Compile these ordered units with that compiler: + +- Worker: `native/speculation/policy.om`, `native/speculation/service.om`. +- Native test client: `native/speculation/policy.om`, + `tests/speculation/support.om`, `tests/speculation/service-test.om`. + +Run the test client with the worker executable's absolute path as its sole +argument. The client starts only that host worker, exercises both pipes, and +reaps it. Existing shell tools coordinate development reconstruction only; +the delivered worker invokes no shell, foreign helper or model runtime. + +## Wire format + +All fields are unsigned 64-bit little-endian words. Requests have five header +words: magic `827343699` (SCP1), version `1`, operation, sequence, body length in +words. Sequences start at one and advance after each framed response, including +semantic refusals. Header and body reads tolerate partial reads and EINTR. + +Responses have seven header words: magic, version, operation, sequence, status, +body length in words, elapsed policy nanoseconds. Timing starts after the full +request arrives and ends before the response is written. The engine must also +measure total round-trip overhead, including transport, and include that cost +in the round. The elapsed field alone is not full adaptation overhead. + +| Operation | Request body | Successful response body | +| --- | --- | --- | +| 1 initialize | 64 identity words, 6 profile words, 77 cost-row words, 31 prior words | Empty | +| 2 begin | warm flag, require-device flag, sampling mode | Empty | +| 3 select | context, remaining output, memory budget, epoch, mode, fixed length | Five decision words from CONTRACT.md | +| 4 observe | accepted drafts, emitted tokens, full elapsed microseconds, EOS, complete | Emitted, consumed, pending-token, done counters | +| 5 consume | Empty; caller acknowledges consumption by the real model owner | Empty | +| 6 cancel | Empty; caller owns actual rollback and cancellation | Empty | +| 7 end | Empty; request must be complete with no active round | Empty | +| 8 exit | Empty; no request may be active | Empty, then process exit 0 | + +Initialize is accepted once per process. Begin requires initialization or a +previously ended/cancelled request. Warm begin retains the policy's learned +statistics under its original identity rules. Reconfiguration requires a new +process. The process performs no shared learning with other instances. + +Semantic errors return the policy's status and no payload. Broken framing, +unknown operations, bad versions/sequences or incomplete frames terminate the +process without a response for that frame. EOF is clean only between requests; +EOF during an active request exits 75. One process accepts at most one million +commands. There is no automatic fallback after process or protocol failure. +The model caller must abort the affected trial and preserve its failure record. + +The process itself does not discover code/model hashes or authenticate a device. +Supplied identities and acknowledgements must be derived from the real owner; +their presence on the wire cannot prove that the model executed correctly. + +## Exact existing-engine attachment point + +The inspected 27B engine is sovereign-core `speed2/specdecode` at +`68fa1683874899eb0b6b4ab68bb2b9b19fcbcbb1`. Its existing +`qwen38_omega/spec.rs::decode_rounds` takes one fixed `k` for the request. +It has no external per-round budget callback. Its server reads `AIEN_Q38_SPEC_K` +when loading, and its `qwen38_spec suite` parses the entire plan before loading. +Those interfaces cannot implement adaptive per-round sizing merely by changing +command arguments between calls. This source supports chains up to eight drafts; +16 and 31 must remain explicitly unsupported until independently qualified. + +A narrow engine connection would call select before drafting, use the returned +budget, preserve existing MTP/verification/complete-state ownership, and report +observe only after actual commit or rollback. It must handle natural EOS, +cancellation and output exhaustion before reporting the exact emitted/consumed +prefix, then acknowledge any correction token at its real consumption boundary. +Native timing must cover draft, verify, commit, host, policy/transport and setup. +First-divergence checks remain mandatory; this interface adds no numerical waiver. + +The user confirmed strict Omega implementation and authorized extending Omega's +compiler and runtime to supply this connection. Native device access, mapped +memory and the full model/state attachment remain prerequisites. The existing +Rust engine remains a reference for behavior. No model launch or hardware trial +is delivered by this policy-service component. +A strictly Omega attachment instead depends on the existing native ABI/runtime +owner. The presence of native host facilities does not establish that ABI. diff --git a/docs/speculation/TEARDOWN-HOST.md b/docs/speculation/TEARDOWN-HOST.md new file mode 100644 index 00000000..531ba2cb --- /dev/null +++ b/docs/speculation/TEARDOWN-HOST.md @@ -0,0 +1,77 @@ +# Teardown refusal and retry fixture + +Refs CUDApp #65 and #67. This is a bounded cleanup repair and a synthetic host +fixture. It does not qualify model inference, GPU execution, or deployment. + +## Source contract + +`nvstate` records the teardown phase: + +| Value | Meaning | Permitted cleanup | +| --- | --- | --- | +| 0 | Closed | Return success without another effect | +| 1 | Driver resources live, including partial construction | Existing RM/UVM teardown and one close attempt per descriptor | +| 2 | Descriptors closed; CPU mappings remain | Retry owned BAR, channel, and buffer unmaps only | + +The compiler's `mapdrop` returns a nonzero syscall result without retiring its +owned mapping slot. The runtime must therefore retain the mapping handle until +unmap succeeds. After descriptor closure, driver-owned memory flags can retire, +but a failed CPU mapping retains its handle, address and length. A failed +cleanup latches `nvfault`; successful cleanup does not make the context reusable. +Descriptor numbers are retired after their first close attempt, including an +error, so a subsequent call cannot close a newly reused descriptor number. + +## Fixture and isolation + +The handwritten `tests/speculation/teardown-host-test.om` runs the actual +`nvstop`/`nvmapfinish`/`nvmforce` control flow in a private source-derived unit. +The disclosed shell composer replaces only these OS effects: + +- Device operations become a bounded fake that refuses any call after the + descriptor phase has ended. +- Device opens become an immediate test assertion failure. +- Unmap and close become stateful fakes that count calls, reject double release, + and can refuse an otherwise valid synthetic mapping. + +The composer refuses an unbound device/open/close/unmap verb. It never changes +the tracked runtime file. The fixture does not open `/dev/nvidia*`, allocate GPU +memory, or submit work. It follows the existing development practice of building +private native translation units and compiling behavioral negative controls; +the shell is test orchestration, not a new product runtime. + +Cases cover normal and repeated shutdown, a BAR unmap refusal, a channel-map +refusal, a buffer unmap refusal, a driver teardown refusal followed by mapping +refusal, successful retry, and a descriptor close error. Each refused mapping +must survive two shutdown attempts, then release when refusal is removed. +Retries must make no extra descriptor closes or driver calls. The context fault +must remain set, and `nvstart` must still refuse reuse. A direct `nvmforce` call +while driver resources are live must refuse without changing ownership flags, +handles, addresses or lengths and without making an OS effect. + +## Reproduction + +Use Linux AArch64 and the compiler from the existing native-device receipt: + +- Omega source: `d7390d88d07dbf48cfbb0583070599c350f814d3`. +- Compiler SHA-256: + `9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db`. + +```sh +sh tests/speculation/run-teardown-host.sh /absolute/path/to/pinned-omc +``` + +The script retains a private temporary directory with exact source units, ELF +files, compiler logs, stdout/stderr, exit statuses, and hashes. It compiles the +original `5e037c7e3d0226abadaa10af9d44bc6339109b3f` context with the same fixture +first: it must fail by a test assertion (exit 1), not compilation error, trap or +timeout. The repaired source must then compile and exit 0 with the PASS marker. +An unsupported host returns 77 and `NOT_RUN`; it is not a test pass. + +## Current qualification limit + +Native compilation and execution are **NOT_RUN** in the merge-review workspace, +which is x86_64 and has no runnable AArch64 compiler or emulator. The fixture and +repair remain candidates for source review and supported-host qualification. +Existing hardware receipts describe older source and must not be reused to +approve this change. Real kernel/model behavior and production activation remain +outside this host fixture. diff --git a/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/README.md b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/README.md new file mode 100644 index 00000000..e0a1d246 --- /dev/null +++ b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/README.md @@ -0,0 +1,64 @@ +# PR 67 teardown retry candidate + +Refs CUDApp [#65](https://github.com/aien-dev/CUDApp/issues/65) and +[#67](https://github.com/aien-dev/CUDApp/pull/67), including review +[5637134696](https://github.com/aien-dev/CUDApp/pull/67#pullrequestreview-5637134696). + +This is an **unqualified source candidate**, based on PR 67 head +`5e037c7e3d0226abadaa10af9d44bc6339109b3f`. The candidate source and test revision +is `ff5b4f9f1b13cffff2669e8207fe38cb5831366f`. Native compilation, native test +execution, GPU execution, model inference and deployment are **NOT_RUN**. + +## Repair and review + +An unsuccessful `mapdrop` leaves its mapping handle owned. The old `nvstop` +cleared the BAR handle despite refusal and marked the context closed even when +channel or buffer mappings remained. A later `nvstop` could consequently report +success without retrying cleanup. + +The repair records a distinct phase after descriptor closure, retains failed +mapping handles and retries only CPU mapping cleanup in that phase. It preserves +the sticky fault and retires each descriptor after one close attempt, including +close errors. No RM/UVM call or descriptor close is repeated after phase 1. + +An independent source review traced normal cleanup, each mapping refusal, +driver teardown refusal and close-error paths against the compiler's mapping +semantics. It found no additional blocker in the runtime change. This review +is source analysis, not a signed supported-host qualification or native test +pass. Its suggested live-driver phase refusal check was added to the fixture. + +The compiler source contract was checked at Omega +`d7390d88d07dbf48cfbb0583070599c350f814d3`, `seed/omc/omc.om`: unsuccessful +`munmap` returns without clearing the live mapping slot. Invalid or stale +handles trap and are not used as a substitute for the syscall refusal case. + +## Verification recorded here + +| Check | Result | Scope | +| --- | --- | --- | +| Shell syntax | PASS | `sh -n tests/speculation/run-teardown-host.sh` | +| Baseline and repaired source-unit composition | PASS | Extracted the actual composer from the tracked shell script; did not compile either unit | +| OS-effect isolation guard | PASS | Both composed units accepted; an appended unbound `devctl` rejected in each | +| Whitespace check | PASS | `git diff --check origin/experiment/27b-adaptive-sizing HEAD` | +| Native host test | NOT_RUN, exit 77 | Workspace is x86_64; no runnable pinned AArch64 compiler or emulator | +| Required legacy host suite | FAIL, exit 2 | `make -j2 OUT_DIR=build/teardown-review test`; existing unconditional AArch64 assembly at `src/omega_blackwell_engine.c:393,558` is rejected on x86_64 | +| Already-started legacy mutation target | PASS, 49/49 killed | Separate legacy host target, not qualification of the native repair | +| GPU/model/deployment | NOT_RUN | No device access or runtime activation | + +`full-host.log` retains the complete failing host-suite output. The full host +suite ran against the same runtime change; later commits only adjusted the +test orchestration, added a fixture assertion and updated documentation. +`source-composition.json` records the exact units' hashes and guard exits. + +## Required supported-host step + +Follow [TEARDOWN-HOST.md](../../docs/speculation/TEARDOWN-HOST.md) on Linux +AArch64 using the pinned compiler. The original source must compile and fail +by the intended assertion; the repaired source must compile and pass. A +compiler error, trap, timeout or unsupported-host skip is not a pass. Preserve +the produced source units, ELF files, compiler logs, stdout/stderr and hashes. + +The current candidate must remain draft/unqualified until that step and all +existing review and signed integration gates are satisfied. Older hardware +receipts cannot qualify this changed source, and the synthetic fixture does +not qualify 27B inference or production activation. diff --git a/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/full-host.log b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/full-host.log new file mode 100644 index 00000000..5a1ffa5d --- /dev/null +++ b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/full-host.log @@ -0,0 +1,61 @@ +mkdir -p build/teardown-review +gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o build/test_omega_gpu_code_alloc tests/test_omega_gpu_code_alloc.c +gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -o build/test_omega_gpu_engine_compile tests/test_omega_gpu_engine_compile.c src/omega_gpu_engine.c +gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -o build/test_omega_gpu_engine tests/test_omega_gpu_engine.c src/omega_gpu_engine.c +sh tools/gpu_engine_mutations.sh +gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -I./m16 -I./nvrm -I./third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc -I./third_party/nvidia-open-580.173.02/kernel-open/common/inc -I./third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm -I./third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include -c -o build/omega_blackwell_engine_syntax.o src/omega_blackwell_engine.c +src/omega_blackwell_engine.c: Assembler messages: +src/omega_blackwell_engine.c:558: Error: number of operands mismatch for `ds' +src/omega_blackwell_engine.c:393: Error: number of operands mismatch for `ds' +make: *** [mk/omega-gpu-engine.mk:46: build/omega_blackwell_engine_syntax.o] Error 1 +make: *** Waiting for unfinished jobs.... +VALIDATE_SKIPPED KILLED MUT:VALIDATE_SKIPPED (harness exit 139 (crash or abort)) +VALID_PROGRAM KILLED MUT:VALID_PROGRAM (harness exit 139 (crash or abort)) +VALID_LAYOUT KILLED MUT:VALID_LAYOUT (1 failing case(s), first: VALID_ARGS_LAYOUT) +VALID_COUNT_ZERO KILLED MUT:VALID_COUNT_ZERO (1 failing case(s), first: VALID_ARGS_ZERO_ELEMENTS) +VALID_ALIGN KILLED MUT:VALID_ALIGN (1 failing case(s), first: VALID_ARGS_OUTPUT_ALIGNMENT) +VALID_POISON_COUNT KILLED MUT:VALID_POISON_COUNT (harness exit 139 (crash or abort)) +VALID_FLAGS KILLED MUT:VALID_FLAGS (1 failing case(s), first: VALID_ARGS_UNKNOWN_FLAG) +VALID_TIMEOUT_MARKER1 KILLED MUT:VALID_TIMEOUT_MARKER1 (1 failing case(s), first: VALID_ARGS_ZERO_MARKER_TIMEOUT) +VALID_TIMEOUT_MARKER2 KILLED MUT:VALID_TIMEOUT_MARKER2 (1 failing case(s), first: VALID_ARGS_ZERO_MARKER2_TIMEOUT_WITH_C3) +BLOCK_CHECK_SKIPPED KILLED MUT:BLOCK_CHECK_SKIPPED (2 failing case(s), first: CERTAIN_BLOCKS_NEXT_JOB_NO_BACKEND_CALL) +BACKEND_CHECK_SKIPPED KILLED MUT:BACKEND_CHECK_SKIPPED (harness exit 139 (crash or abort)) +OPEN_NOT_TRACKED KILLED MUT:OPEN_NOT_TRACKED (20 failing case(s), first: CCESS_FULL_RUN) +ALLOC_NOT_TRACKED KILLED MUT:ALLOC_NOT_TRACKED (20 failing case(s), first: CCESS_FULL_RUN) +CLEANUP_SKIPPED_CHANNEL KILLED MUT:CLEANUP_SKIPPED_CHANNEL (1 failing case(s), first: IL_CHANNEL_CREATE) +CLEANUP_SKIPPED_ALLOC KILLED MUT:CLEANUP_SKIPPED_ALLOC (1 failing case(s), first: IL_ALLOC) +CLEANUP_SKIPPED_COPY_IN KILLED MUT:CLEANUP_SKIPPED_COPY_IN (1 failing case(s), first: IL_PREPARE_COPY_IN) +CLEANUP_SKIPPED_SUBMIT KILLED MUT:CLEANUP_SKIPPED_SUBMIT (2 failing case(s), first: IL_SUBMIT_IS_NOT_UNCERTAIN) +FREE_UNALLOCATED KILLED MUT:FREE_UNALLOCATED (3 failing case(s), first: IL_DEVICE_OPEN) +FREE_SKIPPED KILLED MUT:FREE_SKIPPED (20 failing case(s), first: CCESS_FULL_RUN) +CLOSE_SKIPPED KILLED MUT:CLOSE_SKIPPED (20 failing case(s), first: CCESS_FULL_RUN) +CLEANUP_OVERWRITES_FIRST KILLED MUT:CLEANUP_OVERWRITES_FIRST (3 failing case(s), first: EANUP_FIRST_CLEANUP_FAULT_KEPT) +CLEANUP_FLAG_NOT_SET KILLED MUT:CLEANUP_FLAG_NOT_SET (5 failing case(s), first: EANUP_FREE_FAILS_AFTER_GOOD_RUN) +POISON_FILL_SKIPPED KILLED MUT:POISON_FILL_SKIPPED (18 failing case(s), first: LL_ORDER_FULL_RUN) +STATE_PREPARED_SKIPPED KILLED MUT:STATE_PREPARED_SKIPPED (3 failing case(s), first: ATE_ADVANCES_STEP_BY_STEP) +STATE_SUBMITTED_SKIPPED KILLED MUT:STATE_SUBMITTED_SKIPPED (4 failing case(s), first: ATE_ADVANCES_STEP_BY_STEP) +STATE_GPU_COMPLETE_SKIPPED KILLED MUT:STATE_GPU_COMPLETE_SKIPPED (3 failing case(s), first: ATE_ADVANCES_STEP_BY_STEP) +STATE_OUTPUT_VISIBLE_SKIPPED KILLED MUT:STATE_OUTPUT_VISIBLE_SKIPPED (5 failing case(s), first: CHANGED_NOTHING_WRITTEN) +STATE_OUTPUT_PRODUCED_SKIPPED KILLED MUT:STATE_OUTPUT_PRODUCED_SKIPPED (4 failing case(s), first: ATE_ADVANCES_STEP_BY_STEP) +STATE_SUCCESS_SKIPPED KILLED MUT:STATE_SUCCESS_SKIPPED (4 failing case(s), first: CCESS_FULL_RUN) +SUCCESS_AFTER_CLEANUP_FAIL KILLED MUT:SUCCESS_AFTER_CLEANUP_FAIL (3 failing case(s), first: EANUP_FREE_FAILS_AFTER_GOOD_RUN) +MARKER1_WAIT_SKIPPED KILLED MUT:MARKER1_WAIT_SKIPPED (10 failing case(s), first: LL_ORDER_FULL_RUN) +MARKER1_TIMEOUT_WRONG KILLED MUT:MARKER1_TIMEOUT_WRONG (1 failing case(s), first: R_STEP_TIMEOUTS_FROM_JOB) +MARKER1_RESULT_IGNORED KILLED MUT:MARKER1_RESULT_IGNORED (2 failing case(s), first: CERTAIN_MARKER_TIMEOUT) +UNCERTAIN_FREES_MARKER1 KILLED MUT:UNCERTAIN_FREES_MARKER1 (1 failing case(s), first: CERTAIN_MARKER_TIMEOUT) +MARKER2_WAIT_SKIPPED KILLED MUT:MARKER2_WAIT_SKIPPED (7 failing case(s), first: LL_ORDER_FULL_RUN) +C3_FLAG_IGNORED KILLED MUT:C3_FLAG_IGNORED (1 failing case(s), first: _C3_SKIPS_MARKER2_ONLY) +MARKER2_RESULT_IGNORED KILLED MUT:MARKER2_RESULT_IGNORED (1 failing case(s), first: CERTAIN_MARKER2_UNKNOWN_STATE) +UNCERTAIN_FREES_MARKER2 KILLED MUT:UNCERTAIN_FREES_MARKER2 (1 failing case(s), first: CERTAIN_MARKER2_UNKNOWN_STATE) +RELEASE_WAIT_SKIPPED KILLED MUT:RELEASE_WAIT_SKIPPED (7 failing case(s), first: LL_ORDER_FULL_RUN) +RELEASE_RESULT_IGNORED KILLED MUT:RELEASE_RESULT_IGNORED (1 failing case(s), first: CERTAIN_RELEASE_DRIVER_FAULT) +UNCERTAIN_FREES_RELEASE KILLED MUT:UNCERTAIN_FREES_RELEASE (1 failing case(s), first: CERTAIN_RELEASE_DRIVER_FAULT) +BARRIER_SKIPPED KILLED MUT:BARRIER_SKIPPED (6 failing case(s), first: LL_ORDER_FULL_RUN) +BARRIER_RESULT_IGNORED KILLED MUT:BARRIER_RESULT_IGNORED (1 failing case(s), first: IL_VISIBILITY_BARRIER) +RETAINED_FLAG_NOT_SET KILLED MUT:RETAINED_FLAG_NOT_SET (3 failing case(s), first: CERTAIN_MARKER_TIMEOUT) +NO_BLOCK KILLED MUT:NO_BLOCK (4 failing case(s), first: CERTAIN_MARKER_TIMEOUT) +WAITED_NOT_A_DIFFERENCE KILLED MUT:WAITED_NOT_A_DIFFERENCE (3 failing case(s), first: CERTAIN_MARKER_TIMEOUT) +POISON_INDEX_FIXED KILLED MUT:POISON_INDEX_FIXED (4 failing case(s), first: CHANGED_NOTHING_WRITTEN) +UNCHANGED_COUNT_SATURATES KILLED MUT:UNCHANGED_COUNT_SATURATES (3 failing case(s), first: CHANGED_NOTHING_WRITTEN) +UNCHANGED_CHECK_SKIPPED KILLED MUT:UNCHANGED_CHECK_SKIPPED (6 failing case(s), first: CHANGED_NOTHING_WRITTEN) +mutants: 49 total, 49 killed, 0 survived as redundant, 0 survived as test gaps (receipt /tmp/mutrun.DPhfsQ/out.json) diff --git a/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/receipt.json b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/receipt.json new file mode 100644 index 00000000..7dfa9ce4 --- /dev/null +++ b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/receipt.json @@ -0,0 +1,93 @@ +{ + "schema": "cudapp.merge-desk.native-teardown-review.v1", + "recorded_at": "2026-10-24T06:33:10.999249+00:00", + "qualification": "DRAFT_UNQUALIFIED", + "base": "5e037c7e3d0226abadaa10af9d44bc6339109b3f", + "source": "ff5b4f9f1b13cffff2669e8207fe38cb5831366f", + "runtime_source_commit": "c80a51f8c5993c985b555ccaf280d1da0e09d171", + "host": { + "system": "Linux", + "machine": "x86_64" + }, + "related": [ + "https://github.com/aien-dev/CUDApp/issues/65", + "https://github.com/aien-dev/CUDApp/pull/67", + "https://github.com/aien-dev/CUDApp/pull/67#pullrequestreview-5637134696" + ], + "files": [ + { + "path": "native/nvrm/context.om", + "sha256": "a63b1ab13e30d26f03e022fbb586786551ced447439d666b8d108b9126330a12" + }, + { + "path": "tests/speculation/teardown-host-test.om", + "sha256": "d75d354630c0efef2062f67507e7d9f6898b618fb3abf7931ccbfb8380a8d167" + }, + { + "path": "tests/speculation/run-teardown-host.sh", + "sha256": "6e03d388f77d93d422e056da0ac65a600a4866614eb832eaddc0ec5e6cf53ced" + } + ], + "checks": [ + { + "name": "shell syntax", + "command": "sh -n tests/speculation/run-teardown-host.sh", + "result": "PASS", + "exit": 0 + }, + { + "name": "private source composition and effect guard", + "result": "PASS", + "receipt": "source-composition.json", + "native_compilation": false, + "native_execution": false + }, + { + "name": "whitespace", + "command": "git diff --check origin/experiment/27b-adaptive-sizing HEAD", + "result": "PASS", + "exit": 0 + }, + { + "name": "native fixture", + "command": "sh tests/speculation/run-teardown-host.sh /unavailable/pinned-omc", + "result": "NOT_RUN", + "exit": 77, + "reason": "Requires Linux AArch64 and the pinned runnable compiler; workspace is x86_64 with no emulator" + }, + { + "name": "required legacy host suite", + "command": "make -j2 OUT_DIR=build/teardown-review test", + "result": "FAIL", + "exit": 2, + "reason": "Existing unconditional dsb sy in src/omega_blackwell_engine.c:393,558 rejected by x86 assembler", + "log": "full-host.log" + }, + { + "name": "already-started legacy mutation target", + "result": "PASS", + "killed": 49, + "total": 49, + "scope": "Legacy target only; does not exercise the native .om repair" + }, + { + "name": "independent runtime source review", + "result": "NO_NEW_SOURCE_BLOCKER", + "scope": "Runtime c80a51f unchanged in source candidate; source-order/state-transition review, no native execution" + }, + { + "name": "GPU execution", + "result": "NOT_RUN" + }, + { + "name": "real 27B inference", + "result": "NOT_RUN" + }, + { + "name": "deployment", + "result": "NOT_RUN" + } + ], + "next_gate": "Run baseline assertion-failure and repaired PASS with the pinned compiler on Linux AArch64; retain fresh exact-source evidence and existing signed integration gates", + "remote_mutations": false +} diff --git a/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/source-composition.json b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/source-composition.json new file mode 100644 index 00000000..014e5fe0 --- /dev/null +++ b/evidence/MERGE-DESK-NATIVE-TEARDOWN-20261024/source-composition.json @@ -0,0 +1,22 @@ +{ + "result": "PASS", + "scope": "Source composition and OS-effect isolation guard only; no native compile/execution", + "source": "ff5b4f9f1b13cffff2669e8207fe38cb5831366f", + "base": "5e037c7e3d0226abadaa10af9d44bc6339109b3f", + "rows": [ + { + "arm": "before", + "unit_sha256": "10a2c7238aba855c0b44edcf12b582f4d4aaed1986609791ab3d1417c6a91ee3", + "compose_exit": 0, + "effect_guard_exit": 0, + "unbound_device_mutant_exit": 1 + }, + { + "arm": "after", + "unit_sha256": "7f14d32c61a0c18c449a0b949441ceb8d6287d6b1e00c5a17eb21a286406ed5f", + "compose_exit": 0, + "effect_guard_exit": 0, + "unbound_device_mutant_exit": 1 + } + ] +} diff --git a/evidence/speculation/README.md b/evidence/speculation/README.md new file mode 100644 index 00000000..ee429b5c --- /dev/null +++ b/evidence/speculation/README.md @@ -0,0 +1,70 @@ +# Native component evidence + +This receipt qualifies bounded host components for #63 through #66. It does not +qualify a model adapter, GPU execution, real timing, or a performance claim. +All physical 27B comparison trials are **NOT_RUN**. The issues remain open. + +The tested source is `1b5414577368e58ed562964a4e61785faad75f2c`. +The following evidence-only commit does not change its implementation or tests. +[receipt.json](receipt.json) contains ordered source inputs, source and executable +SHA-256 values, exact test outputs, and each behavioral control's literal edit. +[Reconstruction instructions](../../docs/speculation/REPRODUCE.md) pin the +compiler source, seed input and reconstructed compiler bytes. + +| Executed check | Result | +| --- | --- | +| Source-only compiler bootstrap and compiler fixpoint | PASS, compiler digest matches the pinned receipt | +| Policy tests | 106 checks, exit 0 | +| Cost collector tests | 125 checks, exit 0 | +| Paired report tests | 299 checks, exit 0 | +| Independent selection oracle | 12,801 checks, exit 0 | +| Native fixture, replay and reply checks | Three modes, 10/9/26 checks, all exits 0 | +| Invalid native inputs | Eight expected refusals, no partial stdout | +| Compiled behavioral controls | Nine compile successfully, unchanged tests reject each with exit 1 | +| Existing legacy host regression | All 33 targets PASS, exit 0 | + +The oracle uses a separately expressed two-outcome drafter expectation and +compares selection over probability, cost, memory and remaining-budget grids. +It is synthetic evidence, not a measured acceptance distribution. + +The nine behavioral controls force ordinary selection, omit epoch checks, +admit incomplete rounds, count an unconsumed token as consumed, discard host +overhead, ignore differing outputs, accept the wrong arm build, and overclaim +a finite confidence interval with five pairs, and admit absent baseline build +identities. Compile failures, crashes and +timeouts are excluded from this count. + +The checked-in `synthetic-*.bin` and `.reply` files are generated by the native +fixture program and consumed by the native replay and reply verifier. Every +record remains explicitly synthetic. They contain no model weights, private +prompts, machine configuration or actual performance observations. + +`readelf -l` found only two load segments and no interpreter or dynamic segment +in the replay executable. `strace` of the policy test observed only stdout +writes and exit after process startup. The replay observed stdin reads, one +stdout write and exit; its output was byte-identical to the retained reply. +This is bounded execution evidence, not proof about every possible input. +Raw local build, regression and syscall logs remain outside the repository. + +The legacy regression command was +`quiet-build make -j2 OUT_DIR=build/regression test`. Its result was +`CUDA++ HOST TESTS PASS (33 targets)`. Those tests exercise the existing C++ host +implementation and are reported separately from the new seeded `.om` tests. + +Development tooling included existing shell bootstrap, Git, Node.js orchestration, +readelf and strace. None is linked into, called by, or shipped as the runtime +implementation. No Python was used. An earlier exploratory source used a +reserved identifier and failed compilation; it was corrected before the frozen +source qualification above. An initial output-bypass control also failed to +compile and was replaced with a compiling comparison bypass. Neither compiler +failure is counted as passing evidence. + +Independent final-source review is pending. Full state ownership and rollback, +native 27B attachment, real 1K/32K measurements and held-out comparisons remain +the next gates in [READINESS.md](../../docs/speculation/READINESS.md). + +The original pre-review receipt is retained as [receipt-9ff84f02.json](receipt-9ff84f02.json). +A final source review then found that a differing baseline build could have an +all-zero identity. The new guard, 48 additional checks and ninth compiled +control above establish its correction. The current receipt supersedes the +original for acceptance. diff --git a/evidence/speculation/REVIEW.md b/evidence/speculation/REVIEW.md new file mode 100644 index 00000000..df61ea91 --- /dev/null +++ b/evidence/speculation/REVIEW.md @@ -0,0 +1,32 @@ +# Bounded review disposition + +The existing PR desk independently inspected the original policy and report +decision/statistics paths and replayed the policy executable after checking its +digest. That replay passed 106 checks. It published draft PR #67. This review +did not cover the complete collector, replay, model adapter or device execution; +full final-source acceptance remains pending. + +Four observations were returned and addressed in the contract: + +1. The most recent round supplies a single observed cost sample. This choice was + already described; its responsiveness and noise tradeoff are now explicit. +2. Recovery probing uses eight completed rounds. The contract now states the + eligibility rule, initial rationale and development-only tuning requirement. + The README was corrected: the counter includes all rounds, not only ordinary + rounds. This is at most one recovery probe per eight completed rounds. +3. Latency and TTFT quantiles are independently sorted. They are not attached to + the median-ratio pair. The paired ratio calculation is unchanged. +4. The unbounded interval endpoint is explicitly documented as the uint64-max + sentinel, not a measurement. + +Corrections to the review's explanatory notes: the report permits elapsed time +up to 1,000,000,000 microseconds (1,000 seconds), not one second. Each cost phase +is bounded to 1,000,000,000 microseconds; their sum is at most 6,000,000,000. +Unsupported sampling explicitly selects ordinary mode; unsupported chain-profile +types are refused. The public contract and code govern these behaviors. + +The author's subsequent final-source audit found the missing-baseline-identity +gap. Source `1b5414577368e58ed562964a4e61785faad75f2c` fixes it. The current +receipt contains 299 report checks and a ninth compiled bypass control; the +earlier receipt is retained. This later source delta needs independent review. +No review statement here qualifies the hardware experiment or closes an issue. diff --git a/evidence/speculation/model-mapping/README.md b/evidence/speculation/model-mapping/README.md new file mode 100644 index 00000000..612d5e68 --- /dev/null +++ b/evidence/speculation/model-mapping/README.md @@ -0,0 +1,36 @@ +# Real weight-file access from native Omega + +Test source: `743416c8a78a148ab4c9f5e06238725a683c5d52`. +Compiler source: Omega `d80b428c6ed9e3864fd7fc02cd7392bd4ad67f56`, +proposed in [Omega PR676](https://github.com/aien-dev/omega-mv/pull/676). + +The native Omega executable opened all66 shards referenced by the existing local +27B index. Each shard passed37 comparisons between mapped bytes and independent +file reads: the length prefix, header edges, first/last blocks and32 distributed +blocks. All2,442 comparisons passed. File identity, size and modification metadata +were checked before and after each shard. Each read-only mapping and descriptor +was released. Private checkpoint paths and per-machine records remain local. + +This tests native memory/file attachment with actual weights. It is not a complete +safetensors parser, a checksum of every byte, tensor loading onto the GPU, model +execution or inference correctness. Basic header framing checks are deliberate +preconditions for this test, not general format validation. Model numerical +identity, tensor interpretation and complete state attachment remain required. + +The test program is handwritten Omega. The existing development Node coordinator +read the already-present index, invoked the executable once per shard, and wrote +the local result record; it performs no tensor interpretation or model execution. +The executable requires only the native compiler's file, mapping and argv words. +All runs used quiet-build. No GPU operation, model service change or benchmark +timing was performed. Hardware experiment status remains NOT_RUN. + +To repeat after building the compiler, compile `tests/speculation/model-map-test.om` +to a native executable and pass one existing local shard path as its sole argument. +Success prints `MODEL_MAP_SAMPLES_PASS 37` and exits0. The complete local index +enumeration and artifact identities remain in the private experiment handoff. + +The corrected compiler at Omega078455c9 incorporates the existing branch-range +fix. Its full host and native branch gates pass. All seven experiment executables, +including this probe, rebuild byte-identically under that compiler; see +`corrected-compiler-reproduction.json`. The prior real-file run therefore remains +bound to the same executable bytes. No additional model/GPU run is implied. diff --git a/evidence/speculation/model-mapping/corrected-compiler-reproduction.json b/evidence/speculation/model-mapping/corrected-compiler-reproduction.json new file mode 100644 index 00000000..c93bd25a --- /dev/null +++ b/evidence/speculation/model-mapping/corrected-compiler-reproduction.json @@ -0,0 +1,40 @@ +{ + "compiler_sha256": "9f48f66a9ee9f6a166df615a7ab9c48bf5b06ac2ba544ac51e52e9a3d290a6c4", + "programs": [ + { + "name": "service", + "sha256": "dc0dd2a196583c5f300765ab50474cbc3bed653f2f241eedc26ad6cc5a211bda", + "identical_to_tested_binary": true + }, + { + "name": "service-test", + "sha256": "48b8d60f20b4289c90b04d37dde7df34972f40bf3aae128c7ce8ec8d7c625613", + "identical_to_tested_binary": true + }, + { + "name": "policy-test", + "sha256": "5c76fb1256abe9bbe28d447318d6779bf187422f978df91d490ec9d6fb048c12", + "identical_to_tested_binary": true + }, + { + "name": "cost-test", + "sha256": "019de1453715538737302c6d8d59cd6c8d2f1fd2211731e3c854ec3b85b0343f", + "identical_to_tested_binary": true + }, + { + "name": "report-test", + "sha256": "8c199e1d92a1c82d9c1250283bc532a0c34b3af6aafa65f505b23cb8b025af92", + "identical_to_tested_binary": true + }, + { + "name": "oracle-test", + "sha256": "d2101761e494610743ce8bffc6df2b1068a17d60bd10eafa417de06223df8fb5", + "identical_to_tested_binary": true + }, + { + "name": "model-map-test", + "sha256": "64e3eb413b399707cda7623f9782559776081aa2a0d714167f60cc60c8852b3a", + "identical_to_tested_binary": true + } + ] +} diff --git a/evidence/speculation/model-mapping/receipt.json b/evidence/speculation/model-mapping/receipt.json new file mode 100644 index 00000000..e84f6941 --- /dev/null +++ b/evidence/speculation/model-mapping/receipt.json @@ -0,0 +1,413 @@ +{ + "test_source": "743416c8a78a148ab4c9f5e06238725a683c5d52", + "compiler_source": "d80b428c6ed9e3864fd7fc02cd7392bd4ad67f56", + "compiler_sha256": "1d1aad082539399920bc6c90ff41f0a0c3a1ca3225e518fd0d259e0aeb71732d", + "test_source_sha256": "ad77916b90d002be45c9adcf5bfb026e5a169f9fd5007fda965f7faad62b7d72", + "executable_sha256": "64e3eb413b399707cda7623f9782559776081aa2a0d714167f60cc60c8852b3a", + "evidence_class": "read-only-native-file-mappings-of-existing-weight-artifacts", + "shards": 66, + "samples_per_shard": 37, + "sample_comparisons": 2442, + "rows": [ + { + "shard": 1, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 2, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 3, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 4, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 5, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 6, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 7, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 8, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 9, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 10, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 11, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 12, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 13, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 14, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 15, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 16, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 17, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 18, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 19, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 20, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 21, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 22, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 23, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 24, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 25, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 26, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 27, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 28, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 29, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 30, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 31, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 32, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 33, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 34, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 35, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 36, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 37, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 38, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 39, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 40, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 41, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 42, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 43, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 44, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 45, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 46, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 47, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 48, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 49, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 50, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 51, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 52, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 53, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 54, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 55, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 56, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 57, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 58, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 59, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 60, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 61, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 62, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 63, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 64, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 65, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + }, + { + "shard": 66, + "status": 0, + "stdout": "MODEL_MAP_SAMPLES_PASS 37\n", + "stderr": "" + } + ], + "full_file_checksum_performed": false, + "full_safetensors_validation": false, + "model_execution": false, + "hardware_trials": "NOT_RUN" +} diff --git a/evidence/speculation/native-device/host-replay.json b/evidence/speculation/native-device/host-replay.json new file mode 100644 index 00000000..50f78725 --- /dev/null +++ b/evidence/speculation/native-device/host-replay.json @@ -0,0 +1,37 @@ +{ + "compiler": "9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db", + "programs": { + "policy": { + "sha256": "5c76fb1256abe9bbe28d447318d6779bf187422f978df91d490ec9d6fb048c12", + "result": "SPECULATION_TESTS_PASS 106" + }, + "cost": { + "sha256": "019de1453715538737302c6d8d59cd6c8d2f1fd2211731e3c854ec3b85b0343f", + "result": "SPECULATION_TESTS_PASS 125" + }, + "report": { + "sha256": "8c199e1d92a1c82d9c1250283bc532a0c34b3af6aafa65f505b23cb8b025af92", + "result": "SPECULATION_TESTS_PASS 299" + }, + "oracle": { + "sha256": "d2101761e494610743ce8bffc6df2b1068a17d60bd10eafa417de06223df8fb5", + "result": "SPECULATION_TESTS_PASS 12801" + }, + "service": { + "sha256": "dc0dd2a196583c5f300765ab50474cbc3bed653f2f241eedc26ad6cc5a211bda" + }, + "client": { + "sha256": "48b8d60f20b4289c90b04d37dde7df34972f40bf3aae128c7ce8ec8d7c625613", + "result": "SPECULATION_TESTS_PASS 337" + }, + "map": { + "sha256": "1904f039f081da34430393159721df4578eb2849cb506f477e22a3b044e3b4d1" + } + }, + "model_mapping": { + "shards": 66, + "sampled_comparisons": 2442, + "result": "PASS", + "scope": "sampled file access only" + } +} diff --git a/evidence/speculation/native-device/receipt.json b/evidence/speculation/native-device/receipt.json new file mode 100644 index 00000000..3ef467d0 --- /dev/null +++ b/evidence/speculation/native-device/receipt.json @@ -0,0 +1,74 @@ +{ + "schema": 1, + "runtime_sha256": "a502e645e22f8e61bcdec6e5f09e81a75edabf2d9968fc00294bc780da73504e", + "compiler_source": "d7390d88d07dbf48cfbb0583070599c350f814d3", + "compiler_sha256": "9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db", + "canonical_nvrm_reference": "349913f17c083996680c72b32f767b225005155d", + "driver_abi": "NVIDIA580.173.02", + "admission": "explicit user authorization; confirmed shared correctness window; no timings", + "probes": { + "device": { + "result": "NATIVE_DEVICE_CONTEXT_PASS", + "source_sha256": "6c873bb21179b7fc919dda79d14d3379e8ec4b8d2286a907cfd36b1f23222343", + "translation_unit_sha256": "4cc17e341310770a7d8e6fccf0dee344bf574d139b21affe0fb96e5dd839a9d9", + "executable_sha256": "4c3b9444be63c534e3debf177bc93cdc5c5f88bdabb974a709fb32ab608344e6", + "raw_trace_sha256": "c87b412ed1125089c2636450414ebce3cff15288e22e7f2afae1c2c62e7a20ea", + "ioctl_calls": 33, + "failed_syscalls": 0, + "mmap_calls": 0, + "munmap_calls": 0 + }, + "memory": { + "result": "NATIVE_DEVICE_MEMORY_PASS", + "source_sha256": "de5b1906c5c117b05c1a11fdd466e95221cfd3d998625f04d2ad92477ee0c37a", + "translation_unit_sha256": "396b77510192c4c2aac6ced020717ba4c836396271d609c56095657c62cbadcc", + "executable_sha256": "483dd6c11c6bed28ea11f35e2fb32d0df2125af49206d7e17310f0a8a79ce248", + "raw_trace_sha256": "b349402a1bc554379644491ff9cc7ad73dba472d503ba04827d5397265e97308", + "ioctl_calls": 162, + "failed_syscalls": 0, + "mmap_calls": 24, + "munmap_calls": 12 + }, + "channel": { + "result": "NATIVE_DEVICE_CHANNEL_PASS", + "source_sha256": "4afabac5121101c9ad02595c34f3bcf167581f02eb95dab0a78b5b6c52618999", + "translation_unit_sha256": "1381cf34f492ad7367e777cf35fabf2e9d5ff56867de7aad9856335c78bf7526", + "executable_sha256": "c815d0fe433b037d8417685aad1eb4efeec162d7895059d82bc5d9f4ea1e8dc3", + "raw_trace_sha256": "5a2774785d184f56c60fe20e8c874204c143d0417eaf3e327b8d93cad1d67972", + "ioctl_calls": 162, + "failed_syscalls": 0, + "mmap_calls": 18, + "munmap_calls": 12 + }, + "submit": { + "result": "NATIVE_DEVICE_SUBMIT_PASS", + "source_sha256": "58aade7d377d11a46827b7a86104680f1671e94568ab9015ce56aea523ce337a", + "translation_unit_sha256": "5b938e1051347de85bd3ae6b357481efbfe32b75c36f8a907e70d189de556fe0", + "executable_sha256": "7facdcddc2c5ad123e52d87d8bcd7084290fc86ec3b23a3e44d6ceaf004891e9", + "raw_trace_sha256": "8744f074020964ede93dfa1fc079e29bddd976febe5716c459b1d1fb31f2e442", + "ioctl_calls": 210, + "failed_syscalls": 0, + "mmap_calls": 30, + "munmap_calls": 18 + } + }, + "checks": { + "buffer_allocations": 12, + "buffer_contexts": 3, + "buffer_bytes_compared": 3379200, + "empty_channel_cycles": 3, + "fifo_completion_writes": 2052, + "fifo_ring_wrap_contexts": 2, + "wrong_expected_payload_timeout": "PASS; fault latched and further submission refused" + }, + "excluded": "Earlier UVM scheduling-unconfirmed attempt is not qualification evidence", + "not_run": [ + "SM kernel execution", + "model inference", + "full speculative-state rollback", + "AIENOS endpoint integration", + "four-arm experiment", + "performance comparisons" + ], + "review": "independent final-source review pending" +} diff --git a/evidence/speculation/native-kernel/receipt.json b/evidence/speculation/native-kernel/receipt.json new file mode 100644 index 00000000..5ca37e26 --- /dev/null +++ b/evidence/speculation/native-kernel/receipt.json @@ -0,0 +1,74 @@ +{ + "schema": 1, + "source_commit": "0cf8cd7d5825f89955bce2dbde97f817fb18b355", + "source_sha256": { + "native/nvrm/context.om": "a502e645e22f8e61bcdec6e5f09e81a75edabf2d9968fc00294bc780da73504e", + "native/blackwell/vector.om": "011816cae457368289d21e98016db5206ec54b9a0e33944c80fb7cebaa9e7831", + "native/blackwell/launch.om": "580fe48ab61d496c5cae1567dcb9b1b895c52f5eba9e2138767bd79c3779cf0b", + "tests/speculation/native-kernel-test.om": "20b5d20f1eb3dcf96e4def3ed830007d4daa424973580b3f98f985f390133402", + "tests/speculation/native-launch-data.om": "6bf811db7351ceec3e11f6737db1837cbeb38298f04afcacfbfa3b8e5ec734c8", + "tests/speculation/vector-checks.om": "e889c195571b48033bcd9c8d9c6a8eeffddf3954265e4038789adb18e57834fa", + "tests/speculation/vector-checks-test.om": "3f88a1eacca3bd4cdd6b25ca18ebb7a650b0b559cae394aea05a0da61533a80e" + }, + "compiler_source": "d7390d88d07dbf48cfbb0583070599c350f814d3", + "compiler_sha256": "9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db", + "program_reference": "omega-mv@57f5f425:seed/sm121/vecadd.bin", + "host_differential": { + "program_sha256": "39f3dfdfc529a75a8274a27900acf4e7382b7f280a211e0412c51609f44b62a1", + "program_bytes": 512, + "descriptor_words": 2115, + "fixtures": 5, + "result": "PASS", + "oracle_source": "349913f17c083996680c72b32f767b225005155d", + "oracle_scope": "Independent C host reference only; never linked into Omega runtime or executed on GPU" + }, + "host_regression": { + "result": "VECTOR_CHECKS_HOST_PASS", + "sizes": [ + 1, + 999999, + 1000000, + 1000001, + 1048576 + ], + "unit_sha256": "f3d9dca2d4aafe31002039eb7b6bbeacd665084ca99ace75c6724195d91e0012", + "executable_sha256": "49c9ee660f06b9cd9905d9593aac87c0628c2183a99053f19697eb7c5f4e0276" + }, + "physical": { + "result": "NATIVE_SM121_VECTOR_PASS", + "exit": 0, + "admission": "confirmed shared correctness window, explicit user authorization", + "unit_sha256": "b3a36ac6455446305ea01f8fb354fc328aafafb00d2dfc921f824a577459e77b", + "executable_sha256": "e3da26b0b184df99594f28decb988683a38c3d19d3b4e6e8a189767dbc6d73cb", + "raw_trace_sha256": "5da67d795313776b49d56660fa6adb67f29953e566880ba7d229db1cedef6ca7", + "failed_syscalls": 0, + "correct_sizes": [ + 1, + 63, + 64, + 65, + 257, + 4097, + 65537, + 1048576 + ], + "wrong_math_size": 4097, + "restored_program_size": 4097, + "output_check": "every element plus up to64 untouched tail elements", + "context_cleanup": "PASS" + }, + "excluded": { + "first_attempt_exit": 104, + "cause": "CPU dynamic loop limit exceeded; independently reproduced at1000001", + "fix": "checker chunking; compiler guard unchanged" + }, + "not_run": [ + "FP8 arithmetic", + "27B inference", + "complete speculative-state rollback", + "AIENOS integration", + "four-arm comparison", + "performance measurements" + ], + "review": "independent final-source review pending" +} diff --git a/evidence/speculation/receipt-9ff84f02.json b/evidence/speculation/receipt-9ff84f02.json new file mode 100644 index 00000000..d7da1d59 --- /dev/null +++ b/evidence/speculation/receipt-9ff84f02.json @@ -0,0 +1,310 @@ +{ + "source": "9ff84f025ee1b333365a3d95e487240e086d4991", + "compiler_sha256": "191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9", + "evidence_class": "synthetic-native-host", + "hardware_trials": "NOT_RUN", + "programs": [ + { + "name": "policy-test", + "compile_exit": 0, + "source_sha256": "f50bfdc312abd37a4e0891e4bac5e37d929a0b0dc4238b21cdfab899fd9d8717", + "executable_sha256": "5c76fb1256abe9bbe28d447318d6779bf187422f978df91d490ec9d6fb048c12", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/policy-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 106\n", + "stderr": "" + }, + { + "name": "cost-test", + "compile_exit": 0, + "source_sha256": "6a20052efd03f2252128b7100da56c6f3f3aae290c98b9723f5a25612031d20d", + "executable_sha256": "019de1453715538737302c6d8d59cd6c8d2f1fd2211731e3c854ec3b85b0343f", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/costs.om", + "tests/speculation/support.om", + "tests/speculation/cost-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 125\n", + "stderr": "" + }, + { + "name": "report-test", + "compile_exit": 0, + "source_sha256": "d65545cd72c031f51a908d7b6b2cbf5351ea7f026402e1d5c6d71a4c5b7e806e", + "executable_sha256": "3f8eb6488da901caa165861acb9ff4512194ae0bb112cc0ef5b5e672626e6398", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/report.om", + "tests/speculation/support.om", + "tests/speculation/report-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 251\n", + "stderr": "" + }, + { + "name": "oracle-test", + "compile_exit": 0, + "source_sha256": "a49f8640b645ea3bf730dd9a2b8ef977ce020aec7909660362b2a07aecc4be74", + "executable_sha256": "d2101761e494610743ce8bffc6df2b1068a17d60bd10eafa417de06223df8fb5", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/oracle-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 12801\n", + "stderr": "" + }, + { + "name": "replay", + "compile_exit": 0, + "source_sha256": "ce21d37c915a2e5bddb2a293b04352874231dbfc1ca229ff3bcd28d6701c3767", + "executable_sha256": "b40c4353a0d823a17af010909c36d7ee951b725f3acaef8fd6bb94fc155f404a", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/costs.om", + "native/speculation/report.om", + "native/speculation/replay.om" + ] + }, + { + "name": "packet-fixture", + "compile_exit": 0, + "source_sha256": "f6036495f35aca5f12569ca1d0825c309b9dd66c99a224b99663c7e56363a19d", + "executable_sha256": "a0aca5564fb12bbfb23fa4188278f9a23c18c857f1127aa225aff725e4fbddcc", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/packet-fixture.om" + ] + }, + { + "name": "reply-test", + "compile_exit": 0, + "source_sha256": "5cf249113db3d54a3b24f0120c52de2a7f66a068fb846a05a3166d65d17733ac", + "executable_sha256": "e68a13a6614bfabe41db9923c8cd69b7e98cd1d106d9eb5e88fb37d672ec1102", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/reply-test.om" + ] + } + ], + "roundtrips": [ + { + "mode": 1, + "fixture_exit": 0, + "replay_exit": 0, + "check_exit": 0, + "input_sha256": "ca2daf889fdee9cf313dacedc162a0e465fd58672a74728918077f8b1fa580c3", + "reply_sha256": "5397c56d626b39488760d3943a9ae83f4e670df7c460eba1e4daa91f738190c5", + "check_stdout": "SPECULATION_TESTS_PASS 10\n" + }, + { + "mode": 2, + "fixture_exit": 0, + "replay_exit": 0, + "check_exit": 0, + "input_sha256": "672b2048a1c62a06b150a277afb993e13ba944f012de1d5bc2a2b60dc72de440", + "reply_sha256": "a5863a4e6de0229333d026d55cfab60cb69c8d2ee87332b02840263ec08625c2", + "check_stdout": "SPECULATION_TESTS_PASS 9\n" + }, + { + "mode": 3, + "fixture_exit": 0, + "replay_exit": 0, + "check_exit": 0, + "input_sha256": "b83a0512bba1fe7630fe6ec06169506ff08be0b3156c0f38412fd41a402453cf", + "reply_sha256": "69725222d2e5404a999b96c2f450620c7c12a872b7d4d98fe094ef32fb679888", + "check_stdout": "SPECULATION_TESTS_PASS 26\n" + } + ], + "negative_inputs": [ + { + "name": "empty", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "unaligned", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "truncated", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "oversized", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "bad-magic", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "bad-version", + "expected_exit": 69, + "exit": 69, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "unknown-operation", + "expected_exit": 77, + "exit": 77, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "synthetic-refuses-device", + "expected_exit": 69, + "exit": 69, + "stdout_bytes": 0, + "stderr": "" + } + ], + "behavioral_controls": [ + { + "name": "mutant-always-ordinary", + "compile_exit": 0, + "source_sha256": "08eb917be4bd5aa73d28425a8700c0294e8abfe820324adfb5c5982eca43031c", + "executable_sha256": "43b60a0e2c0adff048a1d7c8a19e544115755c4a3e528f16edfa549a4a01a470", + "test": "policy-test", + "before": "ret srank mode fixed", + "after": "ret srank 0 fixed", + "expected_exit": 1, + "exit": 1, + "stdout": "3\n4\n5\n8\n9\n10\n11\n13\n14\n17\n27\n30\n48\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n86\n90\n91\n94\n95\n98\n99\n101\n105\n106\nSPECULATION_TESTS_FAIL 46\n", + "stderr": "" + }, + { + "name": "mutant-ignore-epoch", + "compile_exit": 0, + "source_sha256": "fcf3dab21409d42849eaf13725d0a77499f9b4986a57b3762e884481b6530256", + "executable_sha256": "f573b6e397ad3d278a0f7f1c0548b328e91cee2a6b2dd924863df41660e4336e", + "test": "policy-test", + "before": "if ne epoch get sprofile 1\nret 69\nend\nif ne epoch get sstate 10\nret 69\nend", + "after": "note mutant omits both epoch checks", + "expected_exit": 1, + "exit": 1, + "stdout": "41\n42\n43\n44\n45\nSPECULATION_TESTS_FAIL 5\n", + "stderr": "" + }, + { + "name": "mutant-unfinished-round", + "compile_exit": 0, + "source_sha256": "ad4473145fbfe26b58d1e686be5a7fc9125aba64051cf2a953e54cb4a32ac279", + "executable_sha256": "623a5b51bef8414f186ae02850490eb009277e8bbda745ce6d58426db9f70341", + "test": "policy-test", + "before": "if ne complete 1\nret 75\nend", + "after": "note mutant admits incomplete round", + "expected_exit": 1, + "exit": 1, + "stdout": "78\n79\n80\n81\n84\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\nSPECULATION_TESTS_FAIL 15\n", + "stderr": "" + }, + { + "name": "mutant-consumed-state", + "compile_exit": 0, + "source_sha256": "e6ee0d7fd2a2ef1e250468ba0b7cf8c4eeb57e15ab510bea8a62279cffafda4b", + "executable_sha256": "6bdf754e1a5074b74310f26956d7669068b3f1c37987346a7aa238af0887dff0", + "test": "policy-test", + "before": "used = accepted", + "after": "used = commit_n", + "expected_exit": 1, + "exit": 1, + "stdout": "10\n14\n84\n86\n87\n88\n94\n95\nSPECULATION_TESTS_FAIL 8\n", + "stderr": "" + }, + { + "name": "mutant-ignore-host-gap", + "compile_exit": 0, + "source_sha256": "a14ed5772982c80309fe450b5557724506ec1a2ca3397e168cff6578dedc206f", + "executable_sha256": "e20f261d21a4008dc5a083b63bfafa4394f60b3bf953ee98bb98e93c41830c5b", + "test": "cost-test", + "before": "put csum p add get csum p sub get cobs 10 sum", + "after": "put csum p get csum p", + "expected_exit": 1, + "exit": 1, + "stdout": "40\n42\n51\nSPECULATION_TESTS_FAIL 3\n", + "stderr": "" + }, + { + "name": "mutant-ignore-output", + "compile_exit": 0, + "source_sha256": "fcb45510f360d59cb1ad60740f1fb1f1d57b2fd33d712a1deab022aef17b56fc", + "executable_sha256": "db6c59ad3b863c56eb396e6367754e193d519ac30cf21af918a50cd058e01408", + "test": "report-test", + "before": "right = get praw add add row 3 i\nif ne left right", + "after": "right = get praw add add row 3 i\nif ne left left", + "expected_exit": 1, + "exit": 1, + "stdout": "77\n78\nSPECULATION_TESTS_FAIL 2\n", + "stderr": "" + }, + { + "name": "mutant-wrong-arm", + "compile_exit": 0, + "source_sha256": "f1fd4cf6e41dcff72bce0332ec788dfb4d1a0b36df511e0694fe733654519563", + "executable_sha256": "f9efefe91d545d114e4c9ff79a752c1e659b32587f129e1760a7be87e02c9282", + "test": "report-test", + "before": "if ne get pobs add i 24 expected\nret 69\nend", + "after": "note mutant accepts wrong arm build", + "expected_exit": 1, + "exit": 1, + "stdout": "233\nSPECULATION_TESTS_FAIL 1\n", + "stderr": "" + }, + { + "name": "mutant-overclaim-five", + "compile_exit": 0, + "source_sha256": "505b00aee704b17e85dd7d0c0a58d0450e29f0b9f44132b969c0c02ba6268cd3", + "executable_sha256": "13f56585276df739ddb978c9d891bd3a465c394b3454275fa8e5f53006435517", + "test": "report-test", + "before": "ret k\nend\nfn pmeasure", + "after": "ret 1\nend\nfn pmeasure", + "expected_exit": 1, + "exit": 1, + "stdout": "102\n103\n104\n105\n108\nSPECULATION_TESTS_FAIL 5\n", + "stderr": "" + } + ], + "reconstruction": { + "bridge_revision": "0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9", + "seed_input": "29b12760f4c962606411d6bf25032aedef063301", + "bootstrap_exit": 0, + "bootstrap_result": "PASS source-only seed bootstrap and compiler fixpoint", + "development_tools": [ + "git", + "existing shell bootstrap", + "cat", + "Node.js orchestration", + "readelf", + "strace", + "quiet-build", + "timeout" + ], + "product_runtime": "freestanding seeded Omega ELF" + } +} diff --git a/evidence/speculation/receipt.json b/evidence/speculation/receipt.json new file mode 100644 index 00000000..559eb335 --- /dev/null +++ b/evidence/speculation/receipt.json @@ -0,0 +1,323 @@ +{ + "source": "1b5414577368e58ed562964a4e61785faad75f2c", + "compiler_sha256": "191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9", + "evidence_class": "synthetic-native-host", + "hardware_trials": "NOT_RUN", + "programs": [ + { + "name": "policy-test", + "compile_exit": 0, + "source_sha256": "f50bfdc312abd37a4e0891e4bac5e37d929a0b0dc4238b21cdfab899fd9d8717", + "executable_sha256": "5c76fb1256abe9bbe28d447318d6779bf187422f978df91d490ec9d6fb048c12", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/policy-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 106\n", + "stderr": "" + }, + { + "name": "cost-test", + "compile_exit": 0, + "source_sha256": "6a20052efd03f2252128b7100da56c6f3f3aae290c98b9723f5a25612031d20d", + "executable_sha256": "019de1453715538737302c6d8d59cd6c8d2f1fd2211731e3c854ec3b85b0343f", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/costs.om", + "tests/speculation/support.om", + "tests/speculation/cost-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 125\n", + "stderr": "" + }, + { + "name": "report-test", + "compile_exit": 0, + "source_sha256": "616ab6a8cc4af935f51a93ac18572fbefbdaa8d7d6f9fcae631d611154189848", + "executable_sha256": "8c199e1d92a1c82d9c1250283bc532a0c34b3af6aafa65f505b23cb8b025af92", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/report.om", + "tests/speculation/support.om", + "tests/speculation/report-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 299\n", + "stderr": "" + }, + { + "name": "oracle-test", + "compile_exit": 0, + "source_sha256": "a49f8640b645ea3bf730dd9a2b8ef977ce020aec7909660362b2a07aecc4be74", + "executable_sha256": "d2101761e494610743ce8bffc6df2b1068a17d60bd10eafa417de06223df8fb5", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/oracle-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 12801\n", + "stderr": "" + }, + { + "name": "replay", + "compile_exit": 0, + "source_sha256": "311a451f30924ac34189e020c12e9964d52d790af3018de400bfd193be6b6055", + "executable_sha256": "60600a1816ede70401ce53895c040297b080ff8ade82d4e93c193fcfba58b90e", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/costs.om", + "native/speculation/report.om", + "native/speculation/replay.om" + ] + }, + { + "name": "packet-fixture", + "compile_exit": 0, + "source_sha256": "f6036495f35aca5f12569ca1d0825c309b9dd66c99a224b99663c7e56363a19d", + "executable_sha256": "a0aca5564fb12bbfb23fa4188278f9a23c18c857f1127aa225aff725e4fbddcc", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/packet-fixture.om" + ] + }, + { + "name": "reply-test", + "compile_exit": 0, + "source_sha256": "5cf249113db3d54a3b24f0120c52de2a7f66a068fb846a05a3166d65d17733ac", + "executable_sha256": "e68a13a6614bfabe41db9923c8cd69b7e98cd1d106d9eb5e88fb37d672ec1102", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/reply-test.om" + ] + } + ], + "roundtrips": [ + { + "mode": 1, + "fixture_exit": 0, + "replay_exit": 0, + "check_exit": 0, + "input_sha256": "ca2daf889fdee9cf313dacedc162a0e465fd58672a74728918077f8b1fa580c3", + "reply_sha256": "5397c56d626b39488760d3943a9ae83f4e670df7c460eba1e4daa91f738190c5", + "check_stdout": "SPECULATION_TESTS_PASS 10\n" + }, + { + "mode": 2, + "fixture_exit": 0, + "replay_exit": 0, + "check_exit": 0, + "input_sha256": "672b2048a1c62a06b150a277afb993e13ba944f012de1d5bc2a2b60dc72de440", + "reply_sha256": "a5863a4e6de0229333d026d55cfab60cb69c8d2ee87332b02840263ec08625c2", + "check_stdout": "SPECULATION_TESTS_PASS 9\n" + }, + { + "mode": 3, + "fixture_exit": 0, + "replay_exit": 0, + "check_exit": 0, + "input_sha256": "b83a0512bba1fe7630fe6ec06169506ff08be0b3156c0f38412fd41a402453cf", + "reply_sha256": "69725222d2e5404a999b96c2f450620c7c12a872b7d4d98fe094ef32fb679888", + "check_stdout": "SPECULATION_TESTS_PASS 26\n" + } + ], + "negative_inputs": [ + { + "name": "empty", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "unaligned", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "truncated", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "oversized", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "bad-magic", + "expected_exit": 65, + "exit": 65, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "bad-version", + "expected_exit": 69, + "exit": 69, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "unknown-operation", + "expected_exit": 77, + "exit": 77, + "stdout_bytes": 0, + "stderr": "" + }, + { + "name": "synthetic-refuses-device", + "expected_exit": 69, + "exit": 69, + "stdout_bytes": 0, + "stderr": "" + } + ], + "behavioral_controls": [ + { + "name": "mutant-always-ordinary", + "compile_exit": 0, + "source_sha256": "08eb917be4bd5aa73d28425a8700c0294e8abfe820324adfb5c5982eca43031c", + "executable_sha256": "43b60a0e2c0adff048a1d7c8a19e544115755c4a3e528f16edfa549a4a01a470", + "test": "policy-test", + "before": "ret srank mode fixed", + "after": "ret srank 0 fixed", + "expected_exit": 1, + "exit": 1, + "stdout": "3\n4\n5\n8\n9\n10\n11\n13\n14\n17\n27\n30\n48\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n86\n90\n91\n94\n95\n98\n99\n101\n105\n106\nSPECULATION_TESTS_FAIL 46\n", + "stderr": "" + }, + { + "name": "mutant-ignore-epoch", + "compile_exit": 0, + "source_sha256": "fcf3dab21409d42849eaf13725d0a77499f9b4986a57b3762e884481b6530256", + "executable_sha256": "f573b6e397ad3d278a0f7f1c0548b328e91cee2a6b2dd924863df41660e4336e", + "test": "policy-test", + "before": "if ne epoch get sprofile 1\nret 69\nend\nif ne epoch get sstate 10\nret 69\nend", + "after": "note mutant omits both epoch checks", + "expected_exit": 1, + "exit": 1, + "stdout": "41\n42\n43\n44\n45\nSPECULATION_TESTS_FAIL 5\n", + "stderr": "" + }, + { + "name": "mutant-unfinished-round", + "compile_exit": 0, + "source_sha256": "ad4473145fbfe26b58d1e686be5a7fc9125aba64051cf2a953e54cb4a32ac279", + "executable_sha256": "623a5b51bef8414f186ae02850490eb009277e8bbda745ce6d58426db9f70341", + "test": "policy-test", + "before": "if ne complete 1\nret 75\nend", + "after": "note mutant admits incomplete round", + "expected_exit": 1, + "exit": 1, + "stdout": "78\n79\n80\n81\n84\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\nSPECULATION_TESTS_FAIL 15\n", + "stderr": "" + }, + { + "name": "mutant-consumed-state", + "compile_exit": 0, + "source_sha256": "e6ee0d7fd2a2ef1e250468ba0b7cf8c4eeb57e15ab510bea8a62279cffafda4b", + "executable_sha256": "6bdf754e1a5074b74310f26956d7669068b3f1c37987346a7aa238af0887dff0", + "test": "policy-test", + "before": "used = accepted", + "after": "used = commit_n", + "expected_exit": 1, + "exit": 1, + "stdout": "10\n14\n84\n86\n87\n88\n94\n95\nSPECULATION_TESTS_FAIL 8\n", + "stderr": "" + }, + { + "name": "mutant-ignore-host-gap", + "compile_exit": 0, + "source_sha256": "a14ed5772982c80309fe450b5557724506ec1a2ca3397e168cff6578dedc206f", + "executable_sha256": "e20f261d21a4008dc5a083b63bfafa4394f60b3bf953ee98bb98e93c41830c5b", + "test": "cost-test", + "before": "put csum p add get csum p sub get cobs 10 sum", + "after": "put csum p get csum p", + "expected_exit": 1, + "exit": 1, + "stdout": "40\n42\n51\nSPECULATION_TESTS_FAIL 3\n", + "stderr": "" + }, + { + "name": "mutant-ignore-output", + "compile_exit": 0, + "source_sha256": "ad7e2061a8511ffcedc4c9952b9fe2e13cffe731e2793fc1002d286ea16d1d9b", + "executable_sha256": "670740c4a4c0cfa8a54c77e4e404c1935e8de5373820ce2600a42da832c49618", + "test": "report-test", + "before": "right = get praw add add row 3 i\nif ne left right", + "after": "right = get praw add add row 3 i\nif ne left left", + "expected_exit": 1, + "exit": 1, + "stdout": "77\n78\nSPECULATION_TESTS_FAIL 2\n", + "stderr": "" + }, + { + "name": "mutant-wrong-arm", + "compile_exit": 0, + "source_sha256": "ae6b60cb73dc6162cc9f6805d4fb9ad41abca1e8619ff14eab912b1eba3786b2", + "executable_sha256": "7320add81dafe3f29891e219148c7b839984ebd34bd6aa830c4259dc9c317972", + "test": "report-test", + "before": "if ne get pobs add i 24 expected\nret 69\nend", + "after": "note mutant accepts wrong arm build", + "expected_exit": 1, + "exit": 1, + "stdout": "233\nSPECULATION_TESTS_FAIL 1\n", + "stderr": "" + }, + { + "name": "mutant-overclaim-five", + "compile_exit": 0, + "source_sha256": "16c2b31e36d22c3d78b5a5a513269587f02dd948b8df61f65c293ef826655a67", + "executable_sha256": "42e585692bae7eae1d05dc47b152ca2ab1611533fda5f420fcf56169b48bdd4b", + "test": "report-test", + "before": "ret k\nend\nfn pmeasure", + "after": "ret 1\nend\nfn pmeasure", + "expected_exit": 1, + "exit": 1, + "stdout": "102\n103\n104\n105\n108\nSPECULATION_TESTS_FAIL 5\n", + "stderr": "" + }, + { + "name": "mutant-missing-base-identity", + "test": "report-test", + "before": "if eq nonzero 0\nret 69\nend\nend\nfor i ulong 32", + "after": "note mutant accepts missing base identities\nend\nfor i ulong 32", + "expected_exit": 1, + "compile_exit": 0, + "source_sha256": "498d3346a519bb0c26d359854deb1d72a297e4689f4b77f9ad2c670655936f71", + "executable_sha256": "ee572737325a7a9907da6ff9e7f7498ac2fef804b8ddc19616b9da6b0a6f5240", + "exit": 1, + "stdout": "263\n266\n269\n272\n293\n296\nSPECULATION_TESTS_FAIL 6\n", + "stderr": "" + } + ], + "reconstruction": { + "bridge_revision": "0fc7d8662cb799e7c206b17c18ea4c3ec2b8fea9", + "seed_input": "29b12760f4c962606411d6bf25032aedef063301", + "bootstrap_exit": 0, + "bootstrap_result": "PASS source-only seed bootstrap and compiler fixpoint", + "development_tools": [ + "git", + "existing shell bootstrap", + "cat", + "Node.js orchestration", + "readelf", + "strace", + "quiet-build", + "timeout" + ], + "product_runtime": "freestanding seeded Omega ELF" + } +} diff --git a/evidence/speculation/service/README.md b/evidence/speculation/service/README.md new file mode 100644 index 00000000..214fe848 --- /dev/null +++ b/evidence/speculation/service/README.md @@ -0,0 +1,47 @@ +# Persistent policy process qualification + +Functional and test source: `b5eaf26f2bc590fe6b0d54a793b43827079ed624`. +The source was exported from that immutable revision before compilation. +[receipt.json](receipt.json) records source ordering, compiler and executable +digests, exits, exact test outputs, and each compiled control's literal edit. + +- Native parent/child pipe integration: **337 checks, exit 0**. +- Six deliberately broken service implementations compiled and were each + rejected by the unchanged native integration test with exit 1. +- Existing policy 106, cost collector 125, paired reporter 299 and independent + oracle 12,801 checks also passed under this native-host compiler profile. +- Existing upstream host qualification passed nine positive groups, 41 refusal + cases and 70 original fixture comparisons after source-only reconstruction. + +The six controls bypass request sequencing, bypass protocol version, admit +synthetic data when device evidence is required, silently accept EOF during a +request, retain an old response payload after refusal, and report zero elapsed +policy time. Compile errors, crashes and timeouts do not count as rejection. + +The test starts eight native worker processes and checks initialization, +cold/warm requests, adaptive selection, incomplete observations, pending-token +acknowledgement, context mismatch, cancellation, EOS, shutdown, truncated headers +and bodies, wrong sequences, wrong versions, bad lengths and unsupported commands. +It validates that the service's elapsed time is positive and no larger than +the parent's measured complete exchange. These timing assertions are process +correctness checks; they are not a performance benchmark. + +A traced replay also passed 337 checks. The syscall summary shows eight child +creations and reaps, nine native executable launches including the test client, +pipe reads/writes, polling, descriptor operations and monotonic clock calls. +`readelf` finds two load segments and no interpreter/dynamic dependency in the +worker. Raw development traces remain local; no model or GPU was involved. + +The initial partial compiler export compared zero original fixtures because the +upstream gate obtains its fixture list from the Git index. That attempt is not +counted as a complete qualification. Restoring the pinned fixture paths and their +index produced the required 70 comparisons. Both local logs are retained. + +See [SERVICE.md](../../../docs/speculation/SERVICE.md) for reconstruction and the +wire contract. Existing shell and Node.js development orchestration are disclosed; +the delivered service and integration test are handwritten seeded Omega. No new +compiler implementation, shell runtime, C/Rust connection or Python was added. + +The real 27B engine connection, its state correctness, hardware cost curves, +full comparison, and independent final-source review remain pending. This receipt +does not close #63, #64, #65 or #66 and does not imply a speedup. diff --git a/evidence/speculation/service/receipt.json b/evidence/speculation/service/receipt.json new file mode 100644 index 00000000..e69a3898 --- /dev/null +++ b/evidence/speculation/service/receipt.json @@ -0,0 +1,180 @@ +{ + "source": "b5eaf26f2bc590fe6b0d54a793b43827079ed624", + "compiler_source": "f0499f415571bdd7496b6de391096915e78f7556", + "compiler_sha256": "e5d60db892c8f21cc8c9128af26d8bded0e96d7f92946f5a549397c43a872649", + "evidence_class": "native-host-processes-with-synthetic-policy-data", + "hardware_trials": "NOT_RUN", + "programs": [ + { + "name": "service", + "compile_exit": 0, + "source_sha256": "25092c9bb231907e314dd7990438f5c955b2fd021718d23fdefaca9ede576dde", + "executable_sha256": "dc0dd2a196583c5f300765ab50474cbc3bed653f2f241eedc26ad6cc5a211bda", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/service.om" + ] + }, + { + "name": "service-test", + "compile_exit": 0, + "source_sha256": "2ed63ec39be291809d0d8e9d77a22a4b64a177885437f62f269de5ce519425b9", + "executable_sha256": "48b8d60f20b4289c90b04d37dde7df34972f40bf3aae128c7ce8ec8d7c625613", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/service-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 337\n", + "stderr": "" + }, + { + "name": "policy-test", + "compile_exit": 0, + "source_sha256": "f50bfdc312abd37a4e0891e4bac5e37d929a0b0dc4238b21cdfab899fd9d8717", + "executable_sha256": "5c76fb1256abe9bbe28d447318d6779bf187422f978df91d490ec9d6fb048c12", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/policy-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 106\n", + "stderr": "" + }, + { + "name": "cost-test", + "compile_exit": 0, + "source_sha256": "6a20052efd03f2252128b7100da56c6f3f3aae290c98b9723f5a25612031d20d", + "executable_sha256": "019de1453715538737302c6d8d59cd6c8d2f1fd2211731e3c854ec3b85b0343f", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/costs.om", + "tests/speculation/support.om", + "tests/speculation/cost-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 125\n", + "stderr": "" + }, + { + "name": "report-test", + "compile_exit": 0, + "source_sha256": "616ab6a8cc4af935f51a93ac18572fbefbdaa8d7d6f9fcae631d611154189848", + "executable_sha256": "8c199e1d92a1c82d9c1250283bc532a0c34b3af6aafa65f505b23cb8b025af92", + "ordered_inputs": [ + "native/speculation/policy.om", + "native/speculation/report.om", + "tests/speculation/support.om", + "tests/speculation/report-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 299\n", + "stderr": "" + }, + { + "name": "oracle-test", + "compile_exit": 0, + "source_sha256": "a49f8640b645ea3bf730dd9a2b8ef977ce020aec7909660362b2a07aecc4be74", + "executable_sha256": "d2101761e494610743ce8bffc6df2b1068a17d60bd10eafa417de06223df8fb5", + "ordered_inputs": [ + "native/speculation/policy.om", + "tests/speculation/support.om", + "tests/speculation/oracle-test.om" + ], + "exit": 0, + "stdout": "SPECULATION_TESTS_PASS 12801\n", + "stderr": "" + } + ], + "controls": [ + { + "name": "mutant-sequence", + "compile_exit": 0, + "source_sha256": "ecd2bda2154a5a81e4b0810f771353ab0db81a4652fdb4ab217a2b1bde7cc5fa", + "executable_sha256": "5774b4e0f521edc52063c4feeed3ff35c69ed566642c42cba32a843fc1442cd0", + "before": "if ne wget 3 get wstate 1", + "after": "if ne wget 3 wget 3", + "test": "service-test", + "expected_exit": 1, + "exit": 1, + "stdout": "271\n274\nSPECULATION_TESTS_FAIL 2\n", + "stderr": "" + }, + { + "name": "mutant-version", + "compile_exit": 0, + "source_sha256": "0105d5b8aac51454727e20c22a88126394360b2b891d47252fe0d6198bd01156", + "executable_sha256": "58f5213ef0da1ab26bdbb354d7d7470aac8aa463710b455259bbad56452a065d", + "before": "if ne wget 1 1", + "after": "if ne wget 1 wget 1", + "test": "service-test", + "expected_exit": 1, + "exit": 1, + "stdout": "285\n288\nSPECULATION_TESTS_FAIL 2\n", + "stderr": "" + }, + { + "name": "mutant-device-class", + "compile_exit": 0, + "source_sha256": "2e0b12692c5fb1609e4c830f861912c4f01a14d21ccea7955cf1249dd84d3c92", + "executable_sha256": "795d80ae0c0753d48854468e637c018739e2e261bd0e50299f46b822c0e25d1d", + "before": "if eq wget 6 1\nif ne get sprofile 4 2\nret 69\nend\nend", + "after": "note mutant admits synthetic device initialization", + "test": "service-test", + "expected_exit": 1, + "exit": 1, + "stdout": "36\n48\n60\n108\n109\n110\n111\n123\n147\n148\n149\n150\n163\n175\n199\n200\nSPECULATION_TESTS_FAIL 16\n", + "stderr": "" + }, + { + "name": "mutant-active-eof", + "compile_exit": 0, + "source_sha256": "2f1f0b58a0a705393d9a6aba7decd67b51daa7cfecabfc892571d68487d263ba", + "executable_sha256": "bc3c84708ddfa453c7fd60b873999f0770b44e3a94e4e1c1f791380f46dca87a", + "before": "if eq v 1\nif eq get wstate 0 2\nret 75", + "after": "if eq v 1\nif eq get wstate 0 2\nret 0", + "test": "service-test", + "expected_exit": 1, + "exit": 1, + "stdout": "316\nSPECULATION_TESTS_FAIL 1\n", + "stderr": "" + }, + { + "name": "mutant-stale-payload", + "compile_exit": 0, + "source_sha256": "f7c994de2bc271206910d060c3c790bac5d1b1904f28916431910c92c03a3ccc", + "executable_sha256": "d869cbc0eb32ffb7059718d1e3dcd7de311425b4c060d6f82c35477ee0f052b8", + "before": "put wstate 2 0\nif eq op 1", + "after": "note mutant retains stale response payload\nif eq op 1", + "test": "service-test", + "expected_exit": 1, + "exit": 1, + "stdout": "121\n133\n160\n183\nSPECULATION_TESTS_FAIL 4\n", + "stderr": "" + }, + { + "name": "mutant-zero-clock", + "compile_exit": 0, + "source_sha256": "337c7667e8bbcf82e998f89e7565474bbbe61b033af530573bdebeb508dccd5b", + "executable_sha256": "f9971db289eb959440c32a0ef63ce9e6efa4ecf608f608c5845d0264d9206ed2", + "before": "wput 6 ulong elapsed", + "after": "wput 6 0", + "test": "service-test", + "expected_exit": 1, + "exit": 1, + "stdout": "11\n22\n34\n46\n58\n69\n81\n93\n105\n119\n131\n143\n158\n170\n181\n193\n205\n216\n227\n239\n251\n262\n298\n309\nSPECULATION_TESTS_FAIL 24\n", + "stderr": "" + } + ], + "host_qualification": { + "positive_groups": 9, + "negative_controls": 41, + "original_fixtures": 70, + "exit": 0, + "raw_log_sha256": "ba7e19fbc9570816f6f9d3959aadc56a5faac1edde1e520cc8b928e66979f2fd", + "initial_partial_export_fixture_count": 0, + "initial_partial_export_qualifies": false + } +} diff --git a/evidence/speculation/synthetic-1.bin b/evidence/speculation/synthetic-1.bin new file mode 100644 index 00000000..bd3fe530 Binary files /dev/null and b/evidence/speculation/synthetic-1.bin differ diff --git a/evidence/speculation/synthetic-1.reply b/evidence/speculation/synthetic-1.reply new file mode 100644 index 00000000..029be718 Binary files /dev/null and b/evidence/speculation/synthetic-1.reply differ diff --git a/evidence/speculation/synthetic-2.bin b/evidence/speculation/synthetic-2.bin new file mode 100644 index 00000000..fc89b709 Binary files /dev/null and b/evidence/speculation/synthetic-2.bin differ diff --git a/evidence/speculation/synthetic-2.reply b/evidence/speculation/synthetic-2.reply new file mode 100644 index 00000000..a63c6a71 Binary files /dev/null and b/evidence/speculation/synthetic-2.reply differ diff --git a/evidence/speculation/synthetic-3.bin b/evidence/speculation/synthetic-3.bin new file mode 100644 index 00000000..b7f6f777 Binary files /dev/null and b/evidence/speculation/synthetic-3.bin differ diff --git a/evidence/speculation/synthetic-3.reply b/evidence/speculation/synthetic-3.reply new file mode 100644 index 00000000..662c690d Binary files /dev/null and b/evidence/speculation/synthetic-3.reply differ diff --git a/native/blackwell/launch.om b/native/blackwell/launch.om new file mode 100644 index 00000000..fb70bee4 --- /dev/null +++ b/native/blackwell/launch.om @@ -0,0 +1,288 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Native VECTOR_1D launch ABI continued from canonical CUDApp349913f1. +note QMD, driver constant template and packet sequence: omega_blackwell_qmd.c/engine.c. +global gbmem long 8 +global gbmax uint 1 +global gbq0 uint 96 +global gbq1 uint 96 +global gbcb uint 224 +global gbargs uint 7 +global gbcmd uchar 65536 +global gbused ulong 1 +fn gblo v ulong to uint +ret uint and v 4294967295 +end +fn gbhi v ulong to uint +ret uint shr v 32 +end +fn gbemit w uint to void +for i ulong 4 +put gbcmd get gbused 0 uchar and shr w mul i 8 255 +put gbused 0 add get gbused 0 1 +end +end +fn gbmth subc uint method uint count uint to void +gbemit or or or uint 536870912 shl count 16 shl subc 13 shr method 2 +end +fn gbptr va ulong to void +gbemit gbhi va +gbemit gblo va +end +fn gbdriver cb ulong to void +for i ulong 224 +put gbcb i 0 +end +note Nonzero words of the existing observed driver template, not a new inferred ABI. +put gbcb 0 641859584 +put gbcb 1 3 +put gbcb 48 2499697920 +put gbcb 49 3893478299 +put gbcb 62 1048575 +put gbcb 64 536870912 +put gbcb 65 3 +put gbcb 66 570425344 +put gbcb 67 3 +put gbcb 68 gbhi cb +put gbcb 69 gblo cb +put gbcb 70 604045312 +put gbcb 71 3 +put gbcb 80 1 +put gbcb 82 67158016 +put gbcb 83 2 +put gbcb 91 1024 +put gbcb 108 79311560 +put gbcb 114 1 +put gbcb 118 288 +put gbcb 126 632711424 +put gbcb 127 3 +for i ulong 3 +put gbcb add 128 i 1 +put gbcb add 132 i 1065353216 +end +put gbcb 135 1024 +for i ulong 4 +put gbcb add 136 i 1 +end +put gbcb 148 79311560 +put gbcb 154 1 +put gbcb 158 288 +put gbcb 166 632711424 +put gbcb 167 3 +for i ulong 3 +put gbcb add 168 i 1 +put gbcb add 172 i 1065353216 +end +put gbcb 175 1024 +for i ulong 4 +put gbcb add 176 i 1 +end +put gbcb 180 48 +put gbcb 183 16777216 +put gbcb 185 59840 +put gbcb 189 59840 +put gbcb 190 16777216 +put gbcb 191 59839 +put gbcb 210 gbhi add cb 896 +put gbcb 211 gblo add cb 896 +put gbcb 212 gbhi add cb 924 +put gbcb 213 gblo add cb 924 +put gbcb 216 64 +put gbcb 217 1 +put gbcb 218 1 +put gbcb 220 1 +put gbcb 221 1 +put gbcb 222 1 +put gbcb 223 16776640 +end +fn gbqmd n uint to void +q = mapaddr get gbmem 2 +cb = mapaddr get gbmem 1 +code = mapaddr get gbmem 4 +scratch = add q 16384 +for i ulong 96 +put gbq0 i 0 +put gbq1 i 0 +end +put gbq0 4 8388610 +put gbq0 10 2293760 +put gbq0 12 gblo shr add q 4096 8 +put gbq0 14 5243392 +put gbq0 34 65537 +put gbq0 35 2049 +put gbq1 4 20905984 +put gbq1 9 3 +put gbq1 10 1638400 +put gbq1 12 gblo shr q 8 +put gbq1 14 793772964 +put gbq1 15 gblo add q 8192 +put gbq1 16 gbhi add q 8192 +put gbq1 17 6 +put gbq1 19 2172715008 +put gbq1 20 56 +put gbq1 22 67108864 +put gbq1 32 gblo shr code 4 +put gbq1 33 or uint and shr code 36 2097151 20971520 +put gbq1 34 65600 +put gbq1 35 135169 +put gbq1 36 78923784 +put gbq1 39 div add n 63 64 +put gbq1 40 1 +put gbq1 41 1 +put gbq1 42 gblo shr cb 6 +put gbq1 43 or uint and shr cb 38 524287 33554432 +put gbq1 44 gblo shr scratch 6 +put gbq1 45 or uint and shr scratch 38 524287 75497472 +put gbq1 52 gblo shr add cb 768 6 +put gbq1 53 or uint and shr add cb 768 38 524287 8388608 +put gbq1 56 gblo shr scratch 6 +put gbq1 57 or uint and shr scratch 38 524287 2147483648 +put gbq1 58 271581201 +put gbq1 59 gblo shr code 8 +gbdriver cb +for i ulong 3 +va = mapaddr get gbmem add i 5 +put gbargs mul i 2 gblo va +put gbargs add mul i 2 1 gbhi va +end +put gbargs 6 n +end +fn gbsetup to void +gbemit 536944737 +gbemit 52928 +gbemit 536944786 +gbemit 1 +gbemit 536944808 +gbemit 15 +gbemit 536946013 +gbemit 3 +gbemit 536946014 +gbemit 536870912 +gbemit 536946015 +gbemit 1048575 +gbemit 536946007 +gbemit 3 +gbemit 536946008 +gbemit 570425344 +gbemit 536946009 +gbemit 0 +end +fn gbdma va ulong count uint to void +gbmth 1 392 2 +gbptr va +gbmth 1 384 2 +gbemit mul count 4 +gbemit 1 +gbmth 1 432 1 +gbemit 65 +gbemit or or uint 1610621037 shl count 16 0 +end +fn gbinline va ulong which bool to void +gbmth 1 792 98 +gbemit or uint 1073741824 uint and shr va 40 511 +gbemit gblo shr va 8 +for i ulong 96 +if which +gbemit get gbq1 i +else +gbemit get gbq0 i +end +end +end +fn gbrel va ulong value uint to void +gbmth 0 92 5 +gbemit gblo va +gbemit gbhi va +gbemit value +gbemit 0 +gbemit 1048577 +end +fn gbbuild n uint to void +gbqmd n +put gbused 0 0 +gbsetup +cb = mapaddr get gbmem 1 +q = mapaddr get gbmem 2 +mark = mapaddr get gbmem 3 +gbdma cb 224 +for i ulong 224 +gbemit get gbcb i +end +gbdma add cb 896 7 +for i ulong 7 +gbemit get gbargs i +end +gbinline q false +gbdma add q 8192 1 +gbemit 1 +gbinline add q 4096 true +gbrel mark 1145324612 +note C3: flush GPU L2 dirty lines, then a second WFI release before CPU readback. +gbmth 0 40 4 +gbemit 0 +gbemit 0 +gbemit 0 +gbemit 2147483648 +gbrel add mark 16 1179010630 +end +fn gbopen n uint to bool +if or eq n 0 gt n 1048576 +put nverr 0 neg long 22 +ret false +end +if not nvfull +ret false +end +if not nvchan +ret false +end +put gbmax 0 n +for i ulong 8 +size = ulong 4096 +if or eq i 0 eq i 2 +size = ulong 65536 +end +if ge i 5 +size = mul ulong n 4 +end +m = nvalloc size true +if le m 0 +ret false +end +put gbmem i m +end +gbvec +r = mapwrite get gbmem 4 0 gbcode 0 get gblen 0 +ret eq r long get gblen 0 +end +fn gblaunch n uint to bool +if or or eq n 0 gt n get gbmax 0 ne get nvfault 0 0 +put nverr 0 neg long 22 +ret false +end +put nvstage 0 40 +gbbuild n +r = mapset get gbmem 2 8192 4 0 +r = mapset get gbmem 3 0 4 0 +r = mapset get gbmem 3 16 4 0 +r = mapwrite get gbmem 0 0 gbcmd 0 get gbused 0 +put nvstage 0 41 +if not nvsend get gbmem 0 0 uint div get gbused 0 4 +ret false +end +put nvstage 0 42 +if not nvwait get gbmem 3 16 1179010630 5000000000 +ret false +end +put nvstage 0 43 +if ne mapget get gbmem 3 0 4 1145324612 +put nverr 0 neg long 5 +put nvfault 0 1 +ret false +end +if ne mapget get gbmem 2 8192 4 6 +put nverr 0 neg long 5 +put nvfault 0 1 +ret false +end +ret true +end diff --git a/native/blackwell/vector.om b/native/blackwell/vector.om new file mode 100644 index 00000000..d2c1bc83 --- /dev/null +++ b/native/blackwell/vector.om @@ -0,0 +1,49 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Seed vecadd.s2 instruction forms, handwritten Omega emission of the same512bytes. +note Each quad is one128-bit instruction. References: Omega57f5f425 seed/sm121. +global gbcode uchar 4096 +global gblen ulong 1 +fn gbword v uint to void +for j ulong 4 +put gbcode get gblen 0 uchar and shr v mul j 8 255 +put gblen 0 add get gblen 0 1 +end +end +fn gbquad a uint b uint c uint d uint to void +gbword a +gbword b +gbword c +gbword d +end +fn gbvec to void +put gblen 0 0 +note Stack constant, block ID, block size, thread ID and element count. +gbquad 4278287234 57088 2048 1040896 +gbquad 620825 0 9472 926208 +gbquad 4278482860 27648 134219776 926208 +gbquad 31001 0 8448 926208 +gbquad 4278548396 29440 134219776 942592 +note Linear index and bounds predicate; inactive threads exit before any access. +gbquad 151616548 4 260964864 2083328 +gbquad 151026700 5 200302704 3136000 +gbquad 2381 0 58720256 1042944 +note Input/output addresses and memory descriptor from the constant bank. +gbquad 4278352770 57344 2560 926208 +gbquad 4278482860 27392 134220288 945664 +gbquad 4278483842 57856 2560 962560 +gbquad 4278614914 58368 2560 975360 +note Address formation and independent input loads, retaining scheduling waits. +gbquad 151156773 4 126746626 2083840 +gbquad 33716609 4 203299072 3088896 +gbquad 151287845 4 126746628 5229568 +gbquad 67467649 4 203299072 991744 +gbquad 151418917 4 126746630 9429504 +note Unsigned32-bit addition, output store, exit and unreachable self-branch guard. +gbquad 34173456 5 134209791 17811968 +gbquad 100694406 9 202381572 1040896 +gbquad 31053 0 58720256 1042944 +gbquad 16546119 4294967292 58982399 1032192 +for i ulong 11 +gbquad 31000 0 0 1032192 +end +end diff --git a/native/nvrm/context.om b/native/nvrm/context.om new file mode 100644 index 00000000..8127efde --- /dev/null +++ b/native/nvrm/context.om @@ -0,0 +1,1086 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Native continuation of canonical nvrm/nvrm.c, source349913f1, NVIDIA ABI580.173.02. +note One explicitly owned context, bounded buffers, channel, submission and completion. +text nvctl "/dev/nvidiactl" +text nvdev "/dev/nvidia0" +text nvuvm "/dev/nvidia-uvm" +global nvfd int 4 +global nvobj uint 16 +global nvhdr uchar 32 +global nvpar uchar 16384 +global nvcard uchar 4608 +global nvseq uint 1 +global nverr long 1 +global nvstage uint 1 +global nvid uint 1 +global nvinst uint 1 +global nvsm uint 1 +global nvcls uint 3 +global nvuuid uchar 16 +global nvreg uchar 2 +note Context phases:0 closed,1 driver resources live,2 descriptors closed with mapping cleanup pending. +global nvstate uchar 1 +global nvmm uint 1 +global nvfault uchar 1 +global nvnext ulong 1 +global nvbar long 1 +global nvfifo long 1 +global nvnotify long 1 +global nvchva long 1 +global nvtoken uint 1 +global nvchreg uchar 1 +global nvsched uchar 1 +global nvput ulong 1 +global nvret ulong 1 +global nvretry uint 1 +global nvmobj uint 96 +global nvmmap long 96 +global nvmaddr ulong 96 +global nvmlen ulong 96 +global nvmflag uchar 96 +fn nhput off ulong v uint to void +for i ulong 4 +put nvhdr add off i uchar and shr v mul i 8 255 +end +end +fn nhget off ulong to uint +v = uint 0 +for i ulong 4 +v = or v shl uint get nvhdr add off i mul i 8 +end +ret v +end +fn npput off ulong v uint to void +for i ulong 4 +put nvpar add off i uchar and shr v mul i 8 255 +end +end +fn npget off ulong to uint +v = uint 0 +for i ulong 4 +v = or v shl uint get nvpar add off i mul i 8 +end +ret v +end +fn npp64 off ulong v ulong to void +for i ulong 8 +put nvpar add off i uchar and shr v mul i 8 255 +end +end +fn npg64 off ulong to ulong +v = ulong 0 +for i ulong 8 +v = or v shl ulong get nvpar add off i mul i 8 +end +ret v +end +fn npuuid to void +npzero +for i ulong 16 +put nvpar i get nvuuid i +end +end +fn ncget off ulong to uint +v = uint 0 +for i ulong 4 +v = or v shl uint get nvcard add off i mul i 8 +end +ret v +end +fn nhzero to void +for i ulong len nvhdr +put nvhdr i 0 +end +end +fn npzero to void +for i ulong len nvpar +put nvpar i 0 +end +end +fn nvos r long status uint to bool +if ne r 0 +put nverr 0 r +ret false +end +if ne status 0 +put nverr 0 long status +ret false +end +ret true +end +fn nvalc parent uint cls uint n ulong to uint +nhzero +nhput 0 get nvobj 0 +nhput 4 parent +if ne cls 65 +if eq get nvseq 0 4294967295 +put nverr 0 neg long 75 +ret 0 +end +nhput 8 get nvseq 0 +put nvseq 0 add get nvseq 0 1 +end +nhput 12 cls +r = devcall get nvfd 0 uint 3223340587 nvhdr 0 32 nvpar 0 n +if not nvos r nhget 28 +ret 0 +end +ret nhget 8 +end +fn nvctrl obj uint cmd uint n ulong to bool +nhzero +nhput 0 get nvobj 0 +nhput 4 obj +nhput 8 cmd +r = devcall get nvfd 0 uint 3223340586 nvhdr 0 32 nvpar 0 n +ret nvos r nhget 28 +end +fn nvfree parent uint obj uint to bool +if eq obj 0 +ret true +end +nhzero +nhput 0 get nvobj 0 +nhput 4 parent +nhput 8 obj +r = devctl get nvfd 0 uint 3222292009 nvhdr 0 16 +ret nvos r nhget 12 +end +fn nvstop to bool +if eq get nvstate 0 0 +ret true +end +if eq get nvstate 0 2 +ret nvmapfinish +end +ok = true +if nvchstop +if not nvmclose +ok = false +end +else +ok = false +end +if gt get nvbar 0 0 +r = mapdrop get nvbar 0 +if ne r 0 +put nverr 0 r +ok = false +else +put nvbar 0 0 +end +end +if ne get nvobj 5 0 +if not nvfree get nvobj 2 get nvobj 5 +ok = false +end +put nvobj 5 0 +end +if ne get nvreg 1 0 +npuuid +r = uvmctl get nvfd 2 uint 26 nvpar 0 20 +if not nvos r npget 16 +ok = false +end +put nvreg 1 0 +end +if ne get nvreg 0 0 +npuuid +r = uvmctl get nvfd 2 uint 38 nvpar 0 20 +if not nvos r npget 16 +ok = false +end +put nvreg 0 0 +end +if ne get nvobj 4 0 +if not nvfree get nvobj 1 get nvobj 4 +ok = false +end +put nvobj 4 0 +end +if ne get nvobj 3 0 +if not nvfree get nvobj 1 get nvobj 3 +ok = false +end +put nvobj 3 0 +end +if ne get nvobj 2 0 +if not nvfree get nvobj 1 get nvobj 2 +ok = false +end +put nvobj 2 0 +end +if ne get nvobj 1 0 +if not nvfree get nvobj 0 get nvobj 1 +ok = false +end +put nvobj 1 0 +end +if ne get nvobj 0 0 +if not nvfree get nvobj 0 get nvobj 0 +ok = false +end +put nvobj 0 0 +end +for j ulong len nvfd +i = sub 3 j +if ge get nvfd i 0 +if ne fclose get nvfd i 0 +ok = false +end +put nvfd i neg int 1 +end +end +note Close is attempted once per descriptor. Never repeat driver calls after this phase. +put nvstate 0 2 +put nvsched 0 0 +if not nvmapfinish +ok = false +end +if not ok +put nvfault 0 1 +end +ret ok +end +note The driver descriptors are closed; only owned CPU mappings may be retried here. +fn nvmapfinish to bool +if ne get nvstate 0 2 +put nverr 0 neg long 16 +ret false +end +ok = true +if gt get nvbar 0 0 +r = mapdrop get nvbar 0 +if ne r 0 +put nverr 0 r +ok = false +else +put nvbar 0 0 +end +end +if gt get nvchva 0 0 +r = mapdrop get nvchva 0 +if ne r 0 +put nverr 0 r +ok = false +else +put nvchva 0 0 +end +end +if not nvmforce +ok = false +end +if not ok +put nvfault 0 1 +ret false +end +note Descriptor closure retired every driver object, including a refused channel teardown. +for i ulong len nvobj +put nvobj i 0 +end +for i ulong len nvreg +put nvreg i 0 +end +put nvchreg 0 0 +put nvput 0 0 +put nvret 0 0 +put nvfifo 0 0 +put nvnotify 0 0 +put nvstate 0 0 +ret true +end +fn nvstart to bool +if ne get nvfault 0 0 +put nverr 0 neg long 5 +ret false +end +if ne get nvstate 0 0 +put nverr 0 neg long 16 +ret false +end +put nvstate 0 1 +put nvnext 0 68719476736 +for i ulong len nvfd +put nvfd i neg int 1 +end +for i ulong len nvobj +put nvobj i 0 +end +put nvseq 0 3472883713 +put nverr 0 0 +put nvstage 0 1 +r = fopen nvctl 0 len nvctl 524290 0 +if lt r 0 +put nverr 0 r +ret false +end +put nvfd 0 int r +put nvstage 0 2 +npzero +root = nvalc 0 65 0 +if eq root 0 +ret false +end +put nvobj 0 root +put nvstage 0 3 +for i ulong len nvcard +put nvcard i 0 +end +r = devctl get nvfd 0 uint 3523233480 nvcard 0 4608 +if not nvos r 0 +ret false +end +found = uint 0 +for i ulong 64 +off = mul i 72 +if ne get nvcard off 0 +found = add found 1 +if ne ncget add off 56 0 +put nverr 0 neg long 19 +ret false +end +put nvid 0 ncget add off 16 +end +end +if ne found 1 +put nverr 0 neg long 19 +ret false +end +put nvstage 0 4 +r = fopen nvdev 0 len nvdev 524290 0 +if lt r 0 +put nverr 0 r +ret false +end +put nvfd 1 int r +npzero +npput 0 uint get nvfd 0 +r = devctl get nvfd 1 uint 3221505737 nvpar 0 4 +if not nvos r 0 +ret false +end +put nvstage 0 5 +npzero +npput 0 get nvid 0 +if not nvctrl root 517 32 +ret false +end +put nvinst 0 npget 8 +put nvstage 0 6 +npzero +npput 0 get nvinst 0 +npput 4 root +dev = nvalc root 128 56 +if eq dev 0 +ret false +end +put nvobj 1 dev +put nvstage 0 7 +npzero +subd = nvalc dev 8320 4 +if eq subd 0 +ret false +end +put nvobj 2 subd +put nvstage 0 8 +npzero +if not nvctrl dev 8389266 804 +ret false +end +n = npget 0 +if gt n 200 +put nverr 0 neg long 75 +ret false +end +for i ulong 3 +put nvcls i 0 +end +for i ulong ulong n +c = npget add 4 mul i 4 +if eq c 52928 +put nvcls 0 c +end +if eq c 51567 +put nvcls 1 c +end +if eq c 50017 +put nvcls 2 c +end +end +for i ulong 3 +if eq get nvcls i 0 +put nverr 0 neg long 19 +ret false +end +end +put nvstage 0 9 +npzero +npput 0 1 +npput 4 12 +if not nvctrl subd 545264168 488 +ret false +end +put nvsm 0 npget 8 +note RM reports SM10.04 on GB10; CUDA target sm121 uses a different numbering contract. +note Matches canonical evidence/m16-blackwell-native-path-requalification-receipt.json. +if ne get nvsm 0 2564 +put nverr 0 neg long 19 +ret false +end +put nvstage 0 10 +ret true +end + +note Low GPU command addresses are reserved without replacement before an owned bind. +note BAR mappings may use Linux-selected addresses; GPU buffers stay below 40 bits. +fn nvcpumap obj uint size ulong system bool flags uint to long +fd = neg long 1 +if system +fd = fopen nvctl 0 len nvctl 524290 0 +else +fd = fopen nvdev 0 len nvdev 524290 0 +end +if lt fd 0 +put nverr 0 fd +ret fd +end +if not system +npzero +npput 0 uint get nvfd 0 +r = devctl int fd uint 3221505737 nvpar 0 4 +if not nvos r 0 +r = fclose int fd +ret neg long 1 +end +end +npzero +npput 0 get nvobj 0 +npput 4 get nvobj 1 +npput 8 obj +npp64 24 size +npput 44 flags +npput 48 uint fd +r = devctl get nvfd 0 uint 3224913486 nvpar 0 56 +if not nvos r npget 40 +r = fclose int fd +ret neg long 1 +end +m = neg long 1 +if system +if gt get nvnext 0 sub 1099511627776 size +put nverr 0 neg long 75 +r = fclose int fd +ret neg long 1 +end +m = maphold get nvnext 0 size +if gt m 0 +put nvnext 0 add get nvnext 0 size +r = mapbind m int fd 0 3 +if ne r 0 +m = r +end +end +else +m = mapnew int fd 0 size 3 1 +end +r = fclose int fd +if ne r 0 +put nverr 0 r +put nvfault 0 1 +if gt m 0 +r = mapdrop m +end +ret neg long 1 +end +if lt m 0 +put nverr 0 m +end +ret m +end + +note Release flags change only after confirmed acceptance. Failed entries stay quarantined. +fn nvmrel slot ulong to bool +f = get nvmflag slot +if ne and f 4 0 +npzero +npp64 0 get nvmaddr slot +npp64 8 get nvmlen slot +r = uvmctl get nvfd 2 uint 34 nvpar 0 24 +if not nvos r npget 16 +put nvfault 0 1 +ret false +end +f = and f 251 +put nvmflag slot f +end +if ne and f 8 0 +npzero +npput 0 get nvobj 0 +npput 4 get nvobj 1 +npput 8 get nvobj 3 +npput 12 get nvmobj slot +npp64 24 get nvmaddr slot +npp64 32 get nvmlen slot +r = devctl get nvfd 0 uint 3224389208 nvpar 0 48 +if not nvos r npget 40 +put nvfault 0 1 +ret false +end +f = and f 247 +put nvmflag slot f +end +if ne and f 1 0 +if not nvfree get nvobj 1 get nvmobj slot +put nvfault 0 1 +ret false +end +f = and f 254 +put nvmflag slot f +end +if ne and f 2 0 +r = mapdrop get nvmmap slot +if not nvos r 0 +put nvfault 0 1 +ret false +end +end +put nvmflag slot 0 +put nvmobj slot 0 +put nvmmap slot 0 +put nvmaddr slot 0 +put nvmlen slot 0 +ret true +end +fn nvmclose to bool +ok = true +for i ulong len nvmflag +if ne get nvmflag i 0 +if not nvmrel i +ok = false +end +end +end +ret ok +end +note Called only after the owning driver context is closed, including error teardown. +fn nvmforce to bool +if ne get nvstate 0 2 +put nverr 0 neg long 16 +ret false +end +ok = true +for i ulong len nvmflag +note Driver-owned flags and handles retired when the descriptors closed. +put nvmflag i and get nvmflag i 2 +put nvmobj i 0 +if ne and get nvmflag i 2 0 +r = mapdrop get nvmmap i +if ne r 0 +put nverr 0 r +ok = false +else +put nvmflag i 0 +put nvmmap i 0 +put nvmaddr i 0 +put nvmlen i 0 +end +else +put nvmmap i 0 +put nvmaddr i 0 +put nvmlen i 0 +end +end +ret ok +end +fn nvdrop m long to bool +if ne get nvput 0 get nvret 0 +put nverr 0 neg long 16 +ret false +end +if and ne get nvobj 8 0 or eq m get nvfifo 0 eq m get nvnotify 0 +put nverr 0 neg long 16 +ret false +end +for i ulong len nvmmap +if and gt m 0 eq get nvmmap i m +ret nvmrel i +end +end +put nverr 0 neg long 22 +ret false +end +fn nvalloc want ulong cached bool to long +if or eq get nvreg 1 0 ne get nvfault 0 0 +put nverr 0 neg long 5 +ret neg long 1 +end +if or eq want 0 gt want 68719476736 +put nverr 0 neg long 22 +ret neg long 1 +end +size = mul div add want 4095 4096 4096 +slot = ulong 96 +for i ulong 96 +if and eq slot 96 eq get nvmflag i 0 +slot = i +end +end +if eq slot 96 +put nverr 0 neg long 24 +ret neg long 1 +end +put nvstage 0 21 +npzero +npput 0 get nvobj 0 +npput 8 49409 +npput 24 436207616 +attr = uint 9 +if cached +attr = 5 +end +npput 28 attr +npput 32 6 +npp64 64 size +npp64 72 4096 +npp64 88 sub size 1 +h = nvalc get nvobj 1 62 128 +if eq h 0 +put nvfault 0 1 +ret neg long 1 +end +put nvmobj slot h +put nvmlen slot size +put nvmflag slot 1 +put nvstage 0 22 +m = nvcpumap h size true 0 +if le m 0 +put nvfault 0 1 +ret neg long 1 +end +put nvmmap slot m +put nvmaddr slot mapaddr m +put nvmflag slot 3 +va = get nvmaddr slot +if or ne and va 4095 0 gt va sub 562949869535232 size +put nverr 0 neg long 75 +put nvfault 0 1 +ret neg long 1 +end +put nvstage 0 23 +npzero +npp64 0 va +npp64 8 size +r = uvmctl get nvfd 2 uint 73 nvpar 0 24 +if not nvos r npget 16 +put nvfault 0 1 +ret neg long 1 +end +put nvmflag slot 7 +put nvstage 0 24 +npzero +npput 0 get nvobj 0 +npput 4 get nvobj 1 +npput 8 get nvobj 3 +npput 12 h +npp64 24 size +npput 32 33040 +npp64 48 va +r = devctl get nvfd 0 uint 3225437783 nvpar 0 64 +if not nvos r npget 56 +put nvfault 0 1 +ret neg long 1 +end +put nvmflag slot 15 +if ne npg64 48 va +put nverr 0 neg long 22 +put nvfault 0 1 +ret neg long 1 +end +put nvstage 0 25 +npzero +npp64 0 va +npp64 8 size +for i ulong 16 +put nvpar add i 24 get nvuuid i +end +npput 40 1 +npp64 9240 1 +npput 9248 uint get nvfd 0 +npput 9252 get nvobj 0 +npput 9256 h +r = uvmctl get nvfd 2 uint 33 nvpar 0 9264 +if not nvos r npget 9260 +put nvfault 0 1 +ret neg long 1 +end +npzero +off = ulong 0 +while lt off size +n = sub size off +if gt n 16384 +n = ulong 16384 +end +r = mapwrite m off nvpar 0 n +off = add off n +end +put nvstage 0 26 +ret m +end + +note Register this private GPU virtual address space with UVM, no buffers or kernels. +fn nvfull to bool +if not nvstart +ret false +end +put nvstage 0 11 +for i ulong 2 +r = fopen nvuvm 0 len nvuvm 524290 0 +if lt r 0 +put nverr 0 r +ret false +end +put nvfd add i 2 int r +end +npzero +r = uvmctl get nvfd 2 uint 805306369 nvpar 0 16 +if not nvos r npget 8 +ret false +end +put nvstage 0 12 +npzero +npput 0 uint get nvfd 2 +r = uvmctl get nvfd 3 uint 75 nvpar 0 8 +if ne r 0 +put nverr 0 r +ret false +end +note Driver platforms may return NV_WARN_NOTHING_TO_DO. Retain the returned status. +put nvmm 0 npget 4 +if and ne get nvmm 0 0 ne get nvmm 0 65542 +put nverr 0 long get nvmm 0 +ret false +end +put nvstage 0 13 +npzero +npp64 8 562949953421311 +v = nvalc get nvobj 1 112 24 +if eq v 0 +ret false +end +put nvobj 3 v +put nvstage 0 14 +npzero +npput 4 72 +npp64 8 562949869535232 +npp64 40 4096 +v = nvalc get nvobj 1 37105 56 +if eq v 0 +ret false +end +put nvobj 4 v +put nvstage 0 15 +npzero +npput 4 2 +npput 8 16 +if not nvctrl get nvobj 2 545259850 268 +ret false +end +if ne npget 8 16 +put nverr 0 neg long 22 +ret false +end +for i ulong 16 +put nvuuid i get nvpar add i 12 +end +npuuid +npput 24 4294967295 +r = uvmctl get nvfd 2 uint 37 nvpar 0 40 +if not nvos r npget 36 +ret false +end +put nvreg 0 1 +put nvstage 0 16 +npuuid +npput 16 uint get nvfd 0 +npput 20 get nvobj 0 +npput 24 get nvobj 4 +r = uvmctl get nvfd 2 uint 25 nvpar 0 32 +if not nvos r npget 28 +ret false +end +put nvreg 1 1 +put nvstage 0 17 +ret true +end + +fn nvfind m long to ulong +for i ulong len nvmmap +if and gt m 0 eq get nvmmap i m +ret i +end +end +ret 96 +end +note Reverse partial channel construction before releasing its buffers or address space. +fn nvchstop to bool +if ne get nvchreg 0 0 +npuuid +npput 16 get nvobj 0 +npput 20 get nvobj 8 +r = uvmctl get nvfd 2 uint 28 nvpar 0 28 +if not nvos r npget 24 +put nvfault 0 1 +ret false +end +put nvchreg 0 0 +end +for i ulong 4 +obj = sub 9 i +parent = ulong 6 +if eq obj 9 +parent = ulong 8 +end +if eq obj 6 +parent = ulong 1 +end +if ne get nvobj obj 0 +if not nvfree get nvobj parent get nvobj obj +put nvfault 0 1 +ret false +end +put nvobj obj 0 +end +end +if gt get nvchva 0 0 +r = mapdrop get nvchva 0 +if not nvos r 0 +put nvfault 0 1 +ret false +end +put nvchva 0 0 +end +put nvsched 0 0 +put nvput 0 0 +put nvret 0 0 +put nvfifo 0 0 +put nvnotify 0 0 +ret true +end + +note Empty queue creation and scheduling; this routine submits no command packets. +fn nvchan to bool +if or eq get nvreg 1 0 ne get nvfault 0 0 +put nverr 0 neg long 16 +ret false +end +if or ne get nvobj 6 0 ne get nvobj 5 0 +put nverr 0 neg long 16 +ret false +end +put nvstage 0 31 +npzero +u = nvalc get nvobj 2 50017 0 +if eq u 0 +ret false +end +put nvobj 5 u +m = nvcpumap u 65536 false 0 +if le m 0 +ret false +end +put nvbar 0 m +put nvstage 0 32 +npzero +npput 12 1 +g = nvalc get nvobj 1 41068 20 +if eq g 0 +ret false +end +put nvobj 6 g +put nvstage 0 33 +npzero +npput 0 get nvobj 4 +npput 4 1 +c = nvalc g 36967 12 +if eq c 0 +ret false +end +put nvobj 7 c +m = nvalloc 65536 false +if le m 0 +ret false +end +put nvfifo 0 m +m = nvalloc 1048576 true +if le m 0 +ret false +end +put nvnotify 0 m +put nvstage 0 34 +npzero +npput 0 get nvmobj nvfind get nvnotify 0 +npput 4 get nvmobj nvfind get nvfifo 0 +npp64 8 mapaddr get nvfifo 0 +npput 16 1024 +npput 24 c +npput 32 get nvmobj nvfind get nvfifo 0 +npp64 64 8192 +f = nvalc g 51567 368 +if eq f 0 +ret false +end +put nvobj 8 f +put nvstage 0 35 +npzero +put nvretry 0 0 +k = nvalc f 52928 0 +while eq k 0 +if or ne get nverr 0 81 ge get nvretry 0 50 +ret false +end +put nvretry 0 add get nvretry 0 1 +r = sleepns long 100000000 +if ne r 0 +put nverr 0 r +ret false +end +k = nvalc f 52928 0 +end +put nvobj 9 k +put nverr 0 0 +put nvstage 0 36 +npzero +npput 0 4294967295 +if not nvctrl f 3278831880 4 +ret false +end +put nvtoken 0 npget 0 +put nvstage 0 37 +if gt get nvnext 0 1099444518912 +put nverr 0 neg long 75 +ret false +end +v = maphold get nvnext 0 67108864 +if le v 0 +put nverr 0 v +ret false +end +put nvchva 0 v +put nvnext 0 add get nvnext 0 67108864 +npuuid +npput 16 uint get nvfd 0 +npput 20 get nvobj 0 +npput 24 f +npp64 32 mapaddr v +npp64 40 67108864 +r = uvmctl get nvfd 2 uint 27 nvpar 0 56 +if not nvos r npget 48 +ret false +end +put nvchreg 0 1 +put nvstage 0 38 +npzero +put nvpar 0 1 +if not nvctrl g 2691432705 3 +ret false +end +put nvsched 0 1 +put nvstage 0 39 +ret true +end + +note One outstanding packet. Completion must be observed before reuse or any buffer release. +fn nvsend m long off ulong words uint to bool +if or ne get nvfault 0 0 eq get nvsched 0 0 +put nverr 0 neg long 5 +ret false +end +if ne get nvput 0 get nvret 0 +put nverr 0 neg long 16 +ret false +end +s = nvfind m +if eq s 96 +put nverr 0 neg long 22 +ret false +end +if or or eq words 0 gt words 2097151 ne and off 3 0 +put nverr 0 neg long 22 +ret false +end +size = get nvmlen s +if gt off size +put nverr 0 neg long 22 +ret false +end +if gt mul ulong words 4 sub size off +put nverr 0 neg long 22 +ret false +end +va = add get nvmaddr s off +if ge va 1099511627776 +put nverr 0 neg long 75 +ret false +end +p = get nvput 0 +if eq p 18446744073709551615 +put nverr 0 neg long 75 +ret false +end +entry = or or va shl ulong words 42 2199023255552 +ret nvpush p entry +end +fn nvpush p ulong entry ulong to bool +r = mapset get nvfifo 0 mul rem p 1024 8 8 entry +p = add p 1 +put nvput 0 p +r = mapset get nvfifo 0 8332 4 rem p 1024 +r = mapset get nvbar 0 144 4 ulong get nvtoken 0 +ret true +end + +fn nvwait m long off ulong value uint budget ulong to bool +if or ne get nvfault 0 0 eq get nvsched 0 0 +put nverr 0 neg long 22 +ret false +end +if eq get nvput 0 get nvret 0 +put nverr 0 neg long 22 +ret false +end +s = nvfind m +if or eq s 96 or eq budget 0 gt budget 30000000000 +put nverr 0 neg long 22 +ret false +end +size = get nvmlen s +if or gt off sub size 4 ne and off 3 0 +put nverr 0 neg long 22 +ret false +end +start = monons +if lt start 0 +put nverr 0 start +put nvfault 0 1 +ret false +end +while true +if eq mapget m off 4 ulong value +put nvret 0 get nvput 0 +ret true +end +now = monons +if or lt now start ge sub now start long budget +put nverr 0 neg long 110 +put nvfault 0 1 +ret false +end +r = sleepns long 100000 +if ne r 0 +put nverr 0 r +put nvfault 0 1 +ret false +end +end +ret false +end diff --git a/native/speculation/costs.om b/native/speculation/costs.om new file mode 100644 index 00000000..ec092faf --- /dev/null +++ b/native/speculation/costs.om @@ -0,0 +1,237 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Bounded observation collector over the existing native benchmark owner's measurements. +note It does not measure time, prove provenance, launch a model or synthesize missing costs. +global cobs ulong 16 +global craw ulong 3584 +global ccount ulong 7 +global csum ulong 49 +global crange ulong 21 +global cbind ulong 36 +global cshape ulong 21 +fn cstart to int +if ne get sstate 0 0 +ret 75 +end +v = sheader +if ne v 0 +ret v +end +if ne get srows 0 1 +ret 77 +end +for r ulong 7 +b = mul r 11 +if gt get srows b 1 +ret 65 +end +if eq get srows b 1 +if ne get srows add b 1 slen r +ret 65 +end +if ne get srows add b 2 add slen r 1 +ret 65 +end +end +for i ulong 3 +put cshape add mul r 3 i get srows add b i +end +end +for i ulong 32 +put cbind i get sid i +end +put cbind 32 get sprofile 1 +put cbind 33 get sprofile 4 +put cbind 34 get sprofile 2 +put cbind 35 get sprofile 3 +for i ulong 7 +put ccount i 0 +end +for i ulong 49 +put csum i 0 +end +for i ulong 21 +put crange i 0 +end +ret 0 +end +fn cbound to int +if ne get cbind 34 get sprofile 2 +ret 69 +end +if ne get cbind 35 get sprofile 3 +ret 69 +end +for r ulong 7 +for i ulong 3 +if ne get cshape add mul r 3 i get srows add mul r 11 i +ret 69 +end +end +end +ret 0 +end +fn cvalid to int +status = cbound +if ne status 0 +ret status +end +for i ulong 32 +if ne get cbind i get sid i +ret 69 +end +if ne get sid i get sid add i 32 +ret 69 +end +end +if ne get cbind 32 get sprofile 1 +ret 69 +end +if ne get cobs 13 get cbind 32 +ret 69 +end +if ne get cobs 14 get cbind 33 +ret 69 +end +if ne get sprofile 4 get cbind 33 +ret 69 +end +if ne get cobs 15 63 +ret 65 +end +r = get cobs 0 +if ge r 7 +ret 65 +end +if ne get srows mul r 11 1 +ret 77 +end +if ne get cobs 1 get ccount r +ret 65 +end +if ge get ccount r 32 +ret 77 +end +if ne get cobs 2 1 +ret 75 +end +if ne get cobs 3 0 +ret 75 +end +if ne get cobs 12 add slen r 1 +ret 65 +end +if eq get cobs 5 0 +ret 65 +end +if eq get cobs 11 0 +ret 65 +end +if eq r 0 +if ne get cobs 4 0 +ret 65 +end +end +sum = ulong 0 +for i ulong 6 +v = get cobs add i 4 +if gt v 1000000000 +ret 65 +end +sum = add sum v +end +if lt get cobs 10 sum +ret 65 +end +if gt get cobs 10 1000000000 +ret 65 +end +ret 0 +end +fn cadd to int +status = cvalid +if ne status 0 +ret status +end +r = get cobs 0 +n = get ccount r +base = mul add mul r 32 n 16 +for i ulong 16 +put craw add base i get cobs i +end +sum = ulong 0 +for i ulong 6 +p = add mul r 7 i +v = get cobs add i 4 +put csum p add get csum p v +sum = add sum v +end +note Attribute uninstrumented round gaps to host overhead, preserving full wall cost. +p = add mul r 7 3 +put csum p add get csum p sub get cobs 10 sum +p = add mul r 7 6 +put csum p add get csum p get cobs 10 +base = mul r 3 +if eq n 0 +put crange base get cobs 10 +end +if lt get cobs 10 get crange base +put crange base get cobs 10 +end +if gt get cobs 10 get crange add base 1 +put crange add base 1 get cobs 10 +end +if gt get cobs 11 get crange add base 2 +put crange add base 2 get cobs 11 +end +put ccount r add n 1 +ret 0 +end +fn cseal to int +note All enabled rows need at least five observations. No partial table publication. +status = cbound +if ne status 0 +ret status +end +if ne get sstate 0 0 +ret 75 +end +for i ulong 32 +if ne get cbind i get sid i +ret 69 +end +if ne get sid i get sid add i 32 +ret 69 +end +end +if ne get cbind 32 get sprofile 1 +ret 69 +end +if ne get cbind 33 get sprofile 4 +ret 69 +end +for r ulong 7 +if eq get srows mul r 11 1 +if lt get ccount r 5 +ret 75 +end +end +end +for r ulong 7 +if eq get srows mul r 11 1 +csealrow r +end +end +put sstate 11 0 +ret 0 +end +fn csealrow r ulong to void +n = get ccount r +b = mul r 11 +for i ulong 6 +note Ceiling each phase avoids inventing a faster zero-duration mean. +v = div add get csum add mul r 7 i sub n 1 n +put srows add add b 3 i v +end +put srows add b 9 get crange add mul r 3 2 +put srows add b 10 n +end diff --git a/native/speculation/policy.om b/native/speculation/policy.om new file mode 100644 index 00000000..0ce51180 --- /dev/null +++ b/native/speculation/policy.om @@ -0,0 +1,438 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Chain sizing component. Integer microseconds and prefix survival millionths. +note This component never launches a model or mutates its KV/recurrent/drafter state. +global scontrol ulong 2 +global sid ulong 64 +global ssaved ulong 32 +global sprofile ulong 6 +global srows ulong 77 +global sprior ulong 31 +global survive ulong 31 +global measured ulong 7 +global sstate ulong 15 +global decision ulong 5 +fn slen row ulong to ulong +if eq row 0 +ret 0 +end +if eq row 6 +ret 31 +end +ret shl 1 sub row 1 +end +fn scost row ulong to ulong +total = ulong 0 +for p ulong 6 +total = add total get srows add add mul row 11 3 p +end +ret total +end +fn sheader to int +if ne get sprofile 0 1 +ret 69 +end +if eq get sprofile 1 0 +ret 69 +end +if ge get sprofile 2 get sprofile 3 +ret 65 +end +if gt get sprofile 3 131072 +ret 65 +end +if lt get sprofile 4 1 +ret 69 +end +if gt get sprofile 4 2 +ret 69 +end +if ne get sprofile 5 1 +ret 77 +end +note Eight complete digest identities; all-zero digests cannot bind a profile. +for d ulong 8 +nonzero = ulong 0 +for j ulong 4 +i = add mul d 4 j +v = get sid i +if ne v get sid add i 32 +ret 69 +end +nonzero = or nonzero v +end +if eq nonzero 0 +ret 69 +end +end +ret 0 +end +fn svalid to int +status = sheader +if ne status 0 +ret status +end +if ne get srows 0 1 +ret 77 +end +for r ulong 7 +b = mul r 11 +enabled = get srows b +if gt enabled 1 +ret 65 +end +if eq enabled 1 +if ne get srows add b 1 slen r +ret 65 +end +if ne get srows add b 2 add slen r 1 +ret 65 +end +if eq get srows add b 4 0 +ret 65 +end +if eq get srows add b 9 0 +ret 65 +end +if lt get srows add b 10 5 +ret 65 +end +if gt get srows add b 10 1000000 +ret 65 +end +for p ulong 6 +if gt get srows add add b 3 p 1000000000 +ret 65 +end +end +if eq r 0 +if ne get srows add b 3 0 +ret 65 +end +end +end +end +ret 0 +end +fn sbegin warm ulong to int +if gt warm 1 +ret 65 +end +if ne get sstate 0 0 +ret 75 +end +s = svalid +if ne s 0 +ret s +end +prev = ulong 1000000 +for i ulong 31 +v = get sprior i +if gt v prev +ret 65 +end +prev = v +end +if eq warm 1 +if ne get sstate 11 1 +ret 69 +end +if ne get sstate 10 get sprofile 1 +ret 69 +end +for i ulong 32 +if ne get ssaved i get sid i +ret 69 +end +end +else +for i ulong 31 +put survive i get sprior i +end +for i ulong 7 +put measured i 0 +end +end +for i ulong 15 +put sstate i 0 +end +for i ulong 5 +put decision i 0 +end +for i ulong 32 +put ssaved i get sid i +end +put sstate 10 get sprofile 1 +put sstate 11 1 +ret 0 +end +fn sexpect r ulong to ulong +v = ulong 1000000 +for i ulong slen r +v = add v get survive i +end +ret v +end +fn sprice r ulong to ulong +if ne get measured r 0 +ret get measured r +end +ret scost r +end +fn sfits r ulong to bool +b = mul r 11 +if ne get srows b 1 +ret false +end +if gt get srows add b 9 get sstate 12 +ret false +end +n = add slen r 1 +if gt n get sstate 2 +ret false +end +if gt n sub get sprofile 3 get sstate 3 +ret false +end +ret true +end +fn sbetter a ulong b ulong observed bool to bool +ca = scost a +cb = scost b +if observed +ca = sprice a +cb = sprice b +end +left = mul sexpect a cb +right = mul sexpect b ca +ret gt left right +end +fn sselect context ulong remain ulong memory ulong epoch ulong mode ulong fixed ulong to int +note Modes 0 ordinary, 1 fixed draft length, 2 adaptive. Any non-greedy sampling uses ordinary. +if ne get sstate 11 1 +ret 75 +end +if ne get sstate 0 0 +ret 75 +end +if ne get sstate 8 0 +ret 75 +end +if ne get sstate 9 0 +ret 75 +end +for i ulong 5 +put decision i 0 +end +v = svalid +if ne v 0 +ret v +end +if gt mode 2 +ret 65 +end +if gt get scontrol 0 1 +ret 65 +end +if eq remain 0 +ret 65 +end +if gt remain 256 +ret 65 +end +if gt get sstate 5 0 +if ne context get sstate 14 +ret 69 +end +if gt remain sub get sstate 13 get sstate 6 +ret 65 +end +else +put sstate 13 remain +end +if ne epoch get sprofile 1 +ret 69 +end +if ne epoch get sstate 10 +ret 69 +end +for i ulong 32 +if ne get ssaved i get sid i +ret 69 +end +end +if eq get scontrol 0 1 +if ne get sprofile 4 2 +ret 69 +end +end +if lt context get sprofile 2 +ret 69 +end +if ge context get sprofile 3 +ret 69 +end +put sstate 2 remain +put sstate 3 context +put sstate 12 memory +if not sfits 0 +ret 77 +end +ret srank mode fixed +end +fn srank mode ulong fixed ulong to int +best = ulong 0 +probe = ulong 0 +reason = ulong 1 +if eq get scontrol 1 0 +if eq mode 1 +found = false +for r ulong 7 +if eq slen r fixed +if sfits r +best = r +found = true +end +end +end +if not found +ret 77 +end +end +if eq mode 2 +reason = 3 +for r ulong 7 +if gt r 0 +if sfits r +note Cross products bounded by 32e6 * 6e9, below uint64 maximum. +if sbetter r best true +best = r +reason = 0 +end +if eq probe 0 +probe = r +else +if sbetter r probe false +probe = r +end +end +end +end +end +if eq best 0 +if ne probe 0 +if ge sub get sstate 5 get sstate 4 8 +best = probe +reason = 4 +put sstate 4 get sstate 5 +end +end +end +end +else +reason = 2 +end +put decision 0 slen best +put decision 1 add slen best 1 +put decision 2 sexpect best +put decision 3 sprice best +put decision 4 reason +put sstate 0 1 +put sstate 1 best +ret 0 +end +fn scancel to void +note Cancels an uncommitted observation. Actual backend rollback belongs to its state owner. +put sstate 0 0 +put sstate 9 1 +end +fn sresume to int +note Caller attests it consumed the emitted correction/bonus using the existing state owner. +if ne get sstate 8 1 +ret 75 +end +if ne get sstate 0 0 +ret 75 +end +put sstate 7 add get sstate 7 1 +put sstate 14 add get sstate 14 1 +put sstate 8 0 +ret 0 +end +fn sobserve accepted ulong commit_n ulong elapsed ulong eos ulong complete ulong to int +if ne get sstate 0 1 +ret 75 +end +if ne complete 1 +ret 75 +end +k = get decision 0 +if gt accepted k +ret 65 +end +if eq commit_n 0 +ret 65 +end +if gt commit_n add accepted 1 +ret 65 +end +if gt commit_n get sstate 2 +ret 65 +end +if gt eos 1 +ret 65 +end +if eq eos 1 +if gt accepted commit_n +ret 65 +end +end +if eq eos 0 +if ne commit_n add accepted 1 +ret 65 +end +end +if eq elapsed 0 +ret 65 +end +if gt elapsed 6000000000 +ret 65 +end +slearn accepted elapsed +put sstate 0 0 +put sstate 5 add get sstate 5 1 +put sstate 6 add get sstate 6 commit_n +used = commit_n +if gt commit_n accepted +used = accepted +put sstate 8 1 +end +put sstate 7 add get sstate 7 used +put sstate 14 add get sstate 3 used +if eq eos 1 +put sstate 9 1 +end +if eq commit_n get sstate 2 +put sstate 9 1 +end +ret 0 +end +fn slearn accepted ulong elapsed ulong to void +k = get decision 0 +note Only completed past rounds teach the estimator; never read future fixture answers. +for i ulong k +event = ulong 0 +if lt i accepted +event = 1000000 +end +put survive i div add mul get survive i 7 event 8 +end +prev = ulong 1000000 +for i ulong 31 +if gt get survive i prev +put survive i prev +end +prev = get survive i +end +r = get sstate 1 +put measured r elapsed +end diff --git a/native/speculation/replay.om b/native/speculation/replay.om new file mode 100644 index 00000000..467b6306 --- /dev/null +++ b/native/speculation/replay.om @@ -0,0 +1,220 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Native diagnostic stream entrypoint. Binary records are observations, not executable code. +note No model loading, network, timer, filesystem helper or external runtime is invoked. +global packet uchar 65537 +global reply uchar 2048 +global nwords ulong 1 +fn word i ulong to ulong +v = ulong 0 +for j ulong 8 +v = or v shl ulong get packet add mul i 8 j mul j 8 +end +ret v +end +fn outword i ulong v ulong to void +for j ulong 8 +put reply add mul i 8 j uchar and shr v mul j 8 255 +end +end +fn unpack to int +note Common header: SCX1 magic, version1, operation1..3, reserved0; then identities/profile/rows/prior. +if lt get nwords 0 182 +ret 65 +end +if ne word 0 827867987 +ret 65 +end +if ne word 1 1 +ret 69 +end +if lt word 2 1 +ret 77 +end +if gt word 2 3 +ret 77 +end +if ne word 3 0 +ret 65 +end +for i ulong 64 +put sid i word add i 4 +end +for i ulong 6 +put sprofile i word add i 68 +end +for i ulong 77 +put srows i word add i 74 +end +for i ulong 31 +put sprior i word add i 151 +end +ret sheader +end +fn replay1 to int +if ne get nwords 0 190 +ret 65 +end +status = sbegin 0 +if ne status 0 +ret status +end +put scontrol 0 word 182 +put scontrol 1 word 183 +status = sselect word 184 word 185 word 186 word 187 word 188 word 189 +if ne status 0 +ret status +end +for i ulong 5 +outword add i 5 get decision i +end +outword 4 5 +ret 0 +end +fn replay2 to int +if lt get nwords 0 183 +ret 65 +end +count = word 182 +if gt count 224 +ret 65 +end +if ne get nwords 0 add 183 mul count 16 +ret 65 +end +status = cstart +if ne status 0 +ret status +end +for r ulong count +for i ulong 16 +put cobs i word add add 183 mul r 16 i +end +status = cadd +if ne status 0 +ret status +end +end +status = cseal +if ne status 0 +ret status +end +for i ulong 77 +outword add i 5 get srows i +end +for i ulong 7 +outword add i 82 get ccount i +end +for i ulong 21 +outword add i 89 get crange i +end +outword 4 105 +ret 0 +end +fn replay3 to int +if lt get nwords 0 317 +ret 65 +end +for i ulong 5 +put pconfig i word add i 182 +end +count = word 188 +if gt count 128 +ret 65 +end +if ne get nwords 0 add 317 mul count 56 +ret 65 +end +for i ulong 128 +put parmids i word add i 189 +end +status = pstart word 187 +if ne status 0 +ret status +end +for r ulong count +for i ulong 56 +put pobs i word add add 317 mul r 56 i +end +status = padd +if ne status 0 +ret status +end +end +for a ulong 3 +status = preport a +if ne status 0 +ret status +end +for i ulong 12 +outword add add 5 mul a 12 i get summary i +end +end +outword 4 36 +ret 0 +end +fn publish to int +outword 0 827867987 +outword 1 1 +outword 2 word 2 +outword 3 get sprofile 4 +bytes = mul add wordout 5 8 +done = ulong 0 +for i ulong 2048 +if eq done bytes +ret 0 +end +w = write 1 reply done sub bytes done +if le w 0 +ret 74 +end +done = add done ulong w +end +ret 74 +end +fn wordout to ulong +v = ulong 0 +for j ulong 8 +v = or v shl ulong get reply add 32 j mul j 8 +end +ret v +end +fn decode bytes ulong to int +if ne rem bytes 8 0 +ret 65 +end +put nwords 0 div bytes 8 +status = unpack +if ne status 0 +ret status +end +if eq word 2 1 +status = replay1 +end +if eq word 2 2 +status = replay2 +end +if eq word 2 3 +status = replay3 +end +if ne status 0 +ret status +end +ret publish +end +fn main to int +n = ulong 0 +for i ulong 65538 +if gt n 65536 +ret 65 +end +r = read 0 packet n sub 65537 n +if lt r 0 +ret 74 +end +if eq r 0 +ret decode n +end +n = add n ulong r +end +ret 65 +end diff --git a/native/speculation/report.om b/native/speculation/report.om new file mode 100644 index 00000000..afc060ff --- /dev/null +++ b/native/speculation/report.om @@ -0,0 +1,424 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note One homogeneous held-out fixture/context/cold-or-warm group per report. +note All attempts retained, invalid attempts poison the group; never retry until green. +global pconfig ulong 5 +global pbind ulong 39 +global parmids ulong 128 +global pinned ulong 128 +global pobs ulong 56 +global praw ulong 14336 +global pslots ulong 128 +global pstate ulong 4 +global ratios ulong 32 +global times ulong 32 +global firsts ulong 32 +global summary ulong 12 +fn pstart n ulong to int +put pstate 3 0 +if lt n 5 +ret 65 +end +if gt n 32 +ret 65 +end +if ne get pconfig 0 1024 +if ne get pconfig 0 32768 +ret 77 +end +end +if gt get pconfig 1 1 +ret 65 +end +if eq get pconfig 2 0 +ret 65 +end +if eq get pconfig 3 0 +ret 65 +end +if gt get pconfig 3 256 +ret 65 +end +if gt get pconfig 4 1 +ret 65 +end +v = svalid +if ne v 0 +ret v +end +v = pids +if ne v 0 +ret v +end +if eq get pconfig 4 1 +if ne get sprofile 4 2 +ret 69 +end +end +for i ulong 32 +put pbind i get sid i +end +put pbind 32 get sprofile 1 +put pbind 33 get sprofile 4 +for i ulong 5 +put pbind add i 34 get pconfig i +end +for i ulong 128 +put pinned i get parmids i +end +for i ulong 128 +put pslots i 0 +end +for i ulong 4 +put pstate i 0 +end +put pstate 3 n +ret 0 +end +fn pids to int +note Same model/tokenizer/numerics/protocol in all arms. Base build may differ. +for a ulong 4 +note A different base build still needs an identity; unused components bind a named absent identity. +for d ulong 8 +nonzero = ulong 0 +for j ulong 4 +nonzero = or nonzero get parmids add add mul a 32 mul d 4 j +end +if eq nonzero 0 +ret 69 +end +end +for i ulong 32 +required = false +if lt i 12 +required = true +end +if ge i 28 +required = true +end +if gt a 0 +if lt i 20 +required = true +end +end +if ge a 2 +required = true +end +if required +if ne get parmids add mul a 32 i get sid i +ret 69 +end +end +end +end +ret 0 +end +fn pvalid to int +if eq get pstate 3 0 +ret 75 +end +for i ulong 5 +if ne get pbind add i 34 get pconfig i +ret 69 +end +end +for i ulong 32 +if ne get pbind i get sid i +ret 69 +end +if ne get sid i get sid add i 32 +ret 69 +end +end +if ne get pbind 32 get sprofile 1 +ret 69 +end +if ne get pbind 33 get sprofile 4 +ret 69 +end +ord = get pstate 0 +if ge ord mul get pstate 3 4 +ret 65 +end +if ne get pobs 22 ord +ret 65 +end +pair = div ord 4 +if ne get pobs 0 pair +ret 65 +end +if ne get pobs 1 rem add ord pair 4 +ret 65 +end +for i ulong 32 +expected = get pinned add mul get pobs 1 32 i +if ne get pobs add i 24 expected +ret 69 +end +end +if ne get pobs 2 get pconfig 2 +ret 69 +end +if ne get pobs 23 get pconfig 0 +ret 69 +end +if ne get pobs 20 get pbind 32 +ret 69 +end +if ne get pobs 21 get pconfig 1 +ret 69 +end +for d ulong 2 +v = ulong 0 +for j ulong 4 +v = or v get pobs add add 3 mul d 4 j +end +if eq v 0 +ret 69 +end +end +if eq get pobs 11 0 +ret 65 +end +if gt get pobs 11 256 +ret 65 +end +if lt get pobs 13 get pobs 12 +ret 65 +end +if lt get pobs 14 get pobs 13 +ret 65 +end +elapsed = sub get pobs 14 get pobs 12 +if eq elapsed 0 +ret 65 +end +if gt elapsed 1000000000 +ret 65 +end +if eq get pobs 15 0 +ret 65 +end +if lt get pobs 16 1 +ret 65 +end +if gt get pobs 16 2 +ret 65 +end +if eq get pobs 16 2 +if ne get pobs 11 256 +ret 65 +end +end +if ne get pobs 17 1 +ret 69 +end +if ne get pobs 18 1 +ret 75 +end +if ne get pobs 19 0 +ret 75 +end +ret 0 +end +fn padd to int +n = get pstate 0 +if ge n 256 +ret 77 +end +status = pvalid +for i ulong 56 +put praw add mul n 56 i get pobs i +end +put pstate 0 add n 1 +if ne status 0 +put pstate 1 add get pstate 1 1 +ret status +end +slot = add mul get pobs 0 4 get pobs 1 +if ne get pslots slot 0 +put pstate 1 add get pstate 1 1 +ret 65 +end +put pslots slot add n 1 +if lt get pobs 11 get pconfig 3 +put pstate 2 1 +end +ret 0 +end +fn prow pair ulong arm ulong to ulong +ret mul sub get pslots add mul pair 4 arm 1 56 +end +fn pfinish to int +if eq get pstate 3 0 +ret 75 +end +for i ulong 5 +if ne get pbind add i 34 get pconfig i +ret 69 +end +end +if ne get pstate 1 0 +ret 75 +end +if ne get pstate 0 mul get pstate 3 4 +ret 75 +end +for i ulong 32 +if ne get pbind i get sid i +ret 69 +end +if ne get sid i get sid add i 32 +ret 69 +end +end +if ne get pbind 32 get sprofile 1 +ret 69 +end +if ne get pbind 33 get sprofile 4 +ret 69 +end +for p ulong get pstate 3 +for a ulong 4 +if eq get pslots add mul p 4 a 0 +ret 75 +end +end +base = prow p 0 +if not pprompt base prow 0 0 +ret 69 +end +for a ulong 4 +row = prow p a +if not pequal base row +ret 69 +end +end +end +ret 0 +end +fn pprompt a ulong b ulong to bool +for i ulong 4 +left = get praw add add a 3 i +right = get praw add add b 3 i +if ne left right +ret false +end +end +ret true +end +fn pequal base ulong row ulong to bool +note Exact greedy output digest and length must agree before speed is interpreted. +for i ulong 9 +left = get praw add add base 3 i +right = get praw add add row 3 i +if ne left right +ret false +end +end +if ne get praw add base 16 get praw add row 16 +ret false +end +ret true +end +fn psort n ulong to void +for i ulong n +for j ulong sub n 1 +if gt get ratios j get ratios add j 1 +t = get ratios j +put ratios j get ratios add j 1 +put ratios add j 1 t +end +if gt get times j get times add j 1 +t = get times j +put times j get times add j 1 +put times add j 1 t +end +if gt get firsts j get firsts add j 1 +t = get firsts j +put firsts j get firsts add j 1 +put firsts add j 1 t +end +end +end +end +fn prank n ulong to ulong +note Exact two-sided 95% distribution-free interval for median paired ratio. +note P[Binomial(n,1/2) < k] <= 1/40. n <=32 keeps every product in uint64. +choose = ulong 1 +sum = ulong 0 +k = ulong 0 +for i ulong add div n 2 1 +sum = add sum choose +if le mul sum 40 shl 1 n +k = add i 1 +end +choose = div mul choose sub n i add i 1 +end +ret k +end +fn pmeasure pair ulong arm ulong to void +a = prow pair 3 +b = prow pair arm +ta = sub get praw add a 14 get praw add a 12 +tb = sub get praw add b 14 get praw add b 12 +put ratios pair div mul tb 1000000 ta +put times pair ta +put firsts pair sub get praw add a 13 get praw add a 12 +if gt get praw add a 15 get summary 9 +put summary 9 get praw add a 15 +end +end +fn preport arm ulong to int +if gt arm 2 +ret 65 +end +for i ulong 12 +put summary i 0 +end +status = pfinish +if ne status 0 +ret status +end +n = get pstate 3 +for p ulong n +pmeasure p arm +end +psort n +mid = div n 2 +put summary 0 n +put summary 1 arm +put summary 2 get ratios mid +put summary 5 get times mid +put summary 7 get firsts mid +if eq rem n 2 0 +put summary 2 div add get ratios mid get ratios sub mid 1 2 +put summary 5 div add get times mid get times sub mid 1 2 +put summary 7 div add get firsts mid get firsts sub mid 1 2 +end +p95 = sub div add mul n 95 99 100 1 +put summary 6 get times p95 +put summary 8 get firsts p95 +rank = prank n +put summary 11 get pbind 33 +if eq rank 0 +put summary 4 18446744073709551615 +ret 0 +end +put summary 3 get ratios sub rank 1 +put summary 4 get ratios sub n rank +if eq get pstate 2 1 +ret 0 +end +if gt get summary 3 1000000 +put summary 10 1 +end +if lt get summary 4 1000000 +put summary 10 3 +end +if eq get summary 3 1000000 +if eq get summary 4 1000000 +put summary 10 2 +end +end +ret 0 +end diff --git a/native/speculation/service.om b/native/speculation/service.om new file mode 100644 index 00000000..7a2e195f --- /dev/null +++ b/native/speculation/service.om @@ -0,0 +1,259 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Persistent native policy process. The model owner retains every model-state operation. +note SCP1 request: magic, version, operation, sequence, body words. All words little-endian u64. +global wreq uchar 2048 +global wout uchar 128 +global wstate ulong 4 +fn wget i ulong to ulong +v = ulong 0 +for j ulong 8 +v = or v shl ulong get wreq add mul i 8 j mul j 8 +end +ret v +end +fn wput i ulong v ulong to void +for j ulong 8 +put wout add mul i 8 j uchar and shr v mul j 8 255 +end +end +fn wread off ulong n ulong to int +done = ulong 0 +for retry ulong 1000000 +if eq done n +ret 0 +end +r = read 0 wreq add off done sub n done +if eq r 0 +if eq done 0 +ret 1 +end +ret 65 +end +if lt r 0 +if ne r neg long 4 +ret 74 +end +else +done = add done ulong r +end +end +ret 74 +end +fn wwrite n ulong to int +done = ulong 0 +for retry ulong 1000000 +if eq done n +ret 0 +end +r = write 1 wout done sub n done +if eq r 0 +ret 74 +end +if lt r 0 +if ne r neg long 4 +ret 74 +end +else +done = add done ulong r +end +end +ret 74 +end +fn wshape op ulong to ulong +if eq op 1 +ret 178 +end +if eq op 2 +ret 3 +end +if eq op 3 +ret 6 +end +if eq op 4 +ret 5 +end +ret 0 +end +fn winit to int +if ne get wstate 0 0 +ret 75 +end +for i ulong 64 +put sid i wget add i 5 +end +for i ulong 6 +put sprofile i wget add i 69 +end +for i ulong 77 +put srows i wget add i 75 +end +for i ulong 31 +put sprior i wget add i 152 +end +v = svalid +if ne v 0 +ret v +end +put wstate 0 1 +ret 0 +end +fn wbegin to int +phase = get wstate 0 +if ne phase 1 +if ne phase 3 +ret 75 +end +end +if gt wget 6 1 +ret 65 +end +if eq wget 6 1 +if ne get sprofile 4 2 +ret 69 +end +end +v = sbegin wget 5 +if ne v 0 +ret v +end +put scontrol 0 wget 6 +put scontrol 1 wget 7 +put wstate 0 2 +ret 0 +end +fn wselect to int +v = sselect wget 5 wget 6 wget 7 wget 8 wget 9 wget 10 +if ne v 0 +ret v +end +for i ulong 5 +wput add i 7 get decision i +end +put wstate 2 5 +ret 0 +end +fn wobserve to int +v = sobserve wget 5 wget 6 wget 7 wget 8 wget 9 +if ne v 0 +ret v +end +for i ulong 4 +wput add i 7 get sstate add i 6 +end +put wstate 2 4 +ret 0 +end +fn wcall op ulong to int +put wstate 2 0 +if eq op 1 +ret winit +end +if eq op 2 +ret wbegin +end +if eq op 8 +if eq get wstate 0 2 +ret 75 +end +put wstate 3 1 +ret 0 +end +if ne get wstate 0 2 +ret 75 +end +if eq op 3 +ret wselect +end +if eq op 4 +ret wobserve +end +if eq op 5 +ret sresume +end +if eq op 6 +scancel +put wstate 0 3 +ret 0 +end +if ne get sstate 9 1 +ret 75 +end +if ne get sstate 0 0 +ret 75 +end +put wstate 0 3 +ret 0 +end +fn wpacket to int +if ne wget 0 827343699 +ret 65 +end +if ne wget 1 1 +ret 69 +end +op = wget 2 +if lt op 1 +ret 77 +end +if gt op 8 +ret 77 +end +if ne wget 3 get wstate 1 +ret 69 +end +if ne wget 4 wshape op +ret 65 +end +v = wread 40 mul wget 4 8 +if eq v 1 +ret 65 +end +if ne v 0 +ret v +end +start = monons +if lt start 0 +ret 74 +end +status = wcall op +elapsed = sub monons start +if lt elapsed 0 +ret 74 +end +wput 0 827343699 +wput 1 1 +wput 2 op +wput 3 get wstate 1 +wput 4 ulong status +wput 5 get wstate 2 +wput 6 ulong elapsed +v = wwrite mul add get wstate 2 7 8 +if ne v 0 +ret v +end +put wstate 1 add get wstate 1 1 +ret 0 +end +fn main to int +put wstate 1 1 +for command ulong 1000000 +v = wread 0 40 +if eq v 1 +if eq get wstate 0 2 +ret 75 +end +ret 0 +end +if ne v 0 +ret v +end +v = wpacket +if ne v 0 +ret v +end +if eq get wstate 3 1 +ret 0 +end +end +ret 77 +end diff --git a/tests/speculation/cost-test.om b/tests/speculation/cost-test.om new file mode 100644 index 00000000..73196958 --- /dev/null +++ b/tests/speculation/cost-test.om @@ -0,0 +1,141 @@ +note SPDX-License-Identifier: AGPL-3.0-only +fn sample r ulong n ulong to void +for i ulong 16 +put cobs i 0 +end +put cobs 0 r +put cobs 1 n +put cobs 2 1 +put cobs 5 add 100 n +put cobs 8 1 +put cobs 10 add 106 n +put cobs 11 add 100 mul r 10 +put cobs 12 add slen r 1 +put cobs 13 7 +put cobs 14 1 +put cobs 15 63 +end +fn collect to void +fixture +check eq cstart 0 +check eq cseal 75 +for r ulong 7 +for i ulong 5 +sample r i +check eq cadd 0 +end +end +check eq cseal 0 +check eq scost 0 108 +check eq get srows 4 102 +check eq get srows 6 5 +check eq get crange 0 106 +check eq get crange 1 110 +check eq get craw 74 110 +check eq get srows 10 5 +check eq get srows 75 160 +check eq svalid 0 +check eq sbegin 0 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 3 108 +scancel +end +fn reject to void +fixture +check eq cstart 0 +sample 0 0 +put cobs 15 31 +check eq cadd 65 +sample 0 0 +put cobs 5 0 +check eq cadd 65 +sample 0 0 +put cobs 2 0 +check eq cadd 75 +sample 0 0 +put cobs 3 1 +check eq cadd 75 +sample 0 0 +put cobs 10 100 +check eq cadd 65 +sample 0 0 +put cobs 10 18446744073709551615 +check eq cadd 65 +sample 0 0 +put cobs 5 18446744073709551615 +check eq cadd 65 +sample 0 0 +put cobs 4 1 +check eq cadd 65 +sample 0 0 +put cobs 13 8 +check eq cadd 69 +sample 0 0 +put cobs 14 2 +check eq cadd 69 +sample 0 0 +put cobs 12 2 +check eq cadd 65 +sample 7 0 +check eq cadd 65 +sample 0 0 +put cobs 11 0 +check eq cadd 65 +sample 0 1 +check eq cadd 65 +check eq get ccount 0 0 +sample 0 0 +check eq cadd 0 +check eq cadd 65 +check eq get ccount 0 1 +put sid 0 999 +check eq cseal 69 +sample 0 1 +check eq cadd 69 +end +fn capacity to void +fixture +note Unsupported shapes must be declared before collection, not dropped after observing costs. +for r ulong 7 +if gt r 0 +put srows mul r 11 0 +end +end +check eq cstart 0 +for i ulong 32 +sample 0 i +check eq cadd 0 +end +sample 0 32 +check eq cadd 77 +check eq get ccount 0 32 +check eq get craw 506 137 +check eq cseal 0 +check eq get srows 11 0 +put srows 11 1 +check eq cseal 69 +end +fn main to int +collect +reject +capacity +fixture +check eq cstart 0 +sample 0 0 +put sprofile 2 1 +check eq cadd 69 +check eq cseal 69 +fixture +check eq cstart 0 +put sprofile 3 64000 +check eq cadd 69 +check eq cseal 69 +fixture +check eq cstart 0 +put srows 11 0 +check eq cadd 69 +check eq cseal 69 +ret finish +end diff --git a/tests/speculation/model-map-test.om b/tests/speculation/model-map-test.om new file mode 100644 index 00000000..0e4b097c --- /dev/null +++ b/tests/speculation/model-map-test.om @@ -0,0 +1,77 @@ +note Read-only weight-file attachment test. No tensor math, GPU or inference is performed. +note argv[1] is one local safetensors shard. Compare real mapped bytes with independent file reads. +global path uchar 4096 +global meta uchar 128 +global after uchar 128 +global mapped uchar 4096 +global direct uchar 4096 +text pass "MODEL_MAP_SAMPLES_PASS 37\n" +fn check yes bool to void +if not yes +exit int 80 +end +end +fn sizeword to ulong +v = ulong 0 +for i ulong 8 +v = or v shl ulong get meta add i 48 mul i 8 +end +ret v +end +fn compare fd int handle long off ulong n ulong to void +check eq mapread handle off mapped 0 n long n +check eq fseek fd long off 0 long off +used = ulong 0 +while lt used n +got = read fd direct used sub n used +check gt got 0 +used = add used ulong got +end +for i ulong n +check eq get mapped i get direct i +end +end +fn main to int +check eq argcnt 2 +pn = argread 1 path 0 len path +check and gt pn 0 lt pn long len path +fd = fopen path 0 ulong pn 524288 0 +check ge fd 0 +check eq fstat int fd meta 0 128 0 +size = sizeword +check and ge size 16 le size 68719476736 +handle = mapnew int fd 0 size 1 2 +check gt handle 0 +compare int fd handle 0 8 +header = ulong 0 +for i ulong 8 +header = or header shl ulong get mapped i mul i 8 +end +check and ge header 2 le header sub size 8 +check le header 67108864 +compare int fd handle 8 1 +check eq get mapped 0 123 +compare int fd handle add 7 header 1 +check or eq get mapped 0 125 eq get mapped 0 32 +take = ulong 4096 +if lt size take +take = size +end +compare int fd handle 0 take +compare int fd handle sub size take take +for i ulong 32 +off = div mul sub size take i 31 +compare int fd handle off take +end +note Recheck file identity, length and modification metadata. atime is allowed to change. +check eq fstat int fd after 0 128 0 +for i ulong 128 +if or or lt i 16 and ge i 48 lt i 56 and ge i 88 lt i 120 +check eq get after i get meta i +end +end +check eq mapdrop handle 0 +check eq fclose int fd 0 +check eq write 1 pass 0 len pass long len pass +ret 0 +end diff --git a/tests/speculation/native-channel-test.om b/tests/speculation/native-channel-test.om new file mode 100644 index 00000000..a7027916 --- /dev/null +++ b/tests/speculation/native-channel-test.om @@ -0,0 +1,52 @@ +note Physical empty-channel lifecycle. No command packets or GPU kernels submitted. +global diag uchar 24 +text ok "NATIVE_DEVICE_CHANNEL_PASS\n" +text bad "NATIVE_DEVICE_CHANNEL_FAIL\n" +fn pack off ulong v long to void +for i ulong 8 +put diag add off i uchar and shr v mul i 8 255 +end +end +fn ck yes bool to void +if not yes +pack 0 long get nvstage 0 +pack 8 get nverr 0 +closed = nvstop +pack 16 long get nvfault 0 +r = write 2 bad 0 len bad +r = write 1 diag 0 len diag +exit int 80 +end +end +fn main to int +for attempt ulong 3 +ck nvfull +ck nvchan +ck not nvchan +ck eq get nverr 0 neg long 16 +ck eq get nvsched 0 1 +ck eq get nvchreg 0 1 +ck eq get nvput 0 0 +ck eq mapget get nvfifo 0 8332 4 0 +ck lt mapaddr get nvfifo 0 1099511627776 +ck not nvdrop get nvfifo 0 +ck eq get nverr 0 neg long 16 +put nverr 0 0 +ck nvstop +ck nvstop +for i ulong len nvmflag +ck eq get nvmflag i 0 +end +for i ulong len nvobj +ck eq get nvobj i 0 +end +for i ulong len nvfd +ck eq get nvfd i neg int 1 +end +ck eq get nvbar 0 0 +ck eq get nvchva 0 0 +ck eq get nvfault 0 0 +end +ck eq write 1 ok 0 len ok long len ok +ret 0 +end diff --git a/tests/speculation/native-device-test.om b/tests/speculation/native-device-test.om new file mode 100644 index 00000000..63f93ce9 --- /dev/null +++ b/tests/speculation/native-device-test.om @@ -0,0 +1,27 @@ +note Physical device context acceptance. No kernels, timings or model execution. +text ok "NATIVE_DEVICE_CONTEXT_PASS\n" +text bad "NATIVE_DEVICE_CONTEXT_FAIL\n" +global result uchar 24 +fn pack off ulong v long to void +for i ulong 8 +put result add off i uchar and shr v mul i 8 255 +end +end +fn main to int +for attempt ulong 3 +good = nvstart +stage = get nvstage 0 +error = get nverr 0 +closed = nvstop +if not and good closed +r = write 2 bad 0 len bad +pack 0 long stage +pack 8 error +pack 16 long get nvsm 0 +r = write 1 result 0 len result +ret 1 +end +end +r = write 1 ok 0 len ok +ret 0 +end diff --git a/tests/speculation/native-kernel-test.om b/tests/speculation/native-kernel-test.om new file mode 100644 index 00000000..8a2adc09 --- /dev/null +++ b/tests/speculation/native-kernel-test.om @@ -0,0 +1,57 @@ +note Physical seeded Omega vector-kernel qualification, full output checks and safe wrong-math control. +global diag uchar 24 +text ok "NATIVE_SM121_VECTOR_PASS\n" +text bad "NATIVE_SM121_VECTOR_FAIL\n" +fn pack off ulong v long to void +for i ulong 8 +put diag add off i uchar and shr v mul i 8 255 +end +end +fn ck yes bool to void +if not yes +pack 0 long get nvstage 0 +pack 8 get nverr 0 +closed = nvstop +pack 16 long get nvfault 0 +r = write 2 bad 0 len bad +r = write 1 diag 0 len diag +exit int 80 +end +end +fn trial n uint salt ulong wrong bool to void +prepare n salt +ck gblaunch n +verify n salt wrong +end +fn program wrong bool to void +gbvec +if wrong +note IADD3 R9,R2,RZ safely computes the wrong value while retaining all memory bounds. +put gbcode 276 255 +end +m = nvalloc 4096 true +ck gt m 0 +put gbmem 4 m +ck eq mapwrite m 0 gbcode 0 get gblen 0 long get gblen 0 +end +fn main to int +ck gbopen 1048576 +ck not gblaunch 0 +ck not gblaunch 1048577 +trial 1 1 false +trial 63 17 false +trial 64 31 false +trial 65 47 false +trial 257 63 false +trial 4097 97 false +trial 65537 131 false +trial 1048576 257 false +program true +trial 4097 311 true +program false +trial 4097 367 false +ck nvstop +ck eq get nvfault 0 0 +ck eq write 1 ok 0 len ok long len ok +ret 0 +end diff --git a/tests/speculation/native-launch-data.om b/tests/speculation/native-launch-data.om new file mode 100644 index 00000000..58d72abf --- /dev/null +++ b/tests/speculation/native-launch-data.om @@ -0,0 +1,53 @@ +note Host-only launch-data differential. The managed address reservations touch no GPU. +fn main to int +gbvec +if ne write 1 gbcode 0 get gblen 0 512 +ret 80 +end +for trial ulong 5 +base = add 68719476736 mul trial 1073741824 +for i ulong 8 +h = maphold add base mul i 65536 65536 +if le h 0 +ret 81 +end +put gbmem i h +end +n = uint 1 +if eq trial 1 +n = uint 63 +end +if eq trial 2 +n = uint 64 +end +if eq trial 3 +n = uint 65 +end +if eq trial 4 +n = uint 4097 +end +gbqmd n +put gbused 0 0 +for i ulong 224 +gbemit get gbcb i +end +for i ulong 96 +gbemit get gbq0 i +end +for i ulong 96 +gbemit get gbq1 i +end +for i ulong 7 +gbemit get gbargs i +end +if ne write 1 gbcmd 0 get gbused 0 1692 +ret 82 +end +for i ulong 8 +if ne mapdrop get gbmem i 0 +ret 83 +end +end +end +ret 0 +end diff --git a/tests/speculation/native-memory-test.om b/tests/speculation/native-memory-test.om new file mode 100644 index 00000000..59fe87ba --- /dev/null +++ b/tests/speculation/native-memory-test.om @@ -0,0 +1,82 @@ +note Physical RM/UVM buffer lifecycle and CPU access. No kernel or GPU coherence claim. +global payload uchar 256 +global readback uchar 256 +global diag uchar 24 +text ok "NATIVE_DEVICE_MEMORY_PASS\n" +text bad "NATIVE_DEVICE_MEMORY_FAIL\n" +fn pack off ulong v long to void +for i ulong 8 +put diag add off i uchar and shr v mul i 8 255 +end +end +fn ck yes bool to void +if not yes +pack 0 long get nvstage 0 +pack 8 get nverr 0 +closed = nvstop +pack 16 long get nvfault 0 +r = write 2 bad 0 len bad +r = write 1 diag 0 len diag +exit int 80 +end +end +fn checkmem m long size ulong salt uint to void +ck gt m 0 +ck eq and mapaddr m 4095 0 +ck eq mapget m 0 8 0 +ck eq mapget m sub size 8 8 0 +for i ulong 256 +put payload i uchar and add uint i salt 255 +end +off = ulong 0 +while lt off size +ck eq mapwrite m off payload 0 256 256 +off = add off 256 +end +off = ulong 0 +while lt off size +ck eq mapread m off readback 0 256 256 +for i ulong 256 +ck eq get readback i get payload i +end +off = add off 256 +end +end +fn main to int +ck nvstop +for attempt uint 3 +ck nvfull +ck not nvstart +ck eq get nverr 0 neg long 16 +put nverr 0 0 +a = nvalloc 4096 true +checkmem a 4096 attempt +b = nvalloc 65536 false +checkmem b 65536 add attempt 17 +ck ne mapaddr a mapaddr b +ck eq mapget a 0 4 ulong add uint 50462976 mul attempt 16843009 +ck nvdrop a +ck not nvdrop a +ck eq get nverr 0 neg long 22 +put nverr 0 0 +c = nvalloc 1048576 true +checkmem c 1048576 add attempt 31 +ck ne c a +ck nvdrop b +ck nvdrop c +d = nvalloc 4097 true +checkmem d 8192 add attempt 47 +note The final live buffer is intentionally released by context shutdown. +ck nvstop +ck nvstop +for i ulong len nvmflag +ck eq get nvmflag i 0 +end +for i ulong len nvfd +ck eq get nvfd i neg int 1 +end +ck eq get nvfault 0 0 +end +ck eq write 1 ok 0 len ok long len ok +ret 0 +end diff --git a/tests/speculation/native-submit-test.om b/tests/speculation/native-submit-test.om new file mode 100644 index 00000000..c3f60f31 --- /dev/null +++ b/tests/speculation/native-submit-test.om @@ -0,0 +1,80 @@ +note Physical FIFO semaphore writes, including ring wrap and timeout latching. +note No SM kernel, model inference, performance claim or live-service replacement. +global diag uchar 24 +text ok "NATIVE_DEVICE_SUBMIT_PASS\n" +text bad "NATIVE_DEVICE_SUBMIT_FAIL\n" +fn pack off ulong v long to void +for i ulong 8 +put diag add off i uchar and shr v mul i 8 255 +end +end +fn ck yes bool to void +if not yes +pack 0 long get nvstage 0 +pack 8 get nverr 0 +closed = nvstop +pack 16 long get nvfault 0 +r = write 2 bad 0 len bad +r = write 1 diag 0 len diag +exit int 80 +end +end +fn packet pb long sem long value uint to void +va = mapaddr sem +ck eq mapset sem 0 4 0 0 +ck eq mapset pb 0 4 537198615 0 +ck eq mapset pb 4 4 and va 4294967295 0 +ck eq mapset pb 8 4 shr va 32 0 +ck eq mapset pb 12 4 ulong value 0 +ck eq mapset pb 16 4 0 0 +ck eq mapset pb 20 4 1048577 0 +end +fn main to int +for attempt ulong 2 +ck nvfull +ck nvchan +pb = nvalloc 4096 false +sem = nvalloc 4096 false +ck gt pb 0 +ck gt sem 0 +ck not nvsend pb 0 0 +ck not nvsend pb 4096 6 +ck not nvsend pb 1 6 +ck eq get nvput 0 0 +for i uint 1026 +value = add i 1 +packet pb sem value +ck eq mapget sem 0 4 0 +ck nvsend pb 0 6 +ck not nvsend pb 0 6 +ck not nvdrop sem +ck eq get nverr 0 neg long 16 +ck nvwait sem 0 value 2000000000 +ck eq mapget sem 0 4 ulong value +ck eq get nvput 0 get nvret 0 +end +ck nvdrop sem +ck nvdrop pb +ck nvstop +ck eq get nvfault 0 0 +end +note A deliberately wrong expected payload must time out and prevent further work. +ck nvfull +ck nvchan +pb = nvalloc 4096 false +sem = nvalloc 4096 false +ck gt pb 0 +ck gt sem 0 +packet pb sem 4096 +ck nvsend pb 0 6 +ck not nvwait sem 0 4097 1000000 +ck eq get nverr 0 neg long 110 +ck eq get nvfault 0 1 +ck not nvsend pb 0 6 +ck not nvdrop sem +ck nvstop +ck not nvstart +ck eq get nverr 0 neg long 5 +ck eq write 1 ok 0 len ok long len ok +ret 0 +end diff --git a/tests/speculation/oracle-test.om b/tests/speculation/oracle-test.om new file mode 100644 index 00000000..c4a1c979 --- /dev/null +++ b/tests/speculation/oracle-test.om @@ -0,0 +1,68 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Independent finite oracle: a two-outcome drafter accepts everything with p, +note or rejects the first token with 1-p, so E = 1 + k*p without a survival loop. +global lens ulong 7 +global oparams ulong 4 +fn oracle to ulong +best = ulong 0 +be = ulong 1000000 +bt = ulong 101 +for r ulong 7 +k = get lens r +if le add k 1 get oparams 2 +if le add 100 mul r 10 get oparams 3 +expect = add 1000000 mul k get oparams 0 +cost = add 101 mul get oparams 1 mul k k +if gt mul expect bt mul be cost +best = k +be = expect +bt = cost +end +end +end +end +ret best +end +fn trialcase remain ulong to void +put oparams 2 remain +check eq sbegin 0 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 remain get oparams 3 7 2 0 0 +check eq get decision 0 oracle +check le get decision 1 remain +check le get decision 2 32000000 +scancel +end +fn sweep to void +fixture +put lens 0 0 +put lens 1 1 +put lens 2 2 +put lens 3 4 +put lens 4 8 +put lens 5 16 +put lens 6 31 +for p ulong 5 +put oparams 0 mul p 250000 +for i ulong 31 +put sprior i get oparams 0 +end +for curve ulong 8 +put oparams 1 curve +for r ulong 7 +put srows add mul r 11 4 add 100 mul curve mul get lens r get lens r +end +for m ulong 2 +put oparams 3 add 130 mul m 30 +for i ulong 32 +trialcase add i 1 +end +end +end +end +end +fn main to int +sweep +ret finish +end diff --git a/tests/speculation/packet-fixture.om b/tests/speculation/packet-fixture.om new file mode 100644 index 00000000..a27f963e --- /dev/null +++ b/tests/speculation/packet-fixture.om @@ -0,0 +1,115 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Native emitter for synthetic public stream fixtures. Selector1 policy,2 costs,3 pairs. +global frame uchar 32768 +global selector uchar 2 +fn fw i ulong v ulong to void +for j ulong 8 +put frame add mul i 8 j uchar and shr v mul j 8 255 +end +end +fn fcost to ulong +fw 182 35 +for r ulong 7 +for n ulong 5 +b = add 183 mul add mul r 5 n 16 +fw b r +fw add b 1 n +fw add b 2 1 +fw add b 5 add 100 n +fw add b 8 1 +fw add b 10 add 106 n +fw add b 11 add 100 mul r 10 +fw add b 12 add slen r 1 +fw add b 13 7 +fw add b 14 1 +fw add b 15 63 +end +end +ret 5944 +end +fn fpairs to ulong +fw 182 1024 +fw 184 1 +fw 185 32 +fw 187 8 +fw 188 32 +for i ulong 128 +fw add i 189 get sid rem i 32 +end +for ord ulong 32 +b = add 317 mul ord 56 +arm = rem add ord div ord 4 4 +fw b div ord 4 +fw add b 1 arm +fw add b 2 1 +for i ulong 8 +fw add add b 3 i add i 1 +end +fw add b 11 64 +fw add b 12 1000 +fw add b 13 1010 +fw add b 14 1200 +if eq arm 3 +fw add b 14 1100 +end +fw add b 15 1000 +fw add b 16 1 +fw add b 17 1 +fw add b 18 1 +fw add b 20 7 +fw add b 22 ord +fw add b 23 1024 +for i ulong 32 +fw add add b 24 i get sid i +end +end +ret 16872 +end +fn main to int +r = read 0 selector 0 2 +if ne r 1 +ret 65 +end +mode = ulong get selector 0 +if lt mode 1 +ret 65 +end +if gt mode 3 +ret 65 +end +fixture +fw 0 827867987 +fw 1 1 +fw 2 mode +for i ulong 64 +fw add i 4 get sid i +end +for i ulong 6 +fw add i 68 get sprofile i +end +for i ulong 77 +fw add i 74 get srows i +end +for i ulong 31 +fw add i 151 get sprior i +end +bytes = ulong 1520 +if eq mode 1 +fw 184 1000 +fw 185 256 +fw 186 1000 +fw 187 7 +fw 188 2 +end +if eq mode 2 +bytes = fcost +end +if eq mode 3 +bytes = fpairs +end +w = write 1 frame 0 bytes +if ne w long bytes +ret 74 +end +ret 0 +end diff --git a/tests/speculation/policy-test.om b/tests/speculation/policy-test.om new file mode 100644 index 00000000..03002c42 --- /dev/null +++ b/tests/speculation/policy-test.om @@ -0,0 +1,239 @@ +note SPDX-License-Identifier: AGPL-3.0-only +fn flat to void +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 0 31 +check eq get decision 1 32 +check eq get decision 2 32000000 +check eq get decision 3 101 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 75 +check eq sobserve 31 32 101 0 1 0 +check eq get sstate 6 32 +check eq get sstate 7 31 +check eq get sstate 8 1 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1031 224 1000 7 2 0 75 +check eq sresume 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1032 224 1000 7 2 0 0 +scancel +end +fn stepped to void +fixture +put srows 70 1000 +put srows 59 1000 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 0 8 +scancel +fixture +for i ulong 31 +put sprior i 0 +end +check eq sbegin 0 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 0 0 +scancel +fixture +note Exact tie: ordinary expected1/cost101 and k1 expected2/cost202. +for r ulong 7 +put srows add mul r 11 4 sub mul add slen r 1 101 1 +end +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 0 0 +scancel +end +fn bounds to void +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 3 1000 7 2 0 0 +check eq get decision 0 2 +scancel +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 130 7 2 0 0 +check eq get decision 0 4 +scancel +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 32999 256 1000 7 2 0 0 +check eq get decision 0 0 +scancel +check eq sselect 1000 256 1000 7 2 0 75 +check eq sbegin 0 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 33000 256 1000 7 2 0 69 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 999 256 1000 7 2 0 69 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 99 7 2 0 77 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 0 1000 7 2 0 65 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 257 1000 7 2 0 65 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 8 2 0 69 +put scontrol 0 1 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 69 +put scontrol 0 0 +put scontrol 1 1 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 0 0 +check eq get decision 4 2 +scancel +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 1 8 0 +check eq get decision 0 8 +scancel +check eq sbegin 0 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 1 3 77 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 3 0 65 +end +fn invalid to void +fixture +put sid 31 999 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 69 +fixture +put sprofile 0 2 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 69 +fixture +put sprofile 5 2 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 77 +fixture +put srows 68 31 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 65 +fixture +put srows 4 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 65 +fixture +put srows 4 18446744073709551615 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 65 +fixture +put srows 10 4 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 65 +fixture +put sprior 2 1000001 +check eq sbegin 0 65 +fixture +put sprior 1 0 +check eq sbegin 0 65 +fixture +put srows 66 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq get decision 0 16 +scancel +fixture +for i ulong 4 +put sid i 0 +put sid add i 32 0 +end +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 69 +end +fn recovery to void +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq sobserve 32 33 101 0 1 65 +check eq sobserve 31 32 101 0 0 75 +check eq get sstate 6 0 +check eq sobserve 31 32 0 0 1 65 +check eq sobserve 0 1 10000 0 1 0 +check eq get sstate 8 1 +check eq sresume 0 +note Every speculative row now has a measured loss; fallback until bounded probe. +for r ulong 7 +if gt r 0 +put measured r 10000 +end +end +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1001 255 1000 7 2 0 0 +check eq get decision 0 0 +check eq get decision 4 3 +check eq sobserve 0 1 101 0 1 0 +check eq sresume 0 +put sstate 5 8 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1002 254 1000 7 2 0 0 +check gt get decision 0 0 +check eq get decision 4 4 +check eq sobserve get decision 0 add get decision 0 1 101 0 1 0 +check eq sresume 0 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1034 222 1000 7 2 0 0 +check gt get decision 0 0 +scancel +fixture +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1000 256 1000 7 2 0 0 +check eq sobserve 3 4 101 1 1 0 +check eq get sstate 9 1 +put scontrol 0 0 +put scontrol 1 0 +check eq sselect 1004 252 1000 7 2 0 75 +check eq sbegin 0 0 +check eq get sstate 6 0 +check eq get measured 6 0 +check eq get survive 3 1000000 +check eq sbegin 1 0 +put sprofile 1 8 +check eq sbegin 1 69 +end +fn main to int +flat +stepped +bounds +invalid +recovery +ret finish +end diff --git a/tests/speculation/reply-test.om b/tests/speculation/reply-test.om new file mode 100644 index 00000000..8bac1113 --- /dev/null +++ b/tests/speculation/reply-test.om @@ -0,0 +1,66 @@ +note SPDX-License-Identifier: AGPL-3.0-only +global answer uchar 881 +fn aw i ulong to ulong +v = ulong 0 +for j ulong 8 +v = or v shl ulong get answer add mul i 8 j mul j 8 +end +ret v +end +fn main to int +n = ulong 0 +for i ulong 882 +if gt n 880 +ret 65 +end +r = read 0 answer n sub 881 n +if lt r 0 +ret 74 +end +if eq r 0 +if lt n 40 +ret 65 +end +check eq aw 0 827867987 +check eq aw 1 1 +check eq aw 3 1 +if eq aw 2 1 +check eq n 80 +check eq aw 4 5 +check eq aw 5 31 +check eq aw 6 32 +check eq aw 7 32000000 +check eq aw 8 101 +check eq aw 9 0 +ret finish +end +if eq aw 2 2 +check eq n 880 +check eq aw 4 105 +check eq aw 9 102 +check eq aw 11 5 +check eq aw 89 106 +check eq aw 90 110 +ret finish +end +if eq aw 2 3 +check eq n 328 +check eq aw 4 36 +for a ulong 3 +b = add 5 mul a 12 +check eq aw b 8 +check eq aw add b 1 a +check eq aw add b 2 2000000 +check eq aw add b 3 2000000 +check eq aw add b 4 2000000 +check eq aw add b 10 1 +check eq aw add b 11 1 +end +ret finish +end +ret 77 +end +n = add n ulong r +end +ret 65 +end diff --git a/tests/speculation/report-test.om b/tests/speculation/report-test.om new file mode 100644 index 00000000..6b514966 --- /dev/null +++ b/tests/speculation/report-test.om @@ -0,0 +1,205 @@ +note SPDX-License-Identifier: AGPL-3.0-only +fn group n ulong to void +fixture +put pconfig 0 1024 +put pconfig 1 0 +put pconfig 2 1 +put pconfig 3 32 +put pconfig 4 0 +for i ulong 128 +put parmids i get sid rem i 32 +end +check eq pstart n 0 +end +fn trial ord ulong to void +for i ulong 56 +put pobs i 0 +end +put pobs 0 div ord 4 +arm = rem add ord div ord 4 4 +put pobs 1 arm +for i ulong 32 +put pobs add i 24 get parmids add mul arm 32 i +end +put pobs 2 1 +for i ulong 8 +put pobs add i 3 add i 1 +end +put pobs 11 64 +put pobs 12 1000 +put pobs 13 1010 +put pobs 14 1200 +if eq arm 3 +put pobs 14 1100 +end +put pobs 15 1000 +put pobs 16 1 +put pobs 17 1 +put pobs 18 1 +put pobs 20 7 +put pobs 22 ord +put pobs 23 1024 +end +fn green to void +group 8 +check eq pfinish 75 +for i ulong 32 +trial i +check eq padd 0 +end +check eq pfinish 0 +for a ulong 3 +check eq preport a 0 +check eq get summary 0 8 +check eq get summary 1 a +check eq get summary 2 2000000 +check eq get summary 3 2000000 +check eq get summary 4 2000000 +check eq get summary 5 100 +check eq get summary 6 100 +check eq get summary 7 10 +check eq get summary 8 10 +check eq get summary 9 1000 +check eq get summary 10 1 +check eq get summary 11 1 +end +check eq preport 3 65 +note Correctness mismatch poisons comparisons, even with explicit success flags. +put praw add prow 0 3 7 999 +check eq pfinish 69 +check eq preport 0 69 +end +fn small to void +group 5 +for i ulong 20 +trial i +check eq padd 0 +end +check eq preport 2 0 +check eq get summary 10 0 +check eq get summary 3 0 +check eq get summary 4 18446744073709551615 +check eq prank 5 0 +check eq prank 6 1 +check eq prank 8 1 +check eq prank 10 2 +end +fn outcomes to void +group 6 +for i ulong 24 +trial i +put pobs 14 1200 +check eq padd 0 +end +check eq preport 1 0 +check eq get summary 10 2 +group 6 +for i ulong 24 +trial i +if eq get pobs 1 3 +put pobs 14 1400 +end +check eq padd 0 +end +check eq preport 1 0 +check eq get summary 2 500000 +check eq get summary 10 3 +group 6 +for i ulong 24 +trial i +put pobs 11 1 +check eq padd 0 +end +check eq preport 1 0 +check eq get summary 10 0 +end +fn invalid to void +group 6 +trial 0 +put pobs 18 0 +check eq padd 75 +check eq get pstate 1 1 +check eq get praw 18 0 +check eq pfinish 75 +group 6 +trial 1 +check eq padd 65 +check eq pfinish 75 +group 6 +trial 0 +put pobs 13 999 +check eq padd 65 +group 6 +trial 0 +put pobs 14 1005 +check eq padd 65 +group 6 +trial 0 +put pobs 19 1 +check eq padd 75 +group 6 +trial 0 +put pobs 17 0 +check eq padd 69 +group 6 +trial 0 +put pobs 21 1 +check eq padd 69 +group 6 +trial 0 +put pobs 16 2 +check eq padd 65 +group 6 +trial 0 +put pobs 11 0 +check eq padd 65 +group 6 +trial 0 +put pobs 14 18446744073709551615 +check eq padd 65 +group 6 +trial 0 +put sid 7 999 +check eq padd 69 +group 6 +trial 0 +put pobs 24 999 +check eq padd 69 +group 6 +put parmids 12 999 +check eq pstart 6 0 +trial 0 +check eq padd 0 +group 6 +put parmids 44 999 +check eq pstart 6 69 +group 6 +put parmids 84 999 +check eq pstart 6 69 +group 6 +trial 0 +put pconfig 0 32768 +check eq padd 69 +group 6 +put pconfig 4 1 +check eq pstart 6 69 +check eq pstart 4 65 +check eq pstart 33 65 +end +fn main to int +green +small +outcomes +invalid +note Missing baseline identities must not make an unqualified base look comparable. +for a ulong 2 +for d ulong 8 +group 6 +for j ulong 4 +put parmids add add mul a 32 mul d 4 j 0 +end +check eq pstart 6 69 +end +end +ret finish +end diff --git a/tests/speculation/run-teardown-host.sh b/tests/speculation/run-teardown-host.sh new file mode 100755 index 00000000..382647c8 --- /dev/null +++ b/tests/speculation/run-teardown-host.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-only +# Disclosed development orchestration; test behavior is handwritten native Omega. +set -u +if [ "$(uname -s)" != Linux ] || [ "$(uname -m)" != aarch64 ]; then + echo 'NOT_RUN: teardown native-host test needs Linux AArch64 and the pinned native compiler' >&2 + exit 77 +fi +if [ "$#" -ne 1 ]; then + echo 'usage: run-teardown-host.sh /absolute/path/to/pinned-omc' >&2 + exit 64 +fi +omc=$1 +expected=9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db +actual=$(sha256sum "$omc") || exit 74 +actual=${actual%% *} +if [ "$actual" != "$expected" ]; then + echo 'REFUSED: compiler digest differs from the d7390d88 native-device receipt' >&2 + exit 69 +fi +root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) || exit 74 +out=$(mktemp -d "${TMPDIR:-/tmp}/cudapp-teardown-host.XXXXXX") || exit 74 +echo "Native-host test outputs: $out" +base=5e037c7e3d0226abadaa10af9d44bc6339109b3f +git -C "$root" show "$base:native/nvrm/context.om" > "$out/before.om" || exit 74 +cp "$root/native/nvrm/context.om" "$out/after.om" || exit 74 +for arm in before after; do + # Substitute only OS-effect verbs in a private unit. Preserve the state-machine code. + awk ' + $2 == "=" && ($3 == "devcall" || $3 == "devctl" || $3 == "uvmctl") { print $1 " = tdriver"; next } + $2 == "=" && $3 == "fopen" { print $1 " = tunexpected"; next } + { for (i=1; i<=NF; i++) { if ($i == "mapdrop") $i="tdrop"; if ($i == "fclose") $i="tclose" }; print } + ' "$out/$arm.om" > "$out/$arm-unit.om" || exit 74 + cat "$root/tests/speculation/teardown-host-test.om" >> "$out/$arm-unit.om" || exit 74 + # A new or differently shaped device effect must not silently escape the shim. + awk '$1 != "note" { for (i=1; i<=NF; i++) if ($i == "devcall" || $i == "devctl" || $i == "uvmctl" || $i == "fopen" || $i == "fclose" || $i == "mapdrop") exit 1 }' "$out/$arm-unit.om" || { + echo 'REFUSED: unbound OS effect in teardown fixture' >&2 + exit 69 + } + timeout 30 "$omc" < "$out/$arm-unit.om" > "$out/$arm.elf" 2> "$out/$arm.compile.log" + rc=$? + if [ "$rc" -ne 0 ] || [ ! -s "$out/$arm.elf" ]; then + echo "FAIL: $arm fixture did not compile successfully (exit $rc)" >&2 + exit 1 + fi + chmod 700 "$out/$arm.elf" || exit 74 + timeout 10 "$out/$arm.elf" > "$out/$arm.stdout" 2> "$out/$arm.stderr" + rc=$? + printf '%s\n' "$rc" > "$out/$arm.exit" || exit 74 + if [ "$arm" = before ]; then + if [ "$rc" -ne 1 ] || ! grep -q '^NATIVE_TEARDOWN_HOST_FAIL$' "$out/$arm.stderr"; then + echo 'FAIL: original source did not fail by the intended test assertion' >&2 + exit 1 + fi + elif [ "$rc" -ne 0 ] || ! grep -q '^NATIVE_TEARDOWN_HOST_PASS$' "$out/$arm.stdout"; then + echo 'FAIL: repaired source did not pass the teardown fixture' >&2 + exit 1 + fi +done +sha256sum "$out"/*.om "$out"/*.elf || exit 74 +echo 'PASS: original cleanup fails its assertion; repaired cleanup passes refusal, retry and close-once controls' diff --git a/tests/speculation/service-test.om b/tests/speculation/service-test.om new file mode 100644 index 00000000..504d6fe4 --- /dev/null +++ b/tests/speculation/service-test.om @@ -0,0 +1,259 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Actual native parent/child pipe exchange. Synthetic policy data, no model or GPU. +global xreq uchar 2048 +global xresp uchar 128 +global xexec uchar 4096 +global xfds uchar 16 +global xstat uchar 4 +global xmeta ulong 5 +fn xput i ulong v ulong to void +for j ulong 8 +put xreq add mul i 8 j uchar and shr v mul j 8 255 +end +end +fn xget i ulong to ulong +v = ulong 0 +for j ulong 8 +v = or v shl ulong get xresp add mul i 8 j mul j 8 +end +ret v +end +fn xfd off ulong to int +v = ulong 0 +for j ulong 4 +v = or v shl ulong get xfds add off j mul j 8 +end +ret int v +end +fn xspawn to int +n = argread 1 xexec 4 4092 +if lt n 1 +ret 65 +end +put xexec 0 1 +put xexec 1 0 +put xexec 2 uchar and ulong n 255 +put xexec 3 uchar shr ulong n 8 +if ne pipefds xfds 0 8 524288 0 +ret 74 +end +if ne pipefds xfds 8 8 524288 0 +ret 74 +end +pid = fork +if lt pid 0 +ret 74 +end +if eq pid 0 +if ne dupfd xfd 0 0 0 0 +exit 111 +end +if ne dupfd xfd 12 1 0 1 +exit 111 +end +for i ulong 4 +r = fclose xfd mul i 4 +end +r = execprog xexec 0 add ulong n 4 +exit 111 +end +r = fclose xfd 0 +r = fclose xfd 12 +put xmeta 0 ulong pid +put xmeta 1 ulong xfd 4 +put xmeta 2 ulong xfd 8 +put xmeta 3 1 +ret 0 +end +fn xread off ulong n ulong to int +done = ulong 0 +for attempt ulong 128 +if eq done n +ret 0 +end +r = waitio int get xmeta 2 1 5000000000 +if le r 0 +ret 74 +end +r = read int get xmeta 2 xresp add off done sub n done +if le r 0 +ret 74 +end +done = add done ulong r +end +ret 74 +end +fn xcall op ulong count ulong to ulong +xput 0 827343699 +xput 1 1 +xput 2 op +xput 3 get xmeta 3 +xput 4 count +bytes = mul add count 5 8 +started = monons +r = write int get xmeta 1 xreq 0 bytes +check eq r long bytes +v = xread 0 56 +check eq v 0 +if ne v 0 +ret 999 +end +check eq xget 0 827343699 +check eq xget 1 1 +check eq xget 2 op +check eq xget 3 get xmeta 3 +check le xget 5 5 +put xmeta 3 add get xmeta 3 1 +if gt xget 5 5 +ret 999 +end +check eq xread 56 mul xget 5 8 0 +check gt xget 6 0 +check le xget 6 ulong sub monons started +if ne xget 4 0 +check eq xget 5 0 +end +ret xget 4 +end +fn xinit to void +for i ulong 64 +xput add i 5 get sid i +end +for i ulong 6 +xput add i 69 get sprofile i +end +for i ulong 77 +xput add i 75 get srows i +end +for i ulong 31 +xput add i 152 get sprior i +end +check eq xcall 1 178 0 +end +fn xbegin warm ulong device ulong to ulong +xput 5 warm +xput 6 device +xput 7 0 +ret xcall 2 3 +end +fn xselect context ulong remain ulong mode ulong k ulong to ulong +xput 5 context +xput 6 remain +xput 7 1000 +xput 8 7 +xput 9 mode +xput 10 k +ret xcall 3 6 +end +fn xobs a ulong n ulong eos ulong full ulong to ulong +xput 5 a +xput 6 n +xput 7 100 +xput 8 eos +xput 9 full +ret xcall 4 5 +end +fn xreap code ulong to void +if ne get xmeta 1 18446744073709551615 +r = fclose int get xmeta 1 +end +r = fclose int get xmeta 2 +r = waitpid int get xmeta 0 xstat 0 4 0 +check eq r long get xmeta 0 +check eq get xstat 0 0 +check eq ulong get xstat 1 code +end +fn exchange to void +check eq xspawn 0 +xinit +check eq xcall 1 178 75 +check eq xbegin 0 1 69 +check eq xbegin 1 0 69 +check eq xbegin 0 0 0 +check eq xbegin 0 0 75 +check eq xcall 8 0 75 +check eq xcall 7 0 75 +check eq xselect 1000 64 2 0 0 +check eq xget 7 31 +check eq xget 8 32 +check eq xget 9 32000000 +check eq xselect 1000 64 2 0 75 +check eq xobs 2 3 0 0 75 +check eq xobs 2 3 0 1 0 +check eq xget 7 3 +check eq xget 8 2 +check eq xget 9 1 +check eq xget 10 0 +check eq xselect 1003 61 2 0 75 +check eq xcall 5 0 0 +check eq xselect 1002 61 2 0 69 +check eq xselect 1003 61 2 0 0 +check eq xget 7 31 +check eq xcall 6 0 0 +check eq xbegin 1 0 0 +check eq xselect 1000 2 1 1 0 +check eq xget 7 1 +check eq xobs 0 1 1 1 0 +check eq xget 10 1 +check eq xcall 7 0 0 +check eq xcall 8 0 0 +xreap 0 +end +fn broken kind ulong code ulong to void +check eq xspawn 0 +if eq kind 3 +xinit +check eq xbegin 0 0 0 +else +xput 0 827343699 +xput 1 1 +xput 2 8 +xput 3 1 +xput 4 0 +bytes = ulong 40 +if eq kind 0 +xput 3 2 +end +if eq kind 1 +bytes = 7 +end +if eq kind 2 +xput 1 2 +end +if eq kind 4 +xput 4 1 +end +if eq kind 5 +xput 2 2 +xput 4 3 +bytes = 48 +end +if eq kind 6 +xput 2 9 +end +r = write int get xmeta 1 xreq 0 bytes +check eq r long bytes +end +r = fclose int get xmeta 1 +put xmeta 1 18446744073709551615 +r = waitio int get xmeta 2 1 5000000000 +check gt r 0 +r = read int get xmeta 2 xresp 0 128 +check eq r 0 +xreap code +end +fn main to int +if ne argcnt 2 +ret 64 +end +fixture +exchange +broken 0 69 +broken 1 65 +broken 2 69 +broken 3 75 +broken 4 65 +broken 5 65 +broken 6 77 +ret finish +end diff --git a/tests/speculation/support.om b/tests/speculation/support.om new file mode 100644 index 00000000..7963a357 --- /dev/null +++ b/tests/speculation/support.om @@ -0,0 +1,64 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Synthetic test support. None of these values are hardware observations. +global tally ulong 2 +global digits uchar 32 +text passmsg "SPECULATION_TESTS_PASS " +text failmsg "SPECULATION_TESTS_FAIL " +fn number n ulong to void +if ge n 10 +number div n 10 +end +put digits 0 uchar add 48 rem n 10 +w = write 1 digits 0 1 +end +fn check yes bool to void +put tally 0 add get tally 0 1 +if not yes +put tally 1 add get tally 1 1 +number get tally 0 +put digits 0 10 +w = write 1 digits 0 1 +end +end +fn finish to int +if ne get tally 1 0 +w = write 1 failmsg 0 len failmsg +number get tally 1 +put digits 0 10 +w = write 1 digits 0 1 +ret 1 +end +w = write 1 passmsg 0 len passmsg +number get tally 0 +put digits 0 10 +w = write 1 digits 0 1 +ret 0 +end +fn fixture to void +for i ulong 64 +put sid i add rem i 32 1 +end +for i ulong 77 +put srows i 0 +end +put sprofile 0 1 +put sprofile 1 7 +put sprofile 2 1000 +put sprofile 3 33000 +put sprofile 4 1 +put sprofile 5 1 +for r ulong 7 +base = mul r 11 +put srows base 1 +put srows add base 1 slen r +put srows add base 2 add slen r 1 +put srows add base 4 100 +put srows add base 8 1 +put srows add base 9 add 100 mul r 10 +put srows add base 10 5 +end +for i ulong 31 +put sprior i 1000000 +end +check eq sbegin 0 0 +end diff --git a/tests/speculation/teardown-host-test.om b/tests/speculation/teardown-host-test.om new file mode 100644 index 00000000..455a1bdc --- /dev/null +++ b/tests/speculation/teardown-host-test.om @@ -0,0 +1,233 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Synthetic host refusal fixture. The private unit replaces device calls, close and mapdrop. +note No GPU file is opened and no kernel, model, or hardware result is claimed. +global tchecks ulong 1 +global tblocked uchar 3 +global tlive uchar 3 +global tdrops ulong 3 +global tcloses ulong 2 +global tdrivercalls ulong 1 +global tdriverfail uchar 1 +global tclosefail uchar 1 +text tok "NATIVE_TEARDOWN_HOST_PASS\n" +text tbad "NATIVE_TEARDOWN_HOST_FAIL\n" +fn tcheck yes bool to void +put tchecks 0 add get tchecks 0 1 +if not yes +r = write 2 tbad 0 len tbad +exit int 1 +end +end +fn tunexpected to long +tcheck false +ret neg long 5 +end +fn tdriver to long +note A retry after descriptor closure must never issue another RM or UVM call. +tcheck eq get nvstate 0 1 +put tdrivercalls 0 add get tdrivercalls 0 1 +if ne get tdriverfail 0 0 +put tdriverfail 0 0 +ret neg long 11 +end +ret 0 +end +fn tdrop m long to long +tcheck and ge m 11 le m 13 +i = ulong sub m 11 +tcheck eq get tlive i 1 +put tdrops i add get tdrops i 1 +if ne get tblocked i 0 +ret neg long 11 +end +put tlive i 0 +ret 0 +end +fn tclose fd int to long +tcheck and ge fd 40 le fd 41 +i = ulong sub fd 40 +put tcloses i add get tcloses i 1 +note A descriptor number could be reused after the first close, even if close reports an error. +tcheck eq get tcloses i 1 +if and eq i 0 ne get tclosefail 0 0 +ret neg long 5 +end +ret 0 +end +fn tprepare to void +for i ulong len nvfd +put nvfd i neg int 1 +end +put nvfd 0 40 +put nvfd 1 41 +for i ulong len nvobj +put nvobj i 0 +end +for i ulong len nvreg +put nvreg i 0 +end +for i ulong len nvmflag +put nvmflag i 0 +put nvmobj i 0 +put nvmmap i 0 +put nvmaddr i 0 +put nvmlen i 0 +end +for i ulong 3 +put tblocked i 0 +put tlive i 1 +put tdrops i 0 +end +for i ulong 2 +put tcloses i 0 +end +put tdrivercalls 0 0 +put tdriverfail 0 0 +put tclosefail 0 0 +put nverr 0 0 +put nvfault 0 0 +put nvstate 0 1 +put nvchreg 0 0 +put nvsched 0 1 +put nvbar 0 11 +put nvchva 0 12 +put nvfifo 0 0 +put nvnotify 0 0 +put nvput 0 0 +put nvret 0 0 +put nvmflag 0 2 +put nvmmap 0 13 +put nvmaddr 0 4096 +put nvmlen 0 4096 +end +fn tclosed to void +tcheck eq get nvstate 0 0 +tcheck eq get nvsched 0 0 +tcheck eq get nvbar 0 0 +tcheck eq get nvchva 0 0 +for i ulong len nvfd +tcheck eq get nvfd i neg int 1 +end +for i ulong 2 +tcheck eq get tcloses i 1 +end +for i ulong 3 +tcheck eq get tlive i 0 +end +for i ulong len nvmflag +tcheck eq get nvmflag i 0 +tcheck eq get nvmobj i 0 +tcheck eq get nvmmap i 0 +tcheck eq get nvmaddr i 0 +tcheck eq get nvmlen i 0 +end +for i ulong len nvobj +tcheck eq get nvobj i 0 +end +end +fn tretained which ulong to void +if eq which 0 +tcheck eq get nvbar 0 11 +end +if eq which 1 +tcheck eq get nvchva 0 12 +end +if eq which 2 +tcheck eq get nvmflag 0 2 +tcheck eq get nvmmap 0 13 +tcheck eq get nvmaddr 0 4096 +tcheck eq get nvmlen 0 4096 +end +tcheck eq get tlive which 1 +tcheck eq get nvstate 0 2 +tcheck eq get nvfault 0 1 +tcheck eq get nvsched 0 0 +for i ulong len nvfd +tcheck eq get nvfd i neg int 1 +end +end +fn tretry which ulong driver_refusal bool to void +tprepare +put tblocked which 1 +if driver_refusal +note Refuse channel destruction before its handles retire; retry must not free them through closed fds. +put nvobj 6 101 +put nvobj 8 102 +put nvobj 9 103 +put tdriverfail 0 1 +end +tcheck not nvstop +tretained which +before = get tdrivercalls 0 +tcheck not nvstop +tretained which +tcheck eq get tdrivercalls 0 before +for i ulong 2 +tcheck eq get tcloses i 1 +end +put tblocked which 0 +tcheck nvstop +tclosed +tcheck eq get tdrivercalls 0 before +tcheck eq get nvfault 0 1 +tcheck not nvstart +tcheck eq get nverr 0 neg long 5 +count = get tdrops which +tcheck nvstop +tcheck eq get tdrops which count +tclosed +end +fn tphaseguard to void +note Force cleanup cannot retire live driver ownership before descriptors close. +tprepare +put nvmflag 0 15 +put nvmobj 0 201 +tcheck not nvmforce +tcheck eq get nverr 0 neg long 16 +tcheck eq get nvstate 0 1 +tcheck eq get nvfault 0 0 +tcheck eq get nvmflag 0 15 +tcheck eq get nvmobj 0 201 +tcheck eq get nvmmap 0 13 +tcheck eq get nvmaddr 0 4096 +tcheck eq get nvmlen 0 4096 +for i ulong 3 +tcheck eq get tdrops i 0 +tcheck eq get tlive i 1 +end +for i ulong 2 +tcheck eq get tcloses i 0 +end +tcheck eq get tdrivercalls 0 0 +tcheck nvstop +tclosed +end +fn main to int +note Closed contexts stay idempotent without touching descriptors or mappings. +tcheck nvstop +tprepare +tcheck nvstop +tclosed +tcheck eq get nvfault 0 0 +for i ulong 3 +tcheck eq get tdrops i 1 +end +tcheck nvstop +tclosed +tretry 0 false +tretry 1 false +tretry 2 false +tretry 1 true +tphaseguard +note An error from the descriptor close must latch the fault without retrying that descriptor. +tprepare +put tclosefail 0 1 +tcheck not nvstop +tclosed +tcheck eq get nvfault 0 1 +tcheck nvstop +tclosed +tcheck not nvstart +tcheck eq write 1 tok 0 len tok long len tok +ret 0 +end diff --git a/tests/speculation/vector-checks-test.om b/tests/speculation/vector-checks-test.om new file mode 100644 index 00000000..a761dc23 --- /dev/null +++ b/tests/speculation/vector-checks-test.om @@ -0,0 +1,51 @@ +note CPU-only regression at the seeded dynamic-loop limit, no device opens. +global gbmem long 8 +global gbmax uint 1 +text ok "VECTOR_CHECKS_HOST_PASS\n" +fn ck yes bool to void +if not yes +exit int 80 +end +end +fn supply i ulong to void +ck eq mapget get gbmem 5 mul i 4 4 aval i 257 +ck eq mapget get gbmem 6 mul i 4 4 bval i 257 +ck eq mapget get gbmem 7 mul i 4 4 xor expect i 257 4294967295 +r = mapset get gbmem 7 mul i 4 4 expect i 257 +end +fn run n uint to void +put gbmax 0 add n 64 +for i ulong 3 +m = mapnew neg int 1 0 mul ulong get gbmax 0 4 3 34 +ck gt m 0 +put gbmem add i 5 m +end +prepare n 257 +note Check every prepared input and poison value, then supply the expected result. +base = ulong 0 +while lt base ulong n +count = sub ulong n base +if gt count 65536 +count = ulong 65536 +end +for j ulong count +supply add base j +end +base = add base count +end +verify n 257 false +r = mapset get gbmem 7 mul sub ulong n 1 4 4 xor expect sub ulong n 1 257 1 +verify n 257 true +for i ulong 3 +ck eq mapdrop get gbmem add i 5 0 +end +end +fn main to int +run 1 +run 999999 +run 1000000 +run 1000001 +run 1048576 +ck eq write 1 ok 0 len ok long len ok +ret 0 +end diff --git a/tests/speculation/vector-checks.om b/tests/speculation/vector-checks.om new file mode 100644 index 00000000..599ffb9e --- /dev/null +++ b/tests/speculation/vector-checks.om @@ -0,0 +1,66 @@ +note Shared whole-vector checks, chunked below the seeded dynamic-loop limit. +fn aval i ulong salt ulong to ulong +ret and add mul i 2654435761 salt 4294967295 +end +fn bval i ulong salt ulong to ulong +ret and xor add mul i 2246822519 3266489917 salt 4294967295 +end +fn expect i ulong salt ulong to ulong +ret and add aval i salt bval i salt 4294967295 +end +fn putvec i ulong salt ulong to void +r = mapset get gbmem 5 mul i 4 4 aval i salt +r = mapset get gbmem 6 mul i 4 4 bval i salt +r = mapset get gbmem 7 mul i 4 4 xor expect i salt 4294967295 +end +fn match i ulong salt ulong to bool +ret eq mapget get gbmem 7 mul i 4 4 expect i salt +end +fn prepare n uint salt ulong to void +base = ulong 0 +while lt base ulong n +count = sub ulong n base +if gt count 65536 +count = ulong 65536 +end +for j ulong count +putvec add base j salt +end +base = add base count +end +tail = sub get gbmax 0 n +if gt tail 64 +tail = uint 64 +end +for i ulong ulong tail +r = mapset get gbmem 7 mul add ulong n i 4 4 3735928559 +end +end +fn verify n uint salt ulong wrong bool to void +mism = ulong 0 +base = ulong 0 +while lt base ulong n +count = sub ulong n base +if gt count 65536 +count = ulong 65536 +end +for j ulong count +if not match add base j salt +mism = add mism 1 +end +end +base = add base count +end +if wrong +ck gt mism 0 +else +ck eq mism 0 +end +tail = sub get gbmax 0 n +if gt tail 64 +tail = uint 64 +end +for i ulong ulong tail +ck eq mapget get gbmem 7 mul add ulong n i 4 4 3735928559 +end +end