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 / docs / speculation / TEARDOWN-HOST.md
| 1 | # Teardown refusal and retry fixture |
| 2 | |
| 3 | Refs CUDApp #65 and #67. This is a bounded cleanup repair and a synthetic host |
| 4 | fixture. It does not qualify model inference, GPU execution, or deployment. |
| 5 | |
| 6 | ## Source contract |
| 7 | |
| 8 | `nvstate` records the teardown phase: |
| 9 | |
| 10 | | Value | Meaning | Permitted cleanup | |
| 11 | | --- | --- | --- | |
| 12 | | 0 | Closed | Return success without another effect | |
| 13 | | 1 | Driver resources live, including partial construction | Existing RM/UVM teardown and one close attempt per descriptor | |
| 14 | | 2 | Descriptors closed; CPU mappings remain | Retry owned BAR, channel, and buffer unmaps only | |
| 15 | |
| 16 | The compiler's `mapdrop` returns a nonzero syscall result without retiring its |
| 17 | owned mapping slot. The runtime must therefore retain the mapping handle until |
| 18 | unmap succeeds. After descriptor closure, driver-owned memory flags can retire, |
| 19 | but a failed CPU mapping retains its handle, address and length. A failed |
| 20 | cleanup latches `nvfault`; successful cleanup does not make the context reusable. |
| 21 | Descriptor numbers are retired after their first close attempt, including an |
| 22 | error, so a subsequent call cannot close a newly reused descriptor number. |
| 23 | |
| 24 | The same ownership rule applies before `nvcpumap` publishes a mapping to its |
| 25 | caller. If descriptor close fails and its immediate unmap is refused, |
| 26 | `nvunpub` retains that mapping for `nvmapfinish`. A faulted or inactive |
| 27 | context refuses another `nvcpumap`, so the retained handle cannot be overwritten. |
| 28 | Failed `mapbind` is different: the pinned compiler contract retires that handle. |
| 29 | |
| 30 | ## Fixture and isolation |
| 31 | |
| 32 | The handwritten `tests/speculation/teardown-host-test.om` runs the actual |
| 33 | `nvstop`/`nvmapfinish`/`nvmforce` control flow in a private source-derived unit. |
| 34 | The disclosed shell composer replaces only these OS effects: |
| 35 | |
| 36 | - Device operations become a bounded fake that refuses any call after the |
| 37 | descriptor phase has ended. |
| 38 | - Device opens become an immediate test assertion failure. |
| 39 | - Unmap and close become stateful fakes that count calls, reject double release, |
| 40 | and can refuse an otherwise valid synthetic mapping. |
| 41 | - The unpublished-mapping case allows one synthetic descriptor open and replaces |
| 42 | `mapnew` with a fake that returns a fourth owned mapping; no real mapping or |
| 43 | device open is performed. |
| 44 | |
| 45 | The composer refuses an unbound device/open/close/unmap verb. It never changes |
| 46 | the tracked runtime file. The fixture does not open `/dev/nvidia*`, allocate GPU |
| 47 | memory, or submit work. It follows the existing development practice of building |
| 48 | private native translation units and compiling behavioral negative controls; |
| 49 | the shell is test orchestration, not a new product runtime. |
| 50 | |
| 51 | Cases cover normal and repeated shutdown, a BAR unmap refusal, a channel-map |
| 52 | refusal, a buffer unmap refusal, a driver teardown refusal followed by mapping |
| 53 | refusal, successful retry, and a descriptor close error. Each refused mapping |
| 54 | must survive two shutdown attempts, then release when refusal is removed. |
| 55 | Retries must make no extra descriptor closes or driver calls. The context fault |
| 56 | must remain set, and `nvstart` must still refuse reuse. A direct `nvmforce` call |
| 57 | while driver resources are live must refuse without changing ownership flags, |
| 58 | handles, addresses or lengths and without making an OS effect. |
| 59 | The additional close-error/unmap-refusal case checks that the unpublished |
| 60 | mapping survives two shutdown attempts, is released on a later successful |
| 61 | retry, and is never double-unmapped. It also checks refusal of another mapping |
| 62 | attempt while that context is faulted. |
| 63 | |
| 64 | ## Reproduction |
| 65 | |
| 66 | Use Linux AArch64 and the compiler from the existing native-device receipt: |
| 67 | |
| 68 | - Omega source: `d7390d88d07dbf48cfbb0583070599c350f814d3`. |
| 69 | - Compiler SHA-256: |
| 70 | `9749f38841a55917d41924a68bce31463ec2339910bddd5e6cbf6ea4420551db`. |
| 71 | |
| 72 | ```sh |
| 73 | sh tests/speculation/run-teardown-host.sh /absolute/path/to/pinned-omc |
| 74 | ``` |
| 75 | |
| 76 | The script retains a private temporary directory with exact source units, ELF |
| 77 | files, compiler logs, stdout/stderr, exit statuses, and hashes. It compiles the |
| 78 | original `f9cd649c1dca92ad81009bcd05a959f34c25c76e` context with the same fixture |
| 79 | first: it must fail by a test assertion (exit 1), not compilation error, trap or |
| 80 | timeout. The repaired source must then compile and exit 0 with the PASS marker. |
| 81 | An unsupported host returns 77 and `NOT_RUN`; it is not a test pass. |
| 82 | |
| 83 | ## Current qualification limit |
| 84 | |
| 85 | The source-compatibility review uses the exact pinned `seed/omc/omc.om`, not |
| 86 | a different compiler profile. Its `topname` and `s_fn` readers limit globals, |
| 87 | texts and parameter names to eight bytes; function names may be 63 bytes. |
| 88 | The initial source review missed overlong names in both this repair and the |
| 89 | inherited fixture. They are now shortened without changing cleanup behavior. |
| 90 | The fixture's custom calls use scalar arguments only; the compiler's prohibition |
| 91 | on passing globals to ordinary `view`/`edit` parameters does not apply to them. |
| 92 | The `tmapnew` fake preserves the native word's five scalar types and long result. |
| 93 | This is source inspection, not evidence that either unit compiles or executes. |
| 94 | |
| 95 | Native compilation and execution are **NOT_RUN** in the merge-review workspace, |
| 96 | which is x86_64 and has no runnable AArch64 compiler or emulator. The fixture and |
| 97 | repair remain candidates for source review and supported-host qualification. |
| 98 | Existing hardware receipts describe older source and must not be reused to |
| 99 | approve this change. Real kernel/model behavior and production activation remain |
| 100 | outside this host fixture. |
| 101 | |
| 102 | ## Supported-host qualification |
| 103 | |
| 104 | On 2026-10-24 a candidate based on `main` (22e9d9b plus this repair, code commit |
| 105 | 2e24216) was compiled with the pinned compiler rebuilt from seed and run on |
| 106 | Linux AArch64: the original cleanup failed by assertion and the repair passed. |
| 107 | Mutants, the GPU vector rerun and the remaining fixture gap are recorded in |
| 108 | `evidence/speculation/release-candidate-teardown/`. |