interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tools / c5 / README.md

168 lines · 8451 bytes Raw Blame History Rendered
1# C5 sharing and D14 recovery
2
3## What existed
4
5At CUDApp `b774723f537cec16a359fe082b8100317a5b5490`,
6`tests/gpu_isolation_test.c` already exercises two chip processes, a real
7nonterminating kernel, a latched session, device-close recovery, a successful
8new 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
10after platform device teardown succeeds. At that revision its marker waits
11each 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
16stand-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
21submission deadline, completion/fault observation, admission, process/context
22handle ownership, bounded memory slices and acknowledged recovery sequencing.
23`model.om` is a deterministic host RM/channel simulator consuming those
24functions. It is not the Blackwell instruction simulator and does not execute
25SASS. A nonterminating simulated kernel never emits completion; a working
26kernel stores eight words and emits two completion markers. The original
27deadline covers both markers. Timeout wins at the deadline, including a
28simultaneous completion. A backward clock observation latches the context.
29
30The model has two independently owned contexts, channels and private mappings
31at identical virtual offsets. Handles carry process identity and context epoch.
32Cross-owner access and stale generations are refused before touching memory.
33Recovery refuses admission throughout these acknowledged actions:
34
351. Latch admission.
362. Quiesce the submission queue.
373. Destroy all channels of this process.
384. Destroy the RM context/client, invalidate mappings and advance the epoch.
395. Recreate the context.
406. Recreate its channel.
417. Rebuild private mappings, then reopen admission.
42
43Failed acknowledgements leave the state and resources unchanged. Generation
44exhaustion refuses recreation rather than reusing old tokens. No simulated
45mapping is reclaimed while the old grid can still run. The other process's
46memory and channel remain untouched.
47
48`runtime.om` adapts these decisions to the hosted and freestanding production
49session through the import-free generated `omega_native_c5` binding. The default
50path computes one overflow-checked absolute nanosecond deadline before ringing
51the doorbell. Both markers and the spin window share it; completion at or after
52the deadline latches. Polls use one millisecond only when it fits, otherwise a
53zero-ms poll until the remaining sub-ms interval expires. A backwards clock
54latches. Timeout still parks resources: it never guesses that an old grid died.
55The existing explicit `omega_gpu_session_recover()` acknowledges the platform's
56bundled quiesce/channel/client close through the Omega recovery states. A failed
57close cannot clear the latch; a successful close permits the next `open()` to
58recreate the device/channel in the same process. No new RM ioctl contract is
59introduced. The old C timing/recovery decisions remain only behind
60`CUDAPP_MIGRATION_PENDING_C_SESSION_TIMEOUT=1` (default OFF).
61
62The real session fake-RM fixture includes marker releases at 3 ms and 6 ms with
63a 5 ms submission budget: the new path times out, explicitly recovers, then
64successfully submits again in the same PID. The old per-marker path incorrectly
65succeeds and is required to fail that exact case as a negative control.
66
67## Host acceptance
68
69```
70OMEGA_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
75requires the host-reference and simulator assertions to succeed. It then
76compiles each mutant and requires its exact assertion exit, not a compiler
77failure or arbitrary trap. Mutants cover deadline equality, overflow, owner,
78epoch, range, failed teardown acknowledgement, action order, epoch advance and
79stale-channel completion. Logs and source/binary hashes are in
80`build/c5-policy/`. The target is in `make test`; without an explicitly runnable
81pinned compiler it is target-only on non-AArch64 hosts.
82
83Boundary 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}]}`
85returned `{18446744073709551615,18446744073709551607,18,7,8,16,
86{{100,101,102,103,104,105,106,107},{200,201,202,203,204,205,206,207}}}`.
87Times in the deterministic simulator are logical ticks, not measured hardware
88nanoseconds. State numbers and assertion exits are enumeration labels.
89
90Additional 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]}`
93returned `{18446744073709,1000000,25000000,5000000,3000000,2}`.
94Here the conversion factor is nanoseconds per millisecond; runtime timeout
95vectors are nanoseconds. The delayed second marker is 6 ms, outside the 5 ms
96budget, but only 3 ms after the first marker.
97`{6*10^6,6-3,6-5}` returned `{6000000,3,1}` (nanoseconds, milliseconds,
98milliseconds respectively).
99
100## Host receipt (2026-11-05)
101
102Source 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
105rebuilt 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
125These are EXERCISED host/model results, not chip qualification.
126
127## Chip runbook: NOT_RUN
128
129Only Drake's current exclusive GPU-window procedure authorizes these commands.
130The lock alone is not authorization. Do not run them while a serving tenant
131must remain live. Keep all existing receipts immutable; use a new output path.
132
133Outside the GPU hold, build the existing chip programs:
134
135```
136OMC=/path/to/pinned/seed/out/omc \
137 taskset -c 10-14 nice -n 10 sh tools/c5/build.sh
138```
139
140Inside the authorized window, first run the two real CUDA++ processes and real
141hang test without depending on PyTorch:
142
143```
144timeout -k 10 300 build/gpu_isolation_test --values-only
145timeout -k 10 300 build/gpu_isolation_test
146```
147
148Require the wrong-values mutant to exit 1 with a wrong-values diagnostic:
149
150```
151timeout -k 10 300 build/gpu_isolation_test_mutant --values-only
152```
153
154The full existing coexistence/pressure/kill matrix additionally needs PyTorch
155as a verification-only CUDA tenant, not a production dependency:
156
157```
158PY=/path/to/torch/python sh tools/c5/chip.sh /new/receipt/path
159```
160
161Capture source revision, compiler/source/binary hashes, command exits, final
162verdicts and kernel logs. The hang test must show timeout, refusal while
163latched, confirmed teardown, correct new launches in that same child PID,
164refusal of pre-recovery command lists, and an unaffected second process.
165A teardown failure is FAIL and must remain latched; do not waive it or restart
166the process and call that same-process recovery. None of these chip commands
167were run for this policy/model implementation. C5/D14 hardware status is not
168upgraded.