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
CUDApp / tools / c5 / README.md
| 1 | # C5 sharing and D14 recovery |
| 2 | |
| 3 | ## What existed |
| 4 | |
| 5 | At CUDApp `b774723f537cec16a359fe082b8100317a5b5490`, |
| 6 | `tests/gpu_isolation_test.c` already exercises two chip processes, a real |
| 7 | nonterminating kernel, a latched session, device-close recovery, a successful |
| 8 | new launch in the same process and refusal of stale command lists. |
| 9 | `src/omega_gpu_session.c` parks uncertain resources and only clears its latch |
| 10 | after platform device teardown succeeds. At that revision its marker waits |
| 11 | each received a timeout independently, not an absolute submission-wide deadline. |
| 12 | |
| 13 | `build.sh` builds that test, a wrong-values mutant, and `c5_matrix.om`. |
| 14 | `chip.sh` runs the hardware matrix beside a PyTorch CUDA tenant. |
| 15 | `selftest.sh` uses stand-in processes to check orchestration only. Neither the |
| 16 | stand-ins nor a process-group kill prove same-process channel recovery. |
| 17 | |
| 18 | ## Added policy and model |
| 19 | |
| 20 | `policy.om` contains pure decision functions for an overflow-checked absolute |
| 21 | submission deadline, completion/fault observation, admission, process/context |
| 22 | handle ownership, bounded memory slices and acknowledged recovery sequencing. |
| 23 | `model.om` is a deterministic host RM/channel simulator consuming those |
| 24 | functions. It is not the Blackwell instruction simulator and does not execute |
| 25 | SASS. A nonterminating simulated kernel never emits completion; a working |
| 26 | kernel stores eight words and emits two completion markers. The original |
| 27 | deadline covers both markers. Timeout wins at the deadline, including a |
| 28 | simultaneous completion. A backward clock observation latches the context. |
| 29 | |
| 30 | The model has two independently owned contexts, channels and private mappings |
| 31 | at identical virtual offsets. Handles carry process identity and context epoch. |
| 32 | Cross-owner access and stale generations are refused before touching memory. |
| 33 | Recovery refuses admission throughout these acknowledged actions: |
| 34 | |
| 35 | 1. Latch admission. |
| 36 | 2. Quiesce the submission queue. |
| 37 | 3. Destroy all channels of this process. |
| 38 | 4. Destroy the RM context/client, invalidate mappings and advance the epoch. |
| 39 | 5. Recreate the context. |
| 40 | 6. Recreate its channel. |
| 41 | 7. Rebuild private mappings, then reopen admission. |
| 42 | |
| 43 | Failed acknowledgements leave the state and resources unchanged. Generation |
| 44 | exhaustion refuses recreation rather than reusing old tokens. No simulated |
| 45 | mapping is reclaimed while the old grid can still run. The other process's |
| 46 | memory and channel remain untouched. |
| 47 | |
| 48 | `runtime.om` adapts these decisions to the hosted and freestanding production |
| 49 | session through the import-free generated `omega_native_c5` binding. The default |
| 50 | path computes one overflow-checked absolute nanosecond deadline before ringing |
| 51 | the doorbell. Both markers and the spin window share it; completion at or after |
| 52 | the deadline latches. Polls use one millisecond only when it fits, otherwise a |
| 53 | zero-ms poll until the remaining sub-ms interval expires. A backwards clock |
| 54 | latches. Timeout still parks resources: it never guesses that an old grid died. |
| 55 | The existing explicit `omega_gpu_session_recover()` acknowledges the platform's |
| 56 | bundled quiesce/channel/client close through the Omega recovery states. A failed |
| 57 | close cannot clear the latch; a successful close permits the next `open()` to |
| 58 | recreate the device/channel in the same process. No new RM ioctl contract is |
| 59 | introduced. The old C timing/recovery decisions remain only behind |
| 60 | `CUDAPP_MIGRATION_PENDING_C_SESSION_TIMEOUT=1` (default OFF). |
| 61 | |
| 62 | The real session fake-RM fixture includes marker releases at 3 ms and 6 ms with |
| 63 | a 5 ms submission budget: the new path times out, explicitly recovers, then |
| 64 | successfully submits again in the same PID. The old per-marker path incorrectly |
| 65 | succeeds and is required to fail that exact case as a negative control. |
| 66 | |
| 67 | ## Host acceptance |
| 68 | |
| 69 | ``` |
| 70 | OMEGA_OMC=/path/to/pinned/seed/out/omc \ |
| 71 | taskset -c 10-14 nice -n 10 make -j3 test-c5-policy test-gpu-session-platform |
| 72 | ``` |
| 73 | |
| 74 | `policy-test.sh` checks `omc.pin`, compiles the concatenated Omega units and |
| 75 | requires the host-reference and simulator assertions to succeed. It then |
| 76 | compiles each mutant and requires its exact assertion exit, not a compiler |
| 77 | failure or arbitrary trap. Mutants cover deadline equality, overflow, owner, |
| 78 | epoch, range, failed teardown acknowledgement, action order, epoch advance and |
| 79 | stale-channel completion. Logs and source/binary hashes are in |
| 80 | `build/c5-policy/`. The target is in `make test`; without an explicitly runnable |
| 81 | pinned compiler it is target-only on non-AArch64 hosts. |
| 82 | |
| 83 | Boundary vectors were checked with WolframLanguageEvaluator: |
| 84 | `{2^64-1,(2^64-1)-8,10+8,17-10,18-10,2*8,Table[100*p+i,{p,1,2},{i,0,7}]}` |
| 85 | returned `{18446744073709551615,18446744073709551607,18,7,8,16, |
| 86 | {{100,101,102,103,104,105,106,107},{200,201,202,203,204,205,206,207}}}`. |
| 87 | Times in the deterministic simulator are logical ticks, not measured hardware |
| 88 | nanoseconds. State numbers and assertion exits are enumeration labels. |
| 89 | |
| 90 | Additional WolframLanguageEvaluator boundary queries: |
| 91 | `{Mod[(2^64-1)+2,2^64],10+9,10+20,30+20}` returned `{1,19,30,50}`. |
| 92 | `{Floor[(2^64-1)/10^6],10^6,25*10^6,5*10^6,3*10^6,Floor[(5*10^6-3*10^6)/10^6]}` |
| 93 | returned `{18446744073709,1000000,25000000,5000000,3000000,2}`. |
| 94 | Here the conversion factor is nanoseconds per millisecond; runtime timeout |
| 95 | vectors are nanoseconds. The delayed second marker is 6 ms, outside the 5 ms |
| 96 | budget, but only 3 ms after the first marker. |
| 97 | `{6*10^6,6-3,6-5}` returned `{6000000,3,1}` (nanoseconds, milliseconds, |
| 98 | milliseconds respectively). |
| 99 | |
| 100 | ## Host receipt (2026-11-05) |
| 101 | |
| 102 | Source implementation: `57278a8` on `feat/c5-recovery-policy`, based on |
| 103 | `b774723f537cec16a359fe082b8100317a5b5490`. Generated scalar output uses |
| 104 | `omc.pin` and the existing CUDApp `omega-bridge.lock` pin; no toolchain was |
| 105 | rebuilt or repinned. |
| 106 | |
| 107 | - `taskset -c 10-14 nice -n 10 make -j3 test-c5-policy test-gpu-session-platform` |
| 108 | initially exited 2: policy/model and 18 session cases passed, but the Linux |
| 109 | fixture still required exactly five fake one-ms polls despite its real |
| 110 | clock callback. GpuPlatformLinux applied the agreed bounded-poll assertion; |
| 111 | no production deadline was relaxed. |
| 112 | - The initial full `make -j3 test` invocation was interrupted by its tool |
| 113 | deadline after 1800 seconds: INCONCLUSIVE, not a test failure. Its partial |
| 114 | stdout is `build/c5-full-test.log`. |
| 115 | - The resumed full `taskset -c 10-14 nice -n 10 make -j3 test` (same four |
| 116 | `OMEGA_*` environment paths as the lane setup; no tool deadline) exited 0. |
| 117 | Final line: `CUDA++ HOST TESTS PASS (89 targets)`. |
| 118 | Stdout: `build/c5-full-test-resumed.log`; session 18/18, Linux fake-RM 17/17, |
| 119 | policy/model mutants 9/9, session mutants 12/12 all passed. |
| 120 | - The legacy timing negative control exited 1 and specifically failed |
| 121 | `SUBMISSION_DEADLINE_SHARED_BY_BOTH_MARKERS`; final line: |
| 122 | `test_omega_gpu_session_platform: 16 passed, 2 failed`. |
| 123 | - `crumb compile . && crumb verify .` exited 0, reporting 39 current crumbs. |
| 124 | |
| 125 | These are EXERCISED host/model results, not chip qualification. |
| 126 | |
| 127 | ## Chip runbook: NOT_RUN |
| 128 | |
| 129 | Only Drake's current exclusive GPU-window procedure authorizes these commands. |
| 130 | The lock alone is not authorization. Do not run them while a serving tenant |
| 131 | must remain live. Keep all existing receipts immutable; use a new output path. |
| 132 | |
| 133 | Outside the GPU hold, build the existing chip programs: |
| 134 | |
| 135 | ``` |
| 136 | OMC=/path/to/pinned/seed/out/omc \ |
| 137 | taskset -c 10-14 nice -n 10 sh tools/c5/build.sh |
| 138 | ``` |
| 139 | |
| 140 | Inside the authorized window, first run the two real CUDA++ processes and real |
| 141 | hang test without depending on PyTorch: |
| 142 | |
| 143 | ``` |
| 144 | timeout -k 10 300 build/gpu_isolation_test --values-only |
| 145 | timeout -k 10 300 build/gpu_isolation_test |
| 146 | ``` |
| 147 | |
| 148 | Require the wrong-values mutant to exit 1 with a wrong-values diagnostic: |
| 149 | |
| 150 | ``` |
| 151 | timeout -k 10 300 build/gpu_isolation_test_mutant --values-only |
| 152 | ``` |
| 153 | |
| 154 | The full existing coexistence/pressure/kill matrix additionally needs PyTorch |
| 155 | as a verification-only CUDA tenant, not a production dependency: |
| 156 | |
| 157 | ``` |
| 158 | PY=/path/to/torch/python sh tools/c5/chip.sh /new/receipt/path |
| 159 | ``` |
| 160 | |
| 161 | Capture source revision, compiler/source/binary hashes, command exits, final |
| 162 | verdicts and kernel logs. The hang test must show timeout, refusal while |
| 163 | latched, confirmed teardown, correct new launches in that same child PID, |
| 164 | refusal of pre-recovery command lists, and an unaffected second process. |
| 165 | A teardown failure is FAIL and must remain latched; do not waive it or restart |
| 166 | the process and call that same-process recovery. None of these chip commands |
| 167 | were run for this policy/model implementation. C5/D14 hardware status is not |
| 168 | upgraded. |