10 KiB
Independent CUDA driver bootstrap contract
Requirements of record for bounded STRA-102 plan
d20f1568-5b7b-477d-8eab-a32219af7fd7, before implementation.
This foundation does not implement inference, model loading or GPU kernels and
must not change production serving or advertise any supported model.
Platform and ABI
- Explicit
cuda-driverCargo feature, disabled by default, plus an explicitDriver::load()call; Linux with 64-bit pointers. Unsupported platforms or disabled capability must return a clear error without touching a CUDA driver. - Load only the installed NVIDIA Driver ABI soname
libcuda.so.1at runtime. No CUDA Toolkit, Strata, Python, C compiler or native build script is a production build/runtime dependency of this Rust crate. - Resolve the fixed documented legacy ABI symbols, with
_v2context, device allocation/free and synchronous copy symbols where required. Missing symbols fail before CUDA initialization or resource mutation. No symbol-version fallback or API reinterpretation. - Isolate all unsafe FFI and dynamic loader code in the driver crate. Public callers get owned typed resources and errors, never raw host/device pointers or mutable CUDA context handles.
Fixed ABI and source evidence
The exact symbol set is cuInit, cuDriverGetVersion, cuDeviceGet,
cuCtxCreate_v2, cuCtxDestroy_v2, cuCtxPushCurrent_v2,
cuCtxPopCurrent_v2, cuCtxSynchronize, cuMemAlloc_v2, cuMemFree_v2,
cuMemcpyHtoD_v2, cuMemcpyDtoH_v2. The legacy create binding has three
arguments: CUcontext*, unsigned int, CUdevice; the current unversioned
CUDA 13 header macro points to the four-argument v4 entry instead and must
not be rebound to this function type. Device pointers are 64-bit for this
64-bit-only surface; byte counts use size_t.
Independent TL verification read the official
NVIDIA cudart 13.0.88 archive
in memory, without installing headers or a toolkit. Archive size 1,491,604 bytes,
SHA256 bc44226f069402ab327bcf9e754660621aa6bc61fb7fc6afe03b794dfaaab658;
cuda.h SHA256 64025f81a9d6d2b10e9e11654f3523e5b046d01b883f0b9ca474e463274b80d4.
Header lines 25633/90 prove the legacy declaration/current alias respectively;
line 274 defines the 64-bit device pointer. Runtime behavior still requires
separate installed-driver qualification. See NVIDIA's
synchronization behavior
for why calling a synchronous-named copy alone does not prove completion of
all host memory references.
Ownership and context discipline
- Driver, context and device-buffer lifetimes keep the dynamic library alive
until every dependent operation and cleanup finishes. Resources cannot be
sent or shared between threads (
!Send,!Sync). - Create a private context and pop it immediately, restoring the caller's previous context. Do not use or mutate an external primary context.
- Push the owned context for every operation that needs it, and restore the previous context on both success and failure. Pop failures must surface as errors; never claim restoration after the driver rejects restoration.
- Buffers cannot outlive their owner context; allocation/copy operations are bounded, checked before driver mutation and reject empty/oversized shapes.
- Copies use exact-sized byte slices with bounded owned staging memory and the synchronous Driver API. DtoH publishes staging only after completion; ambiguous completion errors retain staging and poison the context to prevent dangling host DMA pointers. Synchronize before returning host borrows. Failed copy/synchronization paths must preserve context cleanup, while reporting the original driver failure accurately.
- Cleanup is best-effort on drop, does not panic and must not free resources in an unrelated context. Explicit fallible cleanup should expose failure when the API supports it; permanently failed driver cleanup cannot be guaranteed.
Independent CPU qualification
Only synthetic owned fixtures may be used. The test library is compiled to an
ELF named libcuda.so.1, injected through a private subprocess loader environment
inside a disposable Linux CPU Docker container. No installed driver is called,
no NVIDIA device is exposed, and no GPU/model/request probe is performed.
The fake library records synthetic ABI operations, context stack, allocated bytes,
copy/sync actions and cleanup. Independent assertions cover missing symbols,
init/device/create/push/pop/alloc/copy/sync/free/destroy errors, bounds before
mutation, byte-copy round trips and prior-context restoration. Lifetime and
thread-safety compile-fail gates are required as well as runtime tests.
All existing local gates remain; focused checks add crate format/Clippy/unit and the Linux ELF mock gate. Results below must report the actual environment, counts and cleanup, never infer GPU success from a mock or compile pass.
Qualification state
Actual local CPU result on 2026-10-07:
- Linux aarch64, native CPU Docker Desktop execution; Rust 1.99.0
(
b940084d7 2026-09-28), GNU C compiler Debian 12.2.0-14+deb12u1. - Pinned Rust base OCI index:
sha256:114c7a4425406451c2866b6aafe69fe29b1b298832db1277d411ac73c82d04d6. Independently inspected index contains Linux amd64 manifestsha256:b36c246742b4d323472588f789601be34eb4af053255e2af53969078ee8dcec7and arm64 manifestsha256:e393e07b3c3c39f238de676b0eb60c03dc7aefe5d6e37be6d29c686bf4d7e256. The final owned fixture image after installing matching rustfmt/Clippy wassha256:a7fd4951f84b368826117e60c93f1e067ade2e39b2b69329108e70b052dd136d. - Actual test container: nonroot UID/GID 65532, default runc, network
none, all effective/permitted/bounding capabilities zero, no privileges, no host binds or device requests/devices; raw NVIDIA/DRI device guard passed. Build tools were provisioned in an earlier disposable setup container; all tests and compilation then ran offline with network disabled. - Minimal synthetic workspace contained only exact driver crate source/tests,
matching workspace package/lint declarations, and approved pinned libc
0.2.190. Engine, control-plane, CUDA Toolkit/headers/nvcc and installed
libcudawere physically absent. The existing registry archive SHA256ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78was checked before extraction, then Cargo verified every vendored source checksum. Normal dependency tree was driver crate → libc only. - Default denial/unit tests: 2 passed. Actual enabled-FFI all-target, all-feature Clippy with warnings denied and formatting passed.
- 33 isolated subprocess scenarios passed: round trip, pre-mutation
shape/budget refusal, each of the twelve missing symbols, init/version/device,
create/pop cleanup, push/pop errors, mismatched popped context and poisoned
future work, allocation, both copy directions, explicit synchronization,
copy-plus-sync dual errors in original/cleanup order, free and destroy faults.
The fixture matrix is explicitly ignored by ordinary
cargo test; the harness selects it with--ignoredand requires its marker, so an absent harness cannot appear as a vacuous integration pass. - Delayed synthetic HtoD at destruction read the exact original eight owned staging bytes after the caller source was changed to zeros. Delayed DtoH at destruction wrote retained staging while the still-live caller destination remained unchanged after failed synchronization. These independently witness the declared staging/completion behavior, alongside source review; they are not a proof of all possible memory safety or vendor behavior.
- 10 independent compile refusals passed: Send and Sync for Driver, Device, Context and DeviceBuffer; context outliving Driver; buffer outliving Context. Assertions checked the expected auto-trait/borrow compiler diagnostics.
- Final fake full/missing-DtoH ELF SHA256 values:
551878f9b518b200f8ac3dbf3570ec7494f1a2226917530c84ea30b418c1d41f/a95af6e51e678a5e3fc5f937b4232393493497161195391e256138a5d2009991. Source hashes inside the container matched the working-tree bytes. - All owned setup/test containers, derived fixture images, private source staging, synthetic libraries, trace files and target directories were removed. The shared pinned base image and existing registry cache were retained. Cleanup attempts each resource independently, preserves test failure, and fails a successful test run if any cleanup fails.
Two initial fixture provisioning failures occurred before Rust integration:
missing optional rustfmt/Clippy, then Docker tmpfs execution denial for libc's
Rust build script. The final fixture installs verified toolchain components and
uses an explicitly executable owned /tmp; product behavior and assertions
were not weakened.
Production source receipts: src/lib.rs
7ce58fcf033b5e9704b2d134fc4c16cd2d5c57c5c45a867d2399c310dec3c4d4;
src/ffi.rs 5f00400fab73d98578ca53bfedcb86b4163133d2956a88ac3d2cd156455800c8.
Remaining integration limits
These outcomes qualify a GNU/Linux CPU mock contract. They do not execute an installed NVIDIA driver, GPU allocation/copy or a kernel, and they do not prove vendor cleanup succeeds after a driver failure. A sync fault deliberately retains bounded staging and poisons that context; failed destruction can retain the library/context instead of pretending release occurred. Repeated poisoned contexts can accumulate retained resources; there is no process-wide recovery or memory-bounded serving guarantee in this bootstrap.
The existing statically linked musl executable is also unqualified for this
loader. musl's static dlopen stub
refuses dynamic loading; the GNU/Linux ELF mock pass does not make static musl
capable of loading libcuda.so.1. A separate executable/loader integration gate
is required. The OCI index admits amd64 builds, but this actual local mock run
was arm64; hosted amd64/compiler qualification is separately pending.
Installed-driver GPU allocation/copy, kernel execution, model inference, model quality and paired performance remain separate unqualified gates.